@revenuecat/purchases-js 0.6.0 → 0.8.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.
@@ -171,7 +171,7 @@ export declare enum ErrorCode {
171
171
  }
172
172
 
173
173
  /**
174
- * Parameters for the {@link Purchases.getOfferings}` method.
174
+ * Parameters for the {@link Purchases.getOfferings} method.
175
175
  * @public
176
176
  */
177
177
  export declare interface GetOfferingsParams {
@@ -419,6 +419,11 @@ export declare interface PresentedOfferingContext {
419
419
  * The targeting context used to obtain this object.
420
420
  */
421
421
  readonly targetingContext: TargetingContext | null;
422
+ /**
423
+ * If obtained this information from a placement,
424
+ * the identifier of the placement.
425
+ */
426
+ readonly placementIdentifier: string | null;
422
427
  }
423
428
 
424
429
  /**
@@ -427,9 +432,14 @@ export declare interface PresentedOfferingContext {
427
432
  */
428
433
  export declare interface Price {
429
434
  /**
430
- * Price in full units of the currency.
435
+ * Price in cents of the currency.
436
+ * @deprecated - Use {@link Price.amountMicros} instead.
431
437
  */
432
438
  readonly amount: number;
439
+ /**
440
+ * Price in micro-units of the currency. For example, $9.99 is represented as 9990000.
441
+ */
442
+ readonly amountMicros: number;
433
443
  /**
434
444
  * Returns ISO 4217 currency code for price.
435
445
  * For example, if price is specified in British pounds sterling,
@@ -602,11 +612,27 @@ export declare class Purchases {
602
612
  * @throws {@link PurchasesError} if the API key or user id are invalid.
603
613
  */
604
614
  static configure(apiKey: string, appUserId: string, httpConfig?: HttpConfig): Purchases;
615
+ /**
616
+ * Loads and caches some optional data in the Purchases SDK.
617
+ * Currently only fetching branding information. You can call this method
618
+ * after configuring the SDK to speed up the first call to
619
+ * {@link Purchases.purchase}.
620
+ */
621
+ preload(): Promise<void>;
622
+ private hasLoadedResources;
605
623
  /**
606
624
  * Fetch the configured offerings for this user. You can configure these
607
625
  * in the RevenueCat dashboard.
608
626
  */
609
627
  getOfferings(params?: GetOfferingsParams): Promise<Offerings>;
628
+ /**
629
+ * Retrieves a specific offering by a placement identifier.
630
+ * For more info see https://www.revenuecat.com/docs/tools/targeting
631
+ * @param placementIdentifier - The placement identifier to retrieve the offering for.
632
+ * @param params - The parameters object to customise the offerings fetch. Check {@link GetOfferingsParams}
633
+ */
634
+ getCurrentOfferingForPlacement(placementIdentifier: string, params?: GetOfferingsParams): Promise<Offering | null>;
635
+ private getAllOfferings;
610
636
  /**
611
637
  * Convenience method to check whether a user is entitled to a specific
612
638
  * entitlement. This will use {@link Purchases.getCustomerInfo} under the hood.
@@ -685,6 +711,10 @@ export declare class Purchases {
685
711
  * can be useful for debugging and logging.
686
712
  */
687
713
  readonly underlyingErrorMessage?: string | null | undefined;
714
+ /**
715
+ * Contains extra information that is available in certain types of errors.
716
+ */
717
+ readonly extra?: PurchasesErrorExtra | undefined;
688
718
  constructor(
689
719
  /**
690
720
  * Error code for the error. This is useful to appropriately react to
@@ -699,10 +729,28 @@ export declare class Purchases {
699
729
  * Underlying error message. This provides more details on the error and
700
730
  * can be useful for debugging and logging.
701
731
  */
702
- underlyingErrorMessage?: string | null | undefined);
732
+ underlyingErrorMessage?: string | null | undefined,
733
+ /**
734
+ * Contains extra information that is available in certain types of errors.
735
+ */
736
+ extra?: PurchasesErrorExtra | undefined);
703
737
  toString: () => string;
704
738
  }
705
739
 
740
+ /**
741
+ * Extra information that is available in certain types of errors.
742
+ */
743
+ export declare interface PurchasesErrorExtra {
744
+ /**
745
+ * If this is a request error, the HTTP status code of the response.
746
+ */
747
+ readonly statusCode?: number;
748
+ /**
749
+ * If this is a RevenueCat backend error, the error code from the servers.
750
+ */
751
+ readonly backendErrorCode?: number;
752
+ }
753
+
706
754
  /**
707
755
  * The store where the user originally subscribed.
708
756
  * @public