Class: Bakong::Khqr::MerchantCode::GlobalUniqueIdentifier
- Inherits:
-
TagLengthString
- Object
- TagLengthString
- Bakong::Khqr::MerchantCode::GlobalUniqueIdentifier
- 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
-
#account_information ⇒ Object
readonly
Returns the value of attribute account_information.
-
#acquiring_bank ⇒ Object
readonly
Returns the value of attribute acquiring_bank.
-
#bakong_account_id ⇒ Object
readonly
Returns the value of attribute bakong_account_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
Attributes inherited from TagLengthString
Instance Method Summary collapse
-
#initialize(tag, value_object) ⇒ GlobalUniqueIdentifier
constructor
value_object is expected to have snake_case keys: :bakong_account_id, :merchant_id, :acquiring_bank, :account_information, :is_merchant.
Methods inherited from TagLengthString
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? bakong_account_id_value = value_object[:bakong_account_id] merchant_id_value = value_object[:merchant_id] acquiring_bank_value = value_object[:acquiring_bank] account_information_value = value_object[:account_information] is_merchant = value_object[:is_merchant] bakong_account_id = BakongAccountID.new(EMV[:BAKONG_ACCOUNT_IDENTIFIER], bakong_account_id_value) identifier_string = +bakong_account_id.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: bakong_account_id, merchant_id: merchant_id, acquiring_bank: acquiring_bank_obj } else unless account_information_value.nil? account_info = AccountInformation.new(EMV[:INDIVIDUAL_ACCOUNT_INFORMATION], account_information_value) identifier_string << account_info.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 = account_information_value @data = { bakong_account_id: bakong_account_id, account_information: account_information_value } end @bakong_account_id = bakong_account_id end |
Instance Attribute Details
#account_information ⇒ Object (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 @account_information end |
#acquiring_bank ⇒ Object (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_id ⇒ Object (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 @bakong_account_id end |
#data ⇒ Object (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_id ⇒ Object (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 |