Class: SimpleShipping::Abstract::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_shipping/abstract/client.rb

Overview

Abstract class which provides common interfaces for the next concrete clients:

Direct Known Subclasses

Fedex::Client, Ups::Client

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Client

Create an instance of a client.

Parameters:

* credentials - a hash with credentials.


38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/simple_shipping/abstract/client.rb', line 38

def initialize(options)
  @options    = options.dup
  @live       = options.delete(:live)
  @debug      = options.delete(:debug)
  @debug_path = options.delete(:debug_path)
  credentials = options.delete(:credentials)

  validate_credentials(credentials)
  @credentials = OpenStruct.new(credentials)

  @client = Savon.client(client_options(options))
end

Class Method Details

.set_production_address(address) ⇒ Object

Set the production endpoint.

Parameters:

  • address (String)


24
25
26
# File 'lib/simple_shipping/abstract/client.rb', line 24

def self.set_production_address(address)
  self.production_address = address
end

.set_required_credentials(*args) ⇒ Object

Set credentials which should be validated.



12
13
14
# File 'lib/simple_shipping/abstract/client.rb', line 12

def self.set_required_credentials(*args)
  self.required_credentials = args
end

.set_testing_address(address) ⇒ Object

Set the testing endpoint.

Parameters:

  • address (String)


31
32
33
# File 'lib/simple_shipping/abstract/client.rb', line 31

def self.set_testing_address(address)
  self.testing_address = address
end

.set_wsdl_document(wsdl_path) ⇒ Object

Set the WSDL document used by Savon.



17
18
19
# File 'lib/simple_shipping/abstract/client.rb', line 17

def self.set_wsdl_document(wsdl_path)
  self.wsdl_document = wsdl_path
end