@thefittingroom/sdk 0.0.10 → 0.0.11

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
@@ -63,6 +63,11 @@ shop.user.login(email, password)
63
63
  // Logout current user
64
64
  shop.user.logout()
65
65
 
66
+ // Set the brand userId, the internal userId used by the shop/brand
67
+ // This is a required field for requesting a VTO
68
+ // string | number
69
+ shop.user.setBrandUserId(brandUserId)
70
+
66
71
  // In order for the user to create an avatar, they'll need to download the mobile application.
67
72
  // This will send an SMS to the given phone number with a link to the iOS app
68
73
  // No spaces and must include country code e.g. +18005551234
@@ -113,4 +118,5 @@ UserNotLoggedInError
113
118
  NoColorwaySizeAssetsFoundError
114
119
  NoStylesFoundError
115
120
  RecommendedAvailableSizesError
121
+ BrandUserIdNotSetError
116
122
  ```
@@ -1,14 +1,17 @@
1
1
  import * as firebase from 'firebase/app';
2
2
  import * as firebaseAuth from 'firebase/auth';
3
3
  import { DocumentData, Firestore, QuerySnapshot } from 'firebase/firestore';
4
+ export type BrandUserId = string | number;
4
5
  export declare class FirebaseUser {
5
6
  private readonly firestore;
7
+ brandUserId: BrandUserId;
6
8
  private user;
7
9
  private readonly auth;
8
10
  constructor(firestore: Firestore, app: firebase.FirebaseApp);
9
11
  get id(): string;
10
12
  onInit(): Promise<boolean>;
11
13
  setUser(user: firebaseAuth.User): void;
14
+ setBrandUserId(brandUserId: BrandUserId): void;
12
15
  getToken(): Promise<string>;
13
16
  getUserProfile(): Promise<DocumentData>;
14
17
  watchUserProfileForChanges(predicate: (data: QuerySnapshot<DocumentData>) => Promise<boolean>, timeout: number): Promise<DocumentData>;
@@ -29,4 +29,7 @@ export declare class RecommendedAvailableSizesError extends Error {
29
29
  available_sizes: string[];
30
30
  constructor(recommended_size: string, available_sizes: string[]);
31
31
  }
32
+ export declare class BrandUserIdNotSetError extends Error {
33
+ constructor();
34
+ }
32
35
  export declare const AvatarNotCreated = "avatar not created";
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v0.0.10 (2023-07-31T23:26:47.153Z)
2
+ * thefittingroom v0.0.11 (2023-09-04T22:52:56.755Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  /**
@@ -22768,6 +22768,12 @@ class RecommendedAvailableSizesError extends Error {
22768
22768
  this.available_sizes = available_sizes;
22769
22769
  }
22770
22770
  }
22771
+ class BrandUserIdNotSetError extends Error {
22772
+ constructor() {
22773
+ super('brand user id not set');
22774
+ this.name = 'BrandUserIdNotSetError';
22775
+ }
22776
+ }
22771
22777
  // Backend responses
22772
22778
  const AvatarNotCreated = 'avatar not created';
22773
22779
 
@@ -22780,12 +22786,14 @@ var errors = /*#__PURE__*/Object.freeze({
22780
22786
  NoColorwaySizeAssetsFoundError: NoColorwaySizeAssetsFoundError,
22781
22787
  NoStylesFoundError: NoStylesFoundError,
22782
22788
  RecommendedAvailableSizesError: RecommendedAvailableSizesError,
22789
+ BrandUserIdNotSetError: BrandUserIdNotSetError,
22783
22790
  AvatarNotCreated: AvatarNotCreated
22784
22791
  });
22785
22792
 
22786
22793
  class FirebaseUser {
22787
22794
  constructor(firestore, app) {
22788
22795
  this.firestore = firestore;
22796
+ this.brandUserId = null;
22789
22797
  this.auth = getAuth(app);
22790
22798
  this.auth.setPersistence(browserLocalPersistence);
22791
22799
  }
@@ -22805,6 +22813,9 @@ class FirebaseUser {
22805
22813
  setUser(user) {
22806
22814
  this.user = user;
22807
22815
  }
22816
+ setBrandUserId(brandUserId) {
22817
+ this.brandUserId = brandUserId;
22818
+ }
22808
22819
  async getToken() {
22809
22820
  var _a;
22810
22821
  if (!((_a = this.user) === null || _a === void 0 ? void 0 : _a.uid))
@@ -23108,7 +23119,11 @@ class TfrShop {
23108
23119
  async requestColorwaySizeAssetFrames(colorwaySizeAssetId) {
23109
23120
  if (!this.isLoggedIn)
23110
23121
  throw new UserNotLoggedInError();
23111
- await Fetcher.Post(this.user, `/colorway-size-assets/${colorwaySizeAssetId}/frames`);
23122
+ if (!this.user.brandUserId)
23123
+ throw new BrandUserIdNotSetError();
23124
+ await Fetcher.Post(this.user, `/colorway-size-assets/${colorwaySizeAssetId}/frames`, {
23125
+ brand_user_id: String(this.user.brandUserId),
23126
+ });
23112
23127
  }
23113
23128
  async getColorwaySizeAssetFrames(colorwaySizeAssetSKU) {
23114
23129
  var _a, _b, _c;