Class: Cryptoexchange::Exchanges::Coinut::Services::Pairs

Inherits:
Services::Pairs
  • Object
show all
Defined in:
lib/cryptoexchange/exchanges/coinut/services/pairs.rb

Constant Summary

Constants inherited from Services::Pairs

Services::Pairs::HTTP_METHOD, Services::Pairs::MARKET, Services::Pairs::PAIRS_URL, Services::Pairs::POST_PARAMS

Instance Method Summary collapse

Methods inherited from Services::Pairs

#default_override_exist?, #default_override_path, #exchange_class, #fetch_via_api, #fetch_via_api_using_post, #fetch_via_override, #http_get, #http_post, #user_override_exist?, #user_override_path

Instance Method Details

#adapt(output) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cryptoexchange/exchanges/coinut/services/pairs.rb', line 27

def adapt(output)
  output["SPOT"].map do |pairs, array|
    hash = array.first
    Cryptoexchange::Models::MarketPair.new(
      base: hash["base"],
      target: hash["quote"],
      inst_id: hash["inst_id"].to_s,
      market: Coinut::Market::NAME
    )
  end
end

#fetchObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cryptoexchange/exchanges/coinut/services/pairs.rb', line 6

def fetch
  authentication = Cryptoexchange::Exchanges::Coinut::Authentication.new(
    :pairs,
    Cryptoexchange::Exchanges::Coinut::Market::NAME
  )
  authentication.validate_credentials!

  payload_ = payload
  headers = authentication.headers(payload_)
  output = fetch_via_api_using_post(pairs_url, headers, payload_)
  adapt(output)
end

#pairs_urlObject



23
24
25
# File 'lib/cryptoexchange/exchanges/coinut/services/pairs.rb', line 23

def pairs_url
  Cryptoexchange::Exchanges::Coinut::Market::API_URL
end

#payloadObject



19
20
21
# File 'lib/cryptoexchange/exchanges/coinut/services/pairs.rb', line 19

def payload
  '{"nonce":' + SecureRandom.random_number(99999).to_s + ',"request":"inst_list", "sec_type":"SPOT"}'
end