Class: GDAXClient::HTTP::ProductTicker::Get

Inherits:
Object
  • Object
show all
Includes:
Log::Dependency
Defined in:
lib/gdax_client/http/product_ticker/get.rb,
lib/gdax_client/http/product_ticker/get/response.rb

Defined Under Namespace

Classes: Response, Substitute

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.buildObject



16
17
18
19
20
# File 'lib/gdax_client/http/product_ticker/get.rb', line 16

def self.build
  instance = new
  GDAXClient.configure(instance)
  instance
end

.call(product_id) ⇒ Object



11
12
13
14
# File 'lib/gdax_client/http/product_ticker/get.rb', line 11

def self.call(product_id)
  instance = build
  instance.(product_id)
end

Instance Method Details

#call(product_id) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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