Skip to content

Commit

Permalink
Updated the UPS ShipConfirm service to take more information from the…
Browse files Browse the repository at this point in the history
… response than just the shipment digest value.
  • Loading branch information
laserlemon authored and binarylogic committed Aug 21, 2010
1 parent 6fb1e68 commit 1591a63
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/shippinglogic/ups/ship_confirm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ def self.path
"/ShipConfirm"
end

class Details
attr_accessor :digest, :tracking_number, :rate, :currency

def initialize(response)
self.digest = response[:shipment_digest]
self.tracking_number = response[:shipment_identification_number]

charges = response[:shipment_charges][:total_charges]
self.rate = BigDecimal.new(charges[:monetary_value])
self.currency = charges[:currency_code]
end
end

# shipper options
attribute :shipper_name, :string
attribute :shipper_phone_number, :string
Expand Down Expand Up @@ -52,13 +65,9 @@ def self.path
attribute :signature, :boolean, :default => false
attribute :saturday, :boolean, :default => false

# misc options
#TODO Make use of this option by skipping the ShipAccept API call.
attribute :just_validate, :boolean, :default => false

private
def target
@target ||= parse_response(request(build_request))
@target ||= Details.new(request(build_request))
end

def build_request
Expand Down Expand Up @@ -156,10 +165,6 @@ def build_request
end
end
end

def parse_response(response)
response[:shipment_digest]
end
end
end
end

0 comments on commit 1591a63

Please sign in to comment.