1 /*
2 Package namecom provides a client for accessing the Name.com v4 API.
3 4 See https://www.name.com/api-docs for an introduction
5 to the Name.com v4 API.
6 7 Creating a Client
8 9 To start working with this package, create a client with user credentials
10 11 nc := namecom.New("username","apitoken")
12 13 To check if the username and token are correct using the HelloFunc endpoint
14 15 response, err := nc.HelloFunc(&namecom.HelloRequest{})
16 if err != nil {
17 // TODO: handle error
18 }
19 20 */
21 package namecom
22 23 import (
24 "encoding/json"
25 "errors"
26 "fmt"
27 "io"
28 "net/http"
29 "net/url"
30 "time"
31 )
32 33 // NameCom is a client for connecting to the Name.com API.
34 type NameCom struct {
35 Server string
36 User string
37 Token string
38 Client *http.Client
39 }
40 41 // New creates a new NameCom client using the production environment server endpoint.
42 func New(user, token string) *NameCom {
43 return &NameCom{
44 Server: "https://api.name.com",
45 User: user,
46 Token: token,
47 Client: &http.Client{
48 Timeout: 10 * time.Second,
49 },
50 }
51 }
52 53 // Test creates a new NameCom client using the test environment server enpoint.
54 func Test(user, token string) *NameCom {
55 return &NameCom{
56 Server: "https://api.dev.name.com",
57 User: user,
58 Token: token,
59 Client: &http.Client{
60 Timeout: 10 * time.Second,
61 },
62 }
63 }
64 65 // Test creates a new NameCom client using the test environment server enpoint.
66 func Mock(user, token string, server string) *NameCom {
67 return &NameCom{
68 Server: server,
69 User: user,
70 Token: token,
71 Client: &http.Client{
72 Timeout: 10 * time.Second,
73 },
74 }
75 }
76 77 // Error allows an ErrorResponse object to implement the error interface.
78 func (er ErrorResponse) Error() string {
79 return er.Message + ": " + er.Details
80 }
81 82 func (n *NameCom) errorResponse(resp *http.Response) error {
83 er := &ErrorResponse{}
84 err := json.NewDecoder(resp.Body).Decode(er)
85 if err != nil {
86 return fmt.Errorf("api returned unexpected response: %s", err)
87 }
88 89 return fmt.Errorf("got error: %w", er)
90 }
91 92 func (n *NameCom) get(endpoint string, values url.Values) (io.Reader, error) {
93 if len(values) == 0 {
94 endpoint = endpoint + "?" + values.Encode()
95 }
96 return n.doRequest("GET", endpoint, nil)
97 }
98 99 func (n *NameCom) post(endpoint string, post io.Reader) (io.Reader, error) {
100 return n.doRequest("POST", endpoint, post)
101 }
102 103 func (n *NameCom) put(endpoint string, post io.Reader) (io.Reader, error) {
104 return n.doRequest("PUT", endpoint, post)
105 }
106 107 func (n *NameCom) delete(endpoint string, post io.Reader) (io.Reader, error) {
108 return n.doRequest("DELETE", endpoint, post)
109 }
110 111 func (n *NameCom) doRequest(method, endpoint string, post io.Reader) (io.Reader, error) {
112 if n.User == "" || n.Token == "" {
113 return nil, errors.New("both User and Token must be specified")
114 }
115 if n.Server == "" {
116 n.Server = "api.name.com"
117 }
118 if n.Client == nil {
119 n.Client = &http.Client{Timeout: 10 * time.Second}
120 }
121 122 url := n.Server + endpoint
123 124 req, err := http.NewRequest(method, url, post)
125 if err != nil {
126 return nil, err
127 }
128 129 req.SetBasicAuth(n.User, n.Token)
130 131 resp, err := n.Client.Do(req)
132 if err != nil {
133 return nil, err
134 }
135 136 if resp.StatusCode != 200 {
137 return nil, n.errorResponse(resp)
138 }
139 140 return resp.Body, nil
141 }
142 143 // EmptyResponse is an empty response used for DELETE endpoints.
144 type EmptyResponse struct {
145 }
146 147 // ErrorResponse is what is returned if the HTTP status code is not 200.
148 type ErrorResponse struct {
149 // Message is the error message.
150 Message string `json:"message,omitempty"`
151 // Details may have some additional details about the error.
152 Details string `json:"details,omitempty"`
153 }
154 155 // Contact contains all the contact data.
156 type Contact struct {
157 // First name of the contact.
158 FirstName string `json:"firstName,omitempty"`
159 // Last name of the contact.
160 LastName string `json:"lastName,omitempty"`
161 // Company name of the contact. Leave blank if the contact is an individual as some registries will assume it is a corporate entity otherwise.
162 CompanyName string `json:"companyName,omitempty"`
163 // Address1 is the first line of the contact's address.
164 Address1 string `json:"address1,omitempty"`
165 // Address2 is the second line of the contact's address.
166 Address2 string `json:"address2,omitempty"`
167 // City of the contact's address.
168 City string `json:"city,omitempty"`
169 // State or Province for the contact's address.
170 State string `json:"state,omitempty"`
171 // Zip or Postal Code for the contact's address.
172 Zip string `json:"zip,omitempty"`
173 // Country code for the contact's address. Required to be a ISO 3166-1 alpha-2 code.
174 Country string `json:"country,omitempty"`
175 // Phone number of the contact. Should be specified in the following format: "+cc.llllllll" where cc is the country code and llllllll is the local number.
176 Phone string `json:"phone,omitempty"`
177 // Fax number of the contact. Should be specified in the following format: "+cc.llllllll" where cc is the country code and llllllll is the local number.
178 Fax string `json:"fax,omitempty"`
179 // Email of the contact. Should be a complete and valid email address.
180 Email string `json:"email,omitempty"`
181 }
182 183 // Contacts stores the contact information for the roles related to domains.
184 type Contacts struct {
185 // Registrant is the rightful owner of the account and has the right to use and/or sell the domain name. They are able to make changes to all account, domain, and product settings. This information should be reviewed and updated regularly to ensure accuracy.
186 Registrant *Contact `json:"registrant,omitempty"`
187 // Registrants often designate an administrative contact to manage their domain name(s). They primarily deal with business information such as the name on record, postal address, and contact information for the official registrant.
188 Admin *Contact `json:"admin,omitempty"`
189 // The technical contact manages and maintains a domain’s nameservers. If you’re working with a web designer or someone in a similar role, you many want to assign them as a technical contact.
190 Tech *Contact `json:"tech,omitempty"`
191 // The billing contact is the party responsible for paying bills for the account and taking care of renewals.
192 Billing *Contact `json:"billing,omitempty"`
193 }
194 195 // Domain lists all the data for a domain.
196 type Domain struct {
197 // DomainName is the punycode encoded value of the domain name.
198 DomainName string `json:"domainName,omitempty"`
199 // Nameservers is the list of nameservers for this domain. If unspecified it defaults to your account default nameservers.
200 Nameservers []string `json:"nameservers,omitempty"`
201 // Contacts for the domain.
202 Contacts *Contacts `json:"contacts,omitempty"`
203 // PrivacyEnabled reflects if Whois Privacy is enabled for this domain.
204 PrivacyEnabled bool `json:"privacyEnabled,omitempty"`
205 // Locked indicates that the domain cannot be transferred to another registrar.
206 Locked bool `json:"locked,omitempty"`
207 // AutorenewEnabled indicates if the domain will attempt to renew automatically before expiration.
208 AutorenewEnabled bool `json:"autorenewEnabled,omitempty"`
209 // ExpireDate is the date the domain will expire.
210 ExpireDate string `json:"expireDate,omitempty"`
211 // CreateDate is the date the domain was created at the registry.
212 CreateDate string `json:"createDate,omitempty"`
213 // RenewalPrice is the price to renew the domain. It may be required for the RenewDomain command.
214 RenewalPrice float64 `json:"renewalPrice,omitempty"`
215 }
216 217 // SearchRequest is used to specify the search parameters.
218 type SearchRequest struct {
219 // Timeout is a value in milliseconds on how long to perform the search for. Valid timeouts are between 500ms to 5,000ms. If not specified, timeout defaults to 1,000ms.
220 // Since some additional processing is performed on the results, a response may take longer then the timeout.
221 Timeout int32 `json:"timeout,omitempty"`
222 // Keyword is the search term to search for. It can be just a word, or a whole domain name.
223 Keyword string `json:"keyword,omitempty"`
224 // TLDFilter will limit results to only contain the specified TLDs.
225 TldFilter []string `json:"tldFilter,omitempty"`
226 // PromoCode is not implemented yet.
227 PromoCode string `json:"promoCode,omitempty"`
228 }
229 230 // AvailabilityRequest is used to list the domain names to check availability for.
231 type AvailabilityRequest struct {
232 // DomainNames is the list of domains to check if they are available.
233 DomainNames []string `json:"domainNames,omitempty"`
234 // PromoCode is not implemented yet.
235 PromoCode string `json:"promoCode,omitempty"`
236 }
237 238 // SearchResult is returned by the CheckAvailability, Search, and SearchStream functions.
239 type SearchResult struct {
240 // DomainName is the punycode encoding of the result domain name.
241 DomainName string `json:"domainName,omitempty"`
242 // SLD is first portion of the domain_name.
243 Sld string `json:"sld,omitempty"`
244 // TLD is the rest of the domain_name after the SLD.
245 Tld string `json:"tld,omitempty"`
246 // Purchaseable indicates whether the search result is available for purchase.
247 Purchasable bool `json:"purchasable,omitempty"`
248 // Premium indicates that this search result is a premium result and the purchase_price needs to be passed to the DomainCreate command.
249 Premium bool `json:"premium,omitempty"`
250 // PurchasePrice is the price for purchasing this domain for 1 year. Purchase_price is always in USD.
251 PurchasePrice float64 `json:"purchasePrice,omitempty"`
252 // PurchaseType indicates what kind of purchase this result is for. It should be passed to the DomainCreate command.
253 PurchaseType string `json:"purchaseType,omitempty"`
254 // RenewalPrice is the annual renewal price for this domain as it may be different then the purchase_price.
255 RenewalPrice float64 `json:"renewalPrice,omitempty"`
256 }
257 258 // SearchResponse returns a list of search results.
259 type SearchResponse struct {
260 // Results of the search are returned here, the order should not be relied upon.
261 Results []*SearchResult `json:"results,omitempty"`
262 }
263 264 // ListDomainsRequest is used to pass the pagination parameters to the ListDomains function.
265 type ListDomainsRequest struct {
266 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
267 PerPage int32 `json:"perPage,omitempty"`
268 // Page is which page to return
269 Page int32 `json:"page,omitempty"`
270 }
271 272 // ListDomainsResponse is the response from a list request, it contains the paginated list of Domains.
273 type ListDomainsResponse struct {
274 // Domains is the list of domains in your account.
275 Domains []*Domain `json:"domains,omitempty"`
276 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
277 NextPage int32 `json:"nextPage,omitempty"`
278 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
279 LastPage int32 `json:"lastPage,omitempty"`
280 }
281 282 // GetDomainRequest specifies the domain name to request data for in the GetDomain function.
283 type GetDomainRequest struct {
284 // DomainName is the domain to retrieve.
285 DomainName string `json:"domainName,omitempty"`
286 }
287 288 // CreateDomainRequest has the information that is needed to create a domain with the CreateDomain function.
289 type CreateDomainRequest struct {
290 // Domain is the domain object to create. If privacy_enabled is set, Whois Privacy will also be purchased for an additional amount.
291 Domain *Domain `json:"domain,omitempty"`
292 // PurchasePrice is the amount to pay for the domain. If privacy_enabled is set, the regular price for whois protection will be added automatically. If VAT tax applies, it will also be added automatically.
293 // PurchasePrice is required if purchase_type is not "registration" or if it is a premium domain.
294 PurchasePrice float64 `json:"purchasePrice,omitempty"`
295 // PurchaseType defaults to "registration" but should be copied from the result of a search command otherwise.
296 PurchaseType string `json:"purchaseType,omitempty"`
297 // Years is for how many years to register the domain for. Years defaults to 1 if not passed and cannot be more than 10.
298 // If passing purchase_price make sure to adjust it accordingly.
299 Years int32 `json:"years,omitempty"`
300 // TLDRequirements is a way to pass additional data that is required by some registries.
301 TldRequirements map[string]string `json:"tldRequirements,omitempty"`
302 // PromoCode is not yet implemented.
303 PromoCode string `json:"promoCode,omitempty"`
304 }
305 306 // CreateDomainResponse contains the domain info as well as the order info for the created domain.
307 type CreateDomainResponse struct {
308 // Domain is the newly created domain.
309 Domain *Domain `json:"domain,omitempty"`
310 // Order is an identifier for this purchase.
311 Order int32 `json:"order,omitempty"`
312 // TotalPaid is the total amount paid, including VAT and whois protection.
313 TotalPaid float64 `json:"totalPaid,omitempty"`
314 }
315 316 // RenewDomainRequest passes the domain name and purchase parameters to the RenewDomain function.
317 type RenewDomainRequest struct {
318 // DomainName is the domain to renew.
319 DomainName string `json:"domainName,omitempty"`
320 // PurchasePrice is the amount to pay for the domain renewal. If VAT tax applies, it will also be added automatically.
321 // PurchasePrice is required if this is a premium domain.
322 PurchasePrice float64 `json:"purchasePrice,omitempty"`
323 // Years is for how many years to renew the domain for. Years defaults to 1 if not passed and cannot be more than 10.
324 Years int32 `json:"years,omitempty"`
325 // PromoCode is not yet implemented.
326 PromoCode string `json:"promoCode,omitempty"`
327 }
328 329 // RenewDomainResponse contains the updated domain info as well as the order info for the renewed domain.
330 type RenewDomainResponse struct {
331 // Domain reflects the status of the domain after renewing.
332 Domain *Domain `json:"domain,omitempty"`
333 // Order is an identifier for this purchase
334 Order int32 `json:"order,omitempty"`
335 // TotalPaid is the total amount paid, including VAT.
336 TotalPaid float64 `json:"totalPaid,omitempty"`
337 }
338 339 // AuthCodeRequest passes the domain name to the GetAuthCodeForDomain funtion.
340 type AuthCodeRequest struct {
341 // DomainName is the domain name to retrieve the authorization code for.
342 DomainName string `json:"domainName,omitempty"`
343 }
344 345 // AuthCodeResponse returns the auth code from the GetAuthCodeForDomain funtion.
346 type AuthCodeResponse struct {
347 // AuthCode is the authorization code needed to transfer a domain to another registrar. If you are storing auth codes, be sure to store them in a secure manner.
348 AuthCode string `json:"authCode,omitempty"`
349 }
350 351 // PricingRequest specifies the domain name to request data for in the GetDomain function.
352 type PricingRequest struct {
353 // DomainName is the domain to retrieve.
354 DomainName string `json:"domainName,omitempty"`
355 // Years is for how many years to get pricing for the domain. Years defaults to 1 if not passed and cannot be more than 10.
356 Years int32 `json:"years,omitempty"`
357 }
358 359 // PricingResponse returns the Pricing related information from the GetPricingForDomain function.
360 type PricingResponse struct {
361 // PurchasePrice is the price you will pay to register a domain. Can be passed in the CreateDomain request.
362 PurchasePrice float64 `json:"purchasePrice,omitempty"`
363 // RenewalPrice is the price you will pay to renew a domain. Can be passed in the RenewDomain request.
364 RenewalPrice float64 `json:"renewalPrice,omitempty"`
365 // TransferPrice is the price you will pay to transfer a domain. Can be passed in the CreateTransfer request. The TransferPrice is always for 1 year regardless of the years input.
366 TransferPrice float64 `json:"transferPrice,omitempty"`
367 // Premium indicates that this pricing is a premium result and the respective prices must be passed in create, renew or transfer commands.
368 Premium bool `json:"premium,omitempty"`
369 }
370 371 // PrivacyRequest passes the domain name as well as the purchase parameters to the PurchasePrivacy function.
372 type PrivacyRequest struct {
373 // DomainName is the domain to purchase Whois Privacy for.
374 DomainName string `json:"domainName,omitempty"`
375 // PurchasePrice is the amount you expect to pay.
376 PurchasePrice float64 `json:"purchasePrice,omitempty"`
377 // Years is the number of years you wish to purchase Whois Privacy for. Years defaults to 1 and cannot be more then the domain expiration date.
378 Years int32 `json:"years,omitempty"`
379 // PromoCode is not yet implemented
380 PromoCode string `json:"promoCode,omitempty"`
381 }
382 383 // PrivacyResponse contains the updated domain info as well as the order info for the newly purchased Whois Privacy.
384 type PrivacyResponse struct {
385 // Domain is the status of the domain after the purchase of Whois Privacy.
386 Domain *Domain `json:"domain,omitempty"`
387 // Order is an identifier for this purchase.
388 Order int32 `json:"order,omitempty"`
389 // TotalPaid is the total amount paid, including VAT.
390 TotalPaid float64 `json:"totalPaid,omitempty"`
391 }
392 393 // SetNameserversRequest passes the list of nameservers to set for the SetNameserver function.
394 type SetNameserversRequest struct {
395 // DomainName is the domain name to set the nameservers for.
396 DomainName string `json:"domainName,omitempty"`
397 // Namesevers is a list of the nameservers to set. Nameservers should already be set up and hosting the zone properly as some registries will verify before allowing the change.
398 Nameservers []string `json:"nameservers,omitempty"`
399 }
400 401 // SetContactsRequest passes the contact info for each role to the SetContacts function.
402 type SetContactsRequest struct {
403 // DomainName is the domain name to set the contacts for.
404 DomainName string `json:"domainName,omitempty"`
405 // Contacts is the list of contacts to set.
406 Contacts *Contacts `json:"contacts,omitempty"`
407 }
408 409 // EnableAutorenewForDomainRequest is used to pass the domain name to the EnableAutorenewForDomain function.
410 type EnableAutorenewForDomainRequest struct {
411 // DomainName is the domain name to enable autorenew for.
412 DomainName string `json:"domainName,omitempty"`
413 }
414 415 // DisableAutorenewForDomainRequest is used to pass the domain name to the DisableAutorenewForDomain function.
416 type DisableAutorenewForDomainRequest struct {
417 // DomainName is the domain name to disable autorenew for.
418 DomainName string `json:"domainName,omitempty"`
419 }
420 421 // EnableWhoisPrivacyForDomainRequest is used to pass the domain name to the EnableWhoisPrivacyForDomain function.
422 type EnableWhoisPrivacyForDomainRequest struct {
423 // DomainName is the domain name to enable whoisprivacy for.
424 DomainName string `json:"domainName,omitempty"`
425 }
426 427 // DisableWhoisPrivacyForDomainRequest is used to pass the domain name to the DisableWhoisPrivacyForDomain function.
428 type DisableWhoisPrivacyForDomainRequest struct {
429 // DomainName is the domain name to disable whoisprivacy for.
430 DomainName string `json:"domainName,omitempty"`
431 }
432 433 // LockDomainRequest is used to pass the domain name to the LockDomain function.
434 type LockDomainRequest struct {
435 // DomainName is the domain name to lock.
436 DomainName string `json:"domainName,omitempty"`
437 }
438 439 // UnlockDomainRequest is used to pass the domain name to the UnlockDomain function.
440 type UnlockDomainRequest struct {
441 // DomainName is the domain name to unlock.
442 DomainName string `json:"domainName,omitempty"`
443 }
444 445 // Record is an individual DNS resource record.
446 type Record struct {
447 // Unique record id. Value is ignored on Create, and must match the URI on Update.
448 ID int32 `json:"id,omitempty"`
449 // DomainName is the zone that the record belongs to.
450 DomainName string `json:"domainName,omitempty"`
451 // Host is the hostname relative to the zone: e.g. for a record for blog.example.org, domain would be "example.org" and host would be "blog".
452 // An apex record would be specified by either an empty host "" or "@".
453 // A SRV record would be specified by "_{service}._{protocal}.{host}": e.g. "_sip._tcp.phone" for _sip._tcp.phone.example.org.
454 Host string `json:"host,omitempty"`
455 // FQDN is the Fully Qualified Domain Name. It is the combination of the host and the domain name. It always ends in a ".". FQDN is ignored in CreateRecord, specify via the Host field instead.
456 Fqdn string `json:"fqdn,omitempty"`
457 // Type is one of the following: A, AAAA, ANAME, CNAME, MX, NS, SRV, or TXT.
458 Type string `json:"type,omitempty"`
459 // Answer is either the IP address for A or AAAA records; the target for ANAME, CNAME, MX, or NS records; the text for TXT records.
460 // For SRV records, answer has the following format: "{weight} {port} {target}" e.g. "1 5061 sip.example.org".
461 Answer string `json:"answer,omitempty"`
462 // TTL is the time this record can be cached for in seconds. Name.com allows a minimum TTL of 300, or 5 minutes.
463 TTL uint32 `json:"ttl,omitempty"`
464 // Priority is only required for MX and SRV records, it is ignored for all others.
465 Priority uint32 `json:"priority,omitempty"`
466 }
467 468 // ListRecordsRequest requests a list of records that exist for the domain
469 type ListRecordsRequest struct {
470 // DomainName is the zone to list the records for.
471 DomainName string `json:"domainName,omitempty"`
472 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
473 PerPage int32 `json:"perPage,omitempty"`
474 // Page is which page to return
475 Page int32 `json:"page,omitempty"`
476 }
477 478 // ListRecordsResponse is the response for the ListRecords function.
479 type ListRecordsResponse struct {
480 // Records contains the records in the zone
481 Records []*Record `json:"records,omitempty"`
482 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
483 NextPage int32 `json:"nextPage,omitempty"`
484 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
485 LastPage int32 `json:"lastPage,omitempty"`
486 }
487 488 // GetRecordRequest requests the record identified by id and domain.
489 type GetRecordRequest struct {
490 // DomainName is the zone the record exists in
491 DomainName string `json:"domainName,omitempty"`
492 // ID is the server-assigned unique identifier for this record
493 ID int32 `json:"id,omitempty"`
494 }
495 496 // DeleteRecordRequest deletes a specific record
497 type DeleteRecordRequest struct {
498 // DomainName is the zone that the record to be deleted exists in.
499 DomainName string `json:"domainName,omitempty"`
500 // ID is the server-assigned unique identifier for the Record to be deleted. If the Record with that ID does not exist in the specified Domain, an error is returned.
501 ID int32 `json:"id,omitempty"`
502 }
503 504 // DNSSEC contains all the data required to create a DS record at the registry.
505 type DNSSEC struct {
506 // DomainName is the domain name.
507 DomainName string `json:"domainName,omitempty"`
508 // KeyTag contains the key tag value of the DNSKEY RR that validates this signature. The algorithm to generate it is here: https://tools.ietf.org/html/rfc4034#appendix-B
509 KeyTag int32 `json:"keyTag,omitempty"`
510 // Algorithm is an integer identifying the algorithm used for signing. Valid values can be found here: https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
511 Algorithm int32 `json:"algorithm,omitempty"`
512 // DigestType is an integer identifying the algorithm used to create the digest. Valid values can be found here: https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml
513 DigestType int32 `json:"digestType,omitempty"`
514 // Digest is a digest of the DNSKEY RR that is registered with the registry.
515 Digest string `json:"digest,omitempty"`
516 }
517 518 // ListDNSSECsRequest contains the domain name to list DS records for.
519 type ListDNSSECsRequest struct {
520 // DomainName is the domain name to list keys for.
521 DomainName string `json:"domainName,omitempty"`
522 }
523 524 // ListDNSSECsResponse contains the list of DS records at the registry.
525 type ListDNSSECsResponse struct {
526 // Dnssec is the list of registered DNSSEC keys.
527 Dnssec []*DNSSEC `json:"dnssec,omitempty"`
528 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
529 NextPage int32 `json:"nextPage,omitempty"`
530 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
531 LastPage int32 `json:"lastPage,omitempty"`
532 }
533 534 // GetDNSSECRequest gets the information for a specific DS record at the registry.
535 type GetDNSSECRequest struct {
536 // DomainName is the domain name.
537 DomainName string `json:"domainName,omitempty"`
538 // Digest is the digest for the DNSKEY RR to retrieve.
539 Digest string `json:"digest,omitempty"`
540 }
541 542 // DeleteDNSSECRequest specifies the domain name and digest to remove from the registry.
543 type DeleteDNSSECRequest struct {
544 // DomainName is the domain name the key is registered for.
545 DomainName string `json:"domainName,omitempty"`
546 // Digest is the digest for the DNSKEY RR to remove from the registry.
547 Digest string `json:"digest,omitempty"`
548 }
549 550 // EmailForwarding contains all the information for an email forwarding entry.
551 type EmailForwarding struct {
552 // DomainName is the domain part of the email address to forward.
553 DomainName string `json:"domainName,omitempty"`
554 // EmailBox is the user portion of the email address to forward.
555 EmailBox string `json:"emailBox,omitempty"`
556 // EmailTo is the entire email address to forward email to.
557 EmailTo string `json:"emailTo,omitempty"`
558 }
559 560 // ListEmailForwardingsRequest passes the domain name and pagination information to the ListEmailForwardings function.
561 type ListEmailForwardingsRequest struct {
562 // DomainName is the domain to list email forwarded boxes for.
563 DomainName string `json:"domainName,omitempty"`
564 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
565 PerPage int32 `json:"perPage,omitempty"`
566 // Page is which page to return.
567 Page int32 `json:"page,omitempty"`
568 }
569 570 // ListEmailForwardingsResponse returns the list of email forwarding entries as well as the pagination information.
571 type ListEmailForwardingsResponse struct {
572 // EmailForwarding is the list of forwarded email boxes.
573 EmailForwarding []*EmailForwarding `json:"emailForwarding,omitempty"`
574 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
575 NextPage int32 `json:"nextPage,omitempty"`
576 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
577 LastPage int32 `json:"lastPage,omitempty"`
578 }
579 580 // GetEmailForwardingRequest passes the domain name and email box to request the email forwarding information for.
581 type GetEmailForwardingRequest struct {
582 // DomainName is the domain to list email forwarded box for.
583 DomainName string `json:"domainName,omitempty"`
584 // EmailBox is which email box to retrieve.
585 EmailBox string `json:"emailBox,omitempty"`
586 }
587 588 // DeleteEmailForwardingRequest passes the domain name and email box to the DeleteEmailForwarding function.
589 type DeleteEmailForwardingRequest struct {
590 // DomainName is the domain to delete the email forwarded box from.
591 DomainName string `json:"domainName,omitempty"`
592 // EmailBox is which email box to delete.
593 EmailBox string `json:"emailBox,omitempty"`
594 }
595 596 // HelloRequest doesn't take any parameters.
597 type HelloRequest struct {
598 }
599 600 // HelloResponse is the response from the HelloFunc command
601 type HelloResponse struct {
602 // ServerName is an identfier for which server is being accessed.
603 ServerName string `json:"serverName,omitempty"`
604 // Motd is a message of the day. It might provide some useful information.
605 Motd string `json:"motd,omitempty"`
606 // Username is the account name you are currently logged into.
607 Username string `json:"username,omitempty"`
608 // ServerTime is the current date/time at the server.
609 ServerTime string `json:"serverTime,omitempty"`
610 }
611 612 // OrderItem contains all the order item data.
613 type OrderItem struct {
614 // Id is the unique identifier of the order item.
615 ID int32 `json:"id,omitempty"`
616 // Status indicates state of the order ('success', 'failed', 'refunded').
617 Status string `json:"status,omitempty"`
618 // Name is name of the item ('example.ninja').
619 Name string `json:"name,omitempty"`
620 // Tld is (optional) tld of domain name, if applicable ('ninja').
621 Tld string `json:"tld,omitempty"`
622 // Type is type of the item ('registration', 'whois_privacy').
623 Type string `json:"type,omitempty"`
624 // Price is the final price of the item.
625 Price float32 `json:"price,omitempty"`
626 // PriceNonUsd is the price of the item if order has non-usd currency.
627 PriceNonUsd float32 `json:"priceNonUsd,omitempty"`
628 // OriginalPrice is the original price of the item before discounts.
629 OriginalPrice float32 `json:"originalPrice,omitempty"`
630 // TaxAmount is the tax charged for this item, if applicable.
631 TaxAmount float32 `json:"taxAmount,omitempty"`
632 // Quantity is the number of items.
633 Quantity int32 `json:"quantity,omitempty"`
634 // Duration is the number of intervals.
635 Duration int32 `json:"duration,omitempty"`
636 // Interval is the unit of time ("year", "month").
637 Interval string `json:"interval,omitempty"`
638 }
639 640 // Order contains all the data for an order.
641 type Order struct {
642 // Id is the unique identifier of the order.
643 ID int32 `json:"id,omitempty"`
644 // CreateDate is the date the order was placed.
645 CreateDate string `json:"createDate,omitempty"`
646 // Registrar is registrar with which order is placed.
647 Registrar string `json:"registrar,omitempty"`
648 // Status indicates the state of the order ('success', 'failed').
649 Status string `json:"status,omitempty"`
650 // Currency indicates currency of the order ('USD', 'CNY').
651 Currency string `json:"currency,omitempty"`
652 // OrderItems is the collection of 1 or more items in the order.
653 OrderItems []*OrderItem `json:"orderItems,omitempty"`
654 // AuthAmount is the amount authorized to complete the order purchase.
655 AuthAmount float32 `json:"authAmount,omitempty"`
656 // TotalCapture is the amount captured.
657 TotalCapture float32 `json:"totalCapture,omitempty"`
658 // TotalRefund is the amount, if any, refunded. Default is 0.00. If 0.00, this field is not included in response.
659 TotalRefund float32 `json:"totalRefund,omitempty"`
660 // FinalAmount is the final amount of the order, after discounts and refunds.
661 FinalAmount string `json:"finalAmount,omitempty"`
662 // CurrencyRate is the conversion rate from USD to order's currency. This field is only populated if order's currency is non-USD.
663 CurrencyRate float32 `json:"currencyRate,omitempty"`
664 }
665 666 // ListOrdersRequest is used to pass the pagination parameters to the ListOrders function.
667 type ListOrdersRequest struct {
668 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
669 PerPage int32 `json:"perPage,omitempty"`
670 // Page is which page to return
671 Page int32 `json:"page,omitempty"`
672 }
673 674 // ListOrdersResponse is the response from a list request, it contains the paginated list of Orders.
675 type ListOrdersResponse struct {
676 // ParentAccountId field is populated when requesting account has a parent account id.
677 ParentAccountID int32 `json:"parentAccountId,omitempty"`
678 // Orders is the collection of orders, if any, in the requesting account.
679 Orders []*Order `json:"orders,omitempty"`
680 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
681 NextPage int32 `json:"nextPage,omitempty"`
682 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
683 LastPage int32 `json:"lastPage,omitempty"`
684 }
685 686 // GetOrderRequest specifies the order id to request data for in the GetOrder function.
687 type GetOrderRequest struct {
688 // OrderId is the unique identifier of the requested order.
689 OrderID int32 `json:"orderId,omitempty"`
690 }
691 692 // GetOrderResponse is the response from a specific order request.
693 type GetOrderResponse struct {
694 // ParentAccountId is populated when requesting account has a parent account id.
695 ParentAccountID int32 `json:"parentAccountId,omitempty"`
696 // Order is the order requested.
697 Order *Order `json:"order,omitempty"`
698 }
699 700 // Transfer contains the information related to a transfer of a domain name to Name.com.
701 type Transfer struct {
702 // DomainName is the domain to be transfered to Name.com.
703 DomainName string `json:"domainName,omitempty"`
704 // Email is the email address that the approval email was sent to. Not every TLD requries an approval email. This is usaully pulled from Whois.
705 Email string `json:"email,omitempty"`
706 // Status is the current status of the transfer. Details about statuses can be found in the following Knowledge Base article: <https://www.name.com/support/articles/115012519688-transfer-status-faq>.
707 Status string `json:"status,omitempty"`
708 }
709 710 // ListTransfersRequest passes the pagination information to the ListTransfers function.
711 type ListTransfersRequest struct {
712 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
713 PerPage int32 `json:"perPage,omitempty"`
714 // Page is which page to return
715 Page int32 `json:"page,omitempty"`
716 }
717 718 // ListTransfersResponse returns the list of pending transfers as well as the paginiation information if relevent.
719 type ListTransfersResponse struct {
720 // Transfers is a list of pending transfers
721 Transfers []*Transfer `json:"transfers,omitempty"`
722 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
723 NextPage int32 `json:"nextPage,omitempty"`
724 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
725 LastPage int32 `json:"lastPage,omitempty"`
726 }
727 728 // GetTransferRequest passes the domain name to the GetTransfer function.
729 type GetTransferRequest struct {
730 // DomainName is the domain you want to get the transfer information for.
731 DomainName string `json:"domainName,omitempty"`
732 }
733 734 // CreateTransferRequest passes the required transfer info to the CreateTransfer function.
735 type CreateTransferRequest struct {
736 // DomainName is the domain you want to transfer to Name.com.
737 DomainName string `json:"domainName,omitempty"`
738 // AuthCode is the authorization code for the transfer. Not all TLDs require authorization codes, but most do.
739 AuthCode string `json:"authCode,omitempty"`
740 // PrivacyEnabled is a flag on whether to purchase Whois Privacy with the transfer.
741 PrivacyEnabled bool `json:"privacyEnabled,omitempty"`
742 // PurchasePrice is the amount to pay for the transfer of the domain. If privacy_enabled is set, the regular price for Whois Privacy will be added automatically. If VAT tax applies, it will also be added automatically.
743 // PurchasePrice is required if the domain to transfer is a premium domain.
744 PurchasePrice float64 `json:"purchasePrice,omitempty"`
745 // PromoCode is not implemented yet
746 PromoCode string `json:"promoCode,omitempty"`
747 }
748 749 // CreateTransferResponse returns the newly created transfer resource as well as the order information.
750 type CreateTransferResponse struct {
751 // Transfer is the transfer resource created.
752 Transfer *Transfer `json:"transfer,omitempty"`
753 // Order is an identifier for this purchase.
754 Order int32 `json:"order,omitempty"`
755 // TotalPaid is the total amount paid, including VAT and Whois Privacy.
756 TotalPaid float64 `json:"totalPaid,omitempty"`
757 }
758 759 // CancelTransferRequest passes the domain name to be canceled to the CancelTransfer function.
760 type CancelTransferRequest struct {
761 // DomainName is the domain to cancel the transfer for.
762 DomainName string `json:"domainName,omitempty"`
763 }
764 765 // URLForwarding is the model for URL forwarding entries.
766 type URLForwarding struct {
767 // DomainName is the domain part of the hostname to forward.
768 DomainName string `json:"domainName,omitempty"`
769 // Host is the entirety of the hostname. i.e. www.example.org
770 Host string `json:"host,omitempty"`
771 // ForwardsTo is the URL this host will be forwarded to.
772 ForwardsTo string `json:"forwardsTo,omitempty"`
773 // Type is the type of forwarding. Valid types are: Masked - This retains the original domain in the address bar and will not reveal or display the actual destination URL. If you are forwarding knowledgebase.ninja to Name.com, the address bar will say knowledgebase.ninja. This is sometimes called iframe forwarding. And: Redirect - This does not retain the original domain in the address bar, so the user will see it change and realize they were forwarded from the URL they originally entered. If you are forwarding knowledgebase.ninja to Name.com, the address bar will say Name.com. This is also called 301 forwarding.
774 Type string `json:"type,omitempty"`
775 // Title is the title for the html page to use if the type is masked. Values are ignored for types other then "masked".
776 Title string `json:"title,omitempty"`
777 // Meta is the meta tags to add to the html page if the type is masked. ex: "<meta name='keywords' content='fish, denver, platte'>". Values are ignored for types other then "masked".
778 Meta string `json:"meta,omitempty"`
779 }
780 781 // ListURLForwardingsRequest is the request for the ListURLForwardings function.
782 type ListURLForwardingsRequest struct {
783 // DomainName is the domain to list URL forwarding entries for.
784 DomainName string `json:"domainName,omitempty"`
785 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
786 PerPage int32 `json:"perPage,omitempty"`
787 // Page is which page to return.
788 Page int32 `json:"page,omitempty"`
789 }
790 791 // ListURLForwardingsResponse is the response for the ListURLForwardings function.
792 type ListURLForwardingsResponse struct {
793 // URLForwarding is the list of URL forwarding entries.
794 URLForwarding []*URLForwarding `json:"urlForwarding,omitempty"`
795 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
796 NextPage int32 `json:"nextPage,omitempty"`
797 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
798 LastPage int32 `json:"lastPage,omitempty"`
799 }
800 801 // GetURLForwardingRequest is the request for the GetURLForwarding function.
802 type GetURLForwardingRequest struct {
803 // DomainName is the domain to list URL forwarding entry for.
804 DomainName string `json:"domainName,omitempty"`
805 // Host is the part of the domain name before the domain. i.e. www is the host for www.example.org.
806 Host string `json:"host,omitempty"`
807 }
808 809 // DeleteURLForwardingRequest is the request for the DeleteURLForwarding function.
810 type DeleteURLForwardingRequest struct {
811 // DomainName is the domain to delete the URL forwardind entry from.
812 DomainName string `json:"domainName,omitempty"`
813 // Host is the part of the domain name before the domain. i.e. www is the host for www.example.org.
814 Host string `json:"host,omitempty"`
815 }
816 817 // VanityNameserver contains the hostname as well as the list of IP addresses for nameservers.
818 type VanityNameserver struct {
819 // DomainName is the domain the nameserver is a subdomain of.
820 DomainName string `json:"domainName,omitempty"`
821 // Hostname is the hostname of the nameserver.
822 Hostname string `json:"hostname,omitempty"`
823 // IPs is a list of IP addresses that are used for glue records for this nameserver.
824 Ips []string `json:"ips,omitempty"`
825 }
826 827 // ListVanityNameserversRequest passes the domain name as well as the pagination parameters to the ListVanityNameservers function.
828 type ListVanityNameserversRequest struct {
829 // DomainName is the domain to list the vanity nameservers for.
830 DomainName string `json:"domainName,omitempty"`
831 // Per Page is the number of records to return per request. Per Page defaults to 1,000.
832 PerPage int32 `json:"perPage,omitempty"`
833 // Page is which page to return
834 Page int32 `json:"page,omitempty"`
835 }
836 837 // ListVanityNameserversResponse returns the list of vanity nameservers for the domain.
838 type ListVanityNameserversResponse struct {
839 // VanityNameservers is the list of vanity nameservers.
840 VanityNameservers []*VanityNameserver `json:"vanityNameservers,omitempty"`
841 // NextPage is the identifier for the next page of results. It is only populated if there is another page of results after the current page.
842 NextPage int32 `json:"nextPage,omitempty"`
843 // LastPage is the identifier for the final page of results. It is only populated if there is another page of results after the current page.
844 LastPage int32 `json:"lastPage,omitempty"`
845 }
846 847 // GetVanityNameserverRequest passes the hostname to get the details for.
848 type GetVanityNameserverRequest struct {
849 // DomainName is the domain to for the vanity nameserver.
850 DomainName string `json:"domainName,omitempty"`
851 // Hostname is the hostname for the vanity nameserver.
852 Hostname string `json:"hostname,omitempty"`
853 }
854 855 // DeleteVanityNameserverRequest passes which hostname to remove from the registry.
856 type DeleteVanityNameserverRequest struct {
857 // DomainName is the domain of the vanity nameserver to delete.
858 DomainName string `json:"domainName,omitempty"`
859 // Hostname is the hostname of the vanity nameserver to delete.
860 Hostname string `json:"hostname,omitempty"`
861 }
862