Class: RubyGLS::Connection
- Inherits:
-
Object
- Object
- RubyGLS::Connection
- 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 Helper
Constructor Details
#initialize(base_url:, basic_auth: nil, username: nil, password: nil, contact_id: nil) ⇒ Connection
Returns a new instance of Connection.
8 9 10 |
# File 'lib/ruby-gls/connection.rb', line 8 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.
6 7 8 |
# File 'lib/ruby-gls/connection.rb', line 6 def client @client end |
Instance Method Details
#cancel_parcel(tracking_number) ⇒ Object
42 43 44 45 46 |
# File 'lib/ruby-gls/connection.rb', line 42 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
15 16 17 18 19 20 |
# File 'lib/ruby-gls/connection.rb', line 15 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
35 36 37 |
# File 'lib/ruby-gls/connection.rb', line 35 def get_allowed_services(**opts) action(RubyGLS::URL::GET_ALLOWED_SERVICES, payload: opts) end |
#get_end_of_day_report(date) ⇒ Object
58 59 60 61 62 |
# File 'lib/ruby-gls/connection.rb', line 58 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
51 52 53 |
# File 'lib/ruby-gls/connection.rb', line 51 def update_parcel_weight(**opts) action(RubyGLS::URL::UPDATE_PARCEL_WEIGHT, payload: opts) end |
#validate_parcels(**opts) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/ruby-gls/connection.rb', line 25 def validate_parcels(**opts) payload = opts payload[:Shipment][:Shipper][:ContactID] = client.contact_id action(RubyGLS::URL::VALIDATE_PARCELS, payload: opts) end |