Class: CoinsPhRuby::CoinsPhService
- Inherits:
-
Object
- Object
- CoinsPhRuby::CoinsPhService
- Defined in:
- lib/coins_ph_ruby.rb
Instance Method Summary collapse
- #get_crypto_accounts(_currency = nil) ⇒ Object
- #get_transfers(_id = nil) ⇒ Object
-
#initialize(api_key, api_secret) ⇒ CoinsPhService
constructor
A new instance of CoinsPhService.
- #transfer(amount, account, target_address, message = nil) ⇒ Object
Constructor Details
#initialize(api_key, api_secret) ⇒ CoinsPhService
Returns a new instance of CoinsPhService.
7 8 9 10 11 |
# File 'lib/coins_ph_ruby.rb', line 7 def initialize(api_key, api_secret) @api_key = api_key @api_secret = api_secret @base_url = 'https://coins.ph/api/v3' end |
Instance Method Details
#get_crypto_accounts(_currency = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/coins_ph_ruby.rb', line 13 def get_crypto_accounts(_currency = nil) nonce = Hmac.get_nonce url = @base_url + '/crypto-accounts/' signature = Hmac.sign_request(@api_secret, url, nonce) RestClient.get(url, content_type: :json, accept: :json, ACCESS_SIGNATURE: signature, ACCESS_KEY: @api_key, ACCESS_NONCE: nonce) end |
#get_transfers(_id = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/coins_ph_ruby.rb', line 24 def get_transfers(_id = nil) nonce = Hmac.get_nonce url = @base_url + '/transfers/' signature = Hmac.sign_request(@api_secret, url, nonce) RestClient.get(url, content_type: :json, accept: :json, ACCESS_SIGNATURE: signature, ACCESS_KEY: @api_key, ACCESS_NONCE: nonce) end |
#transfer(amount, account, target_address, message = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/coins_ph_ruby.rb', line 35 def transfer(amount, account, target_address, = nil) body = build_transfer_body(account, amount, , target_address) nonce = Hmac.get_nonce url = @base_url + '/transfers/' signature = Hmac.sign_request(@api_secret, url, nonce, body) RestClient.post(url, body, content_type: :json, accept: :json, ACCESS_SIGNATURE: signature, ACCESS_KEY: @api_key, ACCESS_NONCE: nonce) end |