Class: Netether::NetkiPartner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(partner_id = nil, api_key = nil, api_url = 'https://api.netki.com') ⇒ NetkiPartner

Returns a new instance of NetkiPartner.



190
191
192
193
194
# File 'lib/netether/netether.rb', line 190

def initialize(partner_id=nil, api_key=nil, api_url='https://api.netki.com')
  @partner_id = partner_id
  @api_key = api_key
  @api_url = api_url
end

Instance Attribute Details

#api_keyObject

The Netki object must be initialized with the Partner ID and API Key to be useful

  • Partner ID -> Netki Partner ID is available on your partner API Key Page

  • API Key -> Netki API Key is available only upon API Key creation. Be sure to store it somewhere safe!



188
189
190
# File 'lib/netether/netether.rb', line 188

def api_key
  @api_key
end

#api_urlObject

The Netki object must be initialized with the Partner ID and API Key to be useful

  • Partner ID -> Netki Partner ID is available on your partner API Key Page

  • API Key -> Netki API Key is available only upon API Key creation. Be sure to store it somewhere safe!



188
189
190
# File 'lib/netether/netether.rb', line 188

def api_url
  @api_url
end

#partner_idObject

The Netki object must be initialized with the Partner ID and API Key to be useful

  • Partner ID -> Netki Partner ID is available on your partner API Key Page

  • API Key -> Netki API Key is available only upon API Key creation. Be sure to store it somewhere safe!



188
189
190
# File 'lib/netether/netether.rb', line 188

def partner_id
  @partner_id
end

Instance Method Details

#create_new_domain(domain_name, partner_id = nil) ⇒ Object

Create a new domain

  • domain_name -> Name of new domain to create

  • partner_id -> (optional) Partner that should own the new domain



231
232
233
234
235
236
# File 'lib/netether/netether.rb', line 231

def create_new_domain(domain_name, partner_id=nil)
  api_data = {}
  api_data['partner_id'] = partner_id unless partner_id.nil?
  Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/partner/domain/#{domain_name}", method='POST', JSON.dump(api_data))
  true
end

#create_new_partner(partner_name) ⇒ Object

Create a new Partner

  • partner_name -> Name of new sub-partner to create



200
201
202
203
204
# File 'lib/netether/netether.rb', line 200

def create_new_partner(partner_name)
  encoded_partner_name = URI.encode(partner_name)
  response = Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/admin/partner/#{encoded_partner_name}", method='POST')
  response['partner']['id']
end

#create_new_walletname(domain_name, name, wallets = {}, external_id = nil) ⇒ Object

Create a new Wallet Name object using this factory method.

  • domain_name -> The pre-configured domain name you would like to add this new wallet name to

  • name -> The DNS name that you would like this new wallet name to have (ie.. name.domain_name)

  • wallets -> This is a hash where the key is the currency (ie.. btc, ltc, dgc, tusd) and the value is:

    the wallet address OR
    URL of the BIP32 / BIP70 address server OR
    a hash containing an :address and other metadata
    
  • external_id -> Any unique external ID that you may want to use to track this specific wallet name



297
298
299
300
301
# File 'lib/netether/netether.rb', line 297

def create_new_walletname(domain_name, name, wallets={}, external_id=nil)
  new_wn = WalletName.new(domain_name, name, wallets, external_id: external_id)
  new_wn.set_api_opts(@api_url, @partner_id, @api_key)
  new_wn
end

#delete_domain(domain_name) ⇒ Object

Delete a Domain

  • domain_name -> Name of delete to delete



281
282
283
284
# File 'lib/netether/netether.rb', line 281

def delete_domain(domain_name)
  Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/partner/domain/#{domain_name}", method='DELETE')
  true
end

#delete_partner(partner_name) ⇒ Object

Delete a Partner

  • partner_name -> Name of sub-partner to delete

NOTE: You cannot delete your own partner resource



220
221
222
223
224
# File 'lib/netether/netether.rb', line 220

def delete_partner(partner_name)
  encoded_partner_name = URI.encode(partner_name)
  Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/admin/partner/#{encoded_partner_name}", method='DELETE')
  true
end

#get_domain_dnssec(domain_name) ⇒ Object

Get DNSSEC Status of Domain

  • domain_name -> (Required) Name of domain to get DNSSEC status for

Returns a hash containing the follow DNSSEC-related keys:

  • ds_records (list)

  • public_key_signing_key

  • nextroll_date

  • nameservers (list)



273
274
275
# File 'lib/netether/netether.rb', line 273

def get_domain_dnssec(domain_name)
  Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/partner/domain/dnssec/#{domain_name}", method='GET')
end

#get_domain_status(domain_name = nil) ⇒ Object

List status of domain resources

  • domain_name -> (Optional) Name of domain to return status for

If domain_name is omitted status is returned for all available domain resources.

Returns a list of Hashes, each containing current status for each domain



255
256
257
258
259
260
261
# File 'lib/netether/netether.rb', line 255

def get_domain_status(domain_name=nil)
  uri="#{@api_url}/v1/partner/domain"
  uri << "/#{domain_name}" unless domain_name.nil?

  response = Netether.process_request(@api_key, @partner_id, uri, method='GET')
  response['domains'] || response
end

#get_domainsObject

List available domain resources Returns a list of domain Hashes, each containing a domain_name and tld_type key



242
243
244
245
# File 'lib/netether/netether.rb', line 242

def get_domains()
  response = Netether.process_request(@api_key, @partner_id, "#{@api_url}/api/domain", method='GET')
  response['domains']
end

#get_partnersObject

List current and sub partners Returns a list of partner Hashes, each containing an id and name key



210
211
212
213
# File 'lib/netether/netether.rb', line 210

def get_partners()
  response = Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/admin/partner", method='GET')
  response['partners']
end

#get_wallet_names(domain_name = nil, external_id = nil) ⇒ Object

Returns an array of WalletName objects based on the given search parameters:

  • domain_name -> The pre-configured domain that you have already been using for wallet names

  • external_id -> The external ID previously given to the single wallet name you want to retrieve



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/netether/netether.rb', line 307

def get_wallet_names(domain_name=nil, external_id=nil)
  args = []
  args.push("domain_name=#{domain_name}") if domain_name
  args.push("external_id=#{external_id}") if external_id

  uri = "#{@api_url}/v1/partner/walletname"
  uri = (uri + "?" + args.join("&")) unless args.empty?
  response = Netether.process_request(@api_key, @partner_id, uri, method='GET')

  return [] if !response.has_key? 'wallet_name_count' || response['wallet_name_count'] == 0

  wn_list = []
  response['wallet_names'].each do |wn|
    wallets = {}
    wn['wallets'].each do |wallet|
      wallets[wallet['currency']] = wallet['wallet_address']
    end
    wn_obj = WalletName.new(wn['domain_name'], wn['name'], wallets, external_id: wn['external_id'], id: wn['id'])
    wn_obj.set_api_opts(@api_url, @partner_id, @api_key)
    wn_list.push(wn_obj)
  end
  wn_list
end