@subiz/widget-v4 4.0.61 → 4.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/assets/img/caret.svg +1 -0
  2. package/assets/img/done_green.svg +4 -0
  3. package/assets/img/empty_1.svg +11 -0
  4. package/assets/img/ghn.svg +17 -0
  5. package/assets/img/ghtk.svg +18 -0
  6. package/assets/img/home.svg +1 -0
  7. package/assets/img/info.svg +1 -0
  8. package/assets/img/loader.svg +1 -0
  9. package/assets/img/map-pin.svg +1 -0
  10. package/assets/img/not_found_search.png +0 -0
  11. package/assets/img/package.svg +5 -0
  12. package/assets/img/package_fade.svg +1 -0
  13. package/assets/img/phone.svg +1 -0
  14. package/assets/img/search.svg +1 -0
  15. package/assets/img/shop.svg +1 -0
  16. package/assets/img/shop_faded.svg +1 -0
  17. package/assets/img/user.svg +1 -0
  18. package/assets/img/x.svg +5 -0
  19. package/assets/less/chatbox.less +33 -0
  20. package/assets/less/dropdown_select.less +130 -0
  21. package/assets/less/form.less +7 -20
  22. package/assets/less/order.less +489 -0
  23. package/assets/less/rating.less +3 -8
  24. package/compiled_src/call/call.js +12 -15
  25. package/compiled_src/chatbox/DropdownSelect.js +239 -0
  26. package/compiled_src/chatbox/Event.js +4 -2
  27. package/compiled_src/chatbox/Events.js +1 -0
  28. package/compiled_src/chatbox/MessageInput.js +4 -7
  29. package/compiled_src/chatbox/Order.js +281 -0
  30. package/compiled_src/chatbox/OrderAttachments.js +2 -1
  31. package/compiled_src/chatbox/Rating.js +7 -10
  32. package/compiled_src/chatbox/TextMessage.js +9 -2
  33. package/compiled_src/chatbox/Widget.js +40 -3
  34. package/compiled_src/chatbox/spinner.js +1 -1
  35. package/compiled_src/chatbox/time.js +3 -1
  36. package/compiled_src/common.js +40 -1
  37. package/compiled_src/contact/contact.js +7 -12
  38. package/compiled_src/lib.js +9 -14
  39. package/compiled_src/notif/notif.js +12 -15
  40. package/compiled_src/order/address_picker.js +241 -0
  41. package/compiled_src/order/icon.js +62 -0
  42. package/compiled_src/order/index.js +113 -0
  43. package/compiled_src/order/order.js +1220 -0
  44. package/compiled_src/plugin.js +9 -42
  45. package/compiled_src/popup/countdown.js +4 -7
  46. package/compiled_src/popup/popup.js +9 -12
  47. package/compiled_src/store/api.js +80 -90
  48. package/compiled_src/store/api_fake.js +55 -82
  49. package/compiled_src/store/store.js +163 -158
  50. package/compiled_src/util/common.js +36 -2
  51. package/dist/0b82fa7e5c3b07b40a44.png +1 -0
  52. package/dist/0f4af006e38ee8b93633.png +1 -0
  53. package/dist/{74.js → 132.js} +2232 -235
  54. package/dist/178.js +341 -174
  55. package/dist/17e757ccadd.132.js +1 -0
  56. package/dist/17e757ccadd.178.js +1 -0
  57. package/dist/17e757ccadd.213.js +1 -0
  58. package/dist/17e757ccadd.335.js +1 -0
  59. package/dist/17e757ccadd.362.js +1 -0
  60. package/dist/17e757ccadd.441.js +1 -0
  61. package/dist/17e757ccadd.605.js +1 -0
  62. package/dist/17e757ccadd.678.js +1 -0
  63. package/dist/17e757ccadd.782.js +1 -0
  64. package/dist/17e757ccadd.app.js +1 -0
  65. package/dist/{17db8166252.index.html → 17e757ccadd.index.html} +1 -1
  66. package/dist/{17db8166252.library.html → 17e757ccadd.library.html} +1 -1
  67. package/dist/17e757ccadd.library.js +1 -0
  68. package/dist/{17db8166252.preview.html → 17e757ccadd.preview.html} +1 -1
  69. package/dist/17e757ccadd.preview.js +1 -0
  70. package/dist/17e757ccadd.screenshoot.js +1 -0
  71. package/dist/1ea1c6cd21d25176810c.png +1 -0
  72. package/dist/213.js +18 -88
  73. package/dist/292d42404e1b03398f61.png +1 -0
  74. package/dist/312d376370831b7bea83.png +1 -0
  75. package/dist/313d1bfc1cf776d1aefe.png +1 -0
  76. package/dist/335.js +408 -0
  77. package/dist/362.js +71 -21
  78. package/dist/441.js +69 -43
  79. package/dist/4aa58bb7a66bb44975aa.png +1 -0
  80. package/dist/56ce063bc6c81adb7322.png +1 -0
  81. package/dist/605.js +13 -79
  82. package/dist/678.js +70 -20
  83. package/dist/6a411166ef5cc79e0714.png +1 -0
  84. package/dist/6faf403782fefacc1649.png +1 -0
  85. package/dist/782.js +118 -21
  86. package/dist/79dca33c68fab79c067f.png +1 -0
  87. package/dist/82da1578fa84f9debaeb.png +1 -0
  88. package/dist/8b8e0f0824743974b282.png +1 -0
  89. package/dist/8d551390d81e39130a3c.png +1 -0
  90. package/dist/9fc61b9479877ebdb6c7.png +1 -0
  91. package/dist/HASH +1 -1
  92. package/dist/a165d31dcb3dc90f1057.png +1 -0
  93. package/dist/a98d4a5698812c4426b3.png +1 -0
  94. package/dist/assets/img/caret.998eb8f.svg +1 -0
  95. package/dist/assets/img/done_green.b817fd4.svg +4 -0
  96. package/dist/assets/img/empty_1.0b98af0.svg +11 -0
  97. package/dist/assets/img/ghn.070f8e3.svg +17 -0
  98. package/dist/assets/img/ghtk.326eac1.svg +18 -0
  99. package/dist/assets/img/info.ebce7ea.svg +1 -0
  100. package/dist/assets/img/loader.37000a7.svg +1 -0
  101. package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
  102. package/dist/assets/img/package.8d37d0f.svg +5 -0
  103. package/dist/assets/img/package_fade.763c001.svg +1 -0
  104. package/dist/assets/img/search.f9705ff.svg +1 -0
  105. package/dist/assets/img/shop.f7dc7d8.svg +1 -0
  106. package/dist/assets/img/shop_faded.df7845a.svg +1 -0
  107. package/dist/assets/img/x.26fdfa3.svg +5 -0
  108. package/dist/c41606bf9d1b604e46d5.png +1 -0
  109. package/dist/ce1f7450ce6c1aacd330.png +1 -0
  110. package/dist/cf8c01e88f4770a6e3e5.png +1 -0
  111. package/dist/dfbcfeab1d5622a737e2.png +1 -0
  112. package/dist/e4893ed8c2f7b8329919.png +1 -0
  113. package/dist/ec2ab4eb4ef73d186186.png +1 -0
  114. package/dist/screenshoot.html +1 -1
  115. package/dist/screenshoot.js +448 -386
  116. package/order.html +19 -771
  117. package/package.json +12 -13
  118. package/src/chatbox/DropdownSelect.js +229 -0
  119. package/src/chatbox/Event.js +2 -2
  120. package/src/chatbox/Events.js +43 -42
  121. package/src/chatbox/Order.js +232 -0
  122. package/src/chatbox/OrderAttachments.js +2 -1
  123. package/src/chatbox/TextMessage.js +21 -12
  124. package/src/chatbox/Widget.js +34 -4
  125. package/src/chatbox/spinner.js +1 -1
  126. package/src/chatbox/time.js +1 -1
  127. package/src/common.js +52 -8
  128. package/src/contact/contact.js +1 -1
  129. package/src/order/address_picker.js +235 -0
  130. package/src/order/icon.js +32 -0
  131. package/src/order/index.js +86 -0
  132. package/src/order/order.js +1157 -0
  133. package/src/order/scratch +211 -0
  134. package/src/plugin.js +7 -52
  135. package/src/store/api.js +26 -1
  136. package/src/store/store.js +46 -9
  137. package/src/util/common.js +48 -2
  138. package/webpack.dev.js +2 -0
  139. package/dist/17db8166252.178.js +0 -1
  140. package/dist/17db8166252.213.js +0 -1
  141. package/dist/17db8166252.362.js +0 -1
  142. package/dist/17db8166252.441.js +0 -1
  143. package/dist/17db8166252.605.js +0 -1
  144. package/dist/17db8166252.619.js +0 -1
  145. package/dist/17db8166252.678.js +0 -1
  146. package/dist/17db8166252.74.js +0 -1
  147. package/dist/17db8166252.782.js +0 -1
  148. package/dist/17db8166252.app.js +0 -1
  149. package/dist/17db8166252.library.js +0 -1
  150. package/dist/17db8166252.preview.js +0 -1
  151. package/dist/17db8166252.screenshoot.js +0 -1
  152. package/dist/619.js +0 -777
  153. package/order.js +0 -0
  154. package/test.js +0 -1
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _index = _interopRequireDefault(require("./util/index.js"));
9
9
 
