@rechargeapps/storefront-client 0.9.0 → 0.11.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.d.ts CHANGED
@@ -335,6 +335,9 @@ interface Charge {
335
335
  /** The date time at which the Charge was most recently updated. */
336
336
  updated_at: IsoDateString;
337
337
  }
338
+ interface ChargeResponse {
339
+ charge: Charge;
340
+ }
338
341
  interface ChargeListResponse {
339
342
  next_cursor: null | string;
340
343
  previous_cursor: null | string;
@@ -503,6 +506,12 @@ interface Address {
503
506
  /** The date and time when the address was last updated. */
504
507
  updated_at: IsoDateString;
505
508
  }
509
+ interface SkipFutureChargeAddressResponse {
510
+ charge: Charge;
511
+ }
512
+ interface AddressResponse {
513
+ address: Address;
514
+ }
506
515
  interface AddressListResponse {
507
516
  next_cursor: null | string;
508
517
  previous_cursor: null | string;
@@ -519,7 +528,7 @@ interface AddressListParams extends ListParams<AddressSortBy> {
519
528
 
520
529
  interface Session {
521
530
  apiToken: string;
522
- customerId: string;
531
+ customerId?: string;
523
532
  }
524
533
 
525
534
  /** Returns all addresses from the store, or addresses for the customer given in the parameter. */
@@ -541,7 +550,7 @@ declare function mergeAddresses(session: Session, mergeRequest: MergeAddressesRe
541
550
  */
542
551
  declare function skipFutureCharge(session: Session, id: string | number, skipRequest: SkipFutureChargeAddressRequest): Promise<Charge>;
543
552
 
544
- declare function loginShopifyAppProxy(): Promise<Session | null>;
553
+ declare function loginShopifyAppProxy(): Promise<Session>;
545
554
  declare function loginShopifyApi(customerAccessToken: string, storefrontAccessToken: string): Promise<Session | null>;
546
555
 
547
556
  declare function getCharge(session: Session, id: number | string): Promise<Charge>;
@@ -586,6 +595,11 @@ interface RequestOptionsHeaders {
586
595
  }
587
596
  declare type RequestOptions = GetRequestOptions & CRUDRequestOptions & RequestOptionsHeaders;
588
597
 
598
+ interface LoginResponse {
599
+ api_token: string;
600
+ customer_id?: string;
601
+ }
602
+
589
603
  interface BundleSelection {
590
604
  collectionId: string;
591
605
  externalProductId: string;
@@ -946,24 +960,56 @@ interface CDNBundleSettings {
946
960
  variants: CDNBundleVariant[];
947
961
  }
948
962
 
949
- declare type StorefrontEnvironment = 'stage' | 'prod';
950
- interface StorefrontOptions {
951
- storeIdentifier: string;
952
- /** This is only for internal use. Sets the environment where data is fetched from. */
953
- environment: StorefrontEnvironment;
963
+ interface Customer {
964
+ /** Unique numeric identifier for the Customer. */
965
+ id: number;
966
+ /** An object containing analytics data associated with the customer. */
967
+ analytics_data: AnalyticsData;
968
+ /** The date and time when the customer was created. */
969
+ created_at: IsoDateString;
970
+ /** The email address of the customer. */
971
+ email: string;
972
+ /** An object containing external ids for the customer record. */
973
+ external_customer_id: ExternalId;
974
+ /** Date when first charge was processed for the customer. */
975
+ first_charge_processed_at: IsoDateString;
976
+ /** The customer’s first name. */
977
+ first_name: string;
978
+ /** A boolean that indicates if the customer has a payment method that is in dunning (failed charge). */
979
+ has_payment_method_in_dunning: boolean;
980
+ /** Is the payment method valid or not. */
981
+ has_valid_payment_method: boolean;
982
+ /** The unique string identifier used in a customers portal link. */
983
+ hash: string;
984
+ /** The customer’s last name. */
985
+ last_name: string;
986
+ /** The number of active subscriptions on addresses associated with the customer. */
987
+ subscriptions_active_count: number;
988
+ /** The total number of subscriptions created on addresses associated with the customer. */
989
+ subscriptions_total_count: number;
990
+ /** The date and time when the customer was last updated. */
991
+ updated_at: IsoDateString;
992
+ }
993
+ declare type OptionalUpdateProps$2 = 'email' | 'first_name' | 'last_name' | 'external_customer_id';
994
+ declare type UpdateCustomerRequest = Partial<Pick<Customer, OptionalUpdateProps$2>>;
995
+ interface CustomerDeliveryScheduleParams {
996
+ delivery_count_future?: number;
997
+ future_internal?: number;
998
+ date_max?: IsoDateString;
999
+ }
1000
+ interface Delivery {
1001
+ date: IsoDateString;
1002
+ orders: Order[];
1003
+ }
1004
+ interface CustomerDeliveryScheduleResponse {
1005
+ customer: {
1006
+ id: number;
1007
+ email: string;
1008
+ first_name: string;
1009
+ last_name: string;
1010
+ };
1011
+ deliveries: Delivery[];
954
1012
  }
955
-
956
- declare function getCDNProduct(externalProductId: string | number): Promise<CDNProduct>;
957
- declare function getCDNStoreSettings(): Promise<CDNStoreSettings>;
958
- declare function getCDNWidgetSettings(): Promise<CDNWidgetSettings>;
959
- declare function getCDNProductsAndSettings(): Promise<CDNProductsAndSettings>;
960
- declare function getCDNProducts(): Promise<CDNProductKeyObject[]>;
961
- declare function getCDNProductAndSettings(externalProductId: string | number): Promise<CDNProductAndSettings>;
962
- declare function getCDNBundleSettings(externalProductId: string | number): Promise<CDNBundleSettings | null | undefined>;
963
- declare function resetCDNCache(): Promise<void>;
964
-
965
- declare function getBundleId(bundle: Bundle): Promise<string>;
966
- declare function validateBundle(bundle: Bundle): Promise<boolean>;
967
1013
 
968
1014
  declare type MembershipStatus = 'active' | 'inactive';
969
1015
  interface Membership {
@@ -979,6 +1025,9 @@ interface Membership {
979
1025
  subscription_cancelled_at: IsoDateString | null;
980
1026
  image?: string;
981
1027
  }
1028
+ interface MembershipResponse {
1029
+ membership: Membership;
1030
+ }
982
1031
  interface MembershipListResponse {
983
1032
  next_cursor: null | string;
984
1033
  previous_cursor: null | string;
@@ -1011,15 +1060,6 @@ interface CancelMembershipRequest {
1011
1060
  expires_at: IsoDateString;
1012
1061
  }
1013
1062
 
1014
- /** Retrieves membership information for passed in id */
1015
- declare function getMembership(session: Session, id: string | number): Promise<Membership>;
1016
- /** Retrieves a list of memberships */
1017
- declare function listMemberships(session: Session, query?: MembershipListParams): Promise<MembershipListResponse>;
1018
- /** Cancels a membership */
1019
- declare function cancelMembership(session: Session, id: string | number, cancelRequest: CancelMembershipRequest): Promise<Membership>;
1020
- /** Activates a membership */
1021
- declare function activateMembership(session: Session, id: string | number, activateRequest: ActivateMembershipRequest): Promise<Membership>;
1022
-
1023
1063
  interface Onetime {
1024
1064
  /** Unique numeric identifier for the Onetime purchase. */
1025
1065
  id: number;
@@ -1066,8 +1106,8 @@ interface CreateProps {
1066
1106
  add_to_next_charge?: boolean;
1067
1107
  }
1068
1108
  declare type CreateOnetimeRequest = SubType<Onetime, RequiredCreateProps$1, OptionalCreateProps$1> & CreateProps;
1069
- declare type OptionalUpdateProps$2 = 'address_id' | 'next_charge_scheduled_at' | 'properties' | 'quantity' | 'external_variant_id' | 'sku';
1070
- declare type UpdateOnetimeRequest = Partial<Pick<Onetime, OptionalUpdateProps$2>>;
1109
+ declare type OptionalUpdateProps$1 = 'address_id' | 'next_charge_scheduled_at' | 'properties' | 'quantity' | 'external_variant_id' | 'sku';
1110
+ declare type UpdateOnetimeRequest = Partial<Pick<Onetime, OptionalUpdateProps$1>>;
1071
1111
  interface OnetimesResponse {
1072
1112
  next_cursor: null | string;
1073
1113
  previous_cursor: null | string;
@@ -1076,14 +1116,21 @@ interface OnetimesResponse {
1076
1116
  declare type OnetimesSortBy = 'id-asc' | 'id-desc' | 'created_at-asc' | 'created_at-desc' | 'updated_at-asc' | 'updated_at-desc';
1077
1117
  declare type OnetimeListParams = ListParams<OnetimesSortBy>;
1078
1118
 
1079
- declare function getOnetime(session: Session, id: string | number): Promise<Onetime>;
1080
- declare function listOnetimes(session: Session, query?: OnetimeListParams): Promise<OnetimesResponse>;
1081
- declare function createOnetime(session: Session, createRequest: CreateOnetimeRequest): Promise<Onetime>;
1082
- declare function updateOnetime(session: Session, id: string | number, updateRequest: UpdateOnetimeRequest): Promise<Onetime>;
1083
- declare function deleteOnetime(session: Session, id: string | number): Promise<void>;
1084
-
1085
- declare function getOrder(session: Session, id: string | number): Promise<Order>;
1086
- declare function listOrders(session: Session, query?: OrderListParams): Promise<OrdersResponse>;
1119
+ /** @internal */
1120
+ declare type StorefrontEnvironment = 'stage' | 'prod';
1121
+ /** @internal */
1122
+ interface StorefrontOptions {
1123
+ storeIdentifier: string;
1124
+ /** Recharge storefront access token */
1125
+ storefrontAccessToken?: string;
1126
+ /** This is only for internal use. Sets the environment where data is fetched from. */
1127
+ environment: StorefrontEnvironment;
1128
+ }
1129
+ interface InitOptions {
1130
+ storeIdentifier?: string;
1131
+ /** Recharge storefront access token */
1132
+ storefrontAccessToken?: string;
1133
+ }
1087
1134
 
1088
1135
  interface ChannelSettings {
1089
1136
  api: {
@@ -1149,9 +1196,6 @@ interface PlanListParams extends ListParams<PlanSortBy> {
1149
1196
  type?: PlanType;
1150
1197
  }
1151
1198
 
1152
- declare function getPlan(session: Session, id: string | number): Promise<Plan>;
1153
- declare function listPlans(session: Session, query?: PlanListParams): Promise<PlansResponse>;
1154
-
1155
1199
  interface Subscription {
1156
1200
  /** Unique numeric identifier for the subscription. */
1157
1201
  id: number;
@@ -1248,8 +1292,8 @@ interface SubscriptionListParams extends ListParams<SubscriptionSortBy> {
1248
1292
  declare type RequiredCreateProps = 'address_id' | 'charge_interval_frequency' | 'external_variant_id' | 'next_charge_scheduled_at' | 'order_interval_frequency' | 'order_interval_unit' | 'quantity';
1249
1293
  declare type OptionalCreateProps = 'expire_after_specific_number_of_charges' | 'order_day_of_month' | 'order_day_of_week' | 'external_product_id' | 'product_title' | 'properties' | 'status';
1250
1294
  declare type CreateSubscriptionRequest = SubType<Subscription, RequiredCreateProps, OptionalCreateProps>;
1251
- declare type OptionalUpdateProps$1 = 'charge_interval_frequency' | 'expire_after_specific_number_of_charges' | 'order_day_of_month' | 'order_day_of_week' | 'order_interval_frequency' | 'order_interval_unit' | 'quantity' | 'external_product_id' | 'external_variant_id' | 'properties' | 'sku' | 'sku_override';
1252
- declare type UpdateSubscriptionRequest = Partial<Pick<Subscription, OptionalUpdateProps$1>>;
1295
+ declare type OptionalUpdateProps = 'charge_interval_frequency' | 'expire_after_specific_number_of_charges' | 'order_day_of_month' | 'order_day_of_week' | 'order_interval_frequency' | 'order_interval_unit' | 'quantity' | 'external_product_id' | 'external_variant_id' | 'properties' | 'sku' | 'sku_override';
1296
+ declare type UpdateSubscriptionRequest = Partial<Pick<Subscription, OptionalUpdateProps>>;
1253
1297
  interface UpdateSubscriptionParams {
1254
1298
  /** Controls whether the QUEUED charges linked to the subscription should be regenerated upon subscription update. By default the flag is set to false which will delay charge regeneration 5 seconds. This enables running multiple calls to perform changes and receive responses much faster since the API won’t wait for a charge regeneration to complete. Setting this parameter to true will cause charge regeneration to complete before returning a response. */
1255
1299
  commit?: boolean;
@@ -1260,6 +1304,39 @@ interface CancelSubscriptionRequest {
1260
1304
  send_email?: boolean;
1261
1305
  }
1262
1306
 
1307
+ declare function getCDNProduct(externalProductId: string | number): Promise<CDNProduct>;
1308
+ declare function getCDNStoreSettings(): Promise<CDNStoreSettings>;
1309
+ declare function getCDNWidgetSettings(): Promise<CDNWidgetSettings>;
1310
+ declare function getCDNProductsAndSettings(): Promise<CDNProductsAndSettings>;
1311
+ declare function getCDNProducts(): Promise<CDNProductKeyObject[]>;
1312
+ declare function getCDNProductAndSettings(externalProductId: string | number): Promise<CDNProductAndSettings>;
1313
+ declare function getCDNBundleSettings(externalProductId: string | number): Promise<CDNBundleSettings | null | undefined>;
1314
+ declare function resetCDNCache(): Promise<void>;
1315
+
1316
+ declare function getBundleId(bundle: Bundle): Promise<string>;
1317
+ declare function validateBundle(bundle: Bundle): Promise<boolean>;
1318
+
1319
+ /** Retrieves membership information for passed in id */
1320
+ declare function getMembership(session: Session, id: string | number): Promise<Membership>;
1321
+ /** Retrieves a list of memberships */
1322
+ declare function listMemberships(session: Session, query?: MembershipListParams): Promise<MembershipListResponse>;
1323
+ /** Cancels a membership */
1324
+ declare function cancelMembership(session: Session, id: string | number, cancelRequest: CancelMembershipRequest): Promise<Membership>;
1325
+ /** Activates a membership */
1326
+ declare function activateMembership(session: Session, id: string | number, activateRequest: ActivateMembershipRequest): Promise<Membership>;
1327
+
1328
+ declare function getOnetime(session: Session, id: string | number): Promise<Onetime>;
1329
+ declare function listOnetimes(session: Session, query?: OnetimeListParams): Promise<OnetimesResponse>;
1330
+ declare function createOnetime(session: Session, createRequest: CreateOnetimeRequest): Promise<Onetime>;
1331
+ declare function updateOnetime(session: Session, id: string | number, updateRequest: UpdateOnetimeRequest): Promise<Onetime>;
1332
+ declare function deleteOnetime(session: Session, id: string | number): Promise<void>;
1333
+
1334
+ declare function getOrder(session: Session, id: string | number): Promise<Order>;
1335
+ declare function listOrders(session: Session, query?: OrderListParams): Promise<OrdersResponse>;
1336
+
1337
+ declare function getPlan(session: Session, id: string | number): Promise<Plan>;
1338
+ declare function listPlans(session: Session, query?: PlanListParams): Promise<PlansResponse>;
1339
+
1263
1340
  declare function getSubscription(session: Session, id: string | number): Promise<Subscription>;
1264
1341
  declare function listSubscriptions(session: Session, query?: SubscriptionListParams): Promise<SubscriptionsResponse>;
1265
1342
  /**
@@ -1293,54 +1370,12 @@ declare function cancelSubscription(session: Session, id: string | number, cance
1293
1370
  * and cancellation_reason_comments.
1294
1371
  */
1295
1372
  declare function activateSubscription(session: Session, id: string | number): Promise<Subscription>;
1296
-
1297
- interface Customer {
1298
- /** Unique numeric identifier for the Customer. */
1299
- id: number;
1300
- /** An object containing analytics data associated with the customer. */
1301
- analytics_data: AnalyticsData;
1302
- /** The date and time when the customer was created. */
1303
- created_at: IsoDateString;
1304
- /** The email address of the customer. */
1305
- email: string;
1306
- /** An object containing external ids for the customer record. */
1307
- external_customer_id: ExternalId;
1308
- /** Date when first charge was processed for the customer. */
1309
- first_charge_processed_at: IsoDateString;
1310
- /** The customer’s first name. */
1311
- first_name: string;
1312
- /** A boolean that indicates if the customer has a payment method that is in dunning (failed charge). */
1313
- has_payment_method_in_dunning: boolean;
1314
- /** Is the payment method valid or not. */
1315
- has_valid_payment_method: boolean;
1316
- /** The unique string identifier used in a customers portal link. */
1317
- hash: string;
1318
- /** The customer’s last name. */
1319
- last_name: string;
1320
- /** The number of active subscriptions on addresses associated with the customer. */
1321
- subscriptions_active_count: number;
1322
- /** The total number of subscriptions created on addresses associated with the customer. */
1323
- subscriptions_total_count: number;
1324
- /** The date and time when the customer was last updated. */
1325
- updated_at: IsoDateString;
1326
- }
1327
- declare type OptionalUpdateProps = 'email' | 'first_name' | 'last_name' | 'external_customer_id';
1328
- declare type UpdateCustomerRequest = Partial<Pick<Customer, OptionalUpdateProps>>;
1329
- interface CustomerDeliveryScheduleParams {
1330
- delivery_count_future?: number;
1331
- future_internal?: number;
1332
- date_max?: IsoDateString;
1333
- }
1334
- interface Delivery {
1335
- date: IsoDateString;
1336
- orders: Order[];
1337
- }
1373
+ declare function skipSubscriptionCharge(session: Session, id: number | string, date: IsoDateString): Promise<Charge>;
1338
1374
 
1339
1375
  declare function getCustomer(session: Session): Promise<Customer>;
1340
1376
  declare function updateCustomer(session: Session, updateRequest: UpdateCustomerRequest): Promise<Customer>;
1341
1377
  declare function getDeliverySchedule(session: Session, query?: CustomerDeliveryScheduleParams): Promise<Delivery[]>;
1342
1378
 
1343
- declare type InitOptions = Omit<Partial<StorefrontOptions>, 'environment'>;
1344
1379
  declare const api: {
1345
1380
  get<T>(url: string, requestOptions?: GetRequestOptions): Promise<T>;
1346
1381
  post<T_1>(url: string, requestOptions?: CRUDRequestOptions): Promise<T_1>;
@@ -1349,4 +1384,4 @@ declare const api: {
1349
1384
  };
1350
1385
  declare function initRecharge(opt?: InitOptions): void;
1351
1386
 
1352
- export { Bundle, BundleSelection, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, FirstOption, GetRequestOptions, InitOptions, IntervalUnit, Method, PriceAdjustmentsType, Request, RequestHeaders, RequestOptions, RequestOptionsHeaders, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, Translations, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscount, cancelMembership, cancelSubscription, createAddress, createOnetime, createSubscription, deleteAddress, deleteOnetime, getAddress, getBundleId, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getDeliverySchedule, getMembership, getOnetime, getOrder, getPlan, getSubscription, initRecharge, listAddresses, listCharges, listMemberships, listOnetimes, listOrders, listPlans, listSubscriptions, loginShopifyApi, loginShopifyAppProxy, mergeAddresses, removeDiscount, resetCDNCache, skipCharge, skipFutureCharge, unskipCharge, updateAddress, updateCustomer, updateOnetime, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, validateBundle };
1387
+ export { ActivateMembershipRequest, Address, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, ApplyDiscountRequest, AssociatedAddress, Bundle, BundleSelection, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChannelSettings, Charge, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateOnetimeRequest, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, Delivery, Discount, ExternalId, ExternalTransactionId, FirstOption, GetRequestOptions, HTMLString, InitOptions, IntervalUnit, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipListParams, MembershipListResponse, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Method, Onetime, OnetimeListParams, OnetimesResponse, OnetimesSortBy, Order, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProductImage, Property, Request, RequestHeaders, RequestOptions, RequestOptionsHeaders, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionListParams, SubscriptionPreferences, SubscriptionSortBy, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateCustomerRequest, UpdateOnetimeRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscount, cancelMembership, cancelSubscription, createAddress, createOnetime, createSubscription, deleteAddress, deleteOnetime, getAddress, getBundleId, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getDeliverySchedule, getMembership, getOnetime, getOrder, getPlan, getSubscription, initRecharge, listAddresses, listCharges, listMemberships, listOnetimes, listOrders, listPlans, listSubscriptions, loginShopifyApi, loginShopifyAppProxy, mergeAddresses, removeDiscount, resetCDNCache, skipCharge, skipFutureCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateCustomer, updateOnetime, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, validateBundle };