Class: PurolatorWebServices::Api

Inherits:
Object
  • Object
show all
Includes:
Soap
Defined in:
lib/purolator_web_services/api.rb

Defined Under Namespace

Classes: ServiceException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_url) ⇒ Api

Returns a new instance of Api.



18
19
20
21
# File 'lib/purolator_web_services/api.rb', line 18

def initialize(api_url)
  self.port = Soap::ShippingServicesV3Soap.new(api_url)
  init_service_methods
end

Instance Attribute Details

#portObject

Returns the value of attribute port.



15
16
17
# File 'lib/purolator_web_services/api.rb', line 15

def port
  @port
end

#wiredumpObject (readonly)

Returns the value of attribute wiredump.



16
17
18
# File 'lib/purolator_web_services/api.rb', line 16

def wiredump
  @wiredump
end

Instance Method Details

#issue_request(service_method_name, *args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/purolator_web_services/api.rb', line 23

def issue_request(service_method_name, *args)
  port.wiredump_dev = StringIO.new(@wiredump = "")
  response = port.send(service_method_name, *args)
  extract_result(service_method_name, response)
rescue SOAP::FaultError => soap_fault
  err = ServiceException.new(soap_fault.message)
  err.details = soap_fault.faultstring
  err.set_backtrace([ "#{__FILE__}:#{__LINE__ + 1}", *soap_fault.backtrace ])
  raise err
end