class HTTP::Client

Constants

API_URL

Public Class Methods

get(api_id:, api_key:, query:, unleashed_model:) click to toggle source
# File lib/http/http_client.rb, line 9
def get(api_id:, api_key:, query:, unleashed_model:)
  headers = generate_signature_and_headers(api_key: api_key, api_id: api_id, query: query)
  
  url = "#{API_URL}/#{unleashed_model}"
  HTTParty.get(url, headers: headers)
end
get_from_page(api_id:, api_key:, query:, unleashed_model:, page_number:) click to toggle source
# File lib/http/http_client.rb, line 23
def get_from_page(api_id:, api_key:, query:, unleashed_model:, page_number:)
  headers = generate_signature_and_headers(api_key: api_key, api_id: api_id, query: query)

  url = "#{API_URL}/#{unleashed_model}/Page/#{page_number}"
  response = HTTParty.get(url, headers: headers)
  response["Items"]
end
get_with_guid(api_id:, api_key:, query:, unleashed_model:, guid:) click to toggle source
# File lib/http/http_client.rb, line 16
def get_with_guid(api_id:, api_key:, query:, unleashed_model:, guid:)
  headers = generate_signature_and_headers(api_key: api_key, api_id: api_id, query: query)

  url = "#{API_URL}/#{unleashed_model}/#{guid}"
  HTTParty.get(url, headers: headers)
end

Private Class Methods

generate_signature_and_headers(api_key:, api_id:, query:) click to toggle source
# File lib/http/http_client.rb, line 33
def generate_signature_and_headers(api_key:, api_id:, query:)
  signature = Auth.get_signature(api_key: api_key, query: query)

  {
    "Content-Type" => "application/json",
    "Accept" => "application/json",
    "api-auth-id" => api_id,
    "api-auth-signature" => signature
  }
end