@devite/shopware-client 1.3.3 → 1.4.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/dist/index.cjs CHANGED
@@ -12222,17 +12222,22 @@ class ContextClient extends Client {
12222
12222
  * @throws {Error} if the request failed
12223
12223
  */
12224
12224
  async getContext() {
12225
- const response = await this.get("/context");
12226
- if (response.statusCode === 200) return response.body;
12225
+ const response = await this.get(
12226
+ "/context",
12227
+ this.client.withContextToken()
12228
+ );
12229
+ if (response.statusCode === 200)
12230
+ return response.body.data;
12227
12231
  throw new ShopwareError("Failed to fetch context", response);
12228
12232
  }
12229
12233
  /**
12230
12234
  * @throws {Error} if the request failed
12231
12235
  */
12232
12236
  async updateContext(context) {
12233
- const response = await this.patch("/context", {
12234
- body: new JsonPayload(context)
12235
- });
12237
+ const response = await this.patch(
12238
+ "/context",
12239
+ this.client.withContextToken({ body: new JsonPayload(context) })
12240
+ );
12236
12241
  if (response.statusCode === 200)
12237
12242
  return response.body.data;
12238
12243
  throw new ShopwareError("Failed to update context", response);
@@ -12707,6 +12712,13 @@ class StoreShopwareClient extends ShopwareClient {
12707
12712
  }
12708
12713
  });
12709
12714
  }
12715
+ setContextToken(token) {
12716
+ this.authStore.getOrCreateEntry(new ContextTokenEntry()).save({
12717
+ statusCode: 200,
12718
+ statusMessage: "OK",
12719
+ headers: new Headers({ "sw-context-token": token })
12720
+ });
12721
+ }
12710
12722
  withContextToken(options = {}) {
12711
12723
  const entry = this.authStore.getEntry(
12712
12724
  AuthenticationType.CONTEXT_TOKEN