From e304ad27cbe12ee708b87a54e9f2af375118ebd5 Mon Sep 17 00:00:00 2001 From: Tejaswini Chile Date: Tue, 4 Jan 2022 13:10:29 +0530 Subject: [PATCH] Chore: Custom filter api docs updated (#3668) --- swagger/paths/application/contacts/filter.yml | 55 +++++++ .../paths/application/conversation/filter.yml | 12 ++ swagger/paths/index.yml | 5 + swagger/swagger.json | 142 +++++++++++++++++- 4 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 swagger/paths/application/contacts/filter.yml diff --git a/swagger/paths/application/contacts/filter.yml b/swagger/paths/application/contacts/filter.yml new file mode 100644 index 000000000..27adfbb9f --- /dev/null +++ b/swagger/paths/application/contacts/filter.yml @@ -0,0 +1,55 @@ +tags: + - Contact +operationId: contactFilter +description: Filter contacts with custom filter options and pagination +summary: Contact Filter +security: + - userApiKey: [] + - agentBotApiKey: [] +parameters: + - name: page + in: query + type: integer + - name: payload + in: body + required: true + schema: + type: array + items: + type: object + properties: + attribute_key: + type: string + description: filter attribute name + filter_operator: + type: string + description: filter operator name + enum: [ equal_to, not_equal_to, contains, does_not_contain ] + values: + type: array + items: + type: string + description: array of the attribute values to filter + query_operator: + type: string + description: query operator name + enum: [ AND, OR ] + example: + - attribute_key: 'name' + filter_operator: 'equal_to' + values: ['en'] + query_operator: 'AND' + - attribute_key: 'country_code' + filter_operator: 'equal_to' + values: ['us'] + query_operator: nil + +responses: + 200: + description: Success + schema: + $ref: '#/definitions/contact_list' + 400: + description: Bad Request Error + schema: + $ref: '#/definitions/bad_request_error' diff --git a/swagger/paths/application/conversation/filter.yml b/swagger/paths/application/conversation/filter.yml index ce14b7823..8f7e642c7 100644 --- a/swagger/paths/application/conversation/filter.yml +++ b/swagger/paths/application/conversation/filter.yml @@ -24,6 +24,7 @@ parameters: filter_operator: type: string description: filter operator name + enum: [ equal_to, not_equal_to, contains, does_not_contain ] values: type: array items: @@ -32,6 +33,17 @@ parameters: query_operator: type: string description: query operator name + enum: [ AND, OR ] + example: + - attribute_key: 'browser_language' + filter_operator: 'not_eq' + values: ['en'] + query_operator: 'AND' + - attribute_key: 'status' + filter_operator: 'eq' + values: ['pending'] + query_operator: nil + responses: 200: description: Success diff --git a/swagger/paths/index.yml b/swagger/paths/index.yml index b25d6ff68..8a4154bb8 100644 --- a/swagger/paths/index.yml +++ b/swagger/paths/index.yml @@ -164,6 +164,11 @@ $ref: ./application/contacts/conversations.yml /api/v1/accounts/{account_id}/contacts/search: $ref: ./application/contacts/search.yml +/api/v1/accounts/{account_id}/contacts/filter: + parameters: + - $ref: '#/parameters/account_id' + post: + $ref: ./application/contacts/filter.yml /api/v1/accounts/{account_id}/contacts/{id}/contact_inboxes: $ref: ./application/contact_inboxes/create.yml /api/v1/accounts/{account_id}/contacts/{id}/contactable_inboxes: diff --git a/swagger/swagger.json b/swagger/swagger.json index d19f43a7f..39cc9f95a 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1571,6 +1571,114 @@ } } }, + "/api/v1/accounts/{account_id}/contacts/filter": { + "parameters": [ + { + "$ref": "#/parameters/account_id" + } + ], + "post": { + "tags": [ + "Contact" + ], + "operationId": "contactFilter", + "description": "Filter contacts with custom filter options and pagination", + "summary": "Contact Filter", + "security": [ + { + "userApiKey": [ + + ] + }, + { + "agentBotApiKey": [ + + ] + } + ], + "parameters": [ + { + "name": "page", + "in": "query", + "type": "integer" + }, + { + "name": "payload", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "attribute_key": { + "type": "string", + "description": "filter attribute name" + }, + "filter_operator": { + "type": "string", + "description": "filter operator name", + "enum": [ + "equal_to", + "not_equal_to", + "contains", + "does_not_contain" + ] + }, + "values": { + "type": "array", + "items": { + "type": "string" + }, + "description": "array of the attribute values to filter" + }, + "query_operator": { + "type": "string", + "description": "query operator name", + "enum": [ + "AND", + "OR" + ] + } + } + }, + "example": [ + { + "attribute_key": "name", + "filter_operator": "equal_to", + "values": [ + "en" + ], + "query_operator": "AND" + }, + { + "attribute_key": "country_code", + "filter_operator": "equal_to", + "values": [ + "us" + ], + "query_operator": "nil" + } + ] + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/contact_list" + } + }, + "400": { + "description": "Bad Request Error", + "schema": { + "$ref": "#/definitions/bad_request_error" + } + } + } + } + }, "/api/v1/accounts/{account_id}/contacts/{id}/contact_inboxes": { "post": { "tags": [ @@ -1879,7 +1987,13 @@ }, "filter_operator": { "type": "string", - "description": "filter operator name" + "description": "filter operator name", + "enum": [ + "equal_to", + "not_equal_to", + "contains", + "does_not_contain" + ] }, "values": { "type": "array", @@ -1890,10 +2004,32 @@ }, "query_operator": { "type": "string", - "description": "query operator name" + "description": "query operator name", + "enum": [ + "AND", + "OR" + ] } } - } + }, + "example": [ + { + "attribute_key": "browser_language", + "filter_operator": "not_eq", + "values": [ + "en" + ], + "query_operator": "AND" + }, + { + "attribute_key": "status", + "filter_operator": "eq", + "values": [ + "pending" + ], + "query_operator": "nil" + } + ] } } ],