@stigg/js-client-sdk 2.18.1 → 2.19.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.
@@ -3,12 +3,14 @@ import SdkConfigurationApi from './SdkConfigurationApi';
3
3
  import PaywallApi from './PaywallApi';
4
4
  import CustomersApi from './CustomersApi';
5
5
  import CouponsApi from './CouponsApi';
6
+ import SubscriptionsApi from './SubscriptionsApi';
6
7
  import SubscriptionEstimationsApi from './SubscriptionEstimationsApi';
7
8
  import MockPaywallApi from './MockPaywallApi';
8
9
  import { EdgeApiClient } from './EdgeApiClient';
9
10
  declare class ApiGateway {
10
11
  sdkConfiguration: SdkConfigurationApi;
11
12
  paywall: PaywallApi;
13
+ subscriptions: SubscriptionsApi;
12
14
  mockPaywall: MockPaywallApi;
13
15
  customers: CustomersApi;
14
16
  coupons: CouponsApi;
@@ -1,10 +1,11 @@
1
1
  import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
2
- import { EstimateSubscription, EstimateSubscriptionUpdate } from '../models';
3
- import { EstimateSubscriptionMutation, EstimateSubscriptionUpdateMutation } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { PreviewSubscription, EstimateSubscription, EstimateSubscriptionUpdate } from '../models';
3
+ import { EstimateSubscriptionMutation, EstimateSubscriptionUpdateMutation, PreviewSubscriptionMutation } from '@stigg/api-client-js/src/generated/sdk';
4
4
  declare class SubscriptionEstimationsApi {
5
5
  private readonly client;
6
6
  constructor(client: ApolloClient<NormalizedCacheObject>);
7
7
  estimateSubscription(input: EstimateSubscription): Promise<import("@apollo/client/core").FetchResult<EstimateSubscriptionMutation, Record<string, any>, Record<string, any>>>;
8
8
  estimateSubscriptionUpdate(input: EstimateSubscriptionUpdate): Promise<import("@apollo/client/core").FetchResult<EstimateSubscriptionUpdateMutation, Record<string, any>, Record<string, any>>>;
9
+ previewSubscription(input: PreviewSubscription): Promise<import("@apollo/client/core").FetchResult<PreviewSubscriptionMutation, Record<string, any>, Record<string, any>>>;
9
10
  }
10
11
  export default SubscriptionEstimationsApi;
@@ -0,0 +1,17 @@
1
+ import { CheckoutStateQuery, ApplySubscriptionMutation } from '@stigg/api-client-js/src/generated/sdk';
2
+ import { ApolloClient, NormalizedCacheObject } from '@apollo/client/core';
3
+ import { ApplySubscription, GetCheckoutState } from '../models';
4
+ export declare type ApplySubscriptionParams = ApplySubscription & {
5
+ customerId: string;
6
+ };
7
+ export declare type GetCheckoutStateParams = GetCheckoutState & {
8
+ customerId: string;
9
+ };
10
+ declare class SubscriptionsApi {
11
+ private readonly client;
12
+ constructor(client: ApolloClient<NormalizedCacheObject>);
13
+ applySubscription({ customerId, planId, paymentMethodId, addons, billableFeatures, billingCountryCode, billingId, billingInformation, billingPeriod, metadata, promotionCode, resourceId, skipTrial, startDate, unitQuantity, }: ApplySubscriptionParams): Promise<import("@apollo/client/core").FetchResult<ApplySubscriptionMutation, Record<string, any>, Record<string, any>>>;
14
+ checkoutState({ customerId, resourceId, planId, billingCountryCode }: GetCheckoutStateParams): Promise<import("@apollo/client/core").ApolloQueryResult<CheckoutStateQuery>>;
15
+ private mapBillingInformation;
16
+ }
17
+ export default SubscriptionsApi;
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BooleanEntitlement, Coupon, Customer, Entitlement, GetBooleanEntitlement, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Subscription, WaitForCheckoutCompleted, CustomerPortal, Paywall, EstimateSubscription, SubscriptionPreview, EstimateSubscriptionUpdate, GetCustomerPortal, GetActiveSubscriptions, FetchUsageHistory, UsageHistoryPoint } from './models';
2
1
  import { ClientConfiguration } from './configuration';
