Sha256: 247793a4e46cf5e0e634c1e8ab812497e80176adb386b20a46533395e9dee951
Contents?: true
Size: 1008 Bytes
Versions: 1
Compression:
Stored size: 1008 Bytes
Contents
# frozen_string_literal: true require 'friendly_shipping/services/ups_freight/shipment_document' module FriendlyShipping module Services class TForceFreight # Parses shipment document JSON into a `ShipmentDocument`. class ParseShipmentDocument # Maps document types to friendly names. REVERSE_DOCUMENT_TYPES = DocumentOptions::DOCUMENT_TYPES.map(&:reverse_each).to_h(&:to_a) # @param image_data [Hash] the shipping document JSON # @return [ShipmentDocument] the parsed shipment document 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 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_shipping-0.9.0 | lib/friendly_shipping/services/tforce_freight/parse_shipment_document.rb |