package playtogo import ( "context" "fmt" "net/http" ) type Record struct { ID string `json:"id"` Name string `json:"name"` FullName string `json:"full_name"` Type string `json:"type"` TTL int `json:"ttl"` Disabled bool `json:"disabled"` Content string `json:"content"` Value string `json:"value"` } type DomainRecord struct { ID int `json:"domain_id"` Zone string `json:"zone"` AllowedRecordTypes []string `json:"allowed_record_types"` Records []Record `json:"records"` } func (c *Client) GetRecods(ctx context.Context, domain_id int) ([]Record, error) { var response ApiResponse[DomainRecord] path := fmt.Sprintf("/api/domains/%v/dns/records", domain_id) if err := c.do(ctx, http.MethodGet, path, nil, &response); err != nil { return nil, fmt.Errorf("get records: %w", err) } if !response.Success { return nil, fmt.Errorf("api error: %v", response.Error) } return response.Data.Records, nil } func (c *Client) AddRecord(ctx context.Context, domain_id int, record CreateRecord) (*CreateRecordResult, error) { var response ApiResponse[CreateRecordResult] path := fmt.Sprintf("/api/domains/%v/dns/records", domain_id) if err := c.do(ctx, http.MethodPost, path, record, &response); err != nil { return nil, fmt.Errorf("add record: %w", err) } if !response.Success { return nil, fmt.Errorf("api error: %v", response.Error) } return &response.Data, nil }