# CIMB API Updates ###### tags: cimb updates, 23Apr ### Prepare flipper checks ``` FlipperHelper.feature_enabled?("cimb_withdrawal_service_outage") FlipperHelper.add_feature("cimb_withdrawal_service_outage") FlipperHelper.add_feature("CIMB_23APR22_UPDATE_ENABLE") FlipperHelper.remove_feature("disbursement-api-o-model") FlipperHelper.feature_enabled_by_id?("disbursement-api-o-model", "#{Rails.env}_Merchant_#{current_identity.email}") ``` ### Add back later ``` FlipperHelper.remove_feature("cimb_withdrawal_service_outage") FlipperHelper.feature_enabled?("CIMB_23APR22_UPDATE_ENABLE") ``` - [x] Xfers to send Oauth API calls ``` Cimb::Secrets::base_url #### Included in below requests alr ``` - [x] Account Statement Inquiry API ``` ### CIMB Should receive Xfers request after this job is run #### Alternative bank_account_id = 42 bank_account = BankAccountModel.find(bank_account_id) statement_id = "#{bank_account.account_no}#{Time.now.in_current_zone.to_i}" start_date = 2.days.ago.in_current_zone.strftime("%Y-%m-%d") end_date = Time.now.in_current_zone.strftime("%Y-%m-%d") statements = [] response = nil pagination_key = nil response = Cimb::Services::HttpClient.account_statements_inquiry( bank_account, start_date, end_date, statement_id: statement_id, pagination: { key: pagination_key, }, ) response.succeeded? ``` OR ``` yesterday = 2.days.ago.in_current_zone.strftime("%Y-%m-%d") today = Time.now.in_current_zone.strftime("%Y-%m-%d") Cimb::Jobs::InquireBankStatementsJob.perform_now(42, yesterday, today, paginated: true) ``` - [x] Balance Inquiry API ``` params = { code: "heMUjRFYKI56WlRyb7TWz0PPVnILbx", state:"111650682761" } code = params[:code] @state = params[:state] api_type = @state[0..1] @account_id = Cimb::Secrets.inquiry_account_id(api_type) @client_secret = Cimb::Secrets.client_secret(api_type) @client_id = Cimb::Secrets.client_id(api_type) token_resp = Cimb::Services::HttpClient.get_token(code, @client_secret, @client_id) @access_token = token_resp.try(:dig, "access_token") # Cimb::Services::HttpClient.account_inquiry(@access_token, @account_id, @client_id) ACCOUNT_INQUIRY_SCOPE = "Ainq" statement_id = Time.now.in_current_zone.to_i # unique reference ID for transaction inquiry_api_key = Cimb::Secrets.api_key(ACCOUNT_INQUIRY_SCOPE) query_string = { StatementId: statement_id, AccountType: "CDA", client_id: @client_id, }.to_query endpoint = Cimb::Secrets.base_url url = "#{endpoint}/sg/cimb/v1/accounts/CASA/#{@account_id}?#{query_string}" HTTParty.get( url, headers: { "Authorization": "Bearer #{@access_token}", "API-Key": inquiry_api_key, }, verify: false, ).parsed_response ``` OR ``` Cimb::Services::RequestOauthCallbackService.account_inquiry ``` - Xfers to send Oauth API calls - [ ] FAST payment $1 to intra company account - [ ] Disburse `$1` to `UOB 4513055336` ``` Cimb::Jobs::WasvfWithdrawalJob.perform_now ``` - [ ] Using disbursement api - [x] Xfers to receive BAN for payment debit - [x] Xfers to send HTTP 200 OK to CIMB as ack