Chilkat Online Tools

DataFlex / Zoom API / Get plan usage

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 sV_type
    Integer iHosts
    Integer iUsage
    String sV_Type
    Integer iHosts
    Integer iUsage
    String sPlan_zoom_roomsType
    Integer iPlan_zoom_roomsHosts
    Integer iPlan_zoom_roomsUsage
    String sFree_storage
    String sFree_storage_usage
    String sPlan_storage
    String sPlan_storage_usage
    String sPlan_storage_exceed
    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

    // Adds the "Authorization: Bearer <access_token>" header.
    Set ComAuthToken Of hoHttp To "<access_token>"

    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://api.zoom.us/v2/accounts/:accountId/plans/usage" 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)

    // {
    //   "plan_base": {
    //     "type": "monthly",
    //     "hosts": 2,
    //     "usage": 1
    //   },
    //   "plan_zoom_rooms": {
    //     "type": "zroom_monthly",
    //     "hosts": 1,
    //     "usage": 0
    //   },
    //   "plan_webinar": [
    //     {
    //       "type": "webinar1000",
    //       "hosts": 1,
    //       "usage": 1
    //     }
    //   ],
    //   "plan_zoom_events": [
    //     {
    //       "type": "zoomevents500_monthly",
    //       "hosts": 1,
    //       "usage": 1
    //     }
    //   ],
    //   "plan_large_meeting": [
    //     {
    //       "type": "large500_monthly",
    //       "hosts": 1,
    //       "usage": 1
    //     }
    //   ],
    //   "plan_recording": {
    //     "free_storage": "3 GB",
    //     "free_storage_usage": "0",
    //     "plan_storage": "0",
    //     "plan_storage_usage": "0",
    //     "plan_storage_exceed": "0"
    //   }
    // }

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

    Get ComStringOf Of hoJResp "plan_base.type" To sV_Type
    Get ComIntOf Of hoJResp "plan_base.hosts" To iHosts
    Get ComIntOf Of hoJResp "plan_base.usage" To iUsage
    Get ComStringOf Of hoJResp "plan_zoom_rooms.type" To sPlan_zoom_roomsType
    Get ComIntOf Of hoJResp "plan_zoom_rooms.hosts" To iPlan_zoom_roomsHosts
    Get ComIntOf Of hoJResp "plan_zoom_rooms.usage" To iPlan_zoom_roomsUsage
    Get ComStringOf Of hoJResp "plan_recording.free_storage" To sFree_storage
    Get ComStringOf Of hoJResp "plan_recording.free_storage_usage" To sFree_storage_usage
    Get ComStringOf Of hoJResp "plan_recording.plan_storage" To sPlan_storage
    Get ComStringOf Of hoJResp "plan_recording.plan_storage_usage" To sPlan_storage_usage
    Get ComStringOf Of hoJResp "plan_recording.plan_storage_exceed" To sPlan_storage_exceed
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "plan_webinar" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "plan_webinar[i].type" To sV_type
        Get ComIntOf Of hoJResp "plan_webinar[i].hosts" To iHosts
        Get ComIntOf Of hoJResp "plan_webinar[i].usage" To iUsage
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "plan_zoom_events" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "plan_zoom_events[i].type" To sV_type
        Get ComIntOf Of hoJResp "plan_zoom_events[i].hosts" To iHosts
        Get ComIntOf Of hoJResp "plan_zoom_events[i].usage" To iUsage
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "plan_large_meeting" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "plan_large_meeting[i].type" To sV_type
        Get ComIntOf Of hoJResp "plan_large_meeting[i].hosts" To iHosts
        Get ComIntOf Of hoJResp "plan_large_meeting[i].usage" To iUsage
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/accounts/:accountId/plans/usage

Postman Collection Item JSON

{
  "name": "Get plan usage",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "accounts",
        ":accountId",
        "plans",
        "usage"
      ],
      "variable": [
        {
          "key": "accountId"
        }
      ]
    },
    "description": "Get information on usage of [plans](https://marketplace.zoom.us/docs/api-reference/other-references/plans) of an account. This API supports regular accounts as well as master and sub accounts. To get plan usage of a regular account, use the `account:read:admin` scope and provide “me” as the value of the  `accountId` path parameter.To get plan usage of a master account, provide the keyword \"me\" as the value of the `accountId` path parameter and use the `billing:master` scope. To get plan usage of a sub account, provide the actual account Id of the sub account as the value of the `accountId` path parameter and use the `billing:master` scope. \n\n**Prerequisite**:<br>\nAccount type: master account on a paid Pro, Business or Enterprise plan.<br>\n**Scope:** `billing:master` for master and sub accounts. `account:read:admin` for regular Zoom accounts.<br>\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy`"
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200` <br>\nPlan Usage returned.<br>",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "usage"
          ],
          "variable": [
            {
              "key": "accountId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"plan_base\": {\n  \"type\": \"monthly\",\n  \"hosts\": 2,\n  \"usage\": 1\n },\n \"plan_zoom_rooms\": {\n  \"type\": \"zroom_monthly\",\n  \"hosts\": 1,\n  \"usage\": 0\n },\n \"plan_webinar\": [\n  {\n   \"type\": \"webinar1000\",\n   \"hosts\": 1,\n   \"usage\": 1\n  }\n ],\n \"plan_zoom_events\": [\n  {\n   \"type\": \"zoomevents500_monthly\",\n   \"hosts\": 1,\n   \"usage\": 1\n  }\n ],\n \"plan_large_meeting\": [\n  {\n   \"type\": \"large500_monthly\",\n   \"hosts\": 1,\n   \"usage\": 1\n  }\n ],\n \"plan_recording\": {\n  \"free_storage\": \"3 GB\",\n  \"free_storage_usage\": \"0\",\n  \"plan_storage\": \"0\",\n  \"plan_storage_usage\": \"0\",\n  \"plan_storage_exceed\": \"0\"\n }\n}"
    },
    {
      "name": "**HTTP Status Code:** `400` <br>\n**Error Code:** `200` <br>\nOnly available for paid account.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "usage"
          ],
          "variable": [
            {
              "key": "accountId"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}