Sha256: f4b2f87c8bc57535ebf9b2349a845e3469b416d76af49f02a28e272604d54ade

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

require 'time'
module Hushed
  module Documents
    module Response
      class ShipmentOrderResult
        attr_reader :io

        def initialize(options = {})
          @io = options[:io]
          @document = Nokogiri::XML::Document.parse(@io)
        end

        def client_id
          @client_id ||= so_result['ClientID']
        end

        def business_unit
          @business_unit ||= so_result['BusinessUnit']
        end

        def date_shipped
          @date_shipped ||= Time.parse(so_result['DateShipped']).utc
        end

        def order_number
          @order_number ||= so_result['OrderNumber']
        end

        def carton_count
          @carton_count ||= so_result['CartonCount'].to_i
        end

        def carrier
          @carrier ||= carton['Carrier']
        end

        def service_level
          @service_level ||= carton['ServiceLevel']
        end

        def tracking_number
          @tracking_number ||= carton['TrackingId']
        end

        def so_result
          @so_result ||= @document.css('SOResult').first
        end

        def carton
          @carton ||= @document.css('Carton').first
        end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hushed-0.0.9 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.8 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.7 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.6 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.5 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.4 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.3 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.2 lib/hushed/documents/response/shipment_order_result.rb
hushed-0.0.1 lib/hushed/documents/response/shipment_order_result.rb