Class: Btce::PublicAPI

Inherits:
API
  • Object
show all
Defined in:
lib/btce/api/public_api.rb

Constant Summary collapse

OPERATIONS =
%w(fee ticker trades depth)

Constants inherited from API

API::BTCE_DOMAIN, API::CURRENCIES, API::CURRENCY_PAIRS, API::MAX_DIGITS

Class Method Summary collapse

Methods inherited from API

get_https, get_json

Class Method Details

.get_pair_operation_json(pair, operation, options = {}) ⇒ Object

Raises:

  • (ArgumentError)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/btce/api/public_api.rb', line 42

def get_pair_operation_json(pair, operation, options={})
  list = pair.split('-')
  i = 0
  begin
    raise ArgumentError if not API::CURRENCY_PAIRS.include? list[i]
    i = i + 1
  end while i < list.length
  raise ArgumentError if not OPERATIONS.include? operation

  params = ""
  if options[:limit]
    if options[:limit].is_a? Integer
      if options[:limit] < 1
        raise ArgumentError, "Limit #{options[:limit]} < 1."
      else
        params = "?limit=#{options[:limit]}"
      end
    else
      raise ArgumentError,
        "Non-Integer limit #{options[:limit].inspect}."
    end
  end

  get_json url: "https://#{API::BTCE_DOMAIN}/api/3/#{operation}/#{pair}#{params}"
end