module Coinpayments
Constants
- VERSION
Attributes
configuration[RW]
Public Class Methods
balances(options = {})
click to toggle source
# File lib/coinpayments.rb, line 44 def self.balances(options = {}) api_call(options) end
configure() { |configuration| ... }
click to toggle source
# File lib/coinpayments.rb, line 14 def self.configure yield(configuration) if block_given? end
create_mass_withdrawal(withdrawals)
click to toggle source
# File lib/coinpayments.rb, line 58 def self.create_mass_withdrawal(withdrawals) api_call(withdrawals) end
create_transaction(amount, currency1, currency2, options = {})
click to toggle source
# File lib/coinpayments.rb, line 48 def self.create_transaction(amount, currency1, currency2, options = {}) args = { amount: amount, currency1: currency1, currency2: currency2 }.merge!(options) api_call(args) end
create_withdrawal(amount, currency, address, options = {})
click to toggle source
# File lib/coinpayments.rb, line 53 def self.create_withdrawal(amount, currency, address, options = {}) args = { amount: amount, currency: currency, address: address }.merge!(options) api_call(args) end
get_callback_address(currency, options = {})
click to toggle source
# File lib/coinpayments.rb, line 67 def self.get_callback_address(currency, options = {}) args = { currency: currency }.merge!(options) api_call(args) end
get_tx_info(txid)
click to toggle source
# File lib/coinpayments.rb, line 62 def self.get_tx_info(txid) args = { txid: txid } api_call(args) end
get_withdrawal_info(id)
click to toggle source
# File lib/coinpayments.rb, line 72 def self.get_withdrawal_info(id) args = { id: id } api_call(args) end
rates(options = {})
click to toggle source
# File lib/coinpayments.rb, line 40 def self.rates(options = {}) api_call(options) end
sign(callback_body)
click to toggle source
# File lib/coinpayments.rb, line 77 def self.sign(callback_body) OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), configuration.secret_phrase,callback_body) end
Private Class Methods
api_call(args)
click to toggle source
# File lib/coinpayments.rb, line 32 def self.api_call(args) body = required_params.merge!(cmd: caller[0][/`.*'/][1..-2]).merge!(args) response = HTTParty.post(configuration.base_uri, body: body, headers: {'hmac' => hmac(body)}) response['error'] == 'ok' ? Hashie::Mash.new(response['result']) : response['error'] end
hmac(body)
click to toggle source
# File lib/coinpayments.rb, line 28 def self.hmac(body) OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), configuration.private_api_key, HTTParty::HashConversions.to_params(body)) end
required_params()
click to toggle source
# File lib/coinpayments.rb, line 24 def self.required_params { version: configuration.version, key: configuration.public_api_key } end