Chilkat Online Tools

Swift3 / Support API / Show Workspace

Back to Collection Items

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

    let http = CkoHttp()!
    var success: Bool

    http.basicAuth = true
    http.login = "login"
    http.password = "password"

    http.setRequestHeader("Accept", value: "application/json")

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb("https://example.zendesk.com/api/v2/workspaces/:workspace_id", sbContent: sbResponseBody)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = http.lastStatus.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(http.lastHeader!)")
        print("Failed.")
        return
    }

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

    // {
    //   "workspace": {
    //     "activated": "<boolean>",
    //     "apps": [
    //       {
    //         "ad_be": true,
    //         "ead07": 69455617,
    //         "adipisicinga": true
    //       },
    //       {
    //         "fugiat_e": false,
    //         "dolorf7": -57129708.70016649
    //       }
    //     ],
    //     "conditions": {
    //       "all": [
    //         {
    //           "field": "<string>",
    //           "operator": "<string>",
    //           "value": "<string>"
    //         },
    //         {
    //           "field": "<string>",
    //           "operator": "<string>",
    //           "value": "<string>"
    //         }
    //       ],
    //       "any": [
    //         {
    //           "field": "<string>",
    //           "operator": "<string>",
    //           "value": "<string>"
    //         },
    //         {
    //           "field": "<string>",
    //           "operator": "<string>",
    //           "value": "<string>"
    //         }
    //       ]
    //     },
    //     "created_at": "<dateTime>",
    //     "description": "<string>",
    //     "id": "<integer>",
    //     "macro_ids": [
    //       "<integer>",
    //       "<integer>"
    //     ],
    //     "macros": [
    //       "<integer>",
    //       "<integer>"
    //     ],
    //     "position": "<integer>",
    //     "prefer_workspace_app_order": "<boolean>",
    //     "selected_macros": [
    //       {
    //         "actions": [
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           },
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           }
    //         ],
    //         "title": "<string>",
    //         "active": "<boolean>",
    //         "created_at": "<dateTime>",
    //         "default": "<boolean>",
    //         "description": "<string>",
    //         "id": "<integer>",
    //         "position": "<integer>",
    //         "restriction": {
    //           "in_f25": true,
    //           "nisid81": "reprehenderit anim nostrud id",
    //           "minim_886": false
    //         },
    //         "updated_at": "<dateTime>",
    //         "url": "<string>",
    //         "app_installation": "<string>",
    //         "categories": "<string>",
    //         "permissions": "<string>",
    //         "usage_1h": "<integer>",
    //         "usage_7d": "<integer>",
    //         "usage_24h": "<integer>",
    //         "usage_30d": "<integer>"
    //       },
    //       {
    //         "actions": [
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           },
    //           {
    //             "field": "<string>",
    //             "value": "<string>"
    //           }
    //         ],
    //         "title": "<string>",
    //         "active": "<boolean>",
    //         "created_at": "<dateTime>",
    //         "default": "<boolean>",
    //         "description": "<string>",
    //         "id": "<integer>",
    //         "position": "<integer>",
    //         "restriction": {
    //           "culpa__d7": false,
    //           "ad7": true,
    //           "esse0": -82046233.9137964,
    //           "veniam_f": -91185504
    //         },
    //         "updated_at": "<dateTime>",
    //         "url": "<string>",
    //         "app_installation": "<string>",
    //         "categories": "<string>",
    //         "permissions": "<string>",
    //         "usage_1h": "<integer>",
    //         "usage_7d": "<integer>",
    //         "usage_24h": "<integer>",
    //         "usage_30d": "<integer>"
    //       }
    //     ],
    //     "ticket_form_id": "<integer>",
    //     "title": "<string>",
    //     "updated_at": "<dateTime>",
    //     "url": "<string>"
    //   }
    // }

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

    var ad_be: Bool
    var ead07: Int
    var adipisicinga: Bool
    var fugiat_e: Bool
    var dolorf7: String?
    var field: String?
    var operator: String?
    var value: String?
    var strVal: String?
    var title: String?
    var active: String?
    var created_at: String?
    var default: String?
    var description: String?
    var id: String?
    var position: String?
    var In_f25: Bool
    var Nisid81: String?
    var Minim_886: Bool
    var updated_at: String?
    var url: String?
    var app_installation: String?
    var categories: String?
    var permissions: String?
    var usage_1h: String?
    var usage_7d: String?
    var usage_24h: String?
    var usage_30d: String?
    var Culpa__d7: Bool
    var Ad7: Bool
    var Esse0: String?
    var Veniam_f: Int
    var j: Int
    var count_j: Int

    var Activated: String? = jResp.string(of: "workspace.activated")
    var Created_at: String? = jResp.string(of: "workspace.created_at")
    var Description: String? = jResp.string(of: "workspace.description")
    var Id: String? = jResp.string(of: "workspace.id")
    var Position: String? = jResp.string(of: "workspace.position")
    var Prefer_workspace_app_order: String? = jResp.string(of: "workspace.prefer_workspace_app_order")
    var Ticket_form_id: String? = jResp.string(of: "workspace.ticket_form_id")
    var Title: String? = jResp.string(of: "workspace.title")
    var Updated_at: String? = jResp.string(of: "workspace.updated_at")
    var v_Url: String? = jResp.string(of: "workspace.url")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "workspace.apps").intValue
    while i < count_i {
        jResp.i = i
        ad_be = jResp.bool(of: "workspace.apps[i].ad_be")
        ead07 = jResp.int(of: "workspace.apps[i].ead07").intValue
        adipisicinga = jResp.bool(of: "workspace.apps[i].adipisicinga")
        fugiat_e = jResp.bool(of: "workspace.apps[i].fugiat_e")
        dolorf7 = jResp.string(of: "workspace.apps[i].dolorf7")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "workspace.conditions.all").intValue
    while i < count_i {
        jResp.i = i
        field = jResp.string(of: "workspace.conditions.all[i].field")
        operator = jResp.string(of: "workspace.conditions.all[i].operator")
        value = jResp.string(of: "workspace.conditions.all[i].value")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "workspace.conditions.any").intValue
    while i < count_i {
        jResp.i = i
        field = jResp.string(of: "workspace.conditions.any[i].field")
        operator = jResp.string(of: "workspace.conditions.any[i].operator")
        value = jResp.string(of: "workspace.conditions.any[i].value")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "workspace.macro_ids").intValue
    while i < count_i {
        jResp.i = i
        strVal = jResp.string(of: "workspace.macro_ids[i]")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "workspace.macros").intValue
    while i < count_i {
        jResp.i = i
        strVal = jResp.string(of: "workspace.macros[i]")
        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "workspace.selected_macros").intValue
    while i < count_i {
        jResp.i = i
        title = jResp.string(of: "workspace.selected_macros[i].title")
        active = jResp.string(of: "workspace.selected_macros[i].active")
        created_at = jResp.string(of: "workspace.selected_macros[i].created_at")
        default = jResp.string(of: "workspace.selected_macros[i].default")
        description = jResp.string(of: "workspace.selected_macros[i].description")
        id = jResp.string(of: "workspace.selected_macros[i].id")
        position = jResp.string(of: "workspace.selected_macros[i].position")
        In_f25 = jResp.bool(of: "workspace.selected_macros[i].restriction.in_f25")
        Nisid81 = jResp.string(of: "workspace.selected_macros[i].restriction.nisid81")
        Minim_886 = jResp.bool(of: "workspace.selected_macros[i].restriction.minim_886")
        updated_at = jResp.string(of: "workspace.selected_macros[i].updated_at")
        url = jResp.string(of: "workspace.selected_macros[i].url")
        app_installation = jResp.string(of: "workspace.selected_macros[i].app_installation")
        categories = jResp.string(of: "workspace.selected_macros[i].categories")
        permissions = jResp.string(of: "workspace.selected_macros[i].permissions")
        usage_1h = jResp.string(of: "workspace.selected_macros[i].usage_1h")
        usage_7d = jResp.string(of: "workspace.selected_macros[i].usage_7d")
        usage_24h = jResp.string(of: "workspace.selected_macros[i].usage_24h")
        usage_30d = jResp.string(of: "workspace.selected_macros[i].usage_30d")
        Culpa__d7 = jResp.bool(of: "workspace.selected_macros[i].restriction.culpa__d7")
        Ad7 = jResp.bool(of: "workspace.selected_macros[i].restriction.ad7")
        Esse0 = jResp.string(of: "workspace.selected_macros[i].restriction.esse0")
        Veniam_f = jResp.int(of: "workspace.selected_macros[i].restriction.veniam_f").intValue
        j = 0
        count_j = jResp.size(ofArray: "workspace.selected_macros[i].actions").intValue
        while j < count_j {
            jResp.j = j
            field = jResp.string(of: "workspace.selected_macros[i].actions[j].field")
            value = jResp.string(of: "workspace.selected_macros[i].actions[j].value")
            j = j + 1
        }

        i = i + 1
    }


}

