Sha256: 6bca1102d586c103c83178e3a20db4b877d97d66e419c1df795b6dfa4df8c1c2

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module Eancom
  module Edifact
    class LIN < Segment
      TAG = 'LIN'.freeze
      TYPE = :body.freeze

      def initialize(
        tag: nil,
        line_item_identifier_1:,
        action_request_notification_description_code: '',
        item_identifier:,
        item_type_identification_code:,
        sub_line_indicator_code: nil,
        line_item_identifier_2: nil
      )
        @tag = tag
        @line_item_identifier_1 = line_item_identifier_1
        @action_request_notification_description_code = action_request_notification_description_code
        @item_identifier = item_identifier
        @item_type_identification_code = item_type_identification_code
        @sub_line_indicator_code = sub_line_indicator_code
        @line_item_identifier_2 = line_item_identifier_2

        super(tag: tag || TAG )
      end

      def starts_item?
        true
      end

      def to_json_hash
        hash = {}
        hash.merge!(ean: @item_identifier) if @item_identifier
        hash.merge!(action_request_notification_description_code: @action_request_notification_description_code) if @action_request_notification_description_code
        hash.merge!(item_type_identification_code: find_identifier(:item_type_identification_code)) if @item_type_identification_code
        hash.merge!(sub_line_indicator_code: @sub_line_indicator_code) if @sub_line_indicator_code
        hash.merge!(line_item_identifier_2: @line_item_identifier_2) if @line_item_identifier_2
        hash
      end

      def segment_type
        TYPE
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eancom-2.0.0 lib/eancom/edifact/segments/lin.rb