Class: DogeCoin::Client

Inherits:
Object
  • Object
show all
Includes:
Configuration, Faraday
Defined in:
lib/dogecoin/client.rb

Constant Summary collapse

BASE_URL =
"https://dogeapi.com/wow/?"

Instance Attribute Summary

Attributes included from Configuration

#api_key

Instance Method Summary collapse

Methods included from Configuration

#configure, #reset

Constructor Details

#initializeClient

Returns a new instance of Client.



13
14
15
# File 'lib/dogecoin/client.rb', line 13

def initialize
  reset
end

Instance Method Details

#get_address_by_label(address_label) ⇒ Object

Returns the payment address for the given ADDRESS_LABEL



53
54
55
56
# File 'lib/dogecoin/client.rb', line 53

def get_address_by_label(address_label)
  # /wow/?api_key={API_KEY}&a=get_address_by_label&address_label={ADDRESS_LABEL}
  Faraday.get("#{BASE_URL}api_key=#{api_key}&a=get__address_by_label&address_label=#{address_label}").body
end

#get_address_received(payment_address_or_address_label) ⇒ Object

Returns the current amount received to all addresses with ADDRESS_LABEL or PAYMENT_ADDRESS.



47
48
49
50
# File 'lib/dogecoin/client.rb', line 47

def get_address_received(payment_address_or_address_label)
  # /wow/?api_key={API_KEY}&a=get_address_received&payment_address={PAYMENT_ADDRESS}
  Faraday.get("#{BASE_URL}api_key=#{api_key}&a=get_address_received&payment_address=#{payment_address_or_address_label}").body
end

#get_balanceObject

Returns the DOGE balance of your entire account to 8 decimal places.



18
19
20
21
# File 'lib/dogecoin/client.rb', line 18

def get_balance
  # /wow/?api_key={API_KEY}&a=get_balance
  Faraday.get("#{BASE_URL}api_key=#{api_key}&a=get_balance").body
end

#get_current_blockObject

Returns the current block. This doesn’t require an API key.



65
66
67
68
# File 'lib/dogecoin/client.rb', line 65

def get_current_block
  # /wow/?a=get_current_block
  Faraday.get("#{BASE_URL}#&a=get_current_block").body
end

#get_difficultyObject

Returns the current difficulty. This doesn’t require an API key.



59
60
61
62
# File 'lib/dogecoin/client.rb', line 59

def get_difficulty
  # /wow/?a=get_difficulty
  Faraday.get("#{BASE_URL}&a=get_difficulty").body
end

#get_my_addressesObject

Returns all payment addresses/address_ids for your account.



41
42
43
44
# File 'lib/dogecoin/client.rb', line 41

def get_my_addresses
  # /wow/?api_key={API_KEY}&a=get_my_addresses
  Faraday.get("#{BASE_URL}api_key=#{api_key}&a=get_my_addresses").body
end

#get_new_address(address_label = nil) ⇒ Object

Returns a new payment address for your account. You can pass an optional alphanumeric ADDRESS_LABEL as a label for the address.



31
32
33
34
35
36
37
38
# File 'lib/dogecoin/client.rb', line 31

def get_new_address(address_label = nil)
  # /wow/?api_key={API_KEY}&a=get_new_address&address_label={ADDRESS_LABEL}
  if address_label
    Faraday.get("#{BASE_URL}api_key=#{api_key}&a=get_new_address&address_label=#{address_label}").body
  else
    Faraday.get("#{BASE_URL}api_key=#{api_key}&a=get_new_address").body
  end
end

#withdraw(amount, payment_address) ⇒ Object

Withdraws AMOUNT doge to a PAYMENT_ADDRESS you specify. For now this must be more than 5 doge, and you must have enough extra in your wallet to pay all fees (another 1-3 doge).



25
26
27
28
# File 'lib/dogecoin/client.rb', line 25

def withdraw(amount, payment_address)
  # /wow/?api_key={API_KEY}&a=withdraw&amount={AMOUNT}&payment_address={PAYMENT_ADDRESS}
  Faraday.get("#{BASE_URL}api_key=#{api_key}&a=withdraw&amount=#{amount}&payment_address=#{payment_address}").body
end