Class: Deliveries::Couriers::Spring::Shipments::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/deliveries/couriers/spring/shipments/trace.rb,
lib/deliveries/couriers/spring/shipments/trace/format_response.rb

Defined Under Namespace

Classes: FormatResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracking_code:) ⇒ Trace

Returns a new instance of Trace.



8
9
10
# File 'lib/deliveries/couriers/spring/shipments/trace.rb', line 8

def initialize(tracking_code:)
  self.tracking_code = tracking_code
end

Instance Attribute Details

#tracking_codeObject

Returns the value of attribute tracking_code.



6
7
8
# File 'lib/deliveries/couriers/spring/shipments/trace.rb', line 6

def tracking_code
  @tracking_code
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/deliveries/couriers/spring/shipments/trace.rb', line 12

def execute
  params = {
    Apikey: Deliveries::Couriers::Spring.config(:api_key),
    Command: 'TrackShipment',
    Shipment: {
      TrackingNumber: tracking_code
    }
  }

  response = Deliveries::Couriers::Spring::Request.execute(params: params)

  response[:Shipment]
end