Chilkat Online Tools

DataFlex / Sunshine Conversations API / List Switchboard Integrations

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    String sName
    String sIntegrationId
    String sIntegrationType
    Boolean iDeliverStandbyEvents
    String sNextSwitchboardIntegrationId
    Integer iMessageHistoryCount
    Integer i
    Integer iCount_i
    String sTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "username"
    Set ComPassword Of hoHttp To "password"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://domain.com/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "switchboardIntegrations": [
    //     {
    //       "id": "5ef21b86e933b7355c11c604",
    //       "name": "bot",
    //       "integrationId": "5ef21b86e933b7355c11c605",
    //       "integrationType": "zd:agentWorkspace",
    //       "deliverStandbyEvents": true,
    //       "nextSwitchboardIntegrationId": "5ef21b86e933b7355c11c606",
    //       "messageHistoryCount": 5
    //     },
    //     {
    //       "id": "5ef21b86e933b7355c11c604",
    //       "name": "bot",
    //       "integrationId": "5ef21b86e933b7355c11c605",
    //       "integrationType": "zd:agentWorkspace",
    //       "deliverStandbyEvents": false,
    //       "nextSwitchboardIntegrationId": "5ef21b86e933b7355c11c606",
    //       "messageHistoryCount": 5
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "switchboardIntegrations" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "switchboardIntegrations[i].id" To sId
        Get ComStringOf Of hoJResp "switchboardIntegrations[i].name" To sName
        Get ComStringOf Of hoJResp "switchboardIntegrations[i].integrationId" To sIntegrationId
        Get ComStringOf Of hoJResp "switchboardIntegrations[i].integrationType" To sIntegrationType
        Get ComBoolOf Of hoJResp "switchboardIntegrations[i].deliverStandbyEvents" To iDeliverStandbyEvents
        Get ComStringOf Of hoJResp "switchboardIntegrations[i].nextSwitchboardIntegrationId" To sNextSwitchboardIntegrationId
        Get ComIntOf Of hoJResp "switchboardIntegrations[i].messageHistoryCount" To iMessageHistoryCount
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -X GET
	-u 'username:password'
https://domain.com/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations

Postman Collection Item JSON

{
  "name": "List Switchboard Integrations",
  "_postman_id": "21955de9-b9e9-49b5-ac24-7329e6adc085",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{url}}/v2/apps/{{appId}}/switchboards/:switchboardId/switchboardIntegrations",
      "host": [
        "{{url}}"
      ],
      "path": [
        "v2",
        "apps",
        "{{appId}}",
        "switchboards",
        ":switchboardId",
        "switchboardIntegrations"
      ],
      "variable": [
        {
          "key": "switchboardId"
        }
      ]
    },
    "description": "Lists all switchboard integrations linked to the switchboard.\n"
  },
  "response": [
    {
      "id": "5a125be4-37d6-4eca-915f-529d3fc6b08a",
      "name": "Ok",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/switchboards/:switchboardId/switchboardIntegrations",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "switchboards",
            ":switchboardId",
            "switchboardIntegrations"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "switchboardId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"switchboardIntegrations\": [\n  {\n   \"id\": \"5ef21b86e933b7355c11c604\",\n   \"name\": \"bot\",\n   \"integrationId\": \"5ef21b86e933b7355c11c605\",\n   \"integrationType\": \"zd:agentWorkspace\",\n   \"deliverStandbyEvents\": true,\n   \"nextSwitchboardIntegrationId\": \"5ef21b86e933b7355c11c606\",\n   \"messageHistoryCount\": 5\n  },\n  {\n   \"id\": \"5ef21b86e933b7355c11c604\",\n   \"name\": \"bot\",\n   \"integrationId\": \"5ef21b86e933b7355c11c605\",\n   \"integrationType\": \"zd:agentWorkspace\",\n   \"deliverStandbyEvents\": false,\n   \"nextSwitchboardIntegrationId\": \"5ef21b86e933b7355c11c606\",\n   \"messageHistoryCount\": 5\n  }\n ]\n}"
    },
    {
      "id": "feb621bd-7ff6-43cc-8238-947dd169c626",
      "name": "Switchboard not found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/switchboards/:switchboardId/switchboardIntegrations",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "switchboards",
            ":switchboardId",
            "switchboardIntegrations"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "switchboardId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}