Class: PostNordAPI::Client
- Inherits:
-
Object
- Object
- PostNordAPI::Client
- Defined in:
- lib/post_nord_api/client.rb
Constant Summary collapse
- BASE_URL =
'https://api2.postnord.com/rest'- SANDBOX_BASE_URL =
'https://atapi2.postnord.com/rest'
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(api_key:, test_mode: false) ⇒ Client
constructor
A new instance of Client.
- #shipment ⇒ Object
Constructor Details
#initialize(api_key:, test_mode: false) ⇒ Client
Returns a new instance of Client.
11 12 13 14 |
# File 'lib/post_nord_api/client.rb', line 11 def initialize(api_key:, test_mode: false) @api_key = api_key @test_mode = test_mode end |
Instance Method Details
#connection ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/post_nord_api/client.rb', line 16 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = url_prefix conn.request :json conn.headers = { 'Content-Type' => 'application/json' } conn.params[:apikey] = api_key conn.response :json, content_type: 'application/json' end end |
#shipment ⇒ Object
27 28 29 |
# File 'lib/post_nord_api/client.rb', line 27 def shipment @shipment ||= ShipmentResource.new(self) end |