diff --git a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder index 82b9caacf..84aa6dcff 100644 --- a/app/views/api/v1/conversations/partials/_conversation.json.jbuilder +++ b/app/views/api/v1/conversations/partials/_conversation.json.jbuilder @@ -26,6 +26,7 @@ else end json.account_id conversation.account_id +json.uuid conversation.uuid json.additional_attributes conversation.additional_attributes json.agent_last_seen_at conversation.agent_last_seen_at.to_i json.assignee_last_seen_at conversation.assignee_last_seen_at.to_i diff --git a/app/views/api/v1/models/_conversation.json.jbuilder b/app/views/api/v1/models/_conversation.json.jbuilder index 0951892a6..3fa54bcd9 100644 --- a/app/views/api/v1/models/_conversation.json.jbuilder +++ b/app/views/api/v1/models/_conversation.json.jbuilder @@ -1,4 +1,5 @@ json.id conversation.display_id +json.uuid conversation.uuid json.created_at conversation.created_at.to_i json.contact do json.id conversation.contact.id diff --git a/app/views/public/api/v1/models/_conversation.json.jbuilder b/app/views/public/api/v1/models/_conversation.json.jbuilder index 29ec89e28..b0a464795 100644 --- a/app/views/public/api/v1/models/_conversation.json.jbuilder +++ b/app/views/public/api/v1/models/_conversation.json.jbuilder @@ -1,4 +1,5 @@ json.id resource.display_id +json.uuid resource.uuid json.inbox_id resource.inbox_id json.contact_last_seen_at resource.contact_last_seen_at.to_i json.status resource.status diff --git a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb index f98dfba65..d4929fea1 100644 --- a/spec/controllers/api/v1/accounts/conversations_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/conversations_controller_spec.rb @@ -32,6 +32,7 @@ RSpec.describe 'Conversations API', type: :request do body = JSON.parse(response.body, symbolize_names: true) expect(body[:data][:meta][:all_count]).to eq(1) expect(body[:data][:meta].keys).to include(:all_count, :mine_count, :assigned_count, :unassigned_count) + expect(body[:data][:payload].first[:uuid]).to eq(conversation.uuid) expect(body[:data][:payload].first[:messages].first[:id]).to eq(message.id) end diff --git a/spec/controllers/public/api/v1/inbox/conversations_controller_spec.rb b/spec/controllers/public/api/v1/inbox/conversations_controller_spec.rb index 72b0bfc81..5c00b0543 100644 --- a/spec/controllers/public/api/v1/inbox/conversations_controller_spec.rb +++ b/spec/controllers/public/api/v1/inbox/conversations_controller_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'Public Inbox Contact Conversations API', type: :request do expect(response).to have_http_status(:success) data = response.parsed_body expect(data.length).to eq 1 + expect(data.first['uuid']).to eq contact_inbox.conversations.first.uuid end it 'does not return any private or activity message' do diff --git a/swagger/definitions/request/public/message/update_payload.yml b/swagger/definitions/request/public/message/update_payload.yml index 8e17ff840..b581d7171 100644 --- a/swagger/definitions/request/public/message/update_payload.yml +++ b/swagger/definitions/request/public/message/update_payload.yml @@ -2,7 +2,19 @@ type: object properties: submitted_values: - type: object - description: Replies to the Bot Message Types - - \ No newline at end of file + oneOf: + - type: object + description: Replies to the Bot Message Types + properties: + csat_survey_response: + type: object + description: CSAT Survey Response if original message is CSAT Survey + properties: + rating: + type: integer + description: CSAT Rating + example: 5 + feedback_message: + type: string + description: CSAT Comment + example: 'Great' diff --git a/swagger/index.yml b/swagger/index.yml index bddaf934c..3cf8dd708 100644 --- a/swagger/index.yml +++ b/swagger/index.yml @@ -75,3 +75,6 @@ x-tagGroups: - Contacts API - Conversations API - Messages API + - name: Others + tags: + - CSAT Survey Page \ No newline at end of file diff --git a/swagger/parameters/conversation_uuid.yml b/swagger/parameters/conversation_uuid.yml new file mode 100644 index 000000000..b2bff7f39 --- /dev/null +++ b/swagger/parameters/conversation_uuid.yml @@ -0,0 +1,5 @@ +in: path +name: conversation_uuid +type: integer +required: true +description: The uuid of the conversation diff --git a/swagger/parameters/index.yml b/swagger/parameters/index.yml index 2c61a6a01..5dcc1f418 100644 --- a/swagger/parameters/index.yml +++ b/swagger/parameters/index.yml @@ -22,6 +22,9 @@ contact_sort_param: conversation_id: $ref: ./conversation_id.yml +conversation_uuid: + $ref: ./conversation_uuid.yml + custom_filter_id: $ref: ./custom_filter_id.yml diff --git a/swagger/paths/index.yml b/swagger/paths/index.yml index 3f208c2c9..bad24b218 100644 --- a/swagger/paths/index.yml +++ b/swagger/paths/index.yml @@ -124,6 +124,16 @@ # ---------------- end of public api routes-----------# +# ------------ Other routes ------------# + +/survey/responses/{conversation_uuid}: + parameters: + - $ref: '#/parameters/conversation_uuid' + get: + $ref: ./survey/show.yml + +# ----------- end of other routes -----------# + # ------------ Application API routes ------------# diff --git a/swagger/paths/survey/show.yml b/swagger/paths/survey/show.yml new file mode 100644 index 000000000..c2bd1e8e8 --- /dev/null +++ b/swagger/paths/survey/show.yml @@ -0,0 +1,9 @@ +tags: + - CSAT Survey Page +operationId: get-csat-survey-page +summary: Get CSAT survey page +description: You can redirect the client to this URL, instead of implementing the CSAT survey component yourself. +security: [] +responses: + 200: + description: Success diff --git a/swagger/swagger.json b/swagger/swagger.json index bf39397a6..70a4d5904 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1000,6 +1000,29 @@ } } }, + "/survey/responses/{conversation_uuid}": { + "parameters": [ + { + "$ref": "#/parameters/conversation_uuid" + } + ], + "get": { + "tags": [ + "CSAT Survey Page" + ], + "operationId": "get-csat-survey-page", + "summary": "Get CSAT survey page", + "description": "You can redirect the client to this URL, instead of implementing the CSAT survey component yourself.", + "security": [ + + ], + "responses": { + "200": { + "description": "Success" + } + } + } + }, "/api/v1/accounts/{account_id}/agent_bots": { "parameters": [ { @@ -6567,8 +6590,30 @@ "type": "object", "properties": { "submitted_values": { - "type": "object", - "description": "Replies to the Bot Message Types" + "oneOf": [ + { + "type": "object", + "description": "Replies to the Bot Message Types", + "properties": { + "csat_survey_response": { + "type": "object", + "description": "CSAT Survey Response if original message is CSAT Survey", + "properties": { + "rating": { + "type": "integer", + "description": "CSAT Rating", + "example": 5 + }, + "feedback_message": { + "type": "string", + "description": "CSAT Comment", + "example": "Great" + } + } + } + } + } + ] } } }, @@ -6973,6 +7018,13 @@ "required": true, "description": "The numeric ID of the conversation" }, + "conversation_uuid": { + "in": "path", + "name": "conversation_uuid", + "type": "integer", + "required": true, + "description": "The uuid of the conversation" + }, "custom_filter_id": { "in": "path", "name": "custom_filter_id", @@ -7093,6 +7145,12 @@ "Conversations API", "Messages API" ] + }, + { + "name": "Others", + "tags": [ + "CSAT Survey Page" + ] } ] } \ No newline at end of file