feat: APIs to filter reports (#2889)

Fixes #2823
This commit is contained in:
Tejaswini Chile
2021-08-27 22:46:32 +05:30
committed by GitHub
parent f94abaef5f
commit 65f3e83afd
19 changed files with 542 additions and 61 deletions

View File

@@ -140,3 +140,12 @@ extended_message:
- $ref: '#/definitions/generic_id'
- $ref: '#/definitions/message'
- $ref: ./resource/extension/message/with_source_sender.yml
## report list
report:
type: array
description: 'array of conversation count based on date'
items:
allOf:
- $ref: './resource/report.yml'

View File

@@ -0,0 +1,6 @@
type: object
properties:
value:
type: number
timestamp:
type: string

View File

@@ -63,6 +63,7 @@ x-tagGroups:
- Profile
- Teams
- Custom Filter
- Reports
- name: Public
tags:
- Contacts API

View File

@@ -31,6 +31,12 @@ platform_user_id:
custom_filter_id:
$ref: ./custom_filter_id.yml
report_type:
$ref: ./report_type.yml
report_metric:
$ref: ./report_metric.yml
public_inbox_identifier:
$ref: ./public/inbox_identifier.yml

View File

@@ -0,0 +1,7 @@
in: query
name: metric
schema:
type: string
enum: [conversations_count, incoming_messages_count, outgoing_messages_count, avg_first_response_time, avg_resolution_time, resolutions_count]
required: true
description: The type of metric

View File

@@ -0,0 +1,7 @@
in: query
name: report_type
schema:
type: string
enum: [account,agent,inbox,label]
required: true
description: Type of report

View File

@@ -269,7 +269,7 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat
delete:
$ref: ./teams/delete.yml
### Custom Filters
### Custom Filters goes here
# Teams
/api/v1/accounts/{account_id}/custom_filters:
@@ -296,3 +296,52 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat
$ref: ./custom_filters/update.yml
delete:
$ref: ./custom_filters/delete.yml
### Reports
# List
/api/v1/accounts/{id}/reports:
parameters:
- $ref: '#/parameters/account_id'
- $ref: '#/parameters/report_metric'
- $ref: '#/parameters/report_type'
- in: query
name: id
schema:
type: string
description: The Id of specific object in case of agent/inbox/label
- in: query
name: since
schema:
type: string
description: The timestamp from where report should start.
- in: query
name: until
schema:
type: string
description: The timestamp from where report should stop.
get:
$ref: './reports/index.yml'
# Summary
/api/v1/accounts/{id}/reports/summary:
parameters:
- $ref: '#/parameters/account_id'
- $ref: '#/parameters/report_type'
- in: query
name: id
schema:
type: string
description: The Id of specific object in case of agent/inbox/label
- in: query
name: since
schema:
type: string
description: The timestamp from where report should start.
- in: query
name: until
schema:
type: string
description: The timestamp from where report should stop.
get:
$ref: './reports/summary.yml'

View File

@@ -0,0 +1,17 @@
tags:
- Reports
operationId: list-all-conversation-statistics
summary: Get Account reports
description: Get Account reports for a specific type, metric and date range
responses:
200:
description: Success
schema:
type: array
description: 'Array of date based conversation statistics'
items:
$ref: '#/definitions/report'
404:
description: reports not found
403:
description: Access denied

View File

@@ -0,0 +1,17 @@
tags:
- Reports
operationId: list-all-conversation-statistics-summary
summary: Get Account reports summary
description: Get Account reports summary for a specific type and date range
responses:
200:
description: Success
schema:
type: array
description: 'Array of date based conversation statistics'
items:
$ref: '#/definitions/report'
404:
description: reports not found
403:
description: Access denied

View File

@@ -2757,6 +2757,129 @@
}
}
}
},
"/api/v1/accounts/{id}/reports": {
"parameters": [
{
"$ref": "#/parameters/account_id"
},
{
"$ref": "#/parameters/report_metric"
},
{
"$ref": "#/parameters/report_type"
},
{
"in": "query",
"name": "id",
"schema": {
"type": "string"
},
"description": "The Id of specific object in case of agent/inbox/label"
},
{
"in": "query",
"name": "since",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should start."
},
{
"in": "query",
"name": "until",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should stop."
}
],
"get": {
"tags": [
"Reports"
],
"operationId": "list-all-conversation-statistics",
"summary": "Get Account reports",
"description": "Get Account reports for a specific type, metric and date range",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"description": "Array of date based conversation statistics",
"items": {
"$ref": "#/definitions/report"
}
}
},
"404": {
"description": "reports not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/api/v1/accounts/{id}/reports/summary": {
"parameters": [
{
"$ref": "#/parameters/account_id"
},
{
"$ref": "#/parameters/report_type"
},
{
"in": "query",
"name": "id",
"schema": {
"type": "string"
},
"description": "The Id of specific object in case of agent/inbox/label"
},
{
"in": "query",
"name": "since",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should start."
},
{
"in": "query",
"name": "until",
"schema": {
"type": "string"
},
"description": "The timestamp from where report should stop."
}
],
"get": {
"tags": [
"Reports"
],
"operationId": "list-all-conversation-statistics-summary",
"summary": "Get Account reports summary",
"description": "Get Account reports summary for a specific type and date range",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"description": "Array of date based conversation statistics",
"items": {
"$ref": "#/definitions/report"
}
}
},
"404": {
"description": "reports not found"
},
"403": {
"description": "Access denied"
}
}
}
}
},
"definitions": {
@@ -3844,6 +3967,25 @@
}
}
]
},
"report": {
"type": "array",
"description": "array of conversation count based on date",
"items": {
"allOf": [
{
"type": "object",
"properties": {
"value": {
"type": "number"
},
"timestamp": {
"type": "string"
}
}
}
]
}
}
},
"parameters": {
@@ -3952,6 +4094,38 @@
"required": true,
"description": "The numeric ID of the custom filter"
},
"report_type": {
"in": "query",
"name": "report_type",
"schema": {
"type": "string",
"enum": [
"account",
"agent",
"inbox",
"label"
]
},
"required": true,
"description": "Type of report"
},
"report_metric": {
"in": "query",
"name": "metric",
"schema": {
"type": "string",
"enum": [
"conversations_count",
"incoming_messages_count",
"outgoing_messages_count",
"avg_first_response_time",
"avg_resolution_time",
"resolutions_count"
]
},
"required": true,
"description": "The type of metric"
},
"public_inbox_identifier": {
"in": "path",
"name": "inbox_identifier",
@@ -3994,7 +4168,8 @@
"Integrations",
"Profile",
"Teams",
"Custom Filter"
"Custom Filter",
"Reports"
]
},
{