Class: DhlFreightApi::Resources::Print
- Inherits:
-
Object
- Object
- DhlFreightApi::Resources::Print
- Defined in:
- lib/dhl_freight_api/resources/print.rb
Instance Method Summary collapse
- #base_url ⇒ Object
- #documents_by_id(payload) ⇒ Object
-
#initialize(client) ⇒ Print
constructor
A new instance of Print.
Constructor Details
#initialize(client) ⇒ Print
Returns a new instance of Print.
6 7 8 |
# File 'lib/dhl_freight_api/resources/print.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#base_url ⇒ Object
10 11 12 |
# File 'lib/dhl_freight_api/resources/print.rb', line 10 def base_url "#{@client.base_url}/printapi/v1/print/printdocumentsbyid" end |
#documents_by_id(payload) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dhl_freight_api/resources/print.rb', line 14 def documents_by_id(payload) response = @client.connection.post(base_url, payload) if response.success? Objects::Print.new(response.body) else raise DhlFreightApi::Error.new( "Failed to print documents by ID: #{response.status} - #{response.body}", response_http_code: response.status, response_body: response.body ) end end |