PureBasic / Support API / Show Ticket Metrics
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
CkHttp::setCkBasicAuth(http, 1)
CkHttp::setCkLogin(http, "login")
CkHttp::setCkPassword(http, "password")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://example.zendesk.com/api/v2/ticket_metrics/:ticket_metric_id",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)
; {
; "ticket_metric": [
; {
; "agent_wait_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "assigned_at": "<dateTime>",
; "assignee_stations": "<integer>",
; "assignee_updated_at": "<dateTime>",
; "created_at": "<dateTime>",
; "custom_status_updated_at": "<dateTime>",
; "first_resolution_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "full_resolution_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "group_stations": "<integer>",
; "id": "<integer>",
; "initially_assigned_at": "<dateTime>",
; "latest_comment_added_at": "<dateTime>",
; "on_hold_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "reopens": "<integer>",
; "replies": "<integer>",
; "reply_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "reply_time_in_seconds": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "requester_updated_at": "<dateTime>",
; "requester_wait_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "solved_at": "<dateTime>",
; "status_updated_at": "<dateTime>",
; "ticket_id": "<integer>",
; "updated_at": "<dateTime>",
; "url": "<string>"
; },
; {
; "agent_wait_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "assigned_at": "<dateTime>",
; "assignee_stations": "<integer>",
; "assignee_updated_at": "<dateTime>",
; "created_at": "<dateTime>",
; "custom_status_updated_at": "<dateTime>",
; "first_resolution_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "full_resolution_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "group_stations": "<integer>",
; "id": "<integer>",
; "initially_assigned_at": "<dateTime>",
; "latest_comment_added_at": "<dateTime>",
; "on_hold_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "reopens": "<integer>",
; "replies": "<integer>",
; "reply_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "reply_time_in_seconds": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "requester_updated_at": "<dateTime>",
; "requester_wait_time_in_minutes": {
; "business": "<integer>",
; "calendar": "<integer>"
; },
; "solved_at": "<dateTime>",
; "status_updated_at": "<dateTime>",
; "ticket_id": "<integer>",
; "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
Business.s
Calendar.s
assigned_at.s
assignee_stations.s
assignee_updated_at.s
created_at.s
custom_status_updated_at.s
first_resolution_time_in_minutesBusiness.s
first_resolution_time_in_minutesCalendar.s
full_resolution_time_in_minutesBusiness.s
full_resolution_time_in_minutesCalendar.s
group_stations.s
id.s
initially_assigned_at.s
latest_comment_added_at.s
on_hold_time_in_minutesBusiness.s
on_hold_time_in_minutesCalendar.s
reopens.s
replies.s
reply_time_in_minutesBusiness.s
reply_time_in_minutesCalendar.s
reply_time_in_secondsBusiness.s
reply_time_in_secondsCalendar.s
requester_updated_at.s
requester_wait_time_in_minutesBusiness.s
requester_wait_time_in_minutesCalendar.s
solved_at.s
status_updated_at.s
ticket_id.s
updated_at.s
url.s
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"ticket_metric")
While i < count_i
CkJsonObject::setCkI(jResp, i)
Business = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].agent_wait_time_in_minutes.business")
Calendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].agent_wait_time_in_minutes.calendar")
assigned_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].assigned_at")
assignee_stations = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].assignee_stations")
assignee_updated_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].assignee_updated_at")
created_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].created_at")
custom_status_updated_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].custom_status_updated_at")
first_resolution_time_in_minutesBusiness = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].first_resolution_time_in_minutes.business")
first_resolution_time_in_minutesCalendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].first_resolution_time_in_minutes.calendar")
full_resolution_time_in_minutesBusiness = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].full_resolution_time_in_minutes.business")
full_resolution_time_in_minutesCalendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].full_resolution_time_in_minutes.calendar")
group_stations = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].group_stations")
id = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].id")
initially_assigned_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].initially_assigned_at")
latest_comment_added_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].latest_comment_added_at")
on_hold_time_in_minutesBusiness = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].on_hold_time_in_minutes.business")
on_hold_time_in_minutesCalendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].on_hold_time_in_minutes.calendar")
reopens = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].reopens")
replies = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].replies")
reply_time_in_minutesBusiness = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].reply_time_in_minutes.business")
reply_time_in_minutesCalendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].reply_time_in_minutes.calendar")
reply_time_in_secondsBusiness = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].reply_time_in_seconds.business")
reply_time_in_secondsCalendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].reply_time_in_seconds.calendar")
requester_updated_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].requester_updated_at")
requester_wait_time_in_minutesBusiness = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].requester_wait_time_in_minutes.business")
requester_wait_time_in_minutesCalendar = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].requester_wait_time_in_minutes.calendar")
solved_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].solved_at")
status_updated_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].status_updated_at")
ticket_id = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].ticket_id")
updated_at = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].updated_at")
url = CkJsonObject::ckStringOf(jResp,"ticket_metric[i].url")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -u login:password -X GET
-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_metrics/:ticket_metric_id
Postman Collection Item JSON
{
"name": "Show Ticket Metrics",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_metrics/:ticket_metric_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_metrics",
":ticket_metric_id"
],
"variable": [
{
"key": "ticket_metric_id",
"value": "<string>"
}
]
},
"description": "Returns a specific metric, or the metrics of a specific ticket.\n\n#### Pagination\n\n- Cursor pagination (recommended)\n- Offset pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\n\n#### Allowed For\n\n* Agents\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_metrics/:ticket_metric_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_metrics",
":ticket_metric_id"
],
"variable": [
{
"key": "ticket_metric_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"ticket_metric\": [\n {\n \"agent_wait_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"assigned_at\": \"<dateTime>\",\n \"assignee_stations\": \"<integer>\",\n \"assignee_updated_at\": \"<dateTime>\",\n \"created_at\": \"<dateTime>\",\n \"custom_status_updated_at\": \"<dateTime>\",\n \"first_resolution_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"full_resolution_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"group_stations\": \"<integer>\",\n \"id\": \"<integer>\",\n \"initially_assigned_at\": \"<dateTime>\",\n \"latest_comment_added_at\": \"<dateTime>\",\n \"on_hold_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"reopens\": \"<integer>\",\n \"replies\": \"<integer>\",\n \"reply_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"reply_time_in_seconds\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"requester_updated_at\": \"<dateTime>\",\n \"requester_wait_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"solved_at\": \"<dateTime>\",\n \"status_updated_at\": \"<dateTime>\",\n \"ticket_id\": \"<integer>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n },\n {\n \"agent_wait_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"assigned_at\": \"<dateTime>\",\n \"assignee_stations\": \"<integer>\",\n \"assignee_updated_at\": \"<dateTime>\",\n \"created_at\": \"<dateTime>\",\n \"custom_status_updated_at\": \"<dateTime>\",\n \"first_resolution_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"full_resolution_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"group_stations\": \"<integer>\",\n \"id\": \"<integer>\",\n \"initially_assigned_at\": \"<dateTime>\",\n \"latest_comment_added_at\": \"<dateTime>\",\n \"on_hold_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"reopens\": \"<integer>\",\n \"replies\": \"<integer>\",\n \"reply_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"reply_time_in_seconds\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"requester_updated_at\": \"<dateTime>\",\n \"requester_wait_time_in_minutes\": {\n \"business\": \"<integer>\",\n \"calendar\": \"<integer>\"\n },\n \"solved_at\": \"<dateTime>\",\n \"status_updated_at\": \"<dateTime>\",\n \"ticket_id\": \"<integer>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n ]\n}"
}
]
}