Class: Coinswitch::Dynamic::DynamicClient
- Inherits:
-
Object
- Object
- Coinswitch::Dynamic::DynamicClient
- Includes:
- HTTParty
- Defined in:
- lib/coinswitch.rb
Overview
Your code goes hereā¦
Instance Method Summary collapse
- #bulk_rate(input) ⇒ Object
- #coins ⇒ Object
- #coins_list ⇒ Object
-
#initialize(ip_address = Ipify.ip, api_key = Coinswitch::SANDBOX_API_KEY) ⇒ DynamicClient
constructor
A new instance of DynamicClient.
- #order(depositCoin, destinationCoin, depositCoinAmount, destinationAddress, refundAddress, callbackUrl = '') ⇒ Object
- #orderid(orderid) ⇒ Object
- #orders(start, count) ⇒ Object
- #pairs(depositCoin, destinationCoin) ⇒ Object
- #rate(depositCoin, destinationCoin) ⇒ Object
Constructor Details
#initialize(ip_address = Ipify.ip, api_key = Coinswitch::SANDBOX_API_KEY) ⇒ DynamicClient
Returns a new instance of DynamicClient.
15 16 17 18 19 20 21 22 |
# File 'lib/coinswitch.rb', line 15 def initialize(ip_address=Ipify.ip,api_key=Coinswitch::SANDBOX_API_KEY) ## # This Initialises the client and populates the coins list @ip_address = ip_address @api_key = api_key @coins = coins end |
Instance Method Details
#bulk_rate(input) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/coinswitch.rb', line 74 def bulk_rate(input) ## # https://developer.coinswitch.co/reference#post-v2bulk-rate @@response = self.class.post('/rate', headers:{'x-api-key':@api_key,'x-user-ip':@ip_address}, body:JSON.unparse(input) ) return JSON.parse @@response.body end |
#coins ⇒ Object
29 30 31 32 33 34 |
# File 'lib/coinswitch.rb', line 29 def coins ## # This gets a list of coins that are available for swapping @@response = self.class.get('/coins',headers:{'x-api-key':@api_key,'x-user-ip':@ip_address}) return JSON.parse @@response.body end |
#coins_list ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/coinswitch.rb', line 36 def coins_list ## # Gets ONLY a list of symbols available for trade. @@coins_list = [] @@coins = self.coins @@tomap = @@coins['data'] @@tomap.map{|x| @@coins_list << x["symbol"] } return @@coins_list end |
#order(depositCoin, destinationCoin, depositCoinAmount, destinationAddress, refundAddress, callbackUrl = '') ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/coinswitch.rb', line 63 def order(depositCoin,destinationCoin,depositCoinAmount,destinationAddress,refundAddress,callbackUrl='') @@response = self.class.post('/rate', headers:{'x-api-key':@api_key,'x-user-ip':@ip_address}, body:JSON.unparse({'depositCoin'=> depositCoin,'destinationCoin' => destinationCoin, 'depositCoinAmount' => depositCoinAmount,'destinationAddress' => destinationAddress,'refundAddress' => refundAddress,'callbackUrl' => callbackUrl}) ) return JSON.parse @@response.body end |
#orderid(orderid) ⇒ Object
70 71 72 73 |
# File 'lib/coinswitch.rb', line 70 def orderid(orderid) @@response = self.class.get('/order/'+ orderid.to_s,headers:{'x-api-key':@api_key,'x-user-ip':@ip_address},query:{'orderid'=> orderid}) return JSON.parse @@response.body end |
#orders(start, count) ⇒ Object
83 84 85 86 |
# File 'lib/coinswitch.rb', line 83 def orders(start,count) @@response = self.class.get('/coins',headers:{'x-api-key':@api_key,'x-user-ip':@ip_address},query:{'start'=> start,'count' => count}) return JSON.parse @@response.body end |
#pairs(depositCoin, destinationCoin) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/coinswitch.rb', line 46 def pairs(depositCoin,destinationCoin) ## # determines if pairs are valid if the response is ok @@response = self.class.post('/pairs', headers:{'x-api-key':@api_key,'x-user-ip':@ip_address}, body:JSON.unparse({'depositCoin'=> depositCoin, 'destinationCoin' => destinationCoin})) return JSON.parse @@response.body end |
#rate(depositCoin, destinationCoin) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/coinswitch.rb', line 55 def rate(depositCoin,destinationCoin) @@response = self.class.post('/rate', headers:{'x-api-key':@api_key,'x-user-ip':@ip_address}, body:JSON.unparse({'depositCoin'=> depositCoin,'destinationCoin' => destinationCoin}) ) return JSON.parse @@response.body end |