feat: Update Swagger for the custom filter endpoint (#3367)
This commit is contained in:
@@ -32,6 +32,8 @@ class FilterService
|
|||||||
|
|
||||||
def filter_values(query_hash)
|
def filter_values(query_hash)
|
||||||
if query_hash['attribute_key'] == 'status'
|
if query_hash['attribute_key'] == 'status'
|
||||||
|
return Conversation.statuses.values if query_hash['values'].include?('all')
|
||||||
|
|
||||||
query_hash['values'].map { |x| Conversation.statuses[x.to_sym] }
|
query_hash['values'].map { |x| Conversation.statuses[x.to_sym] }
|
||||||
else
|
else
|
||||||
query_hash['values']
|
query_hash['values']
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ describe ::Conversations::FilterService do
|
|||||||
expect(result.length).to be conversations.count
|
expect(result.length).to be conversations.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'filter conversations by custom_attributes and status with pagination' do
|
||||||
|
params[:payload] = payload
|
||||||
|
params[:page] = 2
|
||||||
|
result = filter_service.new(params, user_1).perform
|
||||||
|
conversations = Conversation.where("additional_attributes ->> 'browser_language' IN (?) AND status IN (?)", ['en'], [1, 2])
|
||||||
|
expect(result.length).to be conversations.count
|
||||||
|
end
|
||||||
|
|
||||||
it 'filter conversations by tags' do
|
it 'filter conversations by tags' do
|
||||||
Conversation.last.update_labels('support')
|
Conversation.last.update_labels('support')
|
||||||
params[:payload] = [
|
params[:payload] = [
|
||||||
|
|||||||
44
swagger/paths/application/conversation/filter.yml
Normal file
44
swagger/paths/application/conversation/filter.yml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- Conversation
|
||||||
|
operationId: conversationFilter
|
||||||
|
description: Filter conversations with custom filter options and pagination
|
||||||
|
summary: Conversations 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
|
||||||
|
values:
|
||||||
|
type: array
|
||||||
|
description: array of the attribute values to filter
|
||||||
|
query_operator:
|
||||||
|
type: string
|
||||||
|
description: query operator name
|
||||||
|
- $ref: '#/parameters/account_id'
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Success
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/conversation_list'
|
||||||
|
400:
|
||||||
|
description: Bad Request Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/bad_request_error'
|
||||||
|
description: Access denied
|
||||||
@@ -174,6 +174,10 @@ public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversat
|
|||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/parameters/account_id'
|
- $ref: '#/parameters/account_id'
|
||||||
$ref: ./application/conversation/create.yml
|
$ref: ./application/conversation/create.yml
|
||||||
|
/api/v1/accounts/{account_id}/conversations/filter:
|
||||||
|
parameters:
|
||||||
|
- $ref: '#/parameters/account_id'
|
||||||
|
$ref: ./application/conversation/filter.yml
|
||||||
/api/v1/accounts/{account_id}/conversations/{converstion_id}:
|
/api/v1/accounts/{account_id}/conversations/{converstion_id}:
|
||||||
parameters:
|
parameters:
|
||||||
- $ref: '#/parameters/account_id'
|
- $ref: '#/parameters/account_id'
|
||||||
|
|||||||
@@ -1908,6 +1908,82 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/api/v1/accounts/{account_id}/conversations/filter": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"Conversation"
|
||||||
|
],
|
||||||
|
"operationId": "conversationFilter",
|
||||||
|
"description": "Filter conversations with custom filter options and pagination",
|
||||||
|
"summary": "Conversations 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"
|
||||||
|
},
|
||||||
|
"values": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "array of the attribute values to filter"
|
||||||
|
},
|
||||||
|
"query_operator": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "query operator name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$ref": "#/parameters/account_id"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/conversation_list"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/bad_request_error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": "Access denied"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/v1/accounts/{account_id}/conversations/{converstion_id}": {
|
"/api/v1/accounts/{account_id}/conversations/{converstion_id}": {
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user