Class: AppleStoreInventoryChecker::APIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_store_inventory_checker/api_client.rb

Class Method Summary collapse

Class Method Details

.get(uri) ⇒ Object



4
5
6
7
8
9
# File 'lib/apple_store_inventory_checker/api_client.rb', line 4

def get(uri)
  http = setup_http(uri)
  req = Net::HTTP::Get.new(uri)
  req.add_field "Accept", "application/json"
  http.request(req)
end

.setup_http(uri) ⇒ Object



11
12
13
14
15
16
# File 'lib/apple_store_inventory_checker/api_client.rb', line 11

def setup_http(uri)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  http
end