Class: TNT::Shipment

Inherits:
Resource
  • Object
show all
Defined in:
lib/tnt.rb

Overview

Shipments endpoint resource

Constant Summary

Constants inherited from Resource

Resource::XML_HEADER, Resource::XML_RENDER_OPTIONS

Class Method Summary collapse

Methods inherited from Resource

credentials, error_response?, extract_error, parse_response, to_xml

Class Method Details

.create(payload) ⇒ TNT::Shipment

Handles the shipment label creation

Returns:



86
87
88
89
90
91
92
93
94
95
# File 'lib/tnt.rb', line 86

def self.create(payload)
  opts = { form: { xml_in: to_xml(payload) } }
  pre_response = request(:post, uri, opts)

  # Use the token and get the real response...
  opts = { form: { xml_in: 'GET_RESULT:' + pre_response['complete'] } }
  response = request(:post, uri, opts)

  new((response['document'] || response).merge(pre_response))
end