Class: Cargowise::ShipmentsClient

Inherits:
AbstractClient show all
Defined in:
lib/cargowise/shipments_client.rb

Overview

SOAP client for retreiving shipment data. Not much to see here, used by the Shipment resource class.

Instance Method Summary collapse

Instance Method Details

#get_shipments_list(endpoint_uri, company_code, username, pass, filter_hash) ⇒ Object

return an array of shipments. Each shipment should correspond to a consolidated shipment from the freight company.

filter_hash should be a hash that will be serialised into an XML fragment specifying the search criteria. See the WSDL documentation for samples



17
18
19
20
21
22
23
# File 'lib/cargowise/shipments_client.rb', line 17

def get_shipments_list(endpoint_uri, company_code, username, pass, filter_hash)
  client = build_client(shipment_wsdl_path, endpoint_uri, company_code, username, pass)
  response = client.call(:get_shipments_list, message: filter_hash)
  response.xpath("//tns:GetShipmentsListResult/tns:WebShipment", {"tns" => Cargowise::DEFAULT_NS}).map do |node|
    Cargowise::Shipment.new(node)
  end
end

#hello(endpoint_uri, company_code, username, pass) ⇒ Object

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



28
29
30
31
32
# File 'lib/cargowise/shipments_client.rb', line 28

def hello(endpoint_uri, company_code, username, pass)
  client = build_client(shipment_wsdl_path, endpoint_uri, company_code, username, pass)
  response = client.call(:hello)
  response.xpath("//tns:HelloResponse/tns:HelloResult/text()", {"tns" => Cargowise::DEFAULT_NS}).to_s
end