@thefittingroom/sdk 0.0.8 → 0.0.9

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 CHANGED
@@ -58,30 +58,50 @@ const shop = initShop(brandId, env)
58
58
  await shop.onInit()
59
59
 
60
60
  // Login user with session
61
- shop.user.login(username, password)
61
+ shop.user.login(email, password)
62
62
 
63
63
  // Logout current user
64
64
  shop.user.logout()
65
65
 
66
- // Submit telephone number for link to iOS app
66
+ // In order for the user to create an avatar, they'll need to download the mobile application.
67
+ // This will send an SMS to the given phone number with a link to the iOS app
67
68
  // No spaces and must include country code e.g. +18005551234
68
69
  shop.submitTelephoneNumber(tel)
70
+
71
+ // await for the avatar creation
72
+ // Returns boolean on whether the avatar is created or not after the configured `avatarTimeout` period
73
+ shop.awaitAvatarCreated()
69
74
  ```
70
75
 
71
76
  #### Shop
72
77
 
78
+ We'll make references to `sku` several times here. This is the unique identifier that matches a styles particular size
79
+ from your inventory to our system.
80
+
73
81
  ```typescript
74
- // returns frames: types.TryOnFrames
75
- shop.tryOn(colorwaySizeAssetSku)
82
+ // A good first step would be to ensure your style and size exists in the fitting room system before executing any of the
83
+ // following functions. You'll get back some data about the style(s), such as the ID of the style, which you can use
84
+ // for the getRecommendedSizes function below.
85
+ // ids: number[] or skus: string[]
86
+ // At least one parameter must not be null
87
+ shop.getStyles(ids, skus)
76
88
 
77
- // await for the avatar creation
78
- shop.awaitAvatarCreated()
89
+ // get recommended sizes for a particular style
90
+ // The styleID can be extracted from the previous getStyles function call.
91
+ const sizeRecommendation = shop.getRecommendedSizes(styleID)
79
92
 
80
- // get recommended sizes for use
81
- shop.getRecommendedSizes()
93
+ // get recommended sizes label for a particular style
94
+ // returns: { recommendedSizeLabel, availableSizeLabels }
95
+ // recommendedSizeLabel: string
96
+ // availableSizeLabels: string[]
97
+ const { recommendedSizeLabel, availableSizeLabels } = shop.getRecommendedSizesLabels(styleID)
82
98
 
83
- // get available styles by ids: number[] or skus: string[]
84
- shop.getStyles(ids, skus)
99
+ // Once the user has downloaded the mobile application and has created an avatar, they may now virtually try on a size.
100
+ // The size they try on must be one of the recommended sizes from the previous function call. or an error will get returned.
101
+ // returns frames: types.TryOnFrames
102
+ // These `frames` are images that can be used to cycle through the VTO 360 degrees.
103
+ // NOTE: this process can take a minute or two
104
+ const frames = await this.shop.tryOn(sku)
85
105
  ```
86
106
 
87
107
  #### Errors
@@ -12,7 +12,11 @@ export declare class TfrShop {
12
12
  onInit(): Promise<boolean>;
13
13
  tryOn(colorwaySizeAssetSku: string): Promise<types.TryOnFrames>;
14
14
  awaitAvatarCreated(): Promise<boolean>;
15
- getRecommendedSizes(brandStyleId: string): Promise<SizeRecommendation>;
15
+ getRecommendedSizes(styleId: string): Promise<SizeRecommendation>;
16
+ getRecommendedSizesLabels(styleId: string): Promise<{
17
+ recommendedSizeLabel: string;
18
+ availableSizeLabels: string[];
19
+ }>;
16
20
  getStyles(ids: number[], skus: string[]): Promise<Map<number, types.FirestoreStyle>>;
17
21
  submitTelephoneNumber(tel: string): Promise<void>;
18
22
  private awaitColorwaySizeAssetFrames;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v0.0.8 (2023-07-19T17:34:22.852Z)
2
+ * thefittingroom v0.0.9 (2023-07-26T23:07:17.052Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  /**
@@ -22993,11 +22993,11 @@ class TfrShop {
22993
22993
  const userProfile = snapshot.docs[0].data();
22994
22994
  return userProfile.avatar_status === 'CREATED';
22995
22995
  }
22996
- async getRecommendedSizes(brandStyleId) {
22996
+ async getRecommendedSizes(styleId) {
22997
22997
  if (!this.isLoggedIn)
22998
22998
  throw new UserNotLoggedInError();
22999
22999
  try {
23000
- const res = await Fetcher.Get(this.user, `/styles/${brandStyleId}/recommendation`);
23000
+ const res = await Fetcher.Get(this.user, `/styles/${styleId}/recommendation`);
23001
23001
  const json = await res.json();
23002
23002
  return json;
23003
23003
  }
@@ -23007,6 +23007,12 @@ class TfrShop {
23007
23007
  throw error;
23008
23008
  }
23009
23009
  }
23010
+ async getRecommendedSizesLabels(styleId) {
23011
+ const sizeRecommendation = await this.getRecommendedSizes(styleId);
23012
+ const recommendedSizeLabel = sizeRecommendation.recommended_sizes.label || sizeRecommendation.recommended_sizes.size_value.size;
23013
+ const availableSizeLabels = sizeRecommendation.available_sizes.map((size) => size.label || size.size_value.size);
23014
+ return { recommendedSizeLabel, availableSizeLabels };
23015
+ }
23010
23016
  async getStyles(ids, skus) {
23011
23017
  const constraints = [rl('brand_id', '==', this.brandId)];
23012
23018
  if ((ids === null || ids === void 0 ? void 0 : ids.length) > 0)