Class: PurolatorRuby::Client
- Inherits:
-
Object
- Object
- PurolatorRuby::Client
- Extended by:
- Forwardable
- Defined in:
- lib/purolator_ruby/client.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #create_shipment(params) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #purolator_call(*args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
12 13 14 |
# File 'lib/purolator_ruby/client.rb', line 12 def initialize( = {}) @credentials = .fetch(:credentials) { EnvironmentCredentials.new } end |
Instance Attribute Details
#credentials ⇒ Object (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 |