@ecomweb/sdk 0.14.0 → 0.14.1
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/dist/index.d.ts +631 -0
- package/dist/index.js +452 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/core/client-info.ts
|
|
2
|
-
var SDK_VERSION = true ? "0.14.
|
|
2
|
+
var SDK_VERSION = true ? "0.14.1" : "dev";
|
|
3
3
|
var CLIENT_HEADER = "X-Ecomweb-Client";
|
|
4
4
|
var SDK_CLIENT_TOKEN = `@ecomweb/sdk/${SDK_VERSION}`;
|
|
5
5
|
function clientHeaderValue(clientInfo) {
|
|
@@ -2956,6 +2956,14 @@ var ProductsApi = class {
|
|
|
2956
2956
|
constructor(http) {
|
|
2957
2957
|
this.http = http;
|
|
2958
2958
|
}
|
|
2959
|
+
/**
|
|
2960
|
+
* Gets one product by id.
|
|
2961
|
+
*
|
|
2962
|
+
* @param storeRef - the store's ref or handle
|
|
2963
|
+
* @param productId - the product id
|
|
2964
|
+
* @param query - optional fields to include
|
|
2965
|
+
* @returns The product, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
2966
|
+
*/
|
|
2959
2967
|
async getById(storeRef, productId, query) {
|
|
2960
2968
|
const queryString = stringify(query ?? {});
|
|
2961
2969
|
const res = await this.http.get(
|
|
@@ -2963,6 +2971,14 @@ var ProductsApi = class {
|
|
|
2963
2971
|
);
|
|
2964
2972
|
return unwrapOrNull(res);
|
|
2965
2973
|
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Gets one product by slug.
|
|
2976
|
+
*
|
|
2977
|
+
* @param storeRef - the store's ref or handle
|
|
2978
|
+
* @param slug - the product slug
|
|
2979
|
+
* @param query - optional fields to include
|
|
2980
|
+
* @returns The product, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
2981
|
+
*/
|
|
2966
2982
|
async getBySlug(storeRef, slug, query) {
|
|
2967
2983
|
const normalizedSlug = slug.normalize("NFC");
|
|
2968
2984
|
const encodedSlug = encodeURIComponent(normalizedSlug);
|
|
@@ -2979,6 +2995,13 @@ var CollectionsApi = class {
|
|
|
2979
2995
|
constructor(http) {
|
|
2980
2996
|
this.http = http;
|
|
2981
2997
|
}
|
|
2998
|
+
/**
|
|
2999
|
+
* Lists collections, one page at a time.
|
|
3000
|
+
*
|
|
3001
|
+
* @param storeRef - the store's ref or handle
|
|
3002
|
+
* @param params - filters, sorting and paging
|
|
3003
|
+
* @returns A page of collections; throws {@link ApiClientError} when the API answers with an error
|
|
3004
|
+
*/
|
|
2982
3005
|
async getAllPaginated(storeRef, params) {
|
|
2983
3006
|
const queryString = stringify(params ?? {});
|
|
2984
3007
|
const res = await this.http.get(
|
|
@@ -2986,6 +3009,13 @@ var CollectionsApi = class {
|
|
|
2986
3009
|
);
|
|
2987
3010
|
return unwrap(res);
|
|
2988
3011
|
}
|
|
3012
|
+
/**
|
|
3013
|
+
* Lists up to 100 collections in one call.
|
|
3014
|
+
*
|
|
3015
|
+
* @param storeRef - the store's ref or handle
|
|
3016
|
+
* @param ids - limit the result to these collection ids
|
|
3017
|
+
* @returns The collections; throws {@link ApiClientError} when the API answers with an error
|
|
3018
|
+
*/
|
|
2989
3019
|
async getAll(storeRef, ids) {
|
|
2990
3020
|
const result = await this.getAllPaginated(storeRef, {
|
|
2991
3021
|
ids,
|
|
@@ -2993,6 +3023,14 @@ var CollectionsApi = class {
|
|
|
2993
3023
|
});
|
|
2994
3024
|
return result.data;
|
|
2995
3025
|
}
|
|
3026
|
+
/**
|
|
3027
|
+
* Gets one collection by slug.
|
|
3028
|
+
*
|
|
3029
|
+
* @param storeRef - the store's ref or handle
|
|
3030
|
+
* @param slug - the collection slug
|
|
3031
|
+
* @param query - `include_seo_metadata` adds the SEO fields
|
|
3032
|
+
* @returns The collection, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3033
|
+
*/
|
|
2996
3034
|
async getBySlug(storeRef, slug, query) {
|
|
2997
3035
|
const queryString = query ? stringify(query) : "";
|
|
2998
3036
|
const res = await this.http.get(
|
|
@@ -3007,6 +3045,13 @@ var CategoriesApi = class {
|
|
|
3007
3045
|
constructor(http) {
|
|
3008
3046
|
this.http = http;
|
|
3009
3047
|
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Lists categories, one page at a time.
|
|
3050
|
+
*
|
|
3051
|
+
* @param storeRef - the store's ref or handle
|
|
3052
|
+
* @param params - filters, sorting and paging
|
|
3053
|
+
* @returns A page of categories; throws {@link ApiClientError} when the API answers with an error
|
|
3054
|
+
*/
|
|
3010
3055
|
async getAllPaginated(storeRef, params) {
|
|
3011
3056
|
const queryString = stringify(params ?? {});
|
|
3012
3057
|
const res = await this.http.get(
|
|
@@ -3014,6 +3059,13 @@ var CategoriesApi = class {
|
|
|
3014
3059
|
);
|
|
3015
3060
|
return unwrap(res);
|
|
3016
3061
|
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Lists up to 1,000 categories in one call.
|
|
3064
|
+
*
|
|
3065
|
+
* @param storeRef - the store's ref or handle
|
|
3066
|
+
* @param activeOnly - `true` (the default) returns only active categories
|
|
3067
|
+
* @returns The categories; throws {@link ApiClientError} when the API answers with an error
|
|
3068
|
+
*/
|
|
3017
3069
|
async getAll(storeRef, activeOnly = true) {
|
|
3018
3070
|
const result = await this.getAllPaginated(storeRef, {
|
|
3019
3071
|
is_active: activeOnly,
|
|
@@ -3021,12 +3073,26 @@ var CategoriesApi = class {
|
|
|
3021
3073
|
});
|
|
3022
3074
|
return result.data;
|
|
3023
3075
|
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Gets one category by id.
|
|
3078
|
+
*
|
|
3079
|
+
* @param storeRef - the store's ref or handle
|
|
3080
|
+
* @param categoryId - the category id
|
|
3081
|
+
* @returns The category, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3082
|
+
*/
|
|
3024
3083
|
async getById(storeRef, categoryId) {
|
|
3025
3084
|
const res = await this.http.get(
|
|
3026
3085
|
`/public/stores/${storeRef}/categories/${categoryId}`
|
|
3027
3086
|
);
|
|
3028
3087
|
return unwrapOrNull(res);
|
|
3029
3088
|
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Gets one category by slug.
|
|
3091
|
+
*
|
|
3092
|
+
* @param storeRef - the store's ref or handle
|
|
3093
|
+
* @param slug - the category slug
|
|
3094
|
+
* @returns The category, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3095
|
+
*/
|
|
3030
3096
|
async getBySlug(storeRef, slug) {
|
|
3031
3097
|
const res = await this.http.get(
|
|
3032
3098
|
`/public/stores/${storeRef}/categories/${encodeURIComponent(slug)}`
|
|
@@ -3047,6 +3113,14 @@ var CartApi = class {
|
|
|
3047
3113
|
basePath(isAuth) {
|
|
3048
3114
|
return isAuth ? "stores" : "public/stores";
|
|
3049
3115
|
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Gets the shopper's cart.
|
|
3118
|
+
*
|
|
3119
|
+
* @param storeRef - the store's ref or handle
|
|
3120
|
+
* @param sessionId - the guest cart session id
|
|
3121
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3122
|
+
* @returns The cart, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3123
|
+
*/
|
|
3050
3124
|
async getCart(storeRef, sessionId, isAuth) {
|
|
3051
3125
|
const res = await this.client(isAuth).get(
|
|
3052
3126
|
`/${this.basePath(isAuth)}/${storeRef}/cart`,
|
|
@@ -3054,24 +3128,60 @@ var CartApi = class {
|
|
|
3054
3128
|
);
|
|
3055
3129
|
return unwrapOrNull(res);
|
|
3056
3130
|
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Adds a product variant to the cart.
|
|
3133
|
+
*
|
|
3134
|
+
* @param storeRef - the store's ref or handle
|
|
3135
|
+
* @param data - the variant and the quantity
|
|
3136
|
+
* @param sessionId - the guest cart session id
|
|
3137
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3138
|
+
* @returns The cart id and the added item; throws {@link ApiClientError} when the API answers with an error
|
|
3139
|
+
*/
|
|
3057
3140
|
async addItem(storeRef, data, sessionId, isAuth) {
|
|
3058
3141
|
const res = await this.client(isAuth).post(`/${this.basePath(isAuth)}/${storeRef}/cart/items`, data, {
|
|
3059
3142
|
headers: { "x-session-id": sessionId }
|
|
3060
3143
|
});
|
|
3061
3144
|
return unwrap(res);
|
|
3062
3145
|
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Changes the quantity of a cart line.
|
|
3148
|
+
*
|
|
3149
|
+
* @param storeRef - the store's ref or handle
|
|
3150
|
+
* @param itemId - the cart line id
|
|
3151
|
+
* @param data - the new quantity
|
|
3152
|
+
* @param sessionId - the guest cart session id
|
|
3153
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3154
|
+
* @returns The cart id and the updated item (`null` when the line was removed); throws {@link ApiClientError} when the API answers with an error
|
|
3155
|
+
*/
|
|
3063
3156
|
async updateItem(storeRef, itemId, data, sessionId, isAuth) {
|
|
3064
3157
|
const res = await this.client(isAuth).put(`/${this.basePath(isAuth)}/${storeRef}/cart/items/${itemId}`, data, {
|
|
3065
3158
|
headers: { "x-session-id": sessionId }
|
|
3066
3159
|
});
|
|
3067
3160
|
return unwrap(res);
|
|
3068
3161
|
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Removes a line from the cart.
|
|
3164
|
+
*
|
|
3165
|
+
* @param storeRef - the store's ref or handle
|
|
3166
|
+
* @param itemId - the cart line id
|
|
3167
|
+
* @param sessionId - the guest cart session id
|
|
3168
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3169
|
+
* @returns The cart id and the removed line's id; throws {@link ApiClientError} when the API answers with an error
|
|
3170
|
+
*/
|
|
3069
3171
|
async removeItem(storeRef, itemId, sessionId, isAuth) {
|
|
3070
3172
|
const res = await this.client(isAuth).delete(`/${this.basePath(isAuth)}/${storeRef}/cart/items/${itemId}`, {
|
|
3071
3173
|
headers: { "x-session-id": sessionId }
|
|
3072
3174
|
});
|
|
3073
3175
|
return unwrap(res);
|
|
3074
3176
|
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Empties the cart.
|
|
3179
|
+
*
|
|
3180
|
+
* @param storeRef - the store's ref or handle
|
|
3181
|
+
* @param sessionId - the guest cart session id
|
|
3182
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3183
|
+
* @returns The cart id; throws {@link ApiClientError} when the API answers with an error
|
|
3184
|
+
*/
|
|
3075
3185
|
async clear(storeRef, sessionId, isAuth) {
|
|
3076
3186
|
const res = await this.client(isAuth).delete(
|
|
3077
3187
|
`/${this.basePath(isAuth)}/${storeRef}/cart`,
|
|
@@ -3118,6 +3228,14 @@ var OrdersApi = class {
|
|
|
3118
3228
|
if (!data || !("id" in data) || data.id == null) return null;
|
|
3119
3229
|
return data;
|
|
3120
3230
|
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Places an order.
|
|
3233
|
+
*
|
|
3234
|
+
* @param storeRef - the store's ref or handle
|
|
3235
|
+
* @param data - the order details
|
|
3236
|
+
* @param isAuth - `true` to place it as the signed-in customer, `false` as a guest
|
|
3237
|
+
* @returns The created order with its items; throws {@link ApiClientError} when the API answers with an error
|
|
3238
|
+
*/
|
|
3121
3239
|
async create(storeRef, data, isAuth) {
|
|
3122
3240
|
if (isAuth) {
|
|
3123
3241
|
const res2 = await this.authHttp.post(
|
|
@@ -3132,6 +3250,13 @@ var OrdersApi = class {
|
|
|
3132
3250
|
);
|
|
3133
3251
|
return unwrap(res);
|
|
3134
3252
|
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Lists the signed-in customer's orders, newest first by default.
|
|
3255
|
+
*
|
|
3256
|
+
* @param storeRef - the store's ref or handle
|
|
3257
|
+
* @param params - search, status filter, sorting and paging (`page`, or `limit` and `offset`)
|
|
3258
|
+
* @returns A page of orders; throws {@link ApiClientError} when the API answers with an error
|
|
3259
|
+
*/
|
|
3135
3260
|
async listCustomerOrders(storeRef, params = {}) {
|
|
3136
3261
|
const limit = params.limit ?? 10;
|
|
3137
3262
|
const page = params.page ?? (params.offset ? Math.floor(params.offset / limit) + 1 : 1);
|
|
@@ -3178,6 +3303,13 @@ var BlogApi = class {
|
|
|
3178
3303
|
this.publicHttp = publicHttp;
|
|
3179
3304
|
this.authHttp = authHttp;
|
|
3180
3305
|
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Lists published blog posts.
|
|
3308
|
+
*
|
|
3309
|
+
* @param storeRef - the store's ref or handle
|
|
3310
|
+
* @param query - filters, sorting and paging
|
|
3311
|
+
* @returns A page of posts; throws {@link ApiClientError} when the API answers with an error
|
|
3312
|
+
*/
|
|
3181
3313
|
async getPosts(storeRef, query = {}) {
|
|
3182
3314
|
const qsStr = stringify(query);
|
|
3183
3315
|
const res = await this.publicHttp.get(
|
|
@@ -3185,6 +3317,14 @@ var BlogApi = class {
|
|
|
3185
3317
|
);
|
|
3186
3318
|
return unwrap(res);
|
|
3187
3319
|
}
|
|
3320
|
+
/**
|
|
3321
|
+
* Gets one published blog post by its slug.
|
|
3322
|
+
*
|
|
3323
|
+
* @param storeRef - the store's ref or handle
|
|
3324
|
+
* @param slug - the post slug
|
|
3325
|
+
* @param options - `incrementView` counts a view; `include_seo_metadata` and `include_products` add those fields
|
|
3326
|
+
* @returns The post, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3327
|
+
*/
|
|
3188
3328
|
async getPostBySlug(storeRef, slug, options = {}) {
|
|
3189
3329
|
const query = stringify({
|
|
3190
3330
|
increment_view: options.incrementView,
|
|
@@ -3196,6 +3336,13 @@ var BlogApi = class {
|
|
|
3196
3336
|
);
|
|
3197
3337
|
return unwrapOrNull(res);
|
|
3198
3338
|
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Lists blog categories.
|
|
3341
|
+
*
|
|
3342
|
+
* @param storeRef - the store's ref or handle
|
|
3343
|
+
* @param query - filters and paging
|
|
3344
|
+
* @returns A page of categories; throws {@link ApiClientError} when the API answers with an error
|
|
3345
|
+
*/
|
|
3199
3346
|
async getCategories(storeRef, query = {}) {
|
|
3200
3347
|
const qsStr = stringify(query);
|
|
3201
3348
|
const res = await this.publicHttp.get(
|
|
@@ -3203,6 +3350,13 @@ var BlogApi = class {
|
|
|
3203
3350
|
);
|
|
3204
3351
|
return unwrap(res);
|
|
3205
3352
|
}
|
|
3353
|
+
/**
|
|
3354
|
+
* Lists blog tags.
|
|
3355
|
+
*
|
|
3356
|
+
* @param storeRef - the store's ref or handle
|
|
3357
|
+
* @param query - filters and paging
|
|
3358
|
+
* @returns A page of tags; throws {@link ApiClientError} when the API answers with an error
|
|
3359
|
+
*/
|
|
3206
3360
|
async getTags(storeRef, query = {}) {
|
|
3207
3361
|
const qsStr = stringify(query);
|
|
3208
3362
|
const res = await this.publicHttp.get(
|
|
@@ -3210,18 +3364,40 @@ var BlogApi = class {
|
|
|
3210
3364
|
);
|
|
3211
3365
|
return unwrap(res);
|
|
3212
3366
|
}
|
|
3367
|
+
/**
|
|
3368
|
+
* Lists the approved comments of a post, as an anonymous visitor.
|
|
3369
|
+
*
|
|
3370
|
+
* @param storeRef - the store's ref or handle
|
|
3371
|
+
* @param postId - the post id
|
|
3372
|
+
* @returns The comments; throws {@link ApiClientError} when the API answers with an error
|
|
3373
|
+
*/
|
|
3213
3374
|
async getPostComments(storeRef, postId) {
|
|
3214
3375
|
const res = await this.publicHttp.get(
|
|
3215
3376
|
`/public/stores/${storeRef}/blog/posts/${postId}/comments`
|
|
3216
3377
|
);
|
|
3217
3378
|
return unwrap(res);
|
|
3218
3379
|
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Lists the approved comments of a post, sending the signed-in customer's credentials.
|
|
3382
|
+
*
|
|
3383
|
+
* @param storeRef - the store's ref or handle
|
|
3384
|
+
* @param postId - the post id
|
|
3385
|
+
* @returns The comments; throws {@link ApiClientError} when the API answers with an error
|
|
3386
|
+
*/
|
|
3219
3387
|
async getPostCommentsAuth(storeRef, postId) {
|
|
3220
3388
|
const res = await this.authHttp.get(
|
|
3221
3389
|
`/public/stores/${storeRef}/blog/posts/${postId}/comments`
|
|
3222
3390
|
);
|
|
3223
3391
|
return unwrap(res);
|
|
3224
3392
|
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Submits a comment on a post, as the signed-in customer. It may wait for moderation.
|
|
3395
|
+
*
|
|
3396
|
+
* @param storeRef - the store's ref or handle
|
|
3397
|
+
* @param postId - the post id
|
|
3398
|
+
* @param data - the author name, the text, and optionally a website and the parent comment id
|
|
3399
|
+
* @returns The created comment; throws {@link ApiClientError} when the API answers with an error
|
|
3400
|
+
*/
|
|
3225
3401
|
async submitComment(storeRef, postId, data) {
|
|
3226
3402
|
const res = await this.authHttp.post(
|
|
3227
3403
|
`/public/stores/${storeRef}/blog/posts/${postId}/comments`,
|
|
@@ -3236,6 +3412,14 @@ var StoresApi = class {
|
|
|
3236
3412
|
constructor(http) {
|
|
3237
3413
|
this.http = http;
|
|
3238
3414
|
}
|
|
3415
|
+
/**
|
|
3416
|
+
* Gets a store's public information, by default with its configuration, settings and embedded scripts.
|
|
3417
|
+
*
|
|
3418
|
+
* @param storeRef - the store's ref or handle
|
|
3419
|
+
* @param options - set `includeConfig`, `includeSettings` or `includeEmbeddedScripts` to `false` to leave that part out
|
|
3420
|
+
* @param requestOptions - extra request options, passed to the HTTP client only when given
|
|
3421
|
+
* @returns The store information, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3422
|
+
*/
|
|
3239
3423
|
async getById(storeRef, options, requestOptions) {
|
|
3240
3424
|
const params = new URLSearchParams();
|
|
3241
3425
|
if (options?.includeConfig ?? true) params.set("include_config", "1");
|
|
@@ -3247,6 +3431,12 @@ var StoresApi = class {
|
|
|
3247
3431
|
const res = requestOptions ? await this.http.get(url, requestOptions) : await this.http.get(url);
|
|
3248
3432
|
return unwrapOrNull(res);
|
|
3249
3433
|
}
|
|
3434
|
+
/**
|
|
3435
|
+
* Gets a store by its subdomain.
|
|
3436
|
+
*
|
|
3437
|
+
* @param subdomain - the store's subdomain
|
|
3438
|
+
* @returns The store, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3439
|
+
*/
|
|
3250
3440
|
async getBySubdomain(subdomain) {
|
|
3251
3441
|
const res = await this.http.get(
|
|
3252
3442
|
`/public/stores/exists/subdomain/${subdomain}`
|
|
@@ -3327,6 +3517,13 @@ var SearchApi = class {
|
|
|
3327
3517
|
constructor(http) {
|
|
3328
3518
|
this.http = http;
|
|
3329
3519
|
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Searches products.
|
|
3522
|
+
*
|
|
3523
|
+
* @param storeRef - the store's ref or handle
|
|
3524
|
+
* @param params - the query, filters and paging
|
|
3525
|
+
* @returns The matching products; throws {@link ApiClientError} when the API answers with an error
|
|
3526
|
+
*/
|
|
3330
3527
|
async searchCatalog(storeRef, params) {
|
|
3331
3528
|
const queryString = stringify(params);
|
|
3332
3529
|
const res = await this.http.get(
|
|
@@ -3334,6 +3531,13 @@ var SearchApi = class {
|
|
|
3334
3531
|
);
|
|
3335
3532
|
return unwrap(res);
|
|
3336
3533
|
}
|
|
3534
|
+
/**
|
|
3535
|
+
* Suggests product matches while the shopper is typing.
|
|
3536
|
+
*
|
|
3537
|
+
* @param storeRef - the store's ref or handle
|
|
3538
|
+
* @param params - the partial query and the suggestion limit
|
|
3539
|
+
* @returns The suggestions; throws {@link ApiClientError} when the API answers with an error
|
|
3540
|
+
*/
|
|
3337
3541
|
async autocompleteCatalog(storeRef, params) {
|
|
3338
3542
|
const queryString = stringify(params);
|
|
3339
3543
|
const res = await this.http.get(
|
|
@@ -3341,6 +3545,13 @@ var SearchApi = class {
|
|
|
3341
3545
|
);
|
|
3342
3546
|
return unwrap(res);
|
|
3343
3547
|
}
|
|
3548
|
+
/**
|
|
3549
|
+
* Searches published blog posts.
|
|
3550
|
+
*
|
|
3551
|
+
* @param storeRef - the store's ref or handle
|
|
3552
|
+
* @param params - the query and paging
|
|
3553
|
+
* @returns The matching posts; throws {@link ApiClientError} when the API answers with an error
|
|
3554
|
+
*/
|
|
3344
3555
|
async searchBlog(storeRef, params) {
|
|
3345
3556
|
const queryString = stringify(params);
|
|
3346
3557
|
const res = await this.http.get(
|
|
@@ -3370,6 +3581,13 @@ var ShippingApi = class {
|
|
|
3370
3581
|
);
|
|
3371
3582
|
return unwrap(res);
|
|
3372
3583
|
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Works out the shipping options and prices for a cart and a destination.
|
|
3586
|
+
*
|
|
3587
|
+
* @param storeRef - the store's ref or handle
|
|
3588
|
+
* @param data - the destination and the cart contents
|
|
3589
|
+
* @returns The available shipping options; throws {@link ApiClientError} when the API answers with an error
|
|
3590
|
+
*/
|
|
3373
3591
|
async calculate(storeRef, data) {
|
|
3374
3592
|
const res = await this.http.post(
|
|
3375
3593
|
`/public/stores/${storeRef}/shipping/calculate`,
|
|
@@ -3384,6 +3602,13 @@ var PromotionsApi = class {
|
|
|
3384
3602
|
constructor(http) {
|
|
3385
3603
|
this.http = http;
|
|
3386
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Checks a promotion code against a cart.
|
|
3607
|
+
*
|
|
3608
|
+
* @param storeRef - the store's ref or handle
|
|
3609
|
+
* @param data - the code and the cart details
|
|
3610
|
+
* @returns The validation result; throws {@link ApiClientError} when the API answers with an error
|
|
3611
|
+
*/
|
|
3387
3612
|
async validate(storeRef, data) {
|
|
3388
3613
|
const res = await this.http.post(
|
|
3389
3614
|
`/public/stores/${storeRef}/promotions/validate`,
|
|
@@ -3391,6 +3616,13 @@ var PromotionsApi = class {
|
|
|
3391
3616
|
);
|
|
3392
3617
|
return unwrap(res);
|
|
3393
3618
|
}
|
|
3619
|
+
/**
|
|
3620
|
+
* Lists promotions the shopper could use, optionally for a given cart subtotal.
|
|
3621
|
+
*
|
|
3622
|
+
* @param storeRef - the store's ref or handle
|
|
3623
|
+
* @param subtotal - the cart subtotal in the store's currency
|
|
3624
|
+
* @returns The suggested promotions; throws {@link ApiClientError} when the API answers with an error
|
|
3625
|
+
*/
|
|
3394
3626
|
async getSuggestions(storeRef, subtotal) {
|
|
3395
3627
|
const params = new URLSearchParams();
|
|
3396
3628
|
if (subtotal !== void 0) params.append("subtotal", subtotal.toString());
|
|
@@ -3406,6 +3638,12 @@ var PaymentMethodsApi = class {
|
|
|
3406
3638
|
constructor(http) {
|
|
3407
3639
|
this.http = http;
|
|
3408
3640
|
}
|
|
3641
|
+
/**
|
|
3642
|
+
* Lists the payment methods the store has turned on.
|
|
3643
|
+
*
|
|
3644
|
+
* @param storeRef - the store's ref or handle
|
|
3645
|
+
* @returns The enabled payment methods; throws {@link ApiClientError} when the API answers with an error
|
|
3646
|
+
*/
|
|
3409
3647
|
async getEnabled(storeRef) {
|
|
3410
3648
|
const res = await this.http.get(
|
|
3411
3649
|
`/public/stores/${storeRef}/payment-methods`
|
|
@@ -3452,6 +3690,14 @@ var ReviewsApi = class {
|
|
|
3452
3690
|
constructor(http) {
|
|
3453
3691
|
this.http = http;
|
|
3454
3692
|
}
|
|
3693
|
+
/**
|
|
3694
|
+
* Lists the published reviews of a product.
|
|
3695
|
+
*
|
|
3696
|
+
* @param storeRef - the store's ref or handle
|
|
3697
|
+
* @param productId - the product id
|
|
3698
|
+
* @param query - filters and paging
|
|
3699
|
+
* @returns A page of reviews; throws {@link ApiClientError} when the API answers with an error
|
|
3700
|
+
*/
|
|
3455
3701
|
async getProductReviews(storeRef, productId, query) {
|
|
3456
3702
|
const queryString = stringify(query ?? {});
|
|
3457
3703
|
const res = await this.http.get(
|
|
@@ -3459,12 +3705,27 @@ var ReviewsApi = class {
|
|
|
3459
3705
|
);
|
|
3460
3706
|
return unwrap(res);
|
|
3461
3707
|
}
|
|
3708
|
+
/**
|
|
3709
|
+
* Gets the public details behind a review invitation link.
|
|
3710
|
+
*
|
|
3711
|
+
* @param storeRef - the store's ref or handle
|
|
3712
|
+
* @param token - the token from the invitation link
|
|
3713
|
+
* @returns The invitation details; throws {@link ApiClientError} when the API answers with an error
|
|
3714
|
+
*/
|
|
3462
3715
|
async getReviewInvitation(storeRef, token) {
|
|
3463
3716
|
const res = await this.http.get(
|
|
3464
3717
|
`public/stores/${storeRef}/review-invitations/${token}`
|
|
3465
3718
|
);
|
|
3466
3719
|
return unwrap(res);
|
|
3467
3720
|
}
|
|
3721
|
+
/**
|
|
3722
|
+
* Lists the review invitations for one order.
|
|
3723
|
+
*
|
|
3724
|
+
* @param storeRef - the store's ref or handle
|
|
3725
|
+
* @param orderNumber - the order number
|
|
3726
|
+
* @param email - the email address on the order
|
|
3727
|
+
* @returns The invitation summaries; throws {@link ApiClientError} when the API answers with an error
|
|
3728
|
+
*/
|
|
3468
3729
|
async getOrderReviewInvitations(storeRef, orderNumber, email) {
|
|
3469
3730
|
const queryString = stringify({ order_number: orderNumber, email });
|
|
3470
3731
|
const res = await this.http.get(
|
|
@@ -3472,6 +3733,14 @@ var ReviewsApi = class {
|
|
|
3472
3733
|
);
|
|
3473
3734
|
return unwrap(res);
|
|
3474
3735
|
}
|
|
3736
|
+
/**
|
|
3737
|
+
* Lists the review invitations for several orders at once.
|
|
3738
|
+
*
|
|
3739
|
+
* @param storeRef - the store's ref or handle
|
|
3740
|
+
* @param orderNumbers - the order numbers
|
|
3741
|
+
* @param email - the email address on the orders
|
|
3742
|
+
* @returns The invitations grouped by order; throws {@link ApiClientError} when the API answers with an error
|
|
3743
|
+
*/
|
|
3475
3744
|
async getBatchOrderReviewInvitations(storeRef, orderNumbers, email) {
|
|
3476
3745
|
const queryString = stringify({ order_numbers: orderNumbers.join(","), email });
|
|
3477
3746
|
const res = await this.http.get(
|
|
@@ -3479,6 +3748,14 @@ var ReviewsApi = class {
|
|
|
3479
3748
|
);
|
|
3480
3749
|
return unwrap(res);
|
|
3481
3750
|
}
|
|
3751
|
+
/**
|
|
3752
|
+
* Submits a review through an invitation link.
|
|
3753
|
+
*
|
|
3754
|
+
* @param storeRef - the store's ref or handle
|
|
3755
|
+
* @param token - the token from the invitation link
|
|
3756
|
+
* @param payload - the rating and review text
|
|
3757
|
+
* @returns The API's answer; throws {@link ApiClientError} when the API answers with an error
|
|
3758
|
+
*/
|
|
3482
3759
|
async submitReviewInvitation(storeRef, token, payload) {
|
|
3483
3760
|
const res = await this.http.post(
|
|
3484
3761
|
`public/stores/${storeRef}/review-invitations/${token}/submit`,
|
|
@@ -3493,6 +3770,13 @@ var CustomersApi = class {
|
|
|
3493
3770
|
constructor(http) {
|
|
3494
3771
|
this.http = http;
|
|
3495
3772
|
}
|
|
3773
|
+
/**
|
|
3774
|
+
* Creates the customer record for a newly signed-in user, or updates it when it exists.
|
|
3775
|
+
*
|
|
3776
|
+
* @param storeRef - the store's ref or handle
|
|
3777
|
+
* @param payload - the identity fields to store
|
|
3778
|
+
* @returns The customer, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
3779
|
+
*/
|
|
3496
3780
|
async upsertForAuth(storeRef, payload) {
|
|
3497
3781
|
return this.http.post(
|
|
3498
3782
|
`/stores/${storeRef}/customers/auth/upsert`,
|
|
@@ -3524,18 +3808,38 @@ var AddressesApi = class {
|
|
|
3524
3808
|
constructor(http) {
|
|
3525
3809
|
this.http = http;
|
|
3526
3810
|
}
|
|
3811
|
+
/**
|
|
3812
|
+
* Lists the signed-in customer's saved addresses.
|
|
3813
|
+
*
|
|
3814
|
+
* @param storeRef - the store's ref or handle
|
|
3815
|
+
* @returns The addresses, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3816
|
+
*/
|
|
3527
3817
|
async list(storeRef) {
|
|
3528
3818
|
const res = await this.http.get(
|
|
3529
3819
|
`/tenant/stores/${storeRef}/customers/address`
|
|
3530
3820
|
);
|
|
3531
3821
|
return unwrapOrNull(res);
|
|
3532
3822
|
}
|
|
3823
|
+
/**
|
|
3824
|
+
* Gets one of the signed-in customer's saved addresses.
|
|
3825
|
+
*
|
|
3826
|
+
* @param storeRef - the store's ref or handle
|
|
3827
|
+
* @param addressId - the address id
|
|
3828
|
+
* @returns The address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3829
|
+
*/
|
|
3533
3830
|
async getById(storeRef, addressId) {
|
|
3534
3831
|
const res = await this.http.get(
|
|
3535
3832
|
`/tenant/stores/${storeRef}/customers/address/${addressId}`
|
|
3536
3833
|
);
|
|
3537
3834
|
return unwrapOrNull(res);
|
|
3538
3835
|
}
|
|
3836
|
+
/**
|
|
3837
|
+
* Saves a new address for the signed-in customer.
|
|
3838
|
+
*
|
|
3839
|
+
* @param storeRef - the store's ref or handle
|
|
3840
|
+
* @param data - the address fields
|
|
3841
|
+
* @returns The created address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3842
|
+
*/
|
|
3539
3843
|
async create(storeRef, data) {
|
|
3540
3844
|
const res = await this.http.post(
|
|
3541
3845
|
`/tenant/stores/${storeRef}/customers/address`,
|
|
@@ -3543,6 +3847,14 @@ var AddressesApi = class {
|
|
|
3543
3847
|
);
|
|
3544
3848
|
return unwrapOrNull(res);
|
|
3545
3849
|
}
|
|
3850
|
+
/**
|
|
3851
|
+
* Updates one of the signed-in customer's saved addresses.
|
|
3852
|
+
*
|
|
3853
|
+
* @param storeRef - the store's ref or handle
|
|
3854
|
+
* @param addressId - the address id
|
|
3855
|
+
* @param data - the fields to change
|
|
3856
|
+
* @returns The updated address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3857
|
+
*/
|
|
3546
3858
|
async update(storeRef, addressId, data) {
|
|
3547
3859
|
const res = await this.http.patch(
|
|
3548
3860
|
`/tenant/stores/${storeRef}/customers/address/${addressId}`,
|
|
@@ -3550,12 +3862,26 @@ var AddressesApi = class {
|
|
|
3550
3862
|
);
|
|
3551
3863
|
return unwrapOrNull(res);
|
|
3552
3864
|
}
|
|
3865
|
+
/**
|
|
3866
|
+
* Deletes one of the signed-in customer's saved addresses.
|
|
3867
|
+
*
|
|
3868
|
+
* @param storeRef - the store's ref or handle
|
|
3869
|
+
* @param addressId - the address id
|
|
3870
|
+
* @returns `true` when the API accepted the deletion, `false` otherwise; it does not throw
|
|
3871
|
+
*/
|
|
3553
3872
|
async delete(storeRef, addressId) {
|
|
3554
3873
|
const res = await this.http.delete(
|
|
3555
3874
|
`/tenant/stores/${storeRef}/customers/address/${addressId}`
|
|
3556
3875
|
);
|
|
3557
3876
|
return res.success;
|
|
3558
3877
|
}
|
|
3878
|
+
/**
|
|
3879
|
+
* Makes a saved address the customer's default.
|
|
3880
|
+
*
|
|
3881
|
+
* @param storeRef - the store's ref or handle
|
|
3882
|
+
* @param addressId - the address id
|
|
3883
|
+
* @returns The updated address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3884
|
+
*/
|
|
3559
3885
|
async setDefault(storeRef, addressId) {
|
|
3560
3886
|
const res = await this.http.patch(
|
|
3561
3887
|
`/tenant/stores/${storeRef}/customers/address/${addressId}/set-default`
|
|
@@ -3569,12 +3895,26 @@ var ContentPagesApi = class {
|
|
|
3569
3895
|
constructor(http) {
|
|
3570
3896
|
this.http = http;
|
|
3571
3897
|
}
|
|
3898
|
+
/**
|
|
3899
|
+
* Lists the published content pages.
|
|
3900
|
+
*
|
|
3901
|
+
* @param storeRef - the store's ref or handle
|
|
3902
|
+
* @returns A page of content pages; throws {@link ApiClientError} when the API answers with an error
|
|
3903
|
+
*/
|
|
3572
3904
|
async getPublished(storeRef) {
|
|
3573
3905
|
const res = await this.http.get(
|
|
3574
3906
|
`/public/stores/${storeRef}/content-pages`
|
|
3575
3907
|
);
|
|
3576
3908
|
return unwrap(res);
|
|
3577
3909
|
}
|
|
3910
|
+
/**
|
|
3911
|
+
* Gets one published content page by slug.
|
|
3912
|
+
*
|
|
3913
|
+
* @param storeRef - the store's ref or handle
|
|
3914
|
+
* @param slug - the page slug
|
|
3915
|
+
* @param query - `include_seo_metadata` adds the SEO fields
|
|
3916
|
+
* @returns The page; throws {@link ApiClientError} when the API answers with an error
|
|
3917
|
+
*/
|
|
3578
3918
|
async getBySlug(storeRef, slug, query) {
|
|
3579
3919
|
const queryString = query ? stringify(query) : "";
|
|
3580
3920
|
const res = await this.http.get(
|
|
@@ -3589,6 +3929,14 @@ var MenusApi = class {
|
|
|
3589
3929
|
constructor(http) {
|
|
3590
3930
|
this.http = http;
|
|
3591
3931
|
}
|
|
3932
|
+
/**
|
|
3933
|
+
* Gets a navigation menu by its ref.
|
|
3934
|
+
*
|
|
3935
|
+
* @param storeRef - the store's ref or handle
|
|
3936
|
+
* @param ref - the menu ref
|
|
3937
|
+
* @param includeItems - `true` (the default) includes the menu items
|
|
3938
|
+
* @returns The menu, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3939
|
+
*/
|
|
3592
3940
|
async getByRef(storeRef, ref, includeItems = true) {
|
|
3593
3941
|
const query = includeItems ? "?include_items=true" : "";
|
|
3594
3942
|
const res = await this.http.get(
|
|
@@ -3634,9 +3982,21 @@ var AuthApi = class {
|
|
|
3634
3982
|
async register(payload) {
|
|
3635
3983
|
return this.http.post(this.publicPath("register"), payload, void 0);
|
|
3636
3984
|
}
|
|
3985
|
+
/**
|
|
3986
|
+
* Signs a customer in with email and password.
|
|
3987
|
+
*
|
|
3988
|
+
* @param payload - the login credentials
|
|
3989
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
3990
|
+
*/
|
|
3637
3991
|
async login(payload) {
|
|
3638
3992
|
return this.http.post(this.publicPath("login"), payload, void 0);
|
|
3639
3993
|
}
|
|
3994
|
+
/**
|
|
3995
|
+
* Exchanges a refresh token for a new token pair. The old refresh token stops working.
|
|
3996
|
+
*
|
|
3997
|
+
* @param refresh_token - the customer's current refresh token
|
|
3998
|
+
* @returns The new token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
3999
|
+
*/
|
|
3640
4000
|
async refresh(refresh_token) {
|
|
3641
4001
|
return this.http.post(
|
|
3642
4002
|
this.publicPath("refresh"),
|
|
@@ -3656,6 +4016,12 @@ var AuthApi = class {
|
|
|
3656
4016
|
void 0
|
|
3657
4017
|
);
|
|
3658
4018
|
}
|
|
4019
|
+
/**
|
|
4020
|
+
* Sends the email-verification message again.
|
|
4021
|
+
*
|
|
4022
|
+
* @param email - the address to verify
|
|
4023
|
+
* @returns The send result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4024
|
+
*/
|
|
3659
4025
|
async resendVerification(email) {
|
|
3660
4026
|
return this.http.post(
|
|
3661
4027
|
this.publicPath("resend-verification"),
|
|
@@ -3663,6 +4029,12 @@ var AuthApi = class {
|
|
|
3663
4029
|
void 0
|
|
3664
4030
|
);
|
|
3665
4031
|
}
|
|
4032
|
+
/**
|
|
4033
|
+
* Starts a password reset by emailing a reset link.
|
|
4034
|
+
*
|
|
4035
|
+
* @param email - the account's email address
|
|
4036
|
+
* @returns The send result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4037
|
+
*/
|
|
3666
4038
|
async forgotPassword(email) {
|
|
3667
4039
|
return this.http.post(
|
|
3668
4040
|
this.publicPath("forgot-password"),
|
|
@@ -3670,6 +4042,12 @@ var AuthApi = class {
|
|
|
3670
4042
|
void 0
|
|
3671
4043
|
);
|
|
3672
4044
|
}
|
|
4045
|
+
/**
|
|
4046
|
+
* Sets a new password using the token from the reset email.
|
|
4047
|
+
*
|
|
4048
|
+
* @param payload - the reset token and the new password
|
|
4049
|
+
* @returns The reset result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4050
|
+
*/
|
|
3673
4051
|
async resetPassword(payload) {
|
|
3674
4052
|
return this.http.post(
|
|
3675
4053
|
this.publicPath("reset-password"),
|
|
@@ -3685,6 +4063,12 @@ var AuthApi = class {
|
|
|
3685
4063
|
void 0
|
|
3686
4064
|
);
|
|
3687
4065
|
}
|
|
4066
|
+
/**
|
|
4067
|
+
* Emails a one-time sign-in code.
|
|
4068
|
+
*
|
|
4069
|
+
* @param email - the account's email address
|
|
4070
|
+
* @returns The send result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4071
|
+
*/
|
|
3688
4072
|
async requestOtp(email) {
|
|
3689
4073
|
return this.http.post(
|
|
3690
4074
|
this.publicPath("otp/request"),
|
|
@@ -3692,6 +4076,12 @@ var AuthApi = class {
|
|
|
3692
4076
|
void 0
|
|
3693
4077
|
);
|
|
3694
4078
|
}
|
|
4079
|
+
/**
|
|
4080
|
+
* Signs a customer in with the one-time code from the email.
|
|
4081
|
+
*
|
|
4082
|
+
* @param payload - the email and the code
|
|
4083
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4084
|
+
*/
|
|
3695
4085
|
async verifyOtp(payload) {
|
|
3696
4086
|
return this.http.post(
|
|
3697
4087
|
this.publicPath("otp/verify"),
|
|
@@ -3699,9 +4089,20 @@ var AuthApi = class {
|
|
|
3699
4089
|
void 0
|
|
3700
4090
|
);
|
|
3701
4091
|
}
|
|
4092
|
+
/**
|
|
4093
|
+
* Starts an anonymous (guest) session.
|
|
4094
|
+
*
|
|
4095
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4096
|
+
*/
|
|
3702
4097
|
async anonymous() {
|
|
3703
4098
|
return this.http.post(this.publicPath("anonymous"), void 0, void 0);
|
|
3704
4099
|
}
|
|
4100
|
+
/**
|
|
4101
|
+
* Gets the URL that starts Google sign-in.
|
|
4102
|
+
*
|
|
4103
|
+
* @param redirect_to - where to send the customer after sign-in, `/` by default
|
|
4104
|
+
* @returns The Google sign-in URL, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4105
|
+
*/
|
|
3705
4106
|
async getGoogleUrl(redirect_to = "/") {
|
|
3706
4107
|
const query = `?redirect_to=${encodeURIComponent(redirect_to)}`;
|
|
3707
4108
|
return this.http.get(
|
|
@@ -3709,6 +4110,12 @@ var AuthApi = class {
|
|
|
3709
4110
|
void 0
|
|
3710
4111
|
);
|
|
3711
4112
|
}
|
|
4113
|
+
/**
|
|
4114
|
+
* Completes Google sign-in by exchanging the authorization code.
|
|
4115
|
+
*
|
|
4116
|
+
* @param code - the authorization code Google returned
|
|
4117
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4118
|
+
*/
|
|
3712
4119
|
async exchangeGoogleCode(code) {
|
|
3713
4120
|
return this.http.post(
|
|
3714
4121
|
this.publicPath("google/exchange"),
|
|
@@ -3716,10 +4123,21 @@ var AuthApi = class {
|
|
|
3716
4123
|
void 0
|
|
3717
4124
|
);
|
|
3718
4125
|
}
|
|
4126
|
+
/**
|
|
4127
|
+
* Reads which sign-in methods this store has turned on.
|
|
4128
|
+
*
|
|
4129
|
+
* @returns The public auth configuration, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4130
|
+
*/
|
|
3719
4131
|
async getAuthConfig() {
|
|
3720
4132
|
return this.http.get(this.publicPath("config"), void 0);
|
|
3721
4133
|
}
|
|
3722
4134
|
// ---- access token required -------------------------------------------
|
|
4135
|
+
/**
|
|
4136
|
+
* Reads the signed-in customer's identity.
|
|
4137
|
+
*
|
|
4138
|
+
* @param access_token - the signed-in customer's access token
|
|
4139
|
+
* @returns The current identity, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4140
|
+
*/
|
|
3723
4141
|
async me(access_token) {
|
|
3724
4142
|
return this.http.get(
|
|
3725
4143
|
this.tenantPath("me"),
|
|
@@ -3734,6 +4152,12 @@ var AuthApi = class {
|
|
|
3734
4152
|
this.auth(access_token)
|
|
3735
4153
|
);
|
|
3736
4154
|
}
|
|
4155
|
+
/**
|
|
4156
|
+
* Signs the customer out of every session.
|
|
4157
|
+
*
|
|
4158
|
+
* @param access_token - the signed-in customer's access token
|
|
4159
|
+
* @returns The API's answer, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4160
|
+
*/
|
|
3737
4161
|
async logoutAll(access_token) {
|
|
3738
4162
|
return this.http.post(
|
|
3739
4163
|
this.tenantPath("logout-all"),
|
|
@@ -3741,6 +4165,13 @@ var AuthApi = class {
|
|
|
3741
4165
|
this.auth(access_token)
|
|
3742
4166
|
);
|
|
3743
4167
|
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Changes the signed-in customer's password.
|
|
4170
|
+
*
|
|
4171
|
+
* @param access_token - the signed-in customer's access token
|
|
4172
|
+
* @param payload - the current and the new password
|
|
4173
|
+
* @returns The API's answer, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4174
|
+
*/
|
|
3744
4175
|
async changePassword(access_token, payload) {
|
|
3745
4176
|
return this.http.post(
|
|
3746
4177
|
this.tenantPath("change-password"),
|
|
@@ -3748,6 +4179,13 @@ var AuthApi = class {
|
|
|
3748
4179
|
this.auth(access_token)
|
|
3749
4180
|
);
|
|
3750
4181
|
}
|
|
4182
|
+
/**
|
|
4183
|
+
* Starts an email change; the new address must be confirmed from the message sent to it.
|
|
4184
|
+
*
|
|
4185
|
+
* @param access_token - the signed-in customer's access token
|
|
4186
|
+
* @param payload - the new email address and the current password
|
|
4187
|
+
* @returns The change-email result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4188
|
+
*/
|
|
3751
4189
|
async changeEmail(access_token, payload) {
|
|
3752
4190
|
return this.http.post(
|
|
3753
4191
|
this.tenantPath("change-email"),
|
|
@@ -3762,12 +4200,25 @@ var MemoryTokenStorage = class {
|
|
|
3762
4200
|
constructor(initial = null) {
|
|
3763
4201
|
this.tokens = initial;
|
|
3764
4202
|
}
|
|
4203
|
+
/**
|
|
4204
|
+
* Reads the stored token pair.
|
|
4205
|
+
*
|
|
4206
|
+
* @returns The stored tokens, or `null` when none are stored
|
|
4207
|
+
*/
|
|
3765
4208
|
async get() {
|
|
3766
4209
|
return this.tokens;
|
|
3767
4210
|
}
|
|
4211
|
+
/**
|
|
4212
|
+
* Stores a token pair, replacing any earlier one.
|
|
4213
|
+
*
|
|
4214
|
+
* @param tokens - the access and refresh tokens
|
|
4215
|
+
*/
|
|
3768
4216
|
async set(tokens) {
|
|
3769
4217
|
this.tokens = tokens;
|
|
3770
4218
|
}
|
|
4219
|
+
/**
|
|
4220
|
+
* Forgets the stored token pair.
|
|
4221
|
+
*/
|
|
3771
4222
|
async clear() {
|
|
3772
4223
|
this.tokens = null;
|
|
3773
4224
|
}
|