Class: NamesiloClient::API

Inherits:
Object
  • Object
show all
Defined in:
lib/namesilo_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(apikey) ⇒ API

Class constructor



13
14
15
16
# File 'lib/namesilo_client.rb', line 13

def initialize(apikey)
  @apikey = apikey
  @host   = 'https://www.namesilo.com/api/'
end

Instance Method Details

#add_account_funds(amount, payment_id) ⇒ Object

addAccountFunds: increase NameSilo account funds balance Parameters

amount: the amount in US Dollars 
payment_id: The ID of the verified credit card


570
571
572
573
# File 'lib/namesilo_client.rb', line 570

def (amount,payment_id)
  params={'amount':amount,'payment_id':payment_id}
  get_request('addAccountFunds?'+get_url_parameters(params)).body
end

#add_auto_renewal(domain) ⇒ Object

addAutoRenewal: Set a domain to be auto-renewed.



479
480
481
482
# File 'lib/namesilo_client.rb', line 479

def add_auto_renewal(domain)
  params={'domain':domain}
  get_request('addAutoRenewal?'+get_url_parameters(params)).body
end

#add_contact(params) ⇒ Object

add a contact information params is a JSON string required fields:

fn: First Name
ln: Last Name
ad: Mailing Address
cy: Mailing City
st: Mailing State/Province/Territory
If country is US or CA, you must use the correct abbreviation
zp: Mailing Zip/Postal Code
ct: Mailing Country
Country must use the correct abbreviation
em: Email Address
ph: Phone Number

Optional Fields

nn: Nickname (24)
cp: Company (64)
ad2: Mailing Address 2 (128)
fx: Fax (32)
US Fields:
  usnc: .US Nexus Category (3) (must use correct abbreviation)
  usap: .US Application Purpose (2) (must use correct abbreviation)
CA Optional Fields
  calf: CIRA Legal Form (correct abbreviations)
  caln: CIRA Language (correct abbreviations)
  caag: CIRA Agreement Version (correct abbreviations)
  cawd: CIRA WHOIS Display


77
78
79
# File 'lib/namesilo_client.rb', line 77

def add_contact(params)
  get_request('contactAdd?'+get_url_parameters(params)).body
end

#add_dns_record(params) ⇒ Object

Add a DNS record Parameters:

domain: The domain being updated
rrtype: DNS record type, e.g. "A", "AAAA", "CNAME", "MX" and "TXT"
rrhost: hostname for the new record 
rrvalue: The value for the resource record
rrdistance: Only used for MX (default is 10 if not provided)
rrttl: The TTL for the new record (default is 7207 if not provided)


152
153
154
# File 'lib/namesilo_client.rb', line 152

def add_dns_record(params)
  get_request('dnsAddRecord?'+get_url_parameters(params)).body
end

#add_dns_sec_record(params) ⇒ Object

dnsSecAddRecord Parameters

