module Eancom module Edifact class PGI < Segment TAG = 'PGI'.freeze TYPE = :body.freeze attr_reader :segment_type def initialize( tag: nil, product_group_type_code:, product_group_name_code: nil, code_list_identification_code: nil, code_list_responsibility_agency_code: nil, product_group_name: nil ) @tag = tag @product_group_type_code = product_group_type_code @product_group_name_code = product_group_name_code @code_list_identification_code = code_list_identification_code @code_list_responsibility_agency_code = code_list_responsibility_agency_code @product_group_name = product_group_name_code super(tag: tag || TAG) end def to_json_hash hash = { 'product_group_identifier': identifier } end def segment_type TYPE end private def identifier @identifier ||= structure.find(:product_group_type_code).dictionary[@product_group_type_code][:identifier] end end end end