Class: UPS::Parsers::ShipAcceptParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/ups/parsers/ship_accept_parser.rb

Instance Attribute Summary

Attributes inherited from BaseParser

#response

Instance Method Summary collapse

Methods inherited from BaseParser

#error_description, #initialize, #parsed_response, #status_code, #status_description, #success?

Constructor Details

This class inherits a constructor from UPS::Parsers::BaseParser

Instance Method Details

#currency_codeObject



59
60
61
# File 'lib/ups/parsers/ship_accept_parser.rb', line 59

def currency_code
  shipment_results[:ShipmentCharges][:TotalCharges][:CurrencyCode]
end

#form_graphic_extensionObject



27
28
29
30
31
# File 'lib/ups/parsers/ship_accept_parser.rb', line 27

def form_graphic_extension
  return unless has_form_graphic?

  ".#{form_graphic[:Image][:ImageFormat][:Code].downcase}"
end

#form_graphic_imageObject



33
34
35
36
37
# File 'lib/ups/parsers/ship_accept_parser.rb', line 33

def form_graphic_image
  return unless has_form_graphic?

  Utils.base64_to_file(form_graphic[:Image][:GraphicImage], form_graphic_extension)
end

#label_graphic_extensionObject Also known as: graphic_extension



11
12
13
# File 'lib/ups/parsers/ship_accept_parser.rb', line 11

def label_graphic_extension
  packages[0].label_graphic_extension
end

#label_graphic_imageObject Also known as: graphic_image



15
16
17
# File 'lib/ups/parsers/ship_accept_parser.rb', line 15

def label_graphic_image
  packages[0].label_graphic_image
end

#label_html_imageObject Also known as: html_image



19
20
21
# File 'lib/ups/parsers/ship_accept_parser.rb', line 19

def label_html_image
  packages[0].label_html_image
end

#master_carton_idObject



45
46
47
# File 'lib/ups/parsers/ship_accept_parser.rb', line 45

def master_carton_id
  shipment_results[:MasterCartonID]
end

#negotiated_rateObject



55
56
57
# File 'lib/ups/parsers/ship_accept_parser.rb', line 55

def negotiated_rate
  negotiated_rate_response && negotiated_rate_response[:NetSummaryCharges][:GrandTotal][:MonetaryValue].to_f
end

#packagesObject



39
40
41
42
43
# File 'lib/ups/parsers/ship_accept_parser.rb', line 39

def packages
  return package_results.map { |package_result| UPS::Models::PackageResult.new(package_result) } if package_results.is_a?(Array)

  [UPS::Models::PackageResult.new(package_results)]
end

#total_chargeObject



49
50
51
52
53
# File 'lib/ups/parsers/ship_accept_parser.rb', line 49

def total_charge
  return shipment_charge unless negotiated_rate

  negotiated_rate
end

#tracking_numberObject



7
8
9
# File 'lib/ups/parsers/ship_accept_parser.rb', line 7

def tracking_number
  packages[0].tracking_number
end