webc-miam 5.0.0 → 6.0.0
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/interfaces/comparable-product.ts +24 -0
- package/interfaces/miam-interface.ts +236 -0
- package/main-es2015.js +1 -1
- package/main-es5.js +1 -1
- package/package.json +1 -1
- package/webc-miam-de.js +1 -1
- package/webc-miam-en.js +1 -1
- package/webc-miam-es.js +1 -1
- package/webc-miam-fr.js +1 -1
- package/webc-miam-it.js +1 -1
- package/webc-miam-nl.js +1 -1
- package/webc-miam-pt.js +1 -1
- package/webc-miam-ro.js +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An interface used to represent a product when Miam synchronizes the client's cart with
|
|
3
|
+
* Miam's basket, and need to compare products present in each one.
|
|
4
|
+
*/
|
|
5
|
+
export interface ComparableProduct {
|
|
6
|
+
/**
|
|
7
|
+
* Id of the product in the client's database (called ext-id on Miam's end).
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* When client side sends an array of ComparableProduct to Miam, the SDK expects quantities
|
|
12
|
+
* to match the quantity of each product in the cart of the client.
|
|
13
|
+
*
|
|
14
|
+
* When Miam sends an array of ComparableProducts to the client, quantities represent the quantity
|
|
15
|
+
* of products to add to the client's cart, and as such can be negatives if products need to be
|
|
16
|
+
* removed from the cart.
|
|
17
|
+
*/
|
|
18
|
+
quantity: number;
|
|
19
|
+
/**
|
|
20
|
+
* The client can add attributes if they need when sending ComparableProducts to the SDK.
|
|
21
|
+
* Miam will send the attributes back if changes are to be made about those products.
|
|
22
|
+
*/
|
|
23
|
+
additionalInfos?: any;
|
|
24
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ComparableProduct } from './comparable-product';
|
|
3
|
+
|
|
4
|
+
export interface MiamInterface {
|
|
5
|
+
/**
|
|
6
|
+
* Method to call when the user begins the payment procedure (typically when they click
|
|
7
|
+
* on a "Confirm my cart" button)
|
|
8
|
+
* @param totalPrice the total price of your basket (can be a floating or integer number)
|
|
9
|
+
*/
|
|
10
|
+
paymentStarted: (totalPrice: number) => void;
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
analytics: {
|
|
15
|
+
/**
|
|
16
|
+
* Initialize Analytics
|
|
17
|
+
*
|
|
18
|
+
* @param domain Plausible domain
|
|
19
|
+
* @param optimizeKey Google Optimize key
|
|
20
|
+
*/
|
|
21
|
+
init: (domain: string, optimizeKey: string) => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// ---------------------------------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
basket: {
|
|
27
|
+
/**
|
|
28
|
+
* Emits true when Miam's basket has succesfully loaded for the first time.
|
|
29
|
+
* Does not emit anything before or after that.
|
|
30
|
+
*/
|
|
31
|
+
basketIsReady$: Observable<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Fetch the first GroceriesList & Basket early (before any action requires it on Miam's
|
|
34
|
+
* side), so you can start the basket-sync earlier
|
|
35
|
+
*/
|
|
36
|
+
initialize: () => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
basketSync: {
|
|
40
|
+
/**
|
|
41
|
+
* The callback parameter is called when Miam's basket changes to update the user's cart accordingly
|
|
42
|
+
*
|
|
43
|
+
* @param pushProductsToBasket a method that updates the user's cart with the pruducts passed in parameter, by adding
|
|
44
|
+
* products if their quantity is positive, and removing them if their quantity is negative
|
|
45
|
+
*/
|
|
46
|
+
definePushProductsToBasket: (pushProductsToBasket: (products: ComparableProduct[]) => void) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Call to notify Miam that the user's cart has been updated
|
|
49
|
+
*
|
|
50
|
+
* @param comparableProducts The products in the user's cart
|
|
51
|
+
*/
|
|
52
|
+
retailerBasketChanged: (comparableProducts: ComparableProduct[]) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Call to notify Miam that the user's cart was paid
|
|
55
|
+
* Miam then refreshes the groceries-list and basket for the next user's cart
|
|
56
|
+
*
|
|
57
|
+
* @param total The total price of the cart paid
|
|
58
|
+
*/
|
|
59
|
+
handlePayment: (total: number) => void
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// ---------------------------------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
features: {
|
|
65
|
+
/**
|
|
66
|
+
* Call to enable recipes to display a video instead of their picture, if there is a video for the recipe
|
|
67
|
+
*/
|
|
68
|
+
enableVideoRecipes: () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Call to enable the catalog to display articles, if their are packages that contain any articles
|
|
71
|
+
*/
|
|
72
|
+
enableArticlesInCatalog: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Call to authorize Miam to ask for user preferences the first time users view the recipe catalog
|
|
75
|
+
*/
|
|
76
|
+
enableUserPreferences: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Call to enable tags displaying on recipe-details
|
|
79
|
+
*/
|
|
80
|
+
enableTagsOnRecipes: () => void;
|
|
81
|
+
/**
|
|
82
|
+
* Call to enable personal recipes on recipe-catalog
|
|
83
|
+
*/
|
|
84
|
+
enablePersonalRecipes: () => void;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// ---------------------------------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
hook: {
|
|
90
|
+
/**
|
|
91
|
+
* Set up a callback which Miam will call before adding a recipe to the user's cart
|
|
92
|
+
*
|
|
93
|
+
* @param callback a method that will be called passing two parameters :
|
|
94
|
+
* - isLogged, true if the user is logged (according to Miam, see user.loadWithExtId for more)
|
|
95
|
+
* - isPosValid true if the PointOfSale is recognized by Miam
|
|
96
|
+
* Typically you might want to use this to show your connexion page if the user tries to add a recipe while logged out
|
|
97
|
+
* or to show your point of sale picker if the user has not chosen one
|
|
98
|
+
*/
|
|
99
|
+
setHookCallback: (callback: (isLogged, isPosValid) => boolean) => void;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// ---------------------------------------------------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
list: {
|
|
105
|
+
/**
|
|
106
|
+
* Resets Miam's GroceriesList & empties all products & recipes added by the user
|
|
107
|
+
* /!\ We heavily recommend not to use this method outside of the web console for testing purposes /!\
|
|
108
|
+
*/
|
|
109
|
+
reset: () => void;
|
|
110
|
+
/**
|
|
111
|
+
* Adds a recipe to Miam's basket
|
|
112
|
+
* /!\ We heavily recommend not to use this method outside of the web console for testing purposes /!\
|
|
113
|
+
*/
|
|
114
|
+
addRecipe: (recipeId: string, guests: number) => Observable<object>;
|
|
115
|
+
/**
|
|
116
|
+
* Returns an observable that will emit true if the recipe passed in parameter is in Miam's GroceriesList
|
|
117
|
+
*/
|
|
118
|
+
hasRecipe: (recipeId: string) => Observable<boolean>;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// ---------------------------------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
pos: {
|
|
124
|
+
/**
|
|
125
|
+
* Call to inform Miam of the point of sale the user is currently on. Do not forget to call the method
|
|
126
|
+
* if it changes after user loads the page
|
|
127
|
+
*
|
|
128
|
+
* @param extId the id of the PointOfSale in client's database
|
|
129
|
+
*/
|
|
130
|
+
loadWithExtId: (extId) => void;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// ---------------------------------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
recipes: {
|
|
136
|
+
/**
|
|
137
|
+
* An observable that emits a value when the recipe-modal is closed
|
|
138
|
+
*/
|
|
139
|
+
hidden: Observable<boolean>;
|
|
140
|
+
/**
|
|
141
|
+
* If called with a parameter to true, recipe-details will show a picture next to the ingredients
|
|
142
|
+
*/
|
|
143
|
+
shouldDisplayIngredientPicturesOnRecipeCards: (should: boolean) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Call with an url of a picture to change the default picture displayed if an ingredient doesn't have a picture
|
|
146
|
+
* and if ingredients picture have been enabled with recipes.shouldDisplayIngredientPicturesOnRecipeCards(true)
|
|
147
|
+
*/
|
|
148
|
+
setDefaultIngredientPicture: (url: string) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Override default labels for difficulty levels
|
|
151
|
+
*
|
|
152
|
+
* @param levels The list of labels to override for each difficulty (difficulties are respectively 1: Easy, 2: Medium, 3: Hard)
|
|
153
|
+
* example : [{value: 1, label: "Beginner"}] to update the label of easy recipes to "Beginner"
|
|
154
|
+
*/
|
|
155
|
+
setDifficultyLevels: (levels: { value: number, label: string }[]) => void;
|
|
156
|
+
|
|
157
|
+
// /**
|
|
158
|
+
// * /!\ DEPRECATED: DO NOT USE /!\
|
|
159
|
+
// */
|
|
160
|
+
// setRecipesPrimaryButtonActions: (display: boolean, addToBasket: boolean) => void;
|
|
161
|
+
// /**
|
|
162
|
+
// * /!\ DEPRECATED: DO NOT USE /!\
|
|
163
|
+
// */
|
|
164
|
+
// setSuggestionsPrimaryButtonActions: (display: boolean, addToBasket: boolean) => void;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// ---------------------------------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
router: {
|
|
170
|
+
/**
|
|
171
|
+
* Inform Miam of the url where the catalog is for the redirection link of recipe-details
|
|
172
|
+
*/
|
|
173
|
+
setRecipeCatalogUrl: (url: string) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Inform Miam of the url where the onboarding section of the catalog should redirect
|
|
176
|
+
*/
|
|
177
|
+
setRecipeInfoLink: (url: string) => void;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
supplier: {
|
|
183
|
+
/**
|
|
184
|
+
* Call to inform Miam of the supplier the user is currently on. Do not forget to call the method
|
|
185
|
+
* if it changes after user loads the page (should not happen escept in very specific cases)
|
|
186
|
+
*
|
|
187
|
+
* @param supplierId the Supplier id in Miam's database
|
|
188
|
+
*/
|
|
189
|
+
load: (supplierId: number | string) => void;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// ---------------------------------------------------------------------------------------------------
|
|
193
|
+
|
|
194
|
+
user: {
|
|
195
|
+
/**
|
|
196
|
+
* Call to inform Miam of the id of the user.
|
|
197
|
+
*
|
|
198
|
+
* @param id a string unique identifier to the user
|
|
199
|
+
* @param forbidProfiling if set to true, desactivate personalized content (personalized recipes & products)
|
|
200
|
+
* @param initBasket DEPRECATED - if set to true, fetch the GroceriesList & Basket of the user (recommanded as
|
|
201
|
+
* it saves time later)
|
|
202
|
+
*/
|
|
203
|
+
loadWithExtId: (id: string, forbidProfiling: boolean, initBasket: boolean) => Observable<object>;
|
|
204
|
+
/**
|
|
205
|
+
* Call to inform Miam that the user has logged out
|
|
206
|
+
*/
|
|
207
|
+
reset: () => void;
|
|
208
|
+
/**
|
|
209
|
+
* If your website has a "favorite products" feature, you can pass the ids of all products
|
|
210
|
+
* which the user has marked as favorites, so they can be prioritized when adding a recipe
|
|
211
|
+
* to their cart, if one of them is returned as a matching product for the recipe.
|
|
212
|
+
*
|
|
213
|
+
* @param favoriteProductIds an array of product ids, passed as string
|
|
214
|
+
*/
|
|
215
|
+
setFavoriteItems: (favoriteProductIds: string[]) => Observable<object>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// ---------------------------------------------------------------------------------------------------
|
|
219
|
+
|
|
220
|
+
view: {
|
|
221
|
+
/**
|
|
222
|
+
* Call to notify Miam of the scrollable element of the client's page, if it is not <body>
|
|
223
|
+
* This is necessary to prevent the page to scroll in the backgroud when Miam opens a popup/modal/drawer
|
|
224
|
+
*/
|
|
225
|
+
setGlobalScrollableElement: (element: HTMLElement) => void;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// ---------------------------------------------------------------------------------------------------
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Override two times will not be considered (DEPRECATED)
|
|
232
|
+
* @param icon have to be a knowed icon name see section 'Custom icons' in read me
|
|
233
|
+
* @param url of the new icon
|
|
234
|
+
*/
|
|
235
|
+
overrideIcon: (icon, url: string) => void;
|
|
236
|
+
}
|