Class: HTTP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/http/http_client.rb

Constant Summary collapse

API_URL =
"https://api.unleashedsoftware.com"

Class Method Summary collapse

Class Method Details

.get(api_id:, api_key:, query:, unleashed_model:) ⇒ Object



9
10
11
12
13
14
# 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:) ⇒ Object



23
24
25
26
27
28
29
# 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:) ⇒ Object



16
17
18
19
20
21
# 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