Module: Deliveries::Courier
- Included in:
- Deliveries::Couriers::CorreosExpress, Deliveries::Couriers::Dummy, Deliveries::Couriers::Envialia, Deliveries::Couriers::MondialRelay, Deliveries::Couriers::MondialRelayDual, Deliveries::Couriers::Spring, Deliveries::Couriers::Ups
- Defined in:
- lib/deliveries/courier.rb
Instance Method Summary collapse
-
#config(key, default: nil) ⇒ Mixed
Get configuration value by key.
- #configure {|@config| ... } ⇒ Object
- #configured? ⇒ Boolean
- #create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, language: nil) ⇒ Object
- #create_shipment(sender:, receiver:, collection_point:, parcels:, reference_code:, shipment_date: nil, remarks: nil, language: nil) ⇒ Object
- #get_collection_point(global_point_id:) ⇒ Object
- #get_collection_points(country:, postcode:) ⇒ Object
- #get_label(tracking_code:, language: nil) ⇒ Object
- #get_labels(tracking_codes:, language: nil) ⇒ Object
- #live? ⇒ Boolean
- #pickup_info(tracking_code:, language: nil) ⇒ Object
- #shipment_info(tracking_code:, language: nil) ⇒ Object
- #test? ⇒ Boolean
Instance Method Details
#config(key, default: nil) ⇒ Mixed
Get configuration value by key.
22 23 24 25 26 27 |
# File 'lib/deliveries/courier.rb', line 22 def config(key, default: nil) raise 'Courier not configured' unless configured? key = key.split('.').map(&:to_sym) if key.is_a? String @config.dig(*key) || default end |
#configure {|@config| ... } ⇒ Object
7 8 9 10 |
# File 'lib/deliveries/courier.rb', line 7 def configure @config ||= ancestors.first::Config.new yield @config end |
#configured? ⇒ Boolean
12 13 14 |
# File 'lib/deliveries/courier.rb', line 12 def configured? @config.present? end |
#create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, language: nil) ⇒ Object
49 50 51 |
# File 'lib/deliveries/courier.rb', line 49 def create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, language: nil) raise NotImplementedError end |
#create_shipment(sender:, receiver:, collection_point:, parcels:, reference_code:, shipment_date: nil, remarks: nil, language: nil) ⇒ Object
45 46 47 |
# File 'lib/deliveries/courier.rb', line 45 def create_shipment(sender:, receiver:, collection_point:, parcels:, reference_code:, shipment_date: nil, remarks: nil, language: nil) raise NotImplementedError end |
#get_collection_point(global_point_id:) ⇒ Object
37 38 39 |
# File 'lib/deliveries/courier.rb', line 37 def get_collection_point(global_point_id:) raise NotImplementedError end |
#get_collection_points(country:, postcode:) ⇒ Object
41 42 43 |
# File 'lib/deliveries/courier.rb', line 41 def get_collection_points(country:, postcode:) raise NotImplementedError end |
#get_label(tracking_code:, language: nil) ⇒ Object
53 54 55 |
# File 'lib/deliveries/courier.rb', line 53 def get_label(tracking_code:, language: nil) raise NotImplementedError end |
#get_labels(tracking_codes:, language: nil) ⇒ Object
57 58 59 |
# File 'lib/deliveries/courier.rb', line 57 def get_labels(tracking_codes:, language: nil) raise NotImplementedError end |
#live? ⇒ Boolean
33 34 35 |
# File 'lib/deliveries/courier.rb', line 33 def live? Deliveries.live? end |
#pickup_info(tracking_code:, language: nil) ⇒ Object
65 66 67 |
# File 'lib/deliveries/courier.rb', line 65 def pickup_info(tracking_code:, language: nil) raise NotImplementedError end |
#shipment_info(tracking_code:, language: nil) ⇒ Object
61 62 63 |
# File 'lib/deliveries/courier.rb', line 61 def shipment_info(tracking_code:, language: nil) raise NotImplementedError end |
#test? ⇒ Boolean
29 30 31 |
# File 'lib/deliveries/courier.rb', line 29 def test? Deliveries.test? end |