chore: Create conversation API should accept assignee & team (#3166)
This commit is contained in:
parent
68e697c379
commit
a35269d275
4 changed files with 31 additions and 1 deletions
|
@ -130,7 +130,9 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
||||||
contact_inbox_id: @contact_inbox.id,
|
contact_inbox_id: @contact_inbox.id,
|
||||||
additional_attributes: additional_attributes,
|
additional_attributes: additional_attributes,
|
||||||
custom_attributes: custom_attributes,
|
custom_attributes: custom_attributes,
|
||||||
snoozed_until: params[:snoozed_until]
|
snoozed_until: params[:snoozed_until],
|
||||||
|
assignee_id: params[:assignee_id],
|
||||||
|
team_id: params[:team_id]
|
||||||
}.merge(status)
|
}.merge(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,7 @@ RSpec.describe 'Conversations API', type: :request do
|
||||||
|
|
||||||
context 'when it is an authenticated user' do
|
context 'when it is an authenticated user' do
|
||||||
let(:agent) { create(:user, account: account, role: :agent) }
|
let(:agent) { create(:user, account: account, role: :agent) }
|
||||||
|
let(:team) { create(:team, account: account) }
|
||||||
|
|
||||||
it 'will not create a new conversation if agent does not have access to inbox' do
|
it 'will not create a new conversation if agent does not have access to inbox' do
|
||||||
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
||||||
|
@ -250,6 +251,19 @@ RSpec.describe 'Conversations API', type: :request do
|
||||||
params: { contact_id: contact.id, inbox_id: inbox.id },
|
params: { contact_id: contact.id, inbox_id: inbox.id },
|
||||||
as: :json
|
as: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates a new conversation with assignee and team' do
|
||||||
|
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
||||||
|
post "/api/v1/accounts/#{account.id}/conversations",
|
||||||
|
headers: agent.create_new_auth_token,
|
||||||
|
params: { source_id: contact_inbox.source_id, contact_id: contact.id, inbox_id: inbox.id, assignee_id: agent.id, team_id: team.id },
|
||||||
|
as: :json
|
||||||
|
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
response_data = JSON.parse(response.body, symbolize_names: true)
|
||||||
|
expect(response_data[:meta][:assignee][:name]).to eq(agent.name)
|
||||||
|
expect(response_data[:meta][:team][:name]).to eq(team.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,6 +73,12 @@ post:
|
||||||
type: string
|
type: string
|
||||||
enum: ['open', 'resolved', 'pending']
|
enum: ['open', 'resolved', 'pending']
|
||||||
description: Specify the conversation whether it's pending, open, closed
|
description: Specify the conversation whether it's pending, open, closed
|
||||||
|
assignee_id:
|
||||||
|
type: string
|
||||||
|
description: Agent Id for assigning a conversation to an agent
|
||||||
|
team_id:
|
||||||
|
type: string
|
||||||
|
description: Team Id for assigning a conversation to a team
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
|
|
|
@ -1796,6 +1796,14 @@
|
||||||
"pending"
|
"pending"
|
||||||
],
|
],
|
||||||
"description": "Specify the conversation whether it's pending, open, closed"
|
"description": "Specify the conversation whether it's pending, open, closed"
|
||||||
|
},
|
||||||
|
"assignee_id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Agent Id for assigning a conversation to an agent"
|
||||||
|
},
|
||||||
|
"team_id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Team Id for assigning a conversation to a team"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue