Sha256: 003ac34411995dfb8d12b481ed70dda600cd960d8d05e963b81529e93e1da0f7

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

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

      attr_reader :segment_type

      def initialize(
        tag: nil,
        country_of_origin_name_code: nil,
        duty_regime_type_code: nil,
        special_condition_code_1: nil,
        special_condition_code_2: nil,
        special_condition_code_3: nil,
        special_condition_code_4: nil,
        special_condition_code_5: nil
      )
        @tag = tag
        @country_of_origin_name_code = country_of_origin_name_code
        @duty_regime_type_code = duty_regime_type_code
        @special_condition_code_1 = special_condition_code_1
        @special_condition_code_2 = special_condition_code_2
        @special_condition_code_3 = special_condition_code_3
        @special_condition_code_4 = special_condition_code_4
        @special_condition_code_5 = special_condition_code_5

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(country_of_origin_name_code: @country_of_origin_name_code) if @country_of_origin_name_code
        hash.merge!(duty_regime_type_code: @duty_regime_type_code) if @duty_regime_type_code
        hash.merge!(special_condition_code_1: find_identifier(:special_condition_code_1)) if @special_condition_code_1
        hash.merge!(special_condition_code_2: find_identifier(:special_condition_code_2)) if @special_condition_code_2
        hash.merge!(special_condition_code_3: find_identifier(:special_condition_code_3)) if @special_condition_code_3
        hash.merge!(special_condition_code_4: find_identifier(:special_condition_code_4)) if @special_condition_code_4
        hash.merge!(special_condition_code_5: find_identifier(:special_condition_code_5)) if @special_condition_code_5
        outer_hash = {}
        outer_hash.merge!(additional_information: hash)
        outer_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/ali.rb