PureBasic / Zoom API / Get account's TSP information
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Adds the "Authorization: Bearer <access_token>" header.
CkHttp::setCkAuthToken(http, "<access_token>")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://api.zoom.us/v2/tsp",sbResponseBody)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttp::ckLastStatus(http)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttp::ckLastHeader(http)
Debug "Failed."
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "tsp_provider": "someprovidername",
; "enable": true,
; "dial_in_numbers": [
; {
; "code": "111",
; "number": "000000000",
; "type": "toll"
; }
; ],
; "tsp_enabled": true,
; "master_account_setting_extended": false,
; "modify_credential_forbidden": true,
; "dial_in_number_unrestricted": false,
; "tsp_bridge": "string"
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
code.s
v_number.s
v_type.s
tsp_provider.s = CkJsonObject::ckStringOf(jResp,"tsp_provider")
enable.i = CkJsonObject::ckBoolOf(jResp,"enable")
tsp_enabled.i = CkJsonObject::ckBoolOf(jResp,"tsp_enabled")
master_account_setting_extended.i = CkJsonObject::ckBoolOf(jResp,"master_account_setting_extended")
modify_credential_forbidden.i = CkJsonObject::ckBoolOf(jResp,"modify_credential_forbidden")
dial_in_number_unrestricted.i = CkJsonObject::ckBoolOf(jResp,"dial_in_number_unrestricted")
tsp_bridge.s = CkJsonObject::ckStringOf(jResp,"tsp_bridge")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"dial_in_numbers")
While i < count_i
CkJsonObject::setCkI(jResp, i)
code = CkJsonObject::ckStringOf(jResp,"dial_in_numbers[i].code")
v_number = CkJsonObject::ckStringOf(jResp,"dial_in_numbers[i].number")
v_type = CkJsonObject::ckStringOf(jResp,"dial_in_numbers[i].type")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/tsp
Postman Collection Item JSON
{
"name": "Get account's TSP information",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/tsp",
"host": [
"{{baseUrl}}"
],
"path": [
"tsp"
]
},
"description": "Get information on Telephony Service Provider on an account level.<br><br>\n**Scopes:** `tsp:read:admin` <br>\n \n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`\n\n**Prerequisites:**<br>\n* A Pro or a higher plan."
},
"response": [
{
"name": "**HTTP Status Code:** `200`<br>\nTSP account detail returned successfully.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/tsp",
"host": [
"{{baseUrl}}"
],
"path": [
"tsp"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"tsp_provider\": \"someprovidername\",\n \"enable\": true,\n \"dial_in_numbers\": [\n {\n \"code\": \"111\",\n \"number\": \"000000000\",\n \"type\": \"toll\"\n }\n ],\n \"tsp_enabled\": true,\n \"master_account_setting_extended\": false,\n \"modify_credential_forbidden\": true,\n \"dial_in_number_unrestricted\": false,\n \"tsp_bridge\": \"string\"\n}"
}
]
}