@askdialog/dialog-sdk 1.0.11 → 1.0.13
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.
- package/README.md +35 -12
- package/dist/Dialog.d.ts +2 -2
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +1 -1
- package/dist/types/constructor.d.ts +2 -2
- package/dist/types/constructor.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,8 +37,19 @@ const client = new Dialog({
|
|
|
37
37
|
apiKey: 'YOUR_API_KEY', // required
|
|
38
38
|
locale: 'TARGETED_LOCALE', // required
|
|
39
39
|
callbacks: {
|
|
40
|
-
addToCart: (
|
|
41
|
-
|
|
40
|
+
addToCart: async ({
|
|
41
|
+
productId,
|
|
42
|
+
quantity,
|
|
43
|
+
variantId,
|
|
44
|
+
}: {
|
|
45
|
+
productId: string;
|
|
46
|
+
quantity: number;
|
|
47
|
+
variantId?: string;
|
|
48
|
+
}) => Promise<void>, // required
|
|
49
|
+
getProduct: async (
|
|
50
|
+
productId: string,
|
|
51
|
+
variantId?: string
|
|
52
|
+
) => Promise<SimplifiedProduct>, // required
|
|
42
53
|
},
|
|
43
54
|
});
|
|
44
55
|
```
|
|
@@ -48,7 +59,7 @@ The locale specifies the language you want to use.
|
|
|
48
59
|
The addToCart function is triggered when a user clicks the AddToCart button.
|
|
49
60
|
The getProduct function is used to display product information in the assistant.
|
|
50
61
|
|
|
51
|
-
When the client is instantiated, it will automatically insert
|
|
62
|
+
When the client is instantiated, it will automatically insert into the DOM the Dialog Assistant script, so you can interact with the assistant using `sendProductMessage` or `sendGenericMessage`.
|
|
52
63
|
|
|
53
64
|
### Getters
|
|
54
65
|
|
|
@@ -130,12 +141,16 @@ Example of expected result:
|
|
|
130
141
|
const client = new Dialog({
|
|
131
142
|
...,
|
|
132
143
|
callbacks: {
|
|
133
|
-
getProduct: (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
getProduct: (
|
|
145
|
+
productId: string,
|
|
146
|
+
variantId?: string): Promise<SimplifiedProduct> => {
|
|
147
|
+
// Call your api to retrieve product information
|
|
148
|
+
const response = await fetch('....');
|
|
149
|
+
const data = await response.json();
|
|
150
|
+
// Need to match SimplifiedProduct type
|
|
151
|
+
return {
|
|
152
|
+
...
|
|
153
|
+
};
|
|
139
154
|
}
|
|
140
155
|
},
|
|
141
156
|
});
|
|
@@ -147,7 +162,15 @@ const client = new Dialog({
|
|
|
147
162
|
const client = new Dialog({
|
|
148
163
|
...,
|
|
149
164
|
callbacks: {
|
|
150
|
-
addToCart: (
|
|
165
|
+
addToCart: ({
|
|
166
|
+
productId,
|
|
167
|
+
quantity,
|
|
168
|
+
variantId,
|
|
169
|
+
}: {
|
|
170
|
+
productId: string;
|
|
171
|
+
quantity: number;
|
|
172
|
+
variantId?: string;
|
|
173
|
+
}): Promise<void> => {
|
|
151
174
|
// Call your api to trigger addToCart
|
|
152
175
|
const response = await fetch('....');
|
|
153
176
|
|
|
@@ -161,10 +184,10 @@ const client = new Dialog({
|
|
|
161
184
|
|
|
162
185
|
### Theming (Still in construction)
|
|
163
186
|
|
|
164
|
-
We are currently working on the theming part so you may find some issues. Contact us if you need more
|
|
187
|
+
We are currently working on the theming part so you may find some issues. Contact us if you need more customization.
|
|
165
188
|
|
|
166
189
|
|
|
167
|
-
⚠️ Title, description and content properties are used only to theme the
|
|
190
|
+
⚠️ Title, description and content properties are used only to theme the Vue component for the moment.
|
|
168
191
|
|
|
169
192
|
```typescript
|
|
170
193
|
const client = new Dialog({
|
package/dist/Dialog.d.ts
CHANGED
|
@@ -25,10 +25,10 @@ export declare class Dialog {
|
|
|
25
25
|
sendProductMessage(params: ProductQuestionPayload): void;
|
|
26
26
|
sendGenericMessage(params: GenericQuestionPayload): void;
|
|
27
27
|
getProduct(productId: string, variantId?: string): Promise<SimplifiedProduct>;
|
|
28
|
-
addToCart({ productId,
|
|
28
|
+
addToCart({ productId, quantity, variantId, }: {
|
|
29
29
|
productId: string;
|
|
30
|
-
variantId: string;
|
|
31
30
|
quantity: number;
|
|
31
|
+
variantId?: string;
|
|
32
32
|
}): Promise<void>;
|
|
33
33
|
registerAddToCartEvent({ productId, variantId, quantity, }: {
|
|
34
34
|
productId: string;
|
package/dist/Dialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../src/Dialog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAMpD,qBAAa,MAAM;IACjB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,UAAU,CAchB;IACF,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,SAAS,CAAW;gBAEhB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,iBAAiB;IAc3E,IAAW,MAAM,IAAI,MAAM,CAE1B;IACD,IAAW,KAAK,IAAI,KAAK,CAExB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,2BAA2B,IAAI,kBAAkB,GAAG,IAAI;IAI/D,OAAO,CAAC,uBAAuB;IAkBlB,cAAc,CAAC,SAAS,EA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AAM,CAE1B;IAEM,2BAA2B,IAAI,kBAAkB,GAAG,IAAI;IAI/D,OAAO,CAAC,uBAAuB;IAkBlB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAK5D,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAKjD,cAAc,IAAI,IAAI;IAItB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;IAIxD,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;IAOxD,UAAU,CACf,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC;IAItB,SAAS,CAAC,EACf,SAAS,EACT,QAAQ,EACR,SAAS,GACV,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIV,sBAAsB,CAAC,EAC5B,SAAS,EACT,SAAS,EACT,QAAQ,GACT,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI;IAQD,2BAA2B,IAAI,IAAI;IAI1C,OAAO,CAAC,cAAc;CA0BvB"}
|
package/dist/Dialog.js
CHANGED
|
@@ -77,7 +77,7 @@ export class Dialog {
|
|
|
77
77
|
getProduct(productId, variantId) {
|
|
78
78
|
return this._callbacks.getProduct(productId, variantId);
|
|
79
79
|
}
|
|
80
|
-
addToCart({ productId,
|
|
80
|
+
addToCart({ productId, quantity, variantId, }) {
|
|
81
81
|
return this._callbacks.addToCart({ productId, variantId, quantity });
|
|
82
82
|
}
|
|
83
83
|
registerAddToCartEvent({ productId, variantId, quantity, }) {
|
|
@@ -4,10 +4,10 @@ export interface DialogConstructor {
|
|
|
4
4
|
apiKey: string;
|
|
5
5
|
locale: string;
|
|
6
6
|
callbacks: {
|
|
7
|
-
addToCart: ({ productId,
|
|
7
|
+
addToCart: ({ productId, quantity, variantId, }: {
|
|
8
8
|
productId: string;
|
|
9
|
-
variantId: string;
|
|
10
9
|
quantity: number;
|
|
10
|
+
variantId?: string;
|
|
11
11
|
}) => Promise<void>;
|
|
12
12
|
getProduct: (productId: string, variantId?: string) => Promise<SimplifiedProduct>;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../src/types/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE;QACT,SAAS,EAAE,CAAC,EACV,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"constructor.d.ts","sourceRoot":"","sources":["../../src/types/constructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE;QACT,SAAS,EAAE,CAAC,EACV,SAAS,EACT,QAAQ,EACR,SAAS,GACV,EAAE;YACD,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,CAAC,EAAE,MAAM,CAAC;SACpB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACpB,UAAU,EAAE,CACV,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,KACf,OAAO,CAAC,iBAAiB,CAAC,CAAC;KACjC,CAAC;IACF,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|