Class: Caly::Client
- Inherits:
-
Object
- Object
- Caly::Client
- Defined in:
- lib/caly/client.rb
Instance Method Summary collapse
- #execute_request(method, path) ⇒ Object
-
#initialize(url, headers) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(url, headers) ⇒ Client
Returns a new instance of Client.
3 4 5 6 |
# File 'lib/caly/client.rb', line 3 def initialize(url, headers) @url = url @headers = headers end |
Instance Method Details
#execute_request(method, path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/caly/client.rb', line 8 def execute_request(method, path) uri = URI.parse([@url, path].join("/")) request = Net::HTTPGenericRequest.new( method.to_s.upcase, false, true, uri, @headers ) response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request(request) end JSON.parse(response.body).merge("code" => response.code) end |