Class: Bakong::Khqr::MerchantCode::GlobalUniqueIdentifier

Inherits:
TagLengthString
  • Object
show all
Defined in:
lib/bakong/khqr/merchant_code/global_unique_identifier.rb

Overview

Tag “29” (individual) or “30” (merchant). Wraps a bakong account ID plus optional merchant/account-information subtags.

Instance Attribute Summary collapse

Attributes inherited from TagLengthString

#length, #tag, #value

Instance Method Summary collapse

Methods inherited from TagLengthString

#to_s

Constructor Details

#initialize(tag, value_object) ⇒ GlobalUniqueIdentifier

value_object is expected to have snake_case keys: :bakong_account_id, :merchant_id, :acquiring_bank, :account_information, :is_merchant



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bakong/khqr/merchant_code/global_unique_identifier.rb', line 18

def initialize(tag, value_object)
  raise Error.from(ERROR_CODES[:MERCHANT_TYPE_REQUIRED]) if value_object.nil?

   = value_object[:bakong_account_id]
  merchant_id_value = value_object[:merchant_id]
  acquiring_bank_value = value_object[:acquiring_bank]
   = value_object[:account_information]
  is_merchant = value_object[:is_merchant]

   = BakongAccountID.new(EMV[:BAKONG_ACCOUNT_IDENTIFIER], )
  identifier_string = +.to_s

  if is_merchant
    merchant_id = MerchantId.new(EMV[:MERCHANT_ACCOUNT_INFORMATION_MERCHANT_ID], merchant_id_value)
    acquiring_bank_obj = AcquiringBank.new(EMV[:MERCHANT_ACCOUNT_INFORMATION_ACQUIRING_BANK], acquiring_bank_value)
    identifier_string << merchant_id.to_s unless merchant_id_value.nil?
    identifier_string << acquiring_bank_obj.to_s unless acquiring_bank_value.nil?

    super(tag, identifier_string)
    @merchant_id = merchant_id
    @acquiring_bank = acquiring_bank_obj
    @data = {
      bakong_account_id: ,
      merchant_id: merchant_id,
      acquiring_bank: acquiring_bank_obj
    }
  else
    unless .nil?
       = AccountInformation.new(EMV[:INDIVIDUAL_ACCOUNT_INFORMATION], )
      identifier_string << .to_s
    end

    unless acquiring_bank_value.nil?
      acquiring_bank_obj = AcquiringBank.new(EMV[:MERCHANT_ACCOUNT_INFORMATION_ACQUIRING_BANK], acquiring_bank_value)
      identifier_string << acquiring_bank_obj.to_s
    end

    super(tag, identifier_string)
    @account_information = 
    @data = {
      bakong_account_id: ,
      account_information: 
    }
  end

  @bakong_account_id = 
end

Instance Attribute Details

#account_informationObject (readonly)

Returns the value of attribute account_information.



14
15
16
# File 'lib/bakong/khqr/merchant_code/global_unique_identifier.rb', line 14

def 
  @account_information
end

#acquiring_bankObject (readonly)

Returns the value of attribute acquiring_bank.



14
15
16
# File 'lib/bakong/khqr/merchant_code/global_unique_identifier.rb', line 14

def acquiring_bank
  @acquiring_bank
end

#bakong_account_idObject (readonly)

Returns the value of attribute bakong_account_id.



14
15
16
# File 'lib/bakong/khqr/merchant_code/global_unique_identifier.rb', line 14

def 
  @bakong_account_id
end

#dataObject (readonly)

Returns the value of attribute data.



14
15
16
# File 'lib/bakong/khqr/merchant_code/global_unique_identifier.rb', line 14

def data
  @data
end

#merchant_idObject (readonly)

Returns the value of attribute merchant_id.



14
15
16
# File 'lib/bakong/khqr/merchant_code/global_unique_identifier.rb', line 14

def merchant_id
  @merchant_id
end