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 23 24 25 26 27 28 |
# 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) begin response = RestClient.get(url, content_type: :json, accept: :json, ACCESS_SIGNATURE: signature, ACCESS_KEY: @api_key, ACCESS_NONCE: nonce) rescue StandardError => e puts e.response end response end |
#get_transfers(_id = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/coins_ph_ruby.rb', line 30 def get_transfers(_id = nil) nonce = Hmac.get_nonce url = @base_url + '/transfers/' signature = Hmac.sign_request(@api_secret, url, nonce) begin response = RestClient.get(url, content_type: :json, accept: :json, ACCESS_SIGNATURE: signature, ACCESS_KEY: @api_key, ACCESS_NONCE: nonce) rescue StandardError => e puts e.response end response end |
#transfer(amount, account, target_address, message = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/coins_ph_ruby.rb', line 47 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) begin response = RestClient.post(url, body, content_type: :json, accept: :json, ACCESS_SIGNATURE: signature, ACCESS_KEY: @api_key, ACCESS_NONCE: nonce) rescue StandardError => e puts e.response end response end |