2
+ import { BooleanEntitlement, Coupon, Customer, CustomerPortal, Entitlement, EstimateSubscription, EstimateSubscriptionUpdate, FetchUsageHistory, GetActiveSubscriptions, GetBooleanEntitlement, GetCheckoutStateResults, GetCheckoutState, GetCustomerPortal, GetMeteredEntitlement, GetNumericEntitlement, GetPaywall, MeteredEntitlement, NumericEntitlement, Paywall, Subscription, SubscriptionPreview, UsageHistoryPoint, WaitForCheckoutCompleted, ApplySubscription, ApplySubscriptionResults, PreviewSubscription } from './models';
3
3
  import { EventNames, Events } from './services/eventEmitter';
4
4
  export interface StiggClient {
5
5
  isCustomerLoaded: boolean;
@@ -15,6 +15,8 @@ export interface StiggClient {
15
15
  clearResource: () => void;
16
16
  getPaywall: (params?: GetPaywall) => Promise<Paywall>;
17
17
  getCustomer: () => Promise<Customer>;
18
+ getCheckoutState: (params: GetCheckoutState) => Promise<GetCheckoutStateResults>;
19
+ applySubscription: (params: ApplySubscription) => Promise<ApplySubscriptionResults>;
18
20
  getActiveSubscriptions: (params?: GetActiveSubscriptions) => Promise<Subscription[]>;
19
21
  getCoupons(): Promise<Coupon[]>;
20
22
  getEntitlements: (resourceId?: string) => Promise<Entitlement[]>;
@@ -26,6 +28,7 @@ export interface StiggClient {
26
28
  getCustomerPortal(params?: GetCustomerPortal): Promise<CustomerPortal>;
27
29
  estimateSubscription(estimateSubscription: EstimateSubscription): Promise<SubscriptionPreview>;
28
30
  estimateSubscriptionUpdate(estimateSubscriptionUpdate: EstimateSubscriptionUpdate): Promise<SubscriptionPreview>;
31
+ previewSubscription(previewSubscription: PreviewSubscription): Promise<SubscriptionPreview>;
29
32
  }
30
33
  export declare class Stigg implements StiggClient {
31
34
  private readonly apiGateway;
@@ -145,6 +148,18 @@ export declare class Stigg implements StiggClient {
145
148
  * @returns {Promise<CustomerPortal>}
146
149
  */
147
150
  getCustomerPortal({ resourceId, productId }?: GetCustomerPortal): Promise<CustomerPortal>;
151
+ /**
152
+ * Get customer checkout details
153
+ * @param {GetCheckoutState} parameters
154
+ * @returns {Promise<GetCheckoutStateResults>}
155
+ */
156
+ getCheckoutState({ planId, resourceId, billingCountryCode, }: GetCheckoutState): Promise<GetCheckoutStateResults>;
157
+ /**
158
+ * Get customer checkout details
159
+ * @param {ApplySubscription} parameters
160
+ * @returns {Promise<ApplySubscriptionResults>}
161
+ */
162
+ applySubscription(applySubscriptionInput: ApplySubscription): Promise<ApplySubscriptionResults>;
148
163
  /**
149
164
  * Fetch customer usage history of a feature.
150
165
  * @return {Promise<UsageHistoryPoint[]>} Array of usage history as data points.
@@ -169,6 +184,12 @@ export declare class Stigg implements StiggClient {
169
184
  * @param {EstimateSubscriptionUpdate} estimateSubscriptionUpdate
170
185
  */
171
186
  estimateSubscriptionUpdate(estimateSubscriptionUpdate: EstimateSubscriptionUpdate): Promise<SubscriptionPreview>;
187
+ /**
188
+ * Estimate checkout
189
+ * @return {Promise<SubscriptionPreview>} Preview of the subscription.
190
+ * @param {PreviewSubscription} previewSubscription
191
+ */
192
+ previewSubscription(previewSubscription: PreviewSubscription): Promise<SubscriptionPreview>;
172
193
  /**
173
194
  * Waits for a subscription to be activated after a completed checkout.
174
195
  * This method should be called on page load after the customer is redirected to the success URL.