Class: Deliveries::Couriers::Spring::Labels::Generate
- Inherits:
-
Object
- Object
- Deliveries::Couriers::Spring::Labels::Generate
- Defined in:
- lib/deliveries/couriers/spring/labels/generate.rb
Instance Attribute Summary collapse
-
#tracking_code ⇒ Object
Returns the value of attribute tracking_code.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(tracking_code:) ⇒ Generate
constructor
A new instance of Generate.
Constructor Details
#initialize(tracking_code:) ⇒ Generate
Returns a new instance of Generate.
8 9 10 |
# File 'lib/deliveries/couriers/spring/labels/generate.rb', line 8 def initialize(tracking_code:) self.tracking_code = tracking_code end |
Instance Attribute Details
#tracking_code ⇒ Object
Returns the value of attribute tracking_code.
6 7 8 |
# File 'lib/deliveries/couriers/spring/labels/generate.rb', line 6 def tracking_code @tracking_code end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/deliveries/couriers/spring/labels/generate.rb', line 12 def execute params = { Apikey: Deliveries::Couriers::Spring.config(:api_key), Command: 'GetShipmentLabel', Shipment: { LabelFormat: 'PDF', TrackingNumber: tracking_code } } response = Deliveries::Couriers::Spring::Request.execute(params: params) { url: response[:Shipment][:CarrierTrackingUrl], decoded_label: Base64.decode64(response[:Shipment][:LabelImage]).force_encoding('binary') } end |