Class: RubyExpressOne::Connection
- Inherits:
-
Object
- Object
- RubyExpressOne::Connection
- Defined in:
- lib/ruby-expressone/connection.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #confirm_shipment(trackingNumber) ⇒ Object
- #create_shipment(payload, plain: true) ⇒ Object
- #get_shipment(id) ⇒ Object
- #get_shipment_events(id) ⇒ Object
-
#initialize(api_key, with_logger: false) ⇒ Connection
constructor
A new instance of Connection.
- #update_shipment(id, payload) ⇒ Object
Constructor Details
#initialize(api_key, with_logger: false) ⇒ Connection
Returns a new instance of Connection.
6 7 8 9 10 |
# File 'lib/ruby-expressone/connection.rb', line 6 def initialize(api_key, with_logger: false) @api_key = api_key @client = RubyExpressOne::Client.new(api_key, with_logger: with_logger) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/ruby-expressone/connection.rb', line 4 def api_key @api_key end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/ruby-expressone/connection.rb', line 4 def client @client end |
Instance Method Details
#confirm_shipment(trackingNumber) ⇒ Object
25 26 27 |
# File 'lib/ruby-expressone/connection.rb', line 25 def confirm_shipment(trackingNumber) action("/api/shipments/confirmshipments?trackingNumber=#{trackingNumber}", http_method: :put) end |
#create_shipment(payload, plain: true) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ruby-expressone/connection.rb', line 18 def create_shipment(payload, plain: true) path = plain ? '/CreateShipmentPlain' : '/CreateShipment' action(path, payload: payload) end |
#get_shipment(id) ⇒ Object
12 13 14 15 16 |
# File 'lib/ruby-expressone/connection.rb', line 12 def get_shipment(id) query_params = { ShipmentId: id } action("/GetShipmentStatusByShipmentId", http_method: :get, query_params: query_params) end |
#get_shipment_events(id) ⇒ Object
33 34 35 |
# File 'lib/ruby-expressone/connection.rb', line 33 def get_shipment_events(id) action("/api/shipments/#{id}/shipmentevents", http_method: :get) end |
#update_shipment(id, payload) ⇒ Object
29 30 31 |
# File 'lib/ruby-expressone/connection.rb', line 29 def update_shipment(id, payload) action("/api/shipments/#{id}", payload: payload, http_method: :patch) end |