Class: PurolatorRuby::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/purolator_ruby/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



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

def initialize(options = {})
  @credentials = options.fetch(:credentials) { EnvironmentCredentials.new }
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



8
9
10
# File 'lib/purolator_ruby/client.rb', line 8

def credentials
  @credentials
end

Instance Method Details

#call(*args) ⇒ Object



16
17
18
# File 'lib/purolator_ruby/client.rb', line 16

def call(*args)
  Request.new(method: args.first, params: args.drop(1).first, client: self).send
end

#create_shipment(params) ⇒ Object



26
27
28
# File 'lib/purolator_ruby/client.rb', line 26

def create_shipment(params)
  call(:create_shipment, params)
end

#purolator_call(*args) ⇒ Object



20
21
22
23
24
# File 'lib/purolator_ruby/client.rb', line 20

def purolator_call(*args)
  with_client(args.first) do |purolator|
    purolator.call(*args)
  end
end