Class: SimpleShipping::Demo::Fedex
- Defined in:
- lib/simple_shipping/demo/fedex.rb
Overview
Helper object to send demo requests to FedEx in order to test credentials and the library.
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
Attributes inherited from Base
Instance Method Summary collapse
-
#fedex_client ⇒ SimpleShipping::Fedex::Client
Initialize the FedEx client.
-
#initialize(options = {}) ⇒ Fedex
constructor
A new instance of Fedex.
-
#package ⇒ SimpleShipping::Package
Build the package object.
-
#shipment_request ⇒ SimpleShipping::Fedex::Response
Send the shipment request to FedEx.
Methods inherited from Base
#recipient, #recipient_address, #recipient_contact, #shipper, #shipper_address, #shipper_contact
Constructor Details
#initialize(options = {}) ⇒ Fedex
Returns a new instance of Fedex.
10 11 12 |
# File 'lib/simple_shipping/demo/fedex.rb', line 10 def initialize( = {}) @options = .reverse_merge(:log => false) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
8 9 10 |
# File 'lib/simple_shipping/demo/fedex.rb', line 8 def credentials @credentials end |
Instance Method Details
#fedex_client ⇒ SimpleShipping::Fedex::Client
Initialize the FedEx client.
32 33 34 35 36 37 38 |
# File 'lib/simple_shipping/demo/fedex.rb', line 32 def fedex_client @fedex_client ||= SimpleShipping::Fedex::Client.new( :credentials => .slice(:key, :password, :account_number, :meter_number), :log => [:log], :live => [:live] ) end |
#package ⇒ SimpleShipping::Package
Build the package object.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/simple_shipping/demo/fedex.rb', line 17 def package @package ||= SimpleShipping::Package.new( :weight => 1, :length => 2, :height => 3, :dimension_units => :in, # you can use :kg as well :weight_units => :lb, # you can use :cm as well :width => 4, :packaging_type => :your ) end |
#shipment_request ⇒ SimpleShipping::Fedex::Response
Send the shipment request to FedEx.
43 44 45 |
# File 'lib/simple_shipping/demo/fedex.rb', line 43 def shipment_request fedex_client.shipment_request(shipper, recipient, package) end |