Class: FriendlyShipping::Services::TForceFreight::ParseShipmentDocument
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::TForceFreight::ParseShipmentDocument
- Defined in:
- lib/friendly_shipping/services/tforce_freight/parse_shipment_document.rb
Overview
Parses shipment document JSON into a ShipmentDocument
.
Constant Summary collapse
- REVERSE_DOCUMENT_TYPES =
Maps document types to friendly names.
DocumentOptions::DOCUMENT_TYPES.map(&:reverse_each).to_h(&:to_a)
Class Method Summary collapse
-
.call(image_data:) ⇒ ShipmentDocument
The parsed shipment document.
Class Method Details
.call(image_data:) ⇒ ShipmentDocument
Returns the parsed shipment document.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/friendly_shipping/services/tforce_freight/parse_shipment_document.rb', line 13 def self.call(image_data:) type_code = image_data["type"] format = image_data["format"] status = image_data["status"] data = image_data["data"] ShipmentDocument.new( document_type: REVERSE_DOCUMENT_TYPES.fetch(type_code), document_format: format.downcase.to_sym, status: status, binary: Base64.decode64(data) ) end |