Sha256: cf519bd0da6cbfbff110750f6c619a962e17844920fbfb2cb2d967e61a3b2cc2
Contents?: true
Size: 940 Bytes
Versions: 2
Compression:
Stored size: 940 Bytes
Contents
# frozen_string_literal: true 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
2 entries across 2 versions & 1 rubygems