Unverified Commit 83deef13 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

Merge branch 'multiple-clients' of github.com:RocketChat/Rocket.Chat.js.SDK into multiple-clients

parents 01e48ef6 745aa658
......@@ -32,6 +32,7 @@
},
"scripts": {
"webpack": "webpack",
"dev": "tsc -w",
"pretest": "tslint --fix -p . && ts-node src/utils/setup.ts",
"test": "nyc mocha ./src/lib/**/*.spec.ts",
"test:hook": "mocha './**/*.spec.ts'",
......@@ -71,7 +72,7 @@
"tslint-config-standard": "^7.0.0",
"typedoc": "0.8.0",
"typedoc-plugin-external-module-name": "^1.1.1",
"typescript": "^2.7.2",
"typescript": "^3.4.3",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
},
......
......@@ -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(`
......
......@@ -4594,9 +4594,9 @@ typescript@2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.1.tgz#c3ccb16ddaa0b2314de031e7e6fee89e5ba346bc"
typescript@^2.7.2:
version "2.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836"
typescript@^3.4.3:
version "3.4.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.3.tgz#0eb320e4ace9b10eadf5bc6103286b0f8b7c224f"
uglify-es@^3.3.4:
version "3.3.9"
......
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