Class: Cargowise::AbstractClient

Inherits:
Handsoap::Service
  • Object
show all
Defined in:
lib/cargowise/abstract_client.rb

Overview

Superclass of all clients, currently we have clients for orders and Shipments.

Not much to see here, just common methods

Direct Known Subclasses

OrdersClient, ShipmentsClient

Instance Method Summary collapse

Instance Method Details

#hello(company_code, username, pass) ⇒ Object

test authentication, returns a string with your company name if successful



22
23
24
25
26
27
# File 'lib/cargowise/abstract_client.rb', line 22

def hello(company_code, username, pass)
  soap_action  = 'http://www.edi.com.au/EnterpriseService/Hello'
  soap_headers = headers(company_code, username, pass)
  response     = invoke('tns:Hello', :soap_action => soap_action, :soap_header => soap_headers, :http_options => cw_http_options)
  response.document.xpath("//tns:HelloResponse/tns:HelloResult/text()", {"tns" => Cargowise::DEFAULT_NS}).to_s
end

#on_create_document(doc) ⇒ Object

:nodoc:



11
12
13
# File 'lib/cargowise/abstract_client.rb', line 11

def on_create_document(doc)
  doc.alias 'tns', Cargowise::DEFAULT_NS
end

#on_response_document(doc) ⇒ Object



15
16
17
# File 'lib/cargowise/abstract_client.rb', line 15

def on_response_document(doc)
  doc.add_namespace 'ns', Cargowise::DEFAULT_NS
end