quiq-chat
Advanced tools
Comparing version 1.22.1 to 1.23.0
@@ -323,3 +323,3 @@ 'use strict'; | ||
var version = "1.22.1"; | ||
var version = "1.23.0"; | ||
@@ -1288,2 +1288,9 @@ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var emailTranscript = function emailTranscript(data) { | ||
return quiqFetch(getUrlForContactPoint() + '/email-transcript', { | ||
method: 'POST', | ||
body: JSON.stringify(data) | ||
}); | ||
}; | ||
/** | ||
@@ -1659,2 +1666,23 @@ * Creates a new session and tracking ID | ||
this.emailTranscript = function () { | ||
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(data) { | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
return _context6.abrupt('return', emailTranscript(data)); | ||
case 1: | ||
case 'end': | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee6, _this2); | ||
})); | ||
return function (_x3) { | ||
return _ref6.apply(this, arguments); | ||
}; | ||
}(); | ||
this.updateMessagePreview = function (text, typing) { | ||
@@ -1665,14 +1693,14 @@ return updateMessagePreview(text, typing); | ||
this.sendRegistration = function () { | ||
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(fields) { | ||
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(fields) { | ||
var result; | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
setQuiqChatContainerVisible(true); | ||
_context6.next = 3; | ||
_context7.next = 3; | ||
return sendRegistration(fields); | ||
case 3: | ||
result = _context6.sent; | ||
result = _context7.sent; | ||
@@ -1684,14 +1712,14 @@ | ||
return _context6.abrupt('return', result); | ||
return _context7.abrupt('return', result); | ||
case 6: | ||
case 'end': | ||
return _context6.stop(); | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee6, _this2); | ||
}, _callee7, _this2); | ||
})); | ||
return function (_x3) { | ||
return _ref6.apply(this, arguments); | ||
return function (_x4) { | ||
return _ref7.apply(this, arguments); | ||
}; | ||
@@ -1761,14 +1789,14 @@ }(); | ||
this._establishWebSocketConnection = function () { | ||
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(connectedCallback) { | ||
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(connectedCallback) { | ||
var wsInfo; | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_this2._disconnectSocket(); // Ensure we only have one websocket connection open | ||
_context7.next = 3; | ||
_context8.next = 3; | ||
return fetchWebsocketInfo(); | ||
case 3: | ||
wsInfo = _context7.sent; | ||
wsInfo = _context8.sent; | ||
@@ -1779,10 +1807,10 @@ _this2._connectSocket(wsInfo, connectedCallback); | ||
case 'end': | ||
return _context7.stop(); | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee7, _this2); | ||
}, _callee8, _this2); | ||
})); | ||
return function (_x4) { | ||
return _ref7.apply(this, arguments); | ||
return function (_x5) { | ||
return _ref8.apply(this, arguments); | ||
}; | ||
@@ -1831,9 +1859,9 @@ }(); | ||
this._handleNewSession = function () { | ||
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(newTrackingId) { | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(newTrackingId) { | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
if (!(_this2.trackingId && newTrackingId !== _this2.trackingId)) { | ||
_context8.next = 7; | ||
_context9.next = 7; | ||
break; | ||
@@ -1853,3 +1881,3 @@ } | ||
// (Connection establishment handler will refresh messages) | ||
_context8.next = 7; | ||
_context9.next = 7; | ||
return _this2._establishWebSocketConnection(); | ||
@@ -1863,10 +1891,10 @@ | ||
case 'end': | ||
return _context8.stop(); | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee8, _this2); | ||
}, _callee9, _this2); | ||
})); | ||
return function (_x5) { | ||
return _ref8.apply(this, arguments); | ||
return function (_x6) { | ||
return _ref9.apply(this, arguments); | ||
}; | ||
@@ -1937,13 +1965,13 @@ }(); | ||
this._handleConnectionEstablish = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() { | ||
this._handleConnectionEstablish = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() { | ||
var conversation; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
_context9.next = 2; | ||
_context10.next = 2; | ||
return getConversation(); | ||
case 2: | ||
conversation = _context9.sent; | ||
conversation = _context10.sent; | ||
@@ -1961,6 +1989,6 @@ | ||
case 'end': | ||
return _context9.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _callee9, _this2); | ||
}, _callee10, _this2); | ||
})); | ||
@@ -1967,0 +1995,0 @@ |
{ | ||
"name": "quiq-chat", | ||
"version": "1.22.1", | ||
"version": "1.23.0", | ||
"description": | ||
@@ -5,0 +5,0 @@ "Library to help with network requests to create a webchat client for Quiq Messaging", |
@@ -100,2 +100,5 @@ # quiq-chat [![Build Status](https://travis-ci.org/Quiq/quiq-chat.svg?branch=master)](https://travis-ci.org/Quiq/quiq-chat) [![npm version](https://badge.fury.io/js/quiq-chat.svg)](https://badge.fury.io/js/quiq-chat) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
#### emailTranscript(data: [EmailTranscriptPayload](#EmailTranscriptPayload)) => void | ||
Email a transcript of the current conversation to the specified e-mail. If an agent has not yet responded to the conversation, a 400 will be returned. | ||
#### sendMessage(text: string) => void | ||
@@ -154,3 +157,3 @@ Send a text message from the customer. Can be used to initiate a conversation if no messages have been sent. | ||
{ | ||
authorType: 'Customer' | 'Agent', | ||
authorType: 'Customer' | 'User' | 'System', | ||
text: string, | ||
@@ -185,1 +188,10 @@ id: string, | ||
``` | ||
### EmailTranscriptPayload | ||
```javascript | ||
{ | ||
email: string, | ||
originUrl: string, | ||
timezone?: string, | ||
}; | ||
``` |
@@ -33,3 +33,3 @@ // @flow | ||
{ | ||
authorType: 'Agent', | ||
authorType: 'User', | ||
text: 'Polo', | ||
@@ -36,0 +36,0 @@ id: 'msg2', |
@@ -12,3 +12,3 @@ // @flow | ||
import {setAccessToken, getAccessToken, getTrackingId} from './storage'; | ||
import type {Conversation, ChatMetadata} from 'types'; | ||
import type {Conversation, ChatMetadata, EmailTranscriptPayload} from 'types'; | ||
import logger from './logging'; | ||
@@ -71,2 +71,8 @@ import Raven from 'raven-js'; | ||
export const emailTranscript = (data: EmailTranscriptPayload) => | ||
quiqFetch(`${getUrlForContactPoint()}/email-transcript`, { | ||
method: 'POST', | ||
body: JSON.stringify(data), | ||
}); | ||
/** | ||
@@ -73,0 +79,0 @@ * Creates a new session and tracking ID |
@@ -22,3 +22,3 @@ // @flow | ||
} from './Utils/utils'; | ||
import type {QuiqChatCallbacks, ConversationResult} from 'types'; | ||
import type {QuiqChatCallbacks, ConversationResult, EmailTranscriptPayload} from 'types'; | ||
import * as storage from './storage'; | ||
@@ -220,2 +220,6 @@ import logger from './logging'; | ||
emailTranscript = async (data: EmailTranscriptPayload) => { | ||
return API.emailTranscript(data); | ||
}; | ||
updateMessagePreview = (text: string, typing: boolean) => { | ||
@@ -222,0 +226,0 @@ return API.updateMessagePreview(text, typing); |
@@ -10,3 +10,3 @@ // @flow | ||
export type EventType = 'Join' | 'Leave' | 'Register'; | ||
export type AuthorType = 'Customer' | 'Agent'; | ||
export type AuthorType = 'Customer' | 'User' | 'System'; | ||
export type TextMessageType = 'Text'; | ||
@@ -47,2 +47,8 @@ export type WebsocketMessageType = 'ChatMessage' | 'BurnItDown'; | ||
export type EmailTranscriptPayload = { | ||
email: string, | ||
originUrl: string, | ||
timezone?: string, | ||
}; | ||
export type QuiqChatCallbacks = { | ||
@@ -49,0 +55,0 @@ onNewMessages?: (messages: Array<TextMessage>) => void, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194
1337426
90
10531