10
+ var common = _interopRequireWildcard(require("./common.js"));
11
+
10
12
  var _preact = require("preact");
11
13
 
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -23,16 +25,13 @@ const LoadPopup = () => Promise.resolve().then(() => _interopRequireWildcard(req
23
25
 
24
26
  const LoadNotif = () => Promise.resolve().then(() => _interopRequireWildcard(require('./notif/notif.js')));
25
27
 
26
- let langMessages = {};
27
- let downloadLock = false;
28
-
29
28
  function Plugin(plugin, store, $container, lib) {
30
29
  if (!$container) throw '$div must is a valid html node';
31
30
  var $div = document.createElement('div');
32
31
  $div.id = plugin.id;
33
32
  $container.appendChild($div);
34
33
 
35
- let _locale = getLocale(plugin, _index.default.detectLang());
34
+ let _locale = common.getLocale(plugin, _index.default.detectLang());
36
35
 
37
36
  var domGate = new _index.default.Gate();
38
37
  var pageIndex = 0;
@@ -165,7 +164,7 @@ function Plugin(plugin, store, $container, lib) {
165
164
  let t = key => {
166
165
  if (_locale === 'debug') return `{{${key}}}`;
167
166
 
168
- let messages = _index.default.get(langMessages, _locale, []);
167
+ let messages = _index.default.get(common.langMessages, _locale, []);
169
168
 
170
169
  let message = _index.default.find(messages, message => message.key === key);
171
170
 
@@ -187,7 +186,7 @@ function Plugin(plugin, store, $container, lib) {
187
186
  t.locale = () => _locale;
188
187
 
189
188
  this.forceDownloadLanguage = async () => {
190
- await downloadLanguage(store, _locale, true);
189
+ await common.downloadLanguage(store, _locale, true);
191
190
  this.update(plugin);
192
191
  };
193
192
 
@@ -197,8 +196,8 @@ function Plugin(plugin, store, $container, lib) {
197
196
 
198
197
  _render();
199
198
 
200
- _locale = getLocale(plugin, locale);
201
- await downloadLanguage(store, _locale);
199
+ _locale = common.getLocale(plugin, locale);
200
+ await common.downloadLanguage(store, _locale);
202
201
  this.t = t;
203
202
 
204
203
  _render();
@@ -237,7 +236,7 @@ function Plugin(plugin, store, $container, lib) {
237
236
  }
238
237
 
239
238
  this.update(plugin);
240
- downloadLanguage(store, _locale).then(() => {
239
+ common.downloadLanguage(store, _locale).then(() => {
241
240
  this.t = t;
242
241
  this.update(plugin);
243
242
  });
@@ -387,36 +386,4 @@ class PluginMgr {
387
386
 
388
387
  }
389
388
 
390
- exports.default = PluginMgr;
391
-
392
- function downloadLanguage(store, locale, force) {
393
- if (downloadLock) return new Promise(resolve => setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100));
394
- downloadLock = true;
395
- let messages;
396
-
397
- if (locale === 'debug' || langMessages[locale] && !force) {
398
- downloadLock = false;
399
- return Promise.resolve();
400
- }
401
-
402
- return store.getLocaleContent(locale).then(res => {
403
- downloadLock = false;
404
- messages = _index.default.get(res, 'body.messages', []);
405
- langMessages[locale] = messages;
406
- });
407
- }
408
-
409
- const getLocale = (plugin, loc) => {
410
- if (!loc) loc = '';
411
-
412
- let found = _index.default.find(plugin.locales, l => l.toLowerCase().trim() === loc.toLowerCase().trim());
413
-
414
- if (found) return found;
415
- found = _index.default.find(plugin.locales, l => {
416
- l = l.replace('-', '_').split('_')[0].trim().toLowerCase();
417
- let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase();
418
- return l == compareloc;
419
- });
420
- if (found) return found;
421
- return plugin.locale || 'en-US';
422
- };
389
+ exports.default = PluginMgr;
@@ -17,18 +17,15 @@ var _preact = require("preact");
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
20
  _tickCoreCommonjs.default.plugin.add(_tickViewFlipCommonjs.default);
23
21
 
24
22
  class Countdown extends _common.Com {
23
+ state = {
24
+ flipKey: '43'
25
+ };
26
+
25
27
  constructor(props) {
26
28
  super(props);
27
-
28
- _defineProperty(this, "state", {
29
- flipKey: '43'
30
- });
31
-
32
29
  this.timer = setInterval(() => {
33
30
  if (this.props._destroy) return this.componentWillUnmount();
34
31
  let cd = this.props.com.countdown || {};
@@ -15,8 +15,6 @@ var _common = require("../common.js");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
19
 
22
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -24,18 +22,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
24
22
  let popupCSS = (() => Promise.resolve().then(() => _interopRequireWildcard(require('./css.js'))))();
25
23
 
26
24
  class Popup extends _common.Com {
25
+ state = {
26
+ close: false,
27
+ cssready: false,
28
+ closeAnimation: true,
29
+ pressedSubmit: false,
30
+ imageReady: false,
31
+ fontReady: false
32
+ };
33
+
27
34
  constructor(props) {
28
35
  super(props);
29
-
30
- _defineProperty(this, "state", {
31
- close: false,
32
- cssready: false,
33
- closeAnimation: true,
34
- pressedSubmit: false,
35
- imageReady: false,
36
- fontReady: false
37
- });
38
-
39
36
  this._formRef = (0, _preact.createRef)();
40
37
  setTimeout(() => this.fillForm(), 1000);
41
38
  setTimeout(async () => {
@@ -9,8 +9,6 @@ var _index = _interopRequireDefault(require("../util/index.js"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
14
12
  const ajax = require('@subiz/ajax/src/ajax.js');
15
13
 
16
14
  ajax.env.XMLHttpRequest = window.XMLHttpRequest;
@@ -25,94 +23,6 @@ function jsonifyTextPlain(param, done) {
25
23
 
26
24
  class _default {
27
25
  constructor(ApiURL, FileURL) {
28
- _defineProperty(this, "listConversations", _ => this.apireq.addQuery('user_id', this.uid).addQuery('integration_id', `${this.accid}.subizv4.subikon`).get('/conversations'));
29
-
30
- _defineProperty(this, "listMessages", (cid, limit, start_id) => this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/conversations/${cid}/messages`));
31
-
32
- _defineProperty(this, "ajax", ajax);
33
-
34
- _defineProperty(this, "start", extraData => {
35
- let data = {
36
- starter_id: this.uid,
37
- starter_type: 'user',
38
- integration_id: `${this.accid}.subizv4.subikon`
39
- };
40
-
41
- _index.default.each(extraData, (v, k) => {
42
- data[k] = v;
43
- });
44
-
45
- return this.apireq.post('/conversations', data);
46
- });
47
-
48
- _defineProperty(this, "sendConvoEvent", (cid, ev) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/events`, ev));
49
-
50
- _defineProperty(this, "createPostback", (cid, p) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/postbacks`, p));
51
-
52
- _defineProperty(this, "markAsReceived", (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/receive`));
53
-
54
- _defineProperty(this, "markAsSeen", (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/seen`));
55
-
56
- _defineProperty(this, "getConversation", cid => this.apireq.get(`/conversations/${cid}`));
57
-
58
- _defineProperty(this, "getLocaleContent", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));
59
-
60
- _defineProperty(this, "sendEvent", data => this.apireq.post(`/users/${this.uid}/events`, data));
61
-
62
- _defineProperty(this, "sendTyping", cid => this.apireq.post(`/conversations/${cid}/typing`));
63
-
64
- _defineProperty(this, "uploadToS3", async file => {
65
- let {
66
- body: signed,
67
- error
68
- } = await this.apireq.post(`/accounts/${this.accid}/files`, {
69
- account_id: this.accid,
70
- description: 'upload\n user-client: web-widget',
71
- name: file.name.replace(/\s+/g, '_'),
72
- size: file.size,
73
- type: file.type
74
- });
75
- if (error) return {
76
- error
77
- };
78
- let contentType = file.type || 'application/octet-stream';
79
- ({
80
- error
81
- } = await ajax.setContentType(contentType).put(signed.signed_url, file));
82
- if (error) return {
83
- error
84
- };
85
- let body;
86
- ({
87
- body,
88
- error
89
- } = await this.apireq.post(`/accounts/${this.accid}/files/${signed.id}`, {
90
- account_id: this.accid
91
- }));
92
- if (error) return {
93
- error
94
- };
95
- return {
96
- url: this.FileURL + body.url
97
- };
98
- });
99
-
100
- _defineProperty(this, "getChallenge", accid => this.apireq.post(`/accounts/${accid}/scrypt-challenges`));
101
-
102
- _defineProperty(this, "time", _ => this.apireq.get('/time'));
103
-
104
- _defineProperty(this, "updateUser", data => this.apireq.post(`/users/${this.uid}`, data));
105
-
106
- _defineProperty(this, "getUser", _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`));
107
-
108
- _defineProperty(this, "getAccountSetting", () => this.apireq.get(`/accounts/${this.accid}/settings`));
109
-
110
- _defineProperty(this, "getIsOnline", () => this.apireq.get(`/accounts/${this.accid}/is_online`));
111
-
112
- _defineProperty(this, "sendImpression", impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression));
113
-
114
- _defineProperty(this, "sendConversion", conversion => this.apireq.post(`/accounts/${this.accid}/campaigns/${conversion.campaign_id}/conversions`, conversion));
115
-
116
26
  this.FileURL = FileURL;
117
27
  this.ApiURL = ApiURL;
118
28
  this.apireq = ajax.setBaseUrl(ApiURL).withCredentials(true).addQuery('v', '6').setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json').beforeHook((param, done) => {
@@ -131,6 +41,31 @@ class _default {
131
41
  this.uid = obj.uid;
132
42
  }
133
43
 
44
+ listConversations = _ => this.apireq.addQuery('user_id', this.uid).addQuery('integration_id', `${this.accid}.subizv4.subikon`).get('/conversations');
45
+ listMessages = (cid, limit, start_id) => this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/conversations/${cid}/messages`);
46
+ ajax = ajax;
47
+ start = extraData => {
48
+ let data = {
49
+ starter_id: this.uid,
50
+ starter_type: 'user',
51
+ integration_id: `${this.accid}.subizv4.subikon`
52
+ };
53
+
54
+ _index.default.each(extraData, (v, k) => {
55
+ data[k] = v;
56
+ });
57
+
58
+ return this.apireq.post('/conversations', data);
59
+ };
60
+ sendConvoEvent = (cid, ev) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/events`, ev);
61
+ createPostback = (cid, p) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/postbacks`, p);
62
+ markAsReceived = (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/receive`);
63
+ markAsSeen = (cid, messageId) => this.apireq.post(`/conversations/${cid}/messages/${messageId}/seen`);
64
+ getConversation = cid => this.apireq.get(`/conversations/${cid}`);
65
+ getLocaleContent = locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`);
66
+ sendEvent = data => this.apireq.post(`/users/${this.uid}/events`, data);
67
+ sendTyping = cid => this.apireq.post(`/conversations/${cid}/typing`);
68
+
134
69
  sendPresence(device, is_focused) {
135
70
  return this.sendEvent({
136
71
  by: {
@@ -164,6 +99,43 @@ class _default {
164
99
  });
165
100
  }
166
101
 
102
+ uploadToS3 = async file => {
103
+ let {
104
+ body: signed,
105
+ error
106
+ } = await this.apireq.post(`/accounts/${this.accid}/files`, {
107
+ account_id: this.accid,
108
+ description: 'upload\n user-client: web-widget',
109
+ name: file.name.replace(/\s+/g, '_'),
110
+ size: file.size,
111
+ type: file.type
112
+ });
113
+ if (error) return {
114
+ error
115
+ };
116
+ let contentType = file.type || 'application/octet-stream';
117
+ ({
118
+ error
119
+ } = await ajax.setContentType(contentType).put(signed.signed_url, file));
120
+ if (error) return {
121
+ error
122
+ };
123
+ let body;
124
+ ({
125
+ body,
126
+ error
127
+ } = await this.apireq.post(`/accounts/${this.accid}/files/${signed.id}`, {
128
+ account_id: this.accid
129
+ }));
130
+ if (error) return {
131
+ error
132
+ };
133
+ return {
134
+ url: this.FileURL + body.url
135
+ };
136
+ };
137
+ getChallenge = accid => this.apireq.post(`/accounts/${accid}/scrypt-challenges`);
138
+
167
139
  async createAgentUser(agenttoken) {
168
140
  for (var i = 0; i < 10; i++) {
169
141
  let {
@@ -206,6 +178,24 @@ class _default {
206
178
  }
207
179
  }
208
180
 
181
+ time = _ => this.apireq.get('/time');
182
+ updateUser = data => this.apireq.post(`/users/${this.uid}`, data);
183
+ getUser = _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`);
184
+ getAccountSetting = () => this.apireq.get(`/accounts/${this.accid}/settings`);
185
+ getIsOnline = () => this.apireq.get(`/accounts/${this.accid}/is_online`);
186
+ sendImpression = impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression);
187
+ sendConversion = conversion => this.apireq.post(`/accounts/${this.accid}/campaigns/${conversion.campaign_id}/conversions`, conversion);
188
+ lookupOrder = key => ajax.setBaseUrl(this.ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json').addQuery('x-signed-key', key).get(`/orders/123`);
189
+ getOrder = id => this.apireq.get(`/accounts/${this.accid}/orders/` + id);
190
+ updateOrder = order => this.apireq.post(`/accounts/${this.accid}/orders/` + order.id, order);
191
+ fetchShippingAddresses = () => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`);
192
+ createShippingAddress = addr => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`, addr);
193
+ list_provinces = () => this.apireq.get(`/accounts/${this.accid}/provinces`);
194
+ list_districts = p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/districts`);
195
+ list_wards = p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/wards`);
196
+ suggest_address = keyword => this.apireq.setQuery({
197
+ keyword: keyword
198
+ }).get(`/accounts/${this.accid}/addresses`);
209
199
  }
210
200
 
211
201
  exports.default = _default;
@@ -9,8 +9,6 @@ var _index = _interopRequireDefault(require("../util/index.js"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
14
12
  const ajax = require('@subiz/ajax/src/ajax.js');
15
13
 
16
14
  ajax.env.XMLHttpRequest = window.XMLHttpRequest;
@@ -29,86 +27,6 @@ const OK200 = Promise.resolve({
29
27
 
30
28
  class _default {
31
29
  constructor(ApiURL, FileURL) {
32
- _defineProperty(this, "listConversations", _ => {
33
- let convo = makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
34
- return Promise.resolve({
35
- body: {
36
- anchor: '',
37
- conversations: [convo]
38
- },
39
- code: 200
40
- });
41
- });
42
-
43
- _defineProperty(this, "listMessages", (cid, limit, start_id) => {
44
- let messages = makeFakeMessages(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
45
- return Promise.resolve({
46
- body: messages,
47
- code: 200
48
- });
49
- });
50
-
51
- _defineProperty(this, "ajax", ajax);
52
-
53
- _defineProperty(this, "start", extraData => OK200);
54
-
55
- _defineProperty(this, "sendConvoEvent", (cid, ev) => OK200);
56
-
57
- _defineProperty(this, "createPostback", (cid, p) => OK200);
58
-
59
- _defineProperty(this, "markAsReceived", (cid, messageId) => OK200);
60
-
61
- _defineProperty(this, "markAsSeen", (cid, messageId) => OK200);
62
-
63
- _defineProperty(this, "getConversation", cid => Promise.resolve({
64
- body: makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid),
65
- code: 200
66
- }));
67
-
68
- _defineProperty(this, "getLocaleContent", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));
69
-
70
- _defineProperty(this, "sendEvent", data => OK200);
71
-
72
- _defineProperty(this, "sendTyping", cid => OK200);
73
-
74
- _defineProperty(this, "sendPresence", data => OK200);
75
-
76
- _defineProperty(this, "sendContent", data => OK200);
77
-
78
- _defineProperty(this, "uploadToS3", async file => OK200);
79
-
80
- _defineProperty(this, "getChallenge", accid => OK200);
81
-
82
- _defineProperty(this, "createUser", accid => Promise.resolve({
83
- account_id: accid,
84
- id: 'usqzgtgfake',
85
- mask: 'fakemask'
86
- }));
87
-
88
- _defineProperty(this, "createAgentUser", agenttoken => Promise.resolve('fakemask'));
89
-
90
- _defineProperty(this, "time", _ => Promise.resolve({
91
- code: 200,
92
- body: new _index.default.Date().toISOString()
93
- }));
94
-
95
- _defineProperty(this, "updateUser", data => OK200);
96
-
97
- _defineProperty(this, "getUser", _ => Promise.resolve({
98
- code: 200,
99
- body: {
100
- id: '-'
101
- }
102
- }));
103
-
104
- _defineProperty(this, "getAccountSetting", () => this.apireq.get(`/accounts/${this.accid}/settings`));
105
-
106
- _defineProperty(this, "getIsOnline", () => this.apireq.get(`/accounts/${this.accid}/is_online`));
107
-
108
- _defineProperty(this, "sendImpression", impression => OK200);
109
-
110
- _defineProperty(this, "sendConversion", conversion => OK200);
111
-
112
30
  this.FileURL = FileURL;
113
31
  this.apireq = ajax.setBaseUrl(ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json');
114
32
  }
@@ -123,6 +41,61 @@ class _default {
123
41
  this.uid = obj.uid;
124
42
  }
125
43
 
44
+ listConversations = _ => {
45
+ let convo = makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
46
+ return Promise.resolve({
47
+ body: {
48
+ anchor: '',
49
+ conversations: [convo]
50
+ },
51
+ code: 200
52
+ });
53
+ };
54
+ listMessages = (cid, limit, start_id) => {
55
+ let messages = makeFakeMessages(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);
56
+ return Promise.resolve({
57
+ body: messages,
58
+ code: 200
59
+ });
60
+ };
61
+ ajax = ajax;
62
+ start = extraData => OK200;
63
+ sendConvoEvent = (cid, ev) => OK200;
64
+ createPostback = (cid, p) => OK200;
65
+ markAsReceived = (cid, messageId) => OK200;
66
+ markAsSeen = (cid, messageId) => OK200;
67
+ getConversation = cid => Promise.resolve({
68
+ body: makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid),
69
+ code: 200
70
+ });
71
+ getLocaleContent = locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`);
72
+ sendEvent = data => OK200;
73
+ sendTyping = cid => OK200;
74
+ sendPresence = data => OK200;
75
+ sendContent = data => OK200;
76
+ uploadToS3 = async file => OK200;
77
+ getChallenge = accid => OK200;
78
+ createUser = accid => Promise.resolve({
79
+ account_id: accid,
80
+ id: 'usqzgtgfake',
81
+ mask: 'fakemask'
82
+ });
83
+ createAgentUser = agenttoken => Promise.resolve('fakemask');
84
+ time = _ => Promise.resolve({
85
+ code: 200,
86
+ body: new _index.default.Date().toISOString()
87
+ });
88
+ updateUser = data => OK200;
89
+ getUser = _ => Promise.resolve({
90
+ code: 200,
91
+ body: {
92
+ id: '-'
93
+ }
94
+ });
95
+ getAccountSetting = () => this.apireq.get(`/accounts/${this.accid}/settings`);
96
+ getIsOnline = () => this.apireq.get(`/accounts/${this.accid}/is_online`);
97
+ sendImpression = impression => OK200;
98
+ sendConversion = conversion => OK200;
126
99
  }
127
100
 
128
101
  exports.default = _default;