Module: Eship::ApiClient
- Defined in:
- lib/eship/api_client.rb
Defined Under Namespace
Classes: ImmutableKey
Class Method Summary collapse
Class Method Details
.default_headers ⇒ Object
6 7 8 9 10 11 |
# File 'lib/eship/api_client.rb', line 6 def self.default_headers { "content-type" => 'application/json', ImmutableKey.new("api-key") => Eship.eship_key } end |
.post(path:, body: {}, headers: {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/eship/api_client.rb', line 13 def self.post(path:, body: {}, headers: {}) path = "#{Eship.base_uri}#{path}" headers = headers.merge(ApiClient.default_headers) response = HTTParty.post(path, body: body.to_json, headers: headers) JSON.parse(response.body) end |