Class: Bakong::OpenApi::Resources::Accounts
- Defined in:
- lib/bakong/open_api/resources/accounts.rb
Overview
‘POST /v1/check_bakong_account` — check whether a Bakong account ID (e.g. “user@bank”) exists. The API returns responseCode 0 when the account exists, 1 + errorCode 11 when it does not. This wrapper collapses that into a Ruby boolean.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#exists?(account_id:) ⇒ Boolean
True if the account exists, false if not.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Bakong::OpenApi::Resources::Base
Instance Method Details
#exists?(account_id:) ⇒ Boolean
Returns true if the account exists, false if not.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bakong/open_api/resources/accounts.rb', line 17 def exists?(account_id:) envelope = connection.post( "/v1/check_bakong_account", body: { accountId: account_id } ) response_code = envelope[:responseCode] || envelope[:response_code] error_code = envelope[:errorCode] || envelope[:error_code] = envelope[:responseMessage] || envelope[:response_message] return true if response_code.to_i.zero? return false if error_code.to_i == 11 # explicitly NOT_FOUND klass = Bakong::OpenApi::DOMAIN_ERROR_CLASSES[error_code.to_i] || Bakong::OpenApi::Error raise klass.new(, response_code: response_code, error_code: error_code, response_message: , body: envelope) end |