domain
digest: The digest
keyTag: The key tag
digestType: The digest type ( accepted values: https://www.namesilo.com/api_reference.php#dnsSecAddRecord )
alg: see: https://www.namesilo.com/api_reference.php#dnsSecAddRecord


400
401
402
# File 'lib/namesilo_client.rb', line 400

def add_dns_sec_record(params)
  get_request('dnsSecAddRecord?'+get_url_parameters(params)).body
end

#add_portfolio(portfolio) ⇒ Object

portfolioAdd Parameters:

portfolio: The encoded name of the portfolio to add


413
414
415
416
# File 'lib/namesilo_client.rb', line 413

def add_portfolio(portfolio)
  params={'portfolio':portfolio}
  get_request('portfolioAdd?'+get_url_parameters(params)).body      
end

#add_privacy(domain) ⇒ Object

addPrivacy: Add WHOIS Privacy to a domain Parameters:

domain


465
466
467
468
# File 'lib/namesilo_client.rb', line 465

def add_privacy(domain)
  params={'domain':domain}
  get_request('addPrivacy?'+get_url_parameters(params)).body
end

#add_registered_name_server(params) ⇒ Object

addRegisteredNameServer: add a registered name server Parameters:

new_host: the host name
ip1(required): IP Address for new name server
ip2-ip13(optional)


440
441
442
# File 'lib/namesilo_client.rb', line 440

def add_registered_name_server(params)
  get_request('addRegisteredNameServer?'+get_url_parameters(params)).body
end

#associate_domain_portfolio(portfolio, domains) ⇒ Object

portfolioDomainAssociate Parameters:

domains
portfolio


430
431
432
433
# File 'lib/namesilo_client.rb', line 430

def associate_domain_portfolio(portfolio,domains)
  params={'portfolio':portfolio,'domains':domains}
  get_request('portfolioDomainAssociate?'+get_url_parameters(params)).body
end

#change_name_servers(params) ⇒ Object

changeNameServers Parameters

domain
ns1-ns13: must provide between 2 and 13 name servers


381
382
383
# File 'lib/namesilo_client.rb', line 381

def change_name_servers(params)
  get_request('changeNameServers?'+get_url_parameters(params)).body
end

#check_register_availability(domains) ⇒ Object

checkRegisterAvailability Parameter: register domain names in JSON, seperated by comma

e.g. {'domains':'namesilo.com,namesilo.net,namesilo.org'}

returns XML with available, unavailable, and invalid domains xpath: /namesilo/reply



189
190
191
# File 'lib/namesilo_client.rb', line 189

def check_register_availability(domains)
  get_request('checkRegisterAvailability?'+get_url_parameters({'domains':domains})).body
end

#check_transfer_availability(domains) ⇒ Object

checkTransferAvailability Parameters

domains: A comma-delimited list of domains


360
361
362
363
# File 'lib/namesilo_client.rb', line 360

def check_transfer_availability(domains)
  params={'domains':domains}
  get_request('checkTransferAvailability?'+get_url_parameters(params)).body
end

#check_transfer_status(domain) ⇒ Object

checkTransferStatus Parameter: domain name returns XML containing domain transfer status xpath: /namesilo/reply



180
181
182
# File 'lib/namesilo_client.rb', line 180

def check_transfer_status(domain)
  get_request('checkTransferStatus?'+get_url_parameters({'domain':domain})).body
end

#contact_domain_associate(params) ⇒ Object

contactDomainAssociate Parameters

domains (required)

registrant(optional): registrant's contact id
administrative(optional): admin's contact id
billing(optional): billing contact id
technical(optional): technical role contact id


373
374
375
# File 'lib/namesilo_client.rb', line 373

def contact_domain_associate(params)
  get_request('contactDomainAssociate?'+get_url_parameters(params)).body
end

#del_dns_sec_record(params) ⇒ Object

dnsSecDeleteRecord Parameters: as same as dnsSecAddRecord



406
407
408
# File 'lib/namesilo_client.rb', line 406

def del_dns_sec_record(params)
  get_request('dnsSecDeleteRecord?'+get_url_parameters(params)).body
end

#delete_contact(contact_id) ⇒ Object

contactDelete



88
89
90
91
# File 'lib/namesilo_client.rb', line 88

def delete_contact(contact_id)
  params={'contact_id':contact_id}
  get_request('contactDelete?'+get_url_parameters(params)).body
end

#delete_dns_record(params) ⇒ Object

Delete DNS record Parameters:

domain
rrid: The unique ID of the resource record


172
173
174
# File 'lib/namesilo_client.rb', line 172

def delete_dns_record(params)
  get_request('dnsDeleteRecord?'+get_url_parameters(params)).body
end

#delete_forward_email(domain, email) ⇒ Object

deleteEmailForward: delete a email forward Parameters

domain
email


553
554
555
556
# File 'lib/namesilo_client.rb', line 553

def delete_forward_email(domain,email)
  params={'domain':domain, 'email':email}
  get_request('deleteEmailForward?'+get_url_parameters(params)).body
end

#delete_forward_sub_domain(domain, subdomain) ⇒ Object

domainForwardSubDomainDelete: delete a subdomain forward Parameters

domain
subdomain


516
517
518
519
# File 'lib/namesilo_client.rb', line 516

def delete_forward_sub_domain(domain, subdomain)
  params={'domain':domain, 'subdomain':subdomain}
  get_request('domainForwardSubDomainDelete?'+get_url_parameters(params)).body
end

#delete_portfolio(portfolio) ⇒ Object

portfolioDelete Parameters:

portfolio: The encoded name of the portfolio to add


421
422
423
424
# File 'lib/namesilo_client.rb', line 421

def delete_portfolio(portfolio)
  params={'portfolio':portfolio}
  get_request('portfolioDelete?'+get_url_parameters(params)).body
end

#delete_registered_name_server(hostname) ⇒ Object

deleteRegisteredNameServer Parameters:

current_host: current host name


457
458
459
460
# File 'lib/namesilo_client.rb', line 457

def delete_registered_name_server(hostname)
  params={'hostname':hostname}
  get_request('deleteRegisteredNameServer?'+get_url_parameters(params)).body
end

#email_verification(email) ⇒ Object

emailVerification: sned an email verification message Parameters

email


561
562
563
564
# File 'lib/namesilo_client.rb', line 561

def email_verification(email)
  params={'email':email}
  get_request('emailVerification?'+get_url_parameters(params)).body
end

#forward_domain(params) ⇒ Object

domainForward Required parameters:

domain
protocol: http or https
address: the web site address to forward to
method: "301", "302" or "cloaked"

Optional parameters:

meta_title: The META title for cloaked forward
meta_description
meta_keywords: The META keywords for cloaked forward


501
502
503
# File 'lib/namesilo_client.rb', line 501

def forward_domain(params)
  get_request('domainForward?'+get_url_parameters(params)).body
end

#forward_email(params) ⇒ Object

configureEmailForward: create a new email forward or modify an existing email forward Required parameters

domain
email
forward1: the first email address to foward emails

Optional parameters

forward2-5


545
546
547
# File 'lib/namesilo_client.rb', line 545

def forward_email(params)
  get_request('configureEmailForward?'+get_url_parameters(params)).body
end

#forward_sub_domain(params) ⇒ Object

domainForwardSubDomain Parameters: as same as forward_domain, plus:

sub_domain


508
509
510
# File 'lib/namesilo_client.rb', line 508

def forward_sub_domain(params)
  get_request('domainForwardSubDomain?'+get_url_parameters(params)).body
end

#get_account_balanceObject

getAccountBalance returns current account funds balance. xpath: /namesilo/reply



264
265
266
# File 'lib/namesilo_client.rb', line 264

def ()
  get_request('getAccountBalance?'+get_url_parameters({})).body
end

#get_connectionObject

Establish connection



19
20
21
22
23
24
# File 'lib/namesilo_client.rb', line 19

def get_connection()
  conn = Faraday.new(:url => @host) do |c|
    c.use Faraday::Request::UrlEncoded 
    c.use Faraday::Adapter::NetHttp     
  end
end

#get_contact_list(params = {}) ⇒ Object

Return namesilo contact information By default, it returns all contact informaton Optional parameter: contact_id e.g. get_contact_list(params=contact_id:‘11111111’)



46
47
48
# File 'lib/namesilo_client.rb', line 46

def get_contact_list(params={})
  get_request('contactList?'+get_url_parameters(params)).body
end

#get_default_parametersObject

Default parameters for Namesilio REST APIs



27
28
29
# File 'lib/namesilo_client.rb', line 27

def get_default_parameters()
  {"version":"1","type":"xml","key":@apikey}
end

#get_domain_info(domain) ⇒ Object

Get domain info Parameter: domain name returns XML containing all domain info xpath: /namesilo/reply



114
115
116
# File 'lib/namesilo_client.rb', line 114

def get_domain_info(domain)
  get_request('getDomainInfo?'+get_url_parameters({'domain':domain})).body
end

#get_portfolio_listObject

Get a list of all active portfolios within your account. returns XML containing all portfolios xpath: /namesilo/reply/portfolios



202
203
204
# File 'lib/namesilo_client.rb', line 202

def get_portfolio_list()
  get_request('portfolioList?'+get_url_parameters({})).body
end

#get_pricesObject

getPrices returns price list xpath: /namesilo/reply



271
272
273
# File 'lib/namesilo_client.rb', line 271

def get_prices()
  get_request('getPrices?'+get_url_parameters({})).body
end

#get_registrant_verification_statusObject

registrantVerificationStatus Shows the verification status for any Registrant email addresses xpath: /namesilo/reply/email



257
258
259
# File 'lib/namesilo_client.rb', line 257

def get_registrant_verification_status()
  get_request('registrantVerificationStatus?'+get_url_parameters({})).body
end

#get_request(endpoint) ⇒ Object



31
32
33
# File 'lib/namesilo_client.rb', line 31

def get_request(endpoint)
  get_connection().get endpoint
end

#get_url_parameters(params) ⇒ Object

Construct URL parameters, combing with default parameters



36
37
38
39
40
# File 'lib/namesilo_client.rb', line 36

def get_url_parameters(params)
  uri = Addressable::URI.new
  uri.query_values = params.merge(get_default_parameters())
  uri.query
end

#list_dns_records(domain) ⇒ Object

List DNS records Parameter: domain name returns XML containing all DNS records xpath: /namesilo/reply/resource_record



122
123
124
# File 'lib/namesilo_client.rb', line 122

def list_dns_records(domain)
  get_request('dnsListRecords?'+get_url_parameters({'domain':domain})).body
end

#list_dns_records_array(domain) ⇒ Object

List DNS records Returns an array containing DNS record object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/namesilo_client.rb', line 128

def list_dns_records_array(domain)
  dns_records = []
  doc = Nokogiri::XML(list_dns_records(domain))
  doc.xpath('/namesilo/reply/resource_record').each do |r|
    record = DnsRecord.new
    record.recordid  = r.xpath('record_id').text()
    record.host      = r.xpath('host').text()
    record.type      = r.xpath('type').text()
    record.value     = r.xpath('value').text()
    record.ttl       = r.xpath('ttl').text()
    record.distance  = r.xpath('distance').text()        
    dns_records << record
  end
  dns_records
end

#list_dns_sec_records(domain) ⇒ Object

dnsSecListRecords Parameters

domain


388
389
390
391
# File 'lib/namesilo_client.rb', line 388

def list_dns_sec_records(domain)
  params={'domain':domain}
  get_request('dnsSecListRecords?'+get_url_parameters(params)).body
end

#list_domainsObject

List all domains Returns XML xpath: /namesilo/reply/domains/domain



96
97
98
# File 'lib/namesilo_client.rb', line 96

def list_domains()
  get_request('listDomains?'+get_url_parameters({})).body
end

#list_domains_arrayObject

list all domains in Array



101
102
103
104
105
106
107
108
# File 'lib/namesilo_client.rb', line 101

def list_domains_array()
  domains = []
  doc = Nokogiri::XML(list_domains())
  doc.xpath('/namesilo/reply/domains/domain').each do |domain|
    domains << domain
  end
  domains
end

#list_email_forwards(domain) ⇒ Object

listEmailForwards returns all email forwards xpath: /namesilo/reply/addresses



233
234
235
# File 'lib/namesilo_client.rb', line 233

def list_email_forwards(domain)
  get_request('listEmailForwards?'+get_url_parameters({'domain':domain})).body
end

#list_email_forwards_array(domain) ⇒ Object

return email forwards array



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/namesilo_client.rb', line 238

def list_email_forwards_array(domain)
  email_forwards = []
  doc = Nokogiri::XML(list_email_forwards(domain))
  doc.xpath('/namesilo/reply/addresses').each do |a|
    ef = EmailForward.new
    ef.email = a.xpath('email').text()
    fts = []
    a.xpath('forwards_to').each do |ft|
      fts << ft.text()
    end
    ef.forwards_to = fts
    email_forwards << ef
  end
  email_forwards
end

#list_name_servers(domain) ⇒ Object

listRegisteredNameServers returns XML containing all name servers xpath: /namesilo/reply/hosts



209
210
211
# File 'lib/namesilo_client.rb', line 209

def list_name_servers(domain)
  get_request('listRegisteredNameServers?'+get_url_parameters({'domain':domain})).body
end

#list_name_servers_array(domain) ⇒ Object

list_name_servers_array



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/namesilo_client.rb', line 214

def list_name_servers_array(domain)
  name_servers = []
  doc = Nokogiri::XML(list_name_servers(domain))
  doc.xpath('/namesilo/reply/hosts').each do |r|
    h = Host.new
    h.host  = r.xpath('host').text()
    ips = []
    r.xpath('ip').each do |ip|
      ips << ip.text()
    end
    h.ips = ips
    name_servers << h
  end
  name_servers
end

#list_ordersObject

listOrders Returns Complete Account Order History xpath: /namesilo/reply/order



278
279
280
# File 'lib/namesilo_client.rb', line 278

def list_orders()
  get_request('listOrders?'+get_url_parameters({})).body
end

#lock_domain(domain) ⇒ Object

domainLock: set a domain to be locked Parameters

domain


524
525
526
527
# File 'lib/namesilo_client.rb', line 524

def lock_domain(domain)
  params={'domain':domain}
  get_request('domainLock?'+get_url_parameters(params)).body
end

#marketplace_active_sales_overviewObject

marketplaceActiveSalesOverview: a list for all active Marketplace sales in your account.



576
577
578
579
# File 'lib/namesilo_client.rb', line 576

def marketplace_active_sales_overview()
  params={}
  get_request('marketplaceActiveSalesOverview?'+get_url_parameters(params)).body
end

#marketplace_add_sale(params) ⇒ Object

marketplaceAddOrModifySale Parameters: see www.namesilo.com/api_reference.php#marketplaceAddOrModifySale



583
584
585
# File 'lib/namesilo_client.rb', line 583

def marketplace_add_sale(params)
  get_request('marketplaceAddOrModifySale?'+get_url_parameters(params)).body
end

#marketplace_landing_page_update(params) ⇒ Object

marketplaceLandingPageUpdate required parameters

domain

optional parameters: see www.namesilo.com/api_reference.php#marketplaceLandingPageUpdate



592
593
594
# File 'lib/namesilo_client.rb', line 592

def marketplace_landing_page_update(params)
  get_request('marketplaceLandingPageUpdate?'+get_url_parameters(params)).body
end

#modify_registered_name_server(params) ⇒ Object

modifyRegisteredNameServer Parameters:

current_host: current host name
new_host: the new host name
ip1
ip2-ip13


450
451
452
# File 'lib/namesilo_client.rb', line 450

def modify_registered_name_server(params)
  get_request('modifyRegisteredNameServer?'+get_url_parameters(params)).body
end

#order_details(order_number) ⇒ Object

orderDetails returns details for provided order number xpath: /namesilo/reply



285
286
287
# File 'lib/namesilo_client.rb', line 285

def order_details(order_number)
  get_request('orderDetails?'+get_url_parameters({'order_number':order_number})).body
end

#register_domain(params) ⇒ Object

registerDomain Parameters

domain(required): The domain to renew
years(required): The number of years to renew the domain    

payment_id(optional)
coupon(optional)
private(optional): if the free WHOIS privacy service will be used or not 
auto_renew(optional)
portfolio(optional): the name of the portfolio to link the registered domain with
ns1-13(optional): up to 13 name servers to use for the domain registration
contact info(optional): see https://www.namesilo.com/api_reference.php#registerDomain


312
313
314
# File 'lib/namesilo_client.rb', line 312

def register_domain(params)
  get_request('registerDomain?'+get_url_parameters(params)).body
end

#remove_auto_renewal(domain) ⇒ Object

removeAutoRenewal: set a domain to not be auto-renewed



485
486
487
488
# File 'lib/namesilo_client.rb', line 485

def remove_auto_renewal(domain)
  params={'domain':domain}
  get_request('removeAutoRenewal?'+get_url_parameters(params)).body
end

#remove_privacy(domain) ⇒ Object

removePrivacy Parameters:

domain


473
474
475
476
# File 'lib/namesilo_client.rb', line 473

def remove_privacy(domain)
  params={'domain':domain}
  get_request('removePrivacy?'+get_url_parameters(params)).body
end

#renew_domain(params) ⇒ Object

renewDomain Parameters (format should be in JSON, e.g. ‘domain’:‘yourdomain.com’,‘years’:‘1’):

domain(required): The domain to renew
years(required): The number of years to renew the domain

payment_id(optional): the id of verified payment method, if not specified, your  balance will be used
coupon(optional): the coupon code used in this transaction


296
297
298
# File 'lib/namesilo_client.rb', line 296

def renew_domain(params)
  get_request('renewDomain?'+get_url_parameters(params)).body
end

#retrieve_auth_code(domain) ⇒ Object

retrieveAuthCode Have the EPP transfer code for the domain emailed to the administrative contact.



195
196
197
# File 'lib/namesilo_client.rb', line 195

def retrieve_auth_code(domain)
  get_request('retrieveAuthCode?'+get_url_parameters({'domain':domain})).body
end

#transfer_domain(params) ⇒ Object

transferDomain Parameters

domain(required)

payment_id(optional)
auth(optional): transfer authorization code
private(optional): if you want the domain to utilize our free WHOIS privacy service
auto_renew(optional) 
portfolio(optional) 
coupon(optional)
Passing Contact Information(optional): see https://www.namesilo.com/api_reference.php#transferDomain
Passing Contact ID(optional): see https://www.namesilo.com/api_reference.php#transferDomain


328
329
330
# File 'lib/namesilo_client.rb', line 328

def transfer_domain(params)
  get_request('transferDomain?'+get_url_parameters(params)).body
end

#transfer_update_change_epp_code(domain, epp_code) ⇒ Object

transferUpdateChangeEPPCode Parameters

domain
auth: The EPP code to use


336
337
338
339
# File 'lib/namesilo_client.rb', line 336

def transfer_update_change_epp_code(domain,epp_code)
  params={'domain':domain,'auth':epp_code}
  get_request('transferUpdateChangeEPPCode?'+get_url_parameters(params)).body
end

#transfer_update_resend_admin_email(domain) ⇒ Object

transferUpdateResendAdminEmail Parameters

domain


344
345
346
347
# File 'lib/namesilo_client.rb', line 344

def transfer_update_resend_admin_email(domain)
  params={'domain':domain}
  get_request('transferUpdateResendAdminEmail?'+get_url_parameters(params)).body
end

#transfer_update_resubmit_to_registry(domain) ⇒ Object

transferUpdateResubmitToRegistry Parameters

domain


352
353
354
355
# File 'lib/namesilo_client.rb', line 352

def transfer_update_resubmit_to_registry(domain)
  params={'domain':domain}
  get_request('transferUpdateResubmitToRegistry?'+get_url_parameters(params)).body
end

#unlock_domain(domain) ⇒ Object

domainUnlock Parameters

domain


532
533
534
535
# File 'lib/namesilo_client.rb', line 532

def unlock_domain(domain)
  params={'domain':domain}
  get_request('domainUnlock?'+get_url_parameters(params)).body
end

#update_contact(params) ⇒ Object

contactUpdate Parameters: see add_contact



83
84
85
# File 'lib/namesilo_client.rb', line 83

def update_contact(params)
  get_request('contactUpdate?'+get_url_parameters(params)).body
end

#update_dns_record(params) ⇒ Object

Update DNS record Parameters:

domain
rrid: The unique ID of the resource record. 
rrhost: The hostname
rrvalue: The value for the resource record
rrdistance: Only used for MX
rrttl: The TTL for this record (default is 7207 if not provided)


164
165
166
# File 'lib/namesilo_client.rb', line 164

def update_dns_record(params)
  get_request('dnsUpdateRecord?'+get_url_parameters(params)).body
end