Class: RubyGLS::Connection
- Inherits:
-
Object
- Object
- RubyGLS::Connection
- Extended by:
- Tracking
- Includes:
- Helper
- Defined in:
- lib/ruby-gls/connection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #cancel_parcel(tracking_number) ⇒ Object
- #create_parcel(**opts) ⇒ Object
- #get_allowed_services(**opts) ⇒ Object
- #get_end_of_day_report(date) ⇒ Object
-
#initialize(base_url:, basic_auth: nil, username: nil, password: nil, contact_id: nil) ⇒ Connection
constructor
A new instance of Connection.
- #update_parcel_weight(**opts) ⇒ Object
- #validate_parcels(**opts) ⇒ Object
Methods included from Tracking
Methods included from Helper
Constructor Details
#initialize(base_url:, basic_auth: nil, username: nil, password: nil, contact_id: nil) ⇒ Connection
Returns a new instance of Connection.
10 11 12 |
# File 'lib/ruby-gls/connection.rb', line 10 def initialize(base_url:, basic_auth: nil, username: nil, password: nil, contact_id: nil) @client = RubyGLS::Client.new(base_url, basic_auth, username, password, contact_id) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/ruby-gls/connection.rb', line 8 def client @client end |
Instance Method Details
#cancel_parcel(tracking_number) ⇒ Object
44 45 46 47 48 |
# File 'lib/ruby-gls/connection.rb', line 44 def cancel_parcel(tracking_number) path = replace_string(RubyGLS::URL::CANCEL_PARCEL, ':parcel_id', tracking_number) action(RubyGLS::URL::CANCEL_PARCEL) end |
#create_parcel(**opts) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/ruby-gls/connection.rb', line 17 def create_parcel(**opts) payload = opts payload[:Shipment][:Shipper][:ContactID] = client.contact_id action(RubyGLS::URL::CREATE_PARCEL, payload: payload) end |
#get_allowed_services(**opts) ⇒ Object
37 38 39 |
# File 'lib/ruby-gls/connection.rb', line 37 def get_allowed_services(**opts) action(RubyGLS::URL::GET_ALLOWED_SERVICES, payload: opts) end |
#get_end_of_day_report(date) ⇒ Object
60 61 62 63 64 |
# File 'lib/ruby-gls/connection.rb', line 60 def get_end_of_day_report(date) path = replace_string(RubyGLS::URL::GET_END_OF_DAY_REPORT, ':date', date) action(path) end |
#update_parcel_weight(**opts) ⇒ Object
53 54 55 |
# File 'lib/ruby-gls/connection.rb', line 53 def update_parcel_weight(**opts) action(RubyGLS::URL::UPDATE_PARCEL_WEIGHT, payload: opts) end |
#validate_parcels(**opts) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/ruby-gls/connection.rb', line 27 def validate_parcels(**opts) payload = opts payload[:Shipment][:Shipper][:ContactID] = client.contact_id action(RubyGLS::URL::VALIDATE_PARCELS, payload: opts) end |