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



9
10
11
12
# File 'lib/namesilo_client.rb', line 9

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

Instance Method Details

#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


73
74
75
# File 'lib/namesilo_client.rb', line 73

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)


108
109
110
# File 'lib/namesilo_client.rb', line 108

def add_dns_record(params)
  get_request('dnsAddRecord?'+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



145
146
147
# File 'lib/namesilo_client.rb', line 145

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

#check_transfer_status(domain) ⇒ Object

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



136
137
138
# File 'lib/namesilo_client.rb', line 136

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

#delete_dns_record(params) ⇒ Object

Delete DNS record Parameters:

domain
rrid: The unique ID of the resource record


128
129
130
# File 'lib/namesilo_client.rb', line 128

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

#get_account_balanceObject

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



186
187
188
# File 'lib/namesilo_client.rb', line 186

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

#get_connectionObject

Establish connection



15
16
17
18
19
20
# File 'lib/namesilo_client.rb', line 15

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’)



42
43
44
# File 'lib/namesilo_client.rb', line 42

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

#get_default_parametersObject

Default parameters for Namesilio REST APIs



23
24
25
# File 'lib/namesilo_client.rb', line 23

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



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

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



158
159
160
# File 'lib/namesilo_client.rb', line 158

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

#get_pricesObject

getPrices returns price list xpath: /namesilo/reply



193
194
195
# File 'lib/namesilo_client.rb', line 193

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



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

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

#get_request(endpoint) ⇒ Object



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

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

#get_url_parameters(params) ⇒ Object

Construct URL parameters, combing with default parameters



32
33
34
35
36
# File 'lib/namesilo_client.rb', line 32

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



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

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

#list_domainsObject

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



80
81
82
# File 'lib/namesilo_client.rb', line 80

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

#list_email_forwards(domain) ⇒ Object

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



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

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

#list_name_servers(domain) ⇒ Object

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



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

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

#list_ordersObject

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



200
201
202
# File 'lib/namesilo_client.rb', line 200

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

#order_details(order_number) ⇒ Object

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



207
208
209
# File 'lib/namesilo_client.rb', line 207

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

#retrieve_auth_code(domain) ⇒ Object

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



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

def retrieve_auth_code(domain)
  get_request('retrieveAuthCode?'+get_url_parameters({'domain':domain})).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)


120
121
122
# File 'lib/namesilo_client.rb', line 120

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