module Eancom module Edifact class IMD < Segment TAG = 'IMD'.freeze TYPE = :body.freeze def initialize( tag: nil, description_format_code:, item_characteristic_code: nil, code_list_identification_code: nil, code_list_responsible_agency_code: nil, item_description_code: nil, code_list_identification_code_1: '', code_list_responsible_agency_code_1: nil, item_description_1: nil, item_description_2: nil, language_name_code: nil, surface_or_layer_code: nil ) @tag = tag @description_format_code = description_format_code @item_characteristic_code = item_characteristic_code @code_list_identification_code = code_list_identification_code @code_list_responsible_agency_code = code_list_responsible_agency_code @item_description_code = item_description_code @code_list_identification_code_1 = code_list_identification_code_1 @code_list_responsible_agency_code_1 = code_list_responsible_agency_code_1 @item_description_1 = item_description_1 @item_description_2 = item_description_2 @language_name_code = language_name_code @surface_or_layer_code = surface_or_layer_code super(tag: tag || TAG) end def to_json_hash hash = {} hash.merge!(description_format_code: find_identifier(:description_format_code)) if @description_format_code hash.merge!(item_characteristic_code: find_identifier(:item_characteristic_code)) if @item_characteristic_code hash.merge!(code_list_identification_code: find_identifier(:code_list_identification_code)) if @code_list_identification_code hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code if @item_description_code identifier = find_identifier(:item_description_code) if identifier hash.merge!(item_description_code: identifier) else hash.merge!(item_description_code: @item_description_code) end end hash.merge!(code_list_identification_code_1: @code_list_identification_code_1) if @code_list_identification_code_1 hash.merge!(code_list_responsible_agency_code_1: find_identifier(:code_list_responsible_agency_code_1)) if @code_list_responsible_agency_code_1 hash.merge!(item_description_1: @item_description_1) if @item_description_1 hash.merge!(item_description_2: @item_description_2) if @item_description_2 hash.merge!(language_name_code: @language_name_code) if @language_name_code hash.merge!(surface_or_layer_code: @surface_or_layer_code) if @surface_or_layer_code hash end def group_name 'item_descriptions' end def segment_type TYPE end end end end