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

#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

#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

#tracking_numberObject



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

def tracking_number
  packages[0].tracking_number
end