Class: DHLAPI::RetoureClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- DHLAPI::RetoureClient
- Defined in:
- lib/dhl_api/clients/retoure_client.rb
Constant Summary collapse
- URL =
'https://api-eu.dhl.com/parcel/de/shipping/returns/v1/orders'- TEST_URL =
'https://api-sandbox.dhl.com/parcel/de/shipping/returns/v1/orders'
Instance Attribute Summary collapse
Attributes inherited from BaseClient
Instance Method Summary collapse
- #connection ⇒ Object
- #create_label(attributes = {}) ⇒ Object
-
#initialize(username: nil, password: nil, label_type: 'BOTH') ⇒ RetoureClient
constructor
A new instance of RetoureClient.
Constructor Details
#initialize(username: nil, password: nil, label_type: 'BOTH') ⇒ RetoureClient
Returns a new instance of RetoureClient.
6 7 8 9 10 |
# File 'lib/dhl_api/clients/retoure_client.rb', line 6 def initialize(username: nil, password: nil, label_type: 'BOTH') @username = username @password = password @label_type = label_type end |
Instance Attribute Details
#label_type ⇒ string #label_type=(value) ⇒ Object
17 18 19 |
# File 'lib/dhl_api/clients/retoure_client.rb', line 17 def label_type @label_type end |
Instance Method Details
#connection ⇒ Object
25 26 27 |
# File 'lib/dhl_api/clients/retoure_client.rb', line 25 def connection super.basic_auth(user: username, pass: password) end |
#create_label(attributes = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/dhl_api/clients/retoure_client.rb', line 19 def create_label(attributes = {}) payload = attributes.deep_transform_keys { |key| key.to_s.camelize(:lower) } self.response = connection.post(url, json: payload, params: { labelType: label_type }) RetoureLabel.new handle_response.parse end |