Commit edee9986 authored by Marcos Defendi's avatar Marcos Defendi
Browse files

Add agentId parameter when getting a new Livechat room.

parent d6c6fda0
......@@ -613,6 +613,12 @@ export interface ILivechatRoom {
department?: string
}
/** Structure to get(new) livechat room */
export interface INewLivechatRoomCredentialAPI {
rid?: string
agentId?: string
}
/** Structure for livechat room messages api */
export interface ILivechatRoomMessagesAPI {
token: string // Visitor token
......
......@@ -15,6 +15,7 @@ import {
INewLivechatOfflineMessageAPI,
INewLivechatCustomFieldsAPI,
ILivechatRoom,
INewLivechatRoomCredentialAPI,
ILivechatUploadAPI
} from '../../interfaces'
......@@ -24,7 +25,7 @@ export default class ApiLivechat extends ApiBase {
credentials: ILivechatRoomCredentialAPI = {} as any
login (guest: INewLivechatGuestAPI | any) { return this.grantVisitor(guest) }
async config (params?: ILivechatTokenAPI) { return (await this.get('livechat/config', params, false)).config }
async room (rid: string = '') { return (await this.get('livechat/room', { token: this.credentials.token, rid }, false)).room }
async room (params?: INewLivechatRoomCredentialAPI) { return (await this.get('livechat/room', { token: this.credentials.token, ...params }, false)).room }
closeChat ({ rid }: ILivechatRoom) { return this.post('livechat/room.close', { rid, token: this.credentials.token }, false) }
transferChat ({ rid, department }: ILivechatRoom) { return (this.post('livechat/room.transfer', { rid, token: this.credentials.token, department }, false)) }
chatSurvey (survey: ILivechatRoomSurveyAPI) { return (this.post('livechat/room.survey', { rid: survey.rid, token: this.credentials.token, data: survey.data }, false)) }
......@@ -38,7 +39,7 @@ export default class ApiLivechat extends ApiBase {
}
async deleteVisitor () { return (await this.del(`livechat/visitor/${this.credentials.token}`)).visitor}
async updateVisitorStatus(status: string) { return (await this.post(`livechat/visitor.status`, { token: this.credentials.token, status })).status }
async nextAgent (department?: any) { return (await this.get(`livechat/agent.next/${this.credentials.token}`, { department })).agent }
async nextAgent (department: string = '') { return (await this.get(`livechat/agent.next/${this.credentials.token}`, { department })).agent }
async agent ({ rid }: any) { return (await this.get(`livechat/agent.info/${rid}/${this.credentials.token}`)).agent }
sendMessage (message: INewLivechatMessageAPI) { return (this.post('livechat/message', { ...message, token: this.credentials.token }, false)) }
editMessage (id: string, message: INewLivechatMessageAPI) { return (this.put(`livechat/message/${id}`, message, false)) }
......
......@@ -33,7 +33,7 @@ async function agent () {
${JSON.stringify(await livechat.agent({ rid, token }), null, '\t')}
Get Livechat Next Agent \`livechat.nextAgent()\`:
${JSON.stringify(await livechat.nextAgent({ token, department }), null, '\t')}
${JSON.stringify(await livechat.nextAgent(department), null, '\t')}
`)
}
......
......@@ -32,7 +32,6 @@ async function messages () {
const editMessage = { token, rid, msg: 'editing livechat message..' }
const result = await livechat.sendMessage(newMessage)
const _id = result && result.message && result.message._id
const roomCredential = { token, rid }
const pageInfo = Object.assign({}, mockVisitorNavigation, { rid })
console.log(`
......
......@@ -4,7 +4,6 @@ import { mockVisitor, mockCustomField, mockCustomFields } from '../config'
silence()
const livechat = new Api({})
const { token } = mockVisitor.visitor
async function visitors () {
console.log(`
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment