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

#initialize(response) ⇒ Details

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

#currencyObject

Returns the value of attribute currency.



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

def currency
  @currency
end

#rateObject

Returns the value of attribute rate.



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

def rate
  @rate
end

#shipmentsObject

Returns the value of attribute shipments.



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

def shipments
  @shipments
end