Class: Shippinglogic::UPS::ShipAccept::Details

Inherits:
Object
  • Object
show all
Defined in:
lib/shippinglogic/ups/ship_accept.rb

Defined Under Namespace

Classes: Shipment

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Details) initialize(response)

Returns a new instance of Details



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shippinglogic/ups/ship_accept.rb', line 15

def initialize(response)
  details = response[:shipment_results]
  
  charges       = details[:shipment_charges][:total_charges]
  self.rate     = BigDecimal.new(charges[:monetary_value])
  self.currency = charges[:currency_code]
  
  self.shipments = [*details[:package_results]].collect do |package|
    shipment                  = Shipment.new
    shipment.tracking_number  = package[:tracking_number]
    shipment.label            = Base64.decode64(package[:label_image][:graphic_image])
    shipment
  end
end

Instance Attribute Details

- (Object) currency

Returns the value of attribute currency



13
14
15
# File 'lib/shippinglogic/ups/ship_accept.rb', line 13

def currency
  @currency
end

- (Object) rate

Returns the value of attribute rate



13
14
15
# File 'lib/shippinglogic/ups/ship_accept.rb', line 13

def rate
  @rate
end

- (Object) shipments

Returns the value of attribute shipments



13
14
15
# File 'lib/shippinglogic/ups/ship_accept.rb', line 13

def shipments
  @shipments
end