class GDAXClient::HTTP::ProductTicker::Get

Public Class Methods

build() click to toggle source
# File lib/gdax_client/http/product_ticker/get.rb, line 16
def self.build
  instance = new
  GDAXClient.configure(instance)
  instance
end
call(product_id) click to toggle source
# File lib/gdax_client/http/product_ticker/get.rb, line 11
def self.call(product_id)
  instance = build
  instance.(product_id)
end

Public Instance Methods

call(product_id) click to toggle source
# File lib/gdax_client/http/product_ticker/get.rb, line 22
def call(product_id)
  endpoint = "/products/#{product_id}/ticker"

  logger.trace "Getting ticker (ProductID: #{product_id}, Endpoint: #{endpoint})"

  raw_response = client.get(endpoint)

  if raw_response.code == '200'
    logger.debug "Retrieved ticker (ProductID: #{product_id}, Endpoint: #{endpoint}, Status: #{raw_response.code}, Message: #{raw_response.message})"
    response = Transform::Read.(raw_response.body, Response, :json)
  else
    logger.debug "Failed to retrieve ticker (ProductID: #{product_id}, Endpoint: #{endpoint}, Status: #{raw_response.code}, Message: #{raw_response.message})"
    response = Response.new
  end

  response.status_code = raw_response.code
  response.message = raw_response.message

  response
end