Chilkat Online Tools

SQL Server / Bond APIs / list external accounts

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    -- The following JSON is sent in the request body.

    -- {
    --   "events": [
    --     "kyc.verification.success",
    --     "kyc.verification.failure",
    --     "kyc.verification.error",
    --     "kyc.verification.timeout",
    --     "kyc.verification.kba"
    --   ],
    --   "callback_url": "",
    --   "description": ""
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'events[0]', 'kyc.verification.success'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'events[1]', 'kyc.verification.failure'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'events[2]', 'kyc.verification.error'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'events[3]', 'kyc.verification.timeout'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'events[4]', 'kyc.verification.kba'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'callback_url', ''
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'description', ''

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Identity', '{{identity}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{authorization}}'

    DECLARE @sbRequestBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT

    EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PTextSb', @resp OUT, 'GET', 'https://{{environment}}.bond.tech/api/v0/accounts/:account_id/external_accounts', @sbRequestBody, 'utf-8', 'application/json', 0, 0
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @sbRequestBody
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @sbRequestBody


END
GO

Curl Command

curl -X GET
	-H "Identity: {{identity}}"
	-H "Authorization: {{authorization}}"
	-d '{
    "events": [
        "kyc.verification.success",
        "kyc.verification.failure",
        "kyc.verification.error",
        "kyc.verification.timeout",
        "kyc.verification.kba"
    ],
    "callback_url": "",
    "description": ""
}'
https://{{environment}}.bond.tech/api/v0/accounts/:account_id/external_accounts

Postman Collection Item JSON

{
  "name": "list external accounts",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Identity",
        "value": "{{identity}}",
        "type": "text"
      },
      {
        "key": "Authorization",
        "value": "{{authorization}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"events\": [\n        \"kyc.verification.success\",\n        \"kyc.verification.failure\",\n        \"kyc.verification.error\",\n        \"kyc.verification.timeout\",\n        \"kyc.verification.kba\"\n    ],\n    \"callback_url\": \"\",\n    \"description\": \"\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://{{environment}}.bond.tech/api/v0/accounts/:account_id/external_accounts",
      "protocol": "https",
      "host": [
        "{{environment}}",
        "bond",
        "tech"
      ],
      "path": [
        "api",
        "v0",
        "accounts",
        ":account_id",
        "external_accounts"
      ],
      "variable": [
        {
          "key": "account_id",
          "value": ""
        }
      ]
    }
  },
  "response": [
    {
      "name": "example",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Identity",
            "value": "{{identity}}",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "{{authorization}}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"events\": [\n        \"kyc.verification.success\",\n        \"kyc.verification.failure\",\n        \"kyc.verification.error\",\n        \"kyc.verification.timeout\",\n        \"kyc.verification.kba\"\n    ],\n    \"callback_url\": \"http://bond.tech\",\n    \"description\": \"Event listener NA\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://sandbox.bond.tech/api/v0/accounts/:account_id/external_accounts",
          "protocol": "https",
          "host": [
            "sandbox",
            "bond",
            "tech"
          ],
          "path": [
            "api",
            "v0",
            "accounts",
            ":account_id",
            "external_accounts"
          ],
          "variable": [
            {
              "key": "account_id",
              "value": ""
            }
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "[\n    {\n        \"linked_account_id\": \"f02ad0f9-1945-4cbc-b1b7-0e96b0189842\",\n        \"plaid_access_token\": \"access-sandbox-04159b72-7e5a-47f1-b2b8-f5a05464332a\", \n        \"customer_id\": \"0c9d3027-a22c-4653-a341-146fa689eb48\", \n        \"card_id\": \"edf4905f-2067-465e-b495-ad4f349eb8ae\", \n        \"date_created\": \"2021-02-11 12:01:36.122439-08\",\n        \"date_updated\": \"2021-02-11 12:01:36.122456-08\",\n        \"status\": \"active\",\n        \"bank_name\": \"Chase\",\n        \"account_number\": \"2222333344445555\",\n        \"routing_number\": \"011401533\",\n        \"account_type\": \"checking\",\n        \"account_category\": \"depository\"\n    },\n    {\n        \"linked_account_id\": \"133f6934-d3b7-4711-8600-0a8119b48c6c\",\n        \"plaid_access_token\": \"access-sandbox-9a4ac1ee-8d85-464d-bb39-e4a9427008e0\", \n        \"customer_id\": \"0c9d3027-a22c-4653-a341-146fa689eb48\", \n        \"card_id\": \"d48c4f5e-a535-4740-829b-ff1c8feb70ea\", \n        \"date_created\": \"2021-01-13 10:38:07.148335-08\",\n        \"date_updated\": \"2021-02-09 13:40:32.090811-08\",\n        \"status\": \"active\",\n        \"bank_name\": \"Bank of America\",\n        \"account_number\": \"1111222233330000\",\n        \"routing_number\": \"011401533\",\n        \"account_type\": \"savings\",\n        \"account_category\": \"depository\"\n    }\n]"
    }
  ]
}