Class: Postat
- Inherits:
-
Object
- Object
- Postat
- Defined in:
- lib/postat.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #delete_label(options = {}) ⇒ Object
-
#generate_label(options = {}) ⇒ Object
NOTE: be careful with the order of attributes to avoid fake missing attribute errors.
-
#initialize ⇒ Postat
constructor
A new instance of Postat.
Constructor Details
#initialize ⇒ Postat
Returns a new instance of Postat.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/postat.rb', line 8 def initialize @client = Savon.client(wsdl: POSTAT_CONFIG[:wsdl], convert_request_keys_to: :none, env_namespace: :soapenv, namespace_identifier: :post, log: true, pretty_print_xml: true, endpoint: POSTAT_CONFIG[:endpoint], namespaces: { 'xmlns:post' => 'http://post.ondot.at', 'xmlns:arr' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays', 'xmlns:core' => 'http://Core.Model', 'xmlns:ser' => 'http://schemas.microsoft.com/2003/10/Serialization/' } ) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/postat.rb', line 6 def client @client end |
Instance Method Details
#delete_label(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/postat.rb', line 25 def delete_label( = {}) = [] [:shipments]&.each do |shipment| row = row['post:Number'] = shipment[:reference_number] add_common_params(row) << { 'post:CancelShipmentRow' => row } end response = client.call(:cancel_shipments, message: { 'post:shipments' => }) handle_response(response, action: :cancel_shipments) end |
#generate_label(options = {}) ⇒ Object
NOTE: be careful with the order of attributes to avoid fake missing attribute errors
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/postat.rb', line 38 def generate_label( = {}) = ['post:DeliveryServiceThirdPartyID'] = [:delivery_code] ['post:Number'] = [:reference_number] ['post:ColloList'] = add_packages([:package]) # message['post:ShippingDateTimeFrom'] = (Time.zone.now + 180).iso8601 ['post:OURecipientAddress'] = add_address([:to]) ['post:OUShipperAddress'] = add_address([:from]) add_common_params() ['post:PrinterObject'] = add_printing_details # TODO: Look for the new attrs names for: PaymentType, Commodities response = client.call(:import_shipment, message: { 'post:row' => }) handle_response response end |