class Netether::WalletName
The WalletName
object represents a Netki Wallet Name object.
Attributes
domain_name[RW]
external_id[RW]
id[RW]
name[RW]
Public Class Methods
new(domain_name, name, wallets, external_id, id,)
click to toggle source
# File lib/netether/netether.rb, line 75 def initialize(domain_name, name, wallets={}, external_id: nil, id: nil) @domain_name = domain_name @name = name @wallets = wallets.inject({}) do |hsh, (currency, value)| hsh[currency] = value.is_a?(Hash) ? value : { address: value } hsh end @external_id = external_id @id = id end
Actions
↑ topPublic Instance Methods
delete()
click to toggle source
Delete this WalletName
object from the remote service
# File lib/netether/netether.rb, line 168 def delete raise 'Unable to Delete Object that Does Not Exist Remotely' unless @id wn_api_data = { wallet_names: [ { domain_name: @domain_name, id: @id } ] } Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/partner/walletname", 'DELETE', JSON.dump(wn_api_data)) end
save()
click to toggle source
Save the currency WalletName
object to the remote service
# File lib/netether/netether.rb, line 124 def save wallet_data = [] @wallets.each do |currency, wallet| # NOTE: Unsure if remote service supports storing metadata (params/bip70 req)? wallet_data.push( { currency: currency, wallet_address: wallet[:_raw] ? wallet[:_raw] : wallet[:address] } ) end wn_data = { domain_name: @domain_name, name: @name, wallets: wallet_data, external_id: @external_id || 'null' } wn_api_data = {} wn_api_data['wallet_names'] = [wn_data] if @id wn_data['id'] = @id response = Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/partner/walletname", 'PUT', JSON.dump(wn_api_data)) else response = Netether.process_request(@api_key, @partner_id, "#{@api_url}/v1/partner/walletname", 'POST', JSON.dump(wn_api_data)) end unless @id response['wallet_names'].each do |wn| if (response['success'] && wn['domain_name'] == @domain_name && wn['name'] == @name) @id = wn['id'] else raise 'Success, but invalid response received!' end end end end
Currency Address Operations
↑ topPublic Instance Methods
remove_currency(currency)
click to toggle source
Remove a used currency from this wallet name
# File lib/netether/netether.rb, line 109 def remove_currency(currency) @wallets.delete(currency) if @wallets.has_key? currency end
set_currency_address(currency, address)
click to toggle source
Set the address or URI for the given currency for this wallet name
# File lib/netether/netether.rb, line 104 def set_currency_address(currency, address) @wallets[currency] = { address: address } end
Getters
↑ topPublic Instance Methods
get_address(currency)
click to toggle source
Get Address for Existing Currency
# File lib/netether/netether.rb, line 92 def get_address(currency) @wallets[currency][:address] end
used_currencies()
click to toggle source
Get Wallet Name Array of Used Currencies
# File lib/netether/netether.rb, line 97 def used_currencies @wallets.keys end