Class: Cryptopia::Api::Market
- Inherits:
-
Object
- Object
- Cryptopia::Api::Market
- Includes:
- HTTParty
- Defined in:
- lib/cryptopia/api/market.rb
Constant Summary collapse
- AVAILABLE_PARAMS =
{ markets: [:baseParam, :hours], market: [:hours], history: [:hours], orders: [:orderCount], order_groups: [:orderCount] }
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #find(market, options = {}) ⇒ Object
- #history(market, options = {}) ⇒ Object
-
#initialize(uri) ⇒ Market
constructor
A new instance of Market.
- #order_groups(markets = [], options = {}) ⇒ Object
- #orders(market, options = {}) ⇒ Object
Constructor Details
#initialize(uri) ⇒ Market
Returns a new instance of Market.
14 15 16 |
# File 'lib/cryptopia/api/market.rb', line 14 def initialize(uri) self.class.base_uri uri end |
Instance Method Details
#all(options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/cryptopia/api/market.rb', line 18 def all( = {}) if invalid_params?(:markets, ) raise ArgumentError, "Arguments must be #{params(:markets)}" end endpoint_call_handler("/GetMarkets", ) end |
#find(market, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cryptopia/api/market.rb', line 26 def find(market, = {}) if valid_market?(market) raise ArgumentError, 'The trade pair must be informed' end if invalid_params?(:market, ) raise ArgumentError, "Arguments must be #{params(:market)}" end endpoint_call_handler("/GetMarket/#{market}", ) end |
#history(market, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cryptopia/api/market.rb', line 38 def history(market, = {}) if valid_market?(market) raise ArgumentError, 'The trade pair must be informed' end if invalid_params?(:history, ) raise ArgumentError, "Arguments must be #{params(:history)}" end endpoint_call_handler("/GetMarketHistory/#{market}", ) end |
#order_groups(markets = [], options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cryptopia/api/market.rb', line 62 def order_groups(markets = [], = {}) if markets.nil? || (!markets.nil? && markets.empty?) raise ArgumentError, 'The trade pairs must be informed' end if invalid_params?(:order_groups, ) raise ArgumentError, "Arguments must be #{params(:order_groups)}" end handled_markets = markets.join('-') endpoint_call_handler("/GetMarketOrderGroups/#{handled_markets}", ) end |
#orders(market, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/cryptopia/api/market.rb', line 50 def orders(market, = {}) if valid_market?(market) raise ArgumentError, 'The trade pair must be informed' end if invalid_params?(:orders, ) raise ArgumentError, "Arguments must be #{params(:orders)}" end endpoint_call_handler("/GetMarketOrders/#{market}", ) end |