Curl Command

curl  -u login:password -X GET
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/workspaces/:workspace_id

Postman Collection Item JSON

{
  "name": "Show Workspace",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/workspaces/:workspace_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "workspaces",
        ":workspace_id"
      ],
      "variable": [
        {
          "key": "workspace_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "#### Allowed For\n* Admins\n"
  },
  "response": [
    {
      "name": "Successful response",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/workspaces/:workspace_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "workspaces",
            ":workspace_id"
          ],
          "variable": [
            {
              "key": "workspace_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"workspace\": {\n    \"activated\": \"<boolean>\",\n    \"apps\": [\n      {\n        \"ad_be\": true,\n        \"ead07\": 69455617,\n        \"adipisicinga\": true\n      },\n      {\n        \"fugiat_e\": false,\n        \"dolorf7\": -57129708.70016649\n      }\n    ],\n    \"conditions\": {\n      \"all\": [\n        {\n          \"field\": \"<string>\",\n          \"operator\": \"<string>\",\n          \"value\": \"<string>\"\n        },\n        {\n          \"field\": \"<string>\",\n          \"operator\": \"<string>\",\n          \"value\": \"<string>\"\n        }\n      ],\n      \"any\": [\n        {\n          \"field\": \"<string>\",\n          \"operator\": \"<string>\",\n          \"value\": \"<string>\"\n        },\n        {\n          \"field\": \"<string>\",\n          \"operator\": \"<string>\",\n          \"value\": \"<string>\"\n        }\n      ]\n    },\n    \"created_at\": \"<dateTime>\",\n    \"description\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"macro_ids\": [\n      \"<integer>\",\n      \"<integer>\"\n    ],\n    \"macros\": [\n      \"<integer>\",\n      \"<integer>\"\n    ],\n    \"position\": \"<integer>\",\n    \"prefer_workspace_app_order\": \"<boolean>\",\n    \"selected_macros\": [\n      {\n        \"actions\": [\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          },\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ],\n        \"title\": \"<string>\",\n        \"active\": \"<boolean>\",\n        \"created_at\": \"<dateTime>\",\n        \"default\": \"<boolean>\",\n        \"description\": \"<string>\",\n        \"id\": \"<integer>\",\n        \"position\": \"<integer>\",\n        \"restriction\": {\n          \"in_f25\": true,\n          \"nisid81\": \"reprehenderit anim nostrud id\",\n          \"minim_886\": false\n        },\n        \"updated_at\": \"<dateTime>\",\n        \"url\": \"<string>\",\n        \"app_installation\": \"<string>\",\n        \"categories\": \"<string>\",\n        \"permissions\": \"<string>\",\n        \"usage_1h\": \"<integer>\",\n        \"usage_7d\": \"<integer>\",\n        \"usage_24h\": \"<integer>\",\n        \"usage_30d\": \"<integer>\"\n      },\n      {\n        \"actions\": [\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          },\n          {\n            \"field\": \"<string>\",\n            \"value\": \"<string>\"\n          }\n        ],\n        \"title\": \"<string>\",\n        \"active\": \"<boolean>\",\n        \"created_at\": \"<dateTime>\",\n        \"default\": \"<boolean>\",\n        \"description\": \"<string>\",\n        \"id\": \"<integer>\",\n        \"position\": \"<integer>\",\n        \"restriction\": {\n          \"culpa__d7\": false,\n          \"ad7\": true,\n          \"esse0\": -82046233.9137964,\n          \"veniam_f\": -91185504\n        },\n        \"updated_at\": \"<dateTime>\",\n        \"url\": \"<string>\",\n        \"app_installation\": \"<string>\",\n        \"categories\": \"<string>\",\n        \"permissions\": \"<string>\",\n        \"usage_1h\": \"<integer>\",\n        \"usage_7d\": \"<integer>\",\n        \"usage_24h\": \"<integer>\",\n        \"usage_30d\": \"<integer>\"\n      }\n    ],\n    \"ticket_form_id\": \"<integer>\",\n    \"title\": \"<string>\",\n    \"updated_at\": \"<dateTime>\",\n    \"url\": \"<string>\"\n  }\n}"
    }
  ]
}