perspectapi-ts-sdk 3.0.2 → 3.2.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.mts +167 -1
- package/dist/index.d.ts +167 -1
- package/dist/index.js +261 -0
- package/dist/index.mjs +260 -0
- package/package.json +1 -1
- package/src/client/bundles-client.ts +263 -0
- package/src/client/site-users-client.ts +115 -0
- package/src/index.ts +8 -0
- package/src/perspect-api-client.ts +3 -0
- package/src/types/index.ts +92 -0
package/dist/index.d.mts
CHANGED
|
@@ -472,6 +472,7 @@ interface CreateCheckoutSessionRequest {
|
|
|
472
472
|
price?: string;
|
|
473
473
|
quantity: number;
|
|
474
474
|
sku_id?: number;
|
|
475
|
+
product_id?: number;
|
|
475
476
|
price_data?: {
|
|
476
477
|
currency: string;
|
|
477
478
|
product_data: {
|
|
@@ -489,6 +490,8 @@ interface CreateCheckoutSessionRequest {
|
|
|
489
490
|
customer_email?: string;
|
|
490
491
|
customerEmail?: string;
|
|
491
492
|
site_user_id?: string;
|
|
493
|
+
referral_code?: string;
|
|
494
|
+
referrer_site_user_id?: string;
|
|
492
495
|
currency?: string;
|
|
493
496
|
metadata?: CheckoutMetadata;
|
|
494
497
|
mode?: 'payment' | 'subscription' | 'setup';
|
|
@@ -611,6 +614,24 @@ interface SiteUserOrder {
|
|
|
611
614
|
created_at: string;
|
|
612
615
|
completed_at?: string;
|
|
613
616
|
}
|
|
617
|
+
interface CreditTransaction {
|
|
618
|
+
id: number;
|
|
619
|
+
amount_cents: number;
|
|
620
|
+
balance_after_cents: number;
|
|
621
|
+
type: string;
|
|
622
|
+
description: string | null;
|
|
623
|
+
created_at: string;
|
|
624
|
+
}
|
|
625
|
+
interface CreditBalance {
|
|
626
|
+
balance_cents: number;
|
|
627
|
+
}
|
|
628
|
+
interface CreditBalanceWithTransactions extends CreditBalance {
|
|
629
|
+
transactions: CreditTransaction[];
|
|
630
|
+
}
|
|
631
|
+
interface GrantCreditRequest {
|
|
632
|
+
amount_cents: number;
|
|
633
|
+
description: string;
|
|
634
|
+
}
|
|
614
635
|
interface RequestOtpRequest {
|
|
615
636
|
email: string;
|
|
616
637
|
waitlist?: boolean;
|
|
@@ -640,6 +661,62 @@ interface UpdateSiteUserRequest {
|
|
|
640
661
|
interface SetProfileValueRequest {
|
|
641
662
|
value: string;
|
|
642
663
|
}
|
|
664
|
+
interface ProductBundleGroup {
|
|
665
|
+
bundle_group_id: number;
|
|
666
|
+
product_id: number;
|
|
667
|
+
name: string;
|
|
668
|
+
description?: string;
|
|
669
|
+
quantity: number;
|
|
670
|
+
position: number;
|
|
671
|
+
created_at: string;
|
|
672
|
+
updated_at: string;
|
|
673
|
+
}
|
|
674
|
+
interface CreateBundleGroupRequest {
|
|
675
|
+
name: string;
|
|
676
|
+
description?: string;
|
|
677
|
+
quantity: number;
|
|
678
|
+
position?: number;
|
|
679
|
+
}
|
|
680
|
+
interface BundleCollection {
|
|
681
|
+
collection_id: number;
|
|
682
|
+
site_id: string;
|
|
683
|
+
site_name: string;
|
|
684
|
+
name: string;
|
|
685
|
+
description?: string;
|
|
686
|
+
available_from?: string;
|
|
687
|
+
available_until?: string;
|
|
688
|
+
published: number;
|
|
689
|
+
created_at: string;
|
|
690
|
+
updated_at: string;
|
|
691
|
+
}
|
|
692
|
+
interface CreateBundleCollectionRequest {
|
|
693
|
+
name: string;
|
|
694
|
+
description?: string;
|
|
695
|
+
available_from?: string;
|
|
696
|
+
available_until?: string;
|
|
697
|
+
published?: number;
|
|
698
|
+
}
|
|
699
|
+
interface BundleCollectionItem {
|
|
700
|
+
id: number;
|
|
701
|
+
collection_id: number;
|
|
702
|
+
product_id: number;
|
|
703
|
+
max_quantity?: number;
|
|
704
|
+
position: number;
|
|
705
|
+
created_at: string;
|
|
706
|
+
updated_at: string;
|
|
707
|
+
}
|
|
708
|
+
interface BundleCollectionItemWithProduct extends BundleCollectionItem {
|
|
709
|
+
product_name: string;
|
|
710
|
+
slug: string;
|
|
711
|
+
unit_amount: number;
|
|
712
|
+
currency: string;
|
|
713
|
+
image_url?: string;
|
|
714
|
+
}
|
|
715
|
+
interface AddCollectionItemRequest {
|
|
716
|
+
product_id: number;
|
|
717
|
+
max_quantity?: number;
|
|
718
|
+
position?: number;
|
|
719
|
+
}
|
|
643
720
|
interface ApiError {
|
|
644
721
|
message: string;
|
|
645
722
|
code?: string;
|
|
@@ -2291,6 +2368,35 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2291
2368
|
success: boolean;
|
|
2292
2369
|
message: string;
|
|
2293
2370
|
}>>;
|
|
2371
|
+
/**
|
|
2372
|
+
* Pause a subscription via Stripe pause_collection
|
|
2373
|
+
* @param siteName - The site name
|
|
2374
|
+
* @param subscriptionId - Subscription ID
|
|
2375
|
+
* @param csrfToken - CSRF token (required)
|
|
2376
|
+
* @param resumesAt - Optional ISO date string when subscription should auto-resume
|
|
2377
|
+
*/
|
|
2378
|
+
pauseSubscription(siteName: string, subscriptionId: string, csrfToken?: string, resumesAt?: string): Promise<ApiResponse<{
|
|
2379
|
+
success: boolean;
|
|
2380
|
+
}>>;
|
|
2381
|
+
/**
|
|
2382
|
+
* Resume a paused subscription
|
|
2383
|
+
* @param siteName - The site name
|
|
2384
|
+
* @param subscriptionId - Subscription ID
|
|
2385
|
+
* @param csrfToken - CSRF token (required)
|
|
2386
|
+
*/
|
|
2387
|
+
resumeSubscription(siteName: string, subscriptionId: string, csrfToken?: string): Promise<ApiResponse<{
|
|
2388
|
+
success: boolean;
|
|
2389
|
+
}>>;
|
|
2390
|
+
/**
|
|
2391
|
+
* Change subscription plan tier
|
|
2392
|
+
* @param siteName - The site name
|
|
2393
|
+
* @param subscriptionId - Subscription ID
|
|
2394
|
+
* @param productId - New product ID to switch to
|
|
2395
|
+
* @param csrfToken - CSRF token (required)
|
|
2396
|
+
*/
|
|
2397
|
+
changeSubscriptionPlan(siteName: string, subscriptionId: string, productId: number, csrfToken?: string): Promise<ApiResponse<{
|
|
2398
|
+
success: boolean;
|
|
2399
|
+
}>>;
|
|
2294
2400
|
/**
|
|
2295
2401
|
* Get linked newsletter subscriptions
|
|
2296
2402
|
* @param siteName - The site name
|
|
@@ -2298,6 +2404,20 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2298
2404
|
getNewsletterSubscriptions(siteName: string): Promise<ApiResponse<{
|
|
2299
2405
|
newsletters: any[];
|
|
2300
2406
|
}>>;
|
|
2407
|
+
/**
|
|
2408
|
+
* Get current credit balance
|
|
2409
|
+
* @param siteName - The site name
|
|
2410
|
+
*/
|
|
2411
|
+
getCreditBalance(siteName: string): Promise<ApiResponse<CreditBalance>>;
|
|
2412
|
+
/**
|
|
2413
|
+
* Get credit balance and paginated transactions
|
|
2414
|
+
* @param siteName - The site name
|
|
2415
|
+
* @param params - Pagination params
|
|
2416
|
+
*/
|
|
2417
|
+
getCreditTransactions(siteName: string, params?: {
|
|
2418
|
+
limit?: number;
|
|
2419
|
+
offset?: number;
|
|
2420
|
+
}): Promise<ApiResponse<CreditBalanceWithTransactions>>;
|
|
2301
2421
|
/**
|
|
2302
2422
|
* List all site users (admin only)
|
|
2303
2423
|
* @param siteName - The site name
|
|
@@ -2329,6 +2449,51 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2329
2449
|
updateUserStatus(siteName: string, userId: string, status: 'active' | 'suspended' | 'pending_verification', csrfToken?: string): Promise<ApiResponse<{
|
|
2330
2450
|
success: boolean;
|
|
2331
2451
|
}>>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Grant credit to a user (admin only)
|
|
2454
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2455
|
+
* @param siteName - The site name
|
|
2456
|
+
* @param userId - User ID
|
|
2457
|
+
* @param data - Amount in cents and description
|
|
2458
|
+
* @param csrfToken - CSRF token (required)
|
|
2459
|
+
*/
|
|
2460
|
+
grantCredit(siteName: string, userId: string, data: GrantCreditRequest, csrfToken?: string): Promise<ApiResponse<{
|
|
2461
|
+
success: boolean;
|
|
2462
|
+
new_balance_cents: number;
|
|
2463
|
+
}>>;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* Bundles & Collections client for PerspectAPI SDK
|
|
2468
|
+
*/
|
|
2469
|
+
|
|
2470
|
+
declare class BundlesClient extends BaseClient {
|
|
2471
|
+
constructor(http: any, cache?: CacheManager);
|
|
2472
|
+
getBundleGroups(siteName: string, productId: number, cachePolicy?: CachePolicy): Promise<ApiResponse<ProductBundleGroup[]>>;
|
|
2473
|
+
createBundleGroup(siteName: string, productId: number, data: CreateBundleGroupRequest): Promise<ApiResponse<ProductBundleGroup>>;
|
|
2474
|
+
updateBundleGroup(siteName: string, productId: number, bundleGroupId: number, data: Partial<CreateBundleGroupRequest>): Promise<ApiResponse<ProductBundleGroup>>;
|
|
2475
|
+
deleteBundleGroup(siteName: string, productId: number, bundleGroupId: number): Promise<ApiResponse<{
|
|
2476
|
+
message: string;
|
|
2477
|
+
}>>;
|
|
2478
|
+
getCollections(siteName: string, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollection[]>>;
|
|
2479
|
+
getCurrentCollection(siteName: string, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollection & {
|
|
2480
|
+
items: BundleCollectionItemWithProduct[];
|
|
2481
|
+
}>>;
|
|
2482
|
+
getCollection(siteName: string, collectionId: number, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollection & {
|
|
2483
|
+
items: BundleCollectionItemWithProduct[];
|
|
2484
|
+
}>>;
|
|
2485
|
+
createCollection(siteName: string, data: CreateBundleCollectionRequest): Promise<ApiResponse<BundleCollection>>;
|
|
2486
|
+
updateCollection(siteName: string, collectionId: number, data: Partial<CreateBundleCollectionRequest>): Promise<ApiResponse<BundleCollection>>;
|
|
2487
|
+
deleteCollection(siteName: string, collectionId: number): Promise<ApiResponse<{
|
|
2488
|
+
message: string;
|
|
2489
|
+
}>>;
|
|
2490
|
+
getCollectionItems(siteName: string, collectionId: number, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollectionItemWithProduct[]>>;
|
|
2491
|
+
addCollectionItem(siteName: string, collectionId: number, data: AddCollectionItemRequest): Promise<ApiResponse<BundleCollectionItem>>;
|
|
2492
|
+
removeCollectionItem(siteName: string, collectionId: number, itemId: number): Promise<ApiResponse<{
|
|
2493
|
+
message: string;
|
|
2494
|
+
}>>;
|
|
2495
|
+
private buildBundleTags;
|
|
2496
|
+
private buildCollectionTags;
|
|
2332
2497
|
}
|
|
2333
2498
|
|
|
2334
2499
|
/**
|
|
@@ -2351,6 +2516,7 @@ declare class PerspectApiClient {
|
|
|
2351
2516
|
readonly contact: ContactClient;
|
|
2352
2517
|
readonly newsletter: NewsletterClient;
|
|
2353
2518
|
readonly siteUsers: SiteUsersClient;
|
|
2519
|
+
readonly bundles: BundlesClient;
|
|
2354
2520
|
constructor(config: PerspectApiConfig);
|
|
2355
2521
|
/**
|
|
2356
2522
|
* Update authentication token
|
|
@@ -2755,4 +2921,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2755
2921
|
error: string;
|
|
2756
2922
|
}>;
|
|
2757
2923
|
|
|
2758
|
-
export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, DEFAULT_IMAGE_SIZES, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
|
2924
|
+
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
package/dist/index.d.ts
CHANGED
|
@@ -472,6 +472,7 @@ interface CreateCheckoutSessionRequest {
|
|
|
472
472
|
price?: string;
|
|
473
473
|
quantity: number;
|
|
474
474
|
sku_id?: number;
|
|
475
|
+
product_id?: number;
|
|
475
476
|
price_data?: {
|
|
476
477
|
currency: string;
|
|
477
478
|
product_data: {
|
|
@@ -489,6 +490,8 @@ interface CreateCheckoutSessionRequest {
|
|
|
489
490
|
customer_email?: string;
|
|
490
491
|
customerEmail?: string;
|
|
491
492
|
site_user_id?: string;
|
|
493
|
+
referral_code?: string;
|
|
494
|
+
referrer_site_user_id?: string;
|
|
492
495
|
currency?: string;
|
|
493
496
|
metadata?: CheckoutMetadata;
|
|
494
497
|
mode?: 'payment' | 'subscription' | 'setup';
|
|
@@ -611,6 +614,24 @@ interface SiteUserOrder {
|
|
|
611
614
|
created_at: string;
|
|
612
615
|
completed_at?: string;
|
|
613
616
|
}
|
|
617
|
+
interface CreditTransaction {
|
|
618
|
+
id: number;
|
|
619
|
+
amount_cents: number;
|
|
620
|
+
balance_after_cents: number;
|
|
621
|
+
type: string;
|
|
622
|
+
description: string | null;
|
|
623
|
+
created_at: string;
|
|
624
|
+
}
|
|
625
|
+
interface CreditBalance {
|
|
626
|
+
balance_cents: number;
|
|
627
|
+
}
|
|
628
|
+
interface CreditBalanceWithTransactions extends CreditBalance {
|
|
629
|
+
transactions: CreditTransaction[];
|
|
630
|
+
}
|
|
631
|
+
interface GrantCreditRequest {
|
|
632
|
+
amount_cents: number;
|
|
633
|
+
description: string;
|
|
634
|
+
}
|
|
614
635
|
interface RequestOtpRequest {
|
|
615
636
|
email: string;
|
|
616
637
|
waitlist?: boolean;
|
|
@@ -640,6 +661,62 @@ interface UpdateSiteUserRequest {
|
|
|
640
661
|
interface SetProfileValueRequest {
|
|
641
662
|
value: string;
|
|
642
663
|
}
|
|
664
|
+
interface ProductBundleGroup {
|
|
665
|
+
bundle_group_id: number;
|
|
666
|
+
product_id: number;
|
|
667
|
+
name: string;
|
|
668
|
+
description?: string;
|
|
669
|
+
quantity: number;
|
|
670
|
+
position: number;
|
|
671
|
+
created_at: string;
|
|
672
|
+
updated_at: string;
|
|
673
|
+
}
|
|
674
|
+
interface CreateBundleGroupRequest {
|
|
675
|
+
name: string;
|
|
676
|
+
description?: string;
|
|
677
|
+
quantity: number;
|
|
678
|
+
position?: number;
|
|
679
|
+
}
|
|
680
|
+
interface BundleCollection {
|
|
681
|
+
collection_id: number;
|
|
682
|
+
site_id: string;
|
|
683
|
+
site_name: string;
|
|
684
|
+
name: string;
|
|
685
|
+
description?: string;
|
|
686
|
+
available_from?: string;
|
|
687
|
+
available_until?: string;
|
|
688
|
+
published: number;
|
|
689
|
+
created_at: string;
|
|
690
|
+
updated_at: string;
|
|
691
|
+
}
|
|
692
|
+
interface CreateBundleCollectionRequest {
|
|
693
|
+
name: string;
|
|
694
|
+
description?: string;
|
|
695
|
+
available_from?: string;
|
|
696
|
+
available_until?: string;
|
|
697
|
+
published?: number;
|
|
698
|
+
}
|
|
699
|
+
interface BundleCollectionItem {
|
|
700
|
+
id: number;
|
|
701
|
+
collection_id: number;
|
|
702
|
+
product_id: number;
|
|
703
|
+
max_quantity?: number;
|
|
704
|
+
position: number;
|
|
705
|
+
created_at: string;
|
|
706
|
+
updated_at: string;
|
|
707
|
+
}
|
|
708
|
+
interface BundleCollectionItemWithProduct extends BundleCollectionItem {
|
|
709
|
+
product_name: string;
|
|
710
|
+
slug: string;
|
|
711
|
+
unit_amount: number;
|
|
712
|
+
currency: string;
|
|
713
|
+
image_url?: string;
|
|
714
|
+
}
|
|
715
|
+
interface AddCollectionItemRequest {
|
|
716
|
+
product_id: number;
|
|
717
|
+
max_quantity?: number;
|
|
718
|
+
position?: number;
|
|
719
|
+
}
|
|
643
720
|
interface ApiError {
|
|
644
721
|
message: string;
|
|
645
722
|
code?: string;
|
|
@@ -2291,6 +2368,35 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2291
2368
|
success: boolean;
|
|
2292
2369
|
message: string;
|
|
2293
2370
|
}>>;
|
|
2371
|
+
/**
|
|
2372
|
+
* Pause a subscription via Stripe pause_collection
|
|
2373
|
+
* @param siteName - The site name
|
|
2374
|
+
* @param subscriptionId - Subscription ID
|
|
2375
|
+
* @param csrfToken - CSRF token (required)
|
|
2376
|
+
* @param resumesAt - Optional ISO date string when subscription should auto-resume
|
|
2377
|
+
*/
|
|
2378
|
+
pauseSubscription(siteName: string, subscriptionId: string, csrfToken?: string, resumesAt?: string): Promise<ApiResponse<{
|
|
2379
|
+
success: boolean;
|
|
2380
|
+
}>>;
|
|
2381
|
+
/**
|
|
2382
|
+
* Resume a paused subscription
|
|
2383
|
+
* @param siteName - The site name
|
|
2384
|
+
* @param subscriptionId - Subscription ID
|
|
2385
|
+
* @param csrfToken - CSRF token (required)
|
|
2386
|
+
*/
|
|
2387
|
+
resumeSubscription(siteName: string, subscriptionId: string, csrfToken?: string): Promise<ApiResponse<{
|
|
2388
|
+
success: boolean;
|
|
2389
|
+
}>>;
|
|
2390
|
+
/**
|
|
2391
|
+
* Change subscription plan tier
|
|
2392
|
+
* @param siteName - The site name
|
|
2393
|
+
* @param subscriptionId - Subscription ID
|
|
2394
|
+
* @param productId - New product ID to switch to
|
|
2395
|
+
* @param csrfToken - CSRF token (required)
|
|
2396
|
+
*/
|
|
2397
|
+
changeSubscriptionPlan(siteName: string, subscriptionId: string, productId: number, csrfToken?: string): Promise<ApiResponse<{
|
|
2398
|
+
success: boolean;
|
|
2399
|
+
}>>;
|
|
2294
2400
|
/**
|
|
2295
2401
|
* Get linked newsletter subscriptions
|
|
2296
2402
|
* @param siteName - The site name
|
|
@@ -2298,6 +2404,20 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2298
2404
|
getNewsletterSubscriptions(siteName: string): Promise<ApiResponse<{
|
|
2299
2405
|
newsletters: any[];
|
|
2300
2406
|
}>>;
|
|
2407
|
+
/**
|
|
2408
|
+
* Get current credit balance
|
|
2409
|
+
* @param siteName - The site name
|
|
2410
|
+
*/
|
|
2411
|
+
getCreditBalance(siteName: string): Promise<ApiResponse<CreditBalance>>;
|
|
2412
|
+
/**
|
|
2413
|
+
* Get credit balance and paginated transactions
|
|
2414
|
+
* @param siteName - The site name
|
|
2415
|
+
* @param params - Pagination params
|
|
2416
|
+
*/
|
|
2417
|
+
getCreditTransactions(siteName: string, params?: {
|
|
2418
|
+
limit?: number;
|
|
2419
|
+
offset?: number;
|
|
2420
|
+
}): Promise<ApiResponse<CreditBalanceWithTransactions>>;
|
|
2301
2421
|
/**
|
|
2302
2422
|
* List all site users (admin only)
|
|
2303
2423
|
* @param siteName - The site name
|
|
@@ -2329,6 +2449,51 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
2329
2449
|
updateUserStatus(siteName: string, userId: string, status: 'active' | 'suspended' | 'pending_verification', csrfToken?: string): Promise<ApiResponse<{
|
|
2330
2450
|
success: boolean;
|
|
2331
2451
|
}>>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Grant credit to a user (admin only)
|
|
2454
|
+
* Adds credit to the user's ledger and Stripe Customer Balance.
|
|
2455
|
+
* @param siteName - The site name
|
|
2456
|
+
* @param userId - User ID
|
|
2457
|
+
* @param data - Amount in cents and description
|
|
2458
|
+
* @param csrfToken - CSRF token (required)
|
|
2459
|
+
*/
|
|
2460
|
+
grantCredit(siteName: string, userId: string, data: GrantCreditRequest, csrfToken?: string): Promise<ApiResponse<{
|
|
2461
|
+
success: boolean;
|
|
2462
|
+
new_balance_cents: number;
|
|
2463
|
+
}>>;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* Bundles & Collections client for PerspectAPI SDK
|
|
2468
|
+
*/
|
|
2469
|
+
|
|
2470
|
+
declare class BundlesClient extends BaseClient {
|
|
2471
|
+
constructor(http: any, cache?: CacheManager);
|
|
2472
|
+
getBundleGroups(siteName: string, productId: number, cachePolicy?: CachePolicy): Promise<ApiResponse<ProductBundleGroup[]>>;
|
|
2473
|
+
createBundleGroup(siteName: string, productId: number, data: CreateBundleGroupRequest): Promise<ApiResponse<ProductBundleGroup>>;
|
|
2474
|
+
updateBundleGroup(siteName: string, productId: number, bundleGroupId: number, data: Partial<CreateBundleGroupRequest>): Promise<ApiResponse<ProductBundleGroup>>;
|
|
2475
|
+
deleteBundleGroup(siteName: string, productId: number, bundleGroupId: number): Promise<ApiResponse<{
|
|
2476
|
+
message: string;
|
|
2477
|
+
}>>;
|
|
2478
|
+
getCollections(siteName: string, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollection[]>>;
|
|
2479
|
+
getCurrentCollection(siteName: string, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollection & {
|
|
2480
|
+
items: BundleCollectionItemWithProduct[];
|
|
2481
|
+
}>>;
|
|
2482
|
+
getCollection(siteName: string, collectionId: number, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollection & {
|
|
2483
|
+
items: BundleCollectionItemWithProduct[];
|
|
2484
|
+
}>>;
|
|
2485
|
+
createCollection(siteName: string, data: CreateBundleCollectionRequest): Promise<ApiResponse<BundleCollection>>;
|
|
2486
|
+
updateCollection(siteName: string, collectionId: number, data: Partial<CreateBundleCollectionRequest>): Promise<ApiResponse<BundleCollection>>;
|
|
2487
|
+
deleteCollection(siteName: string, collectionId: number): Promise<ApiResponse<{
|
|
2488
|
+
message: string;
|
|
2489
|
+
}>>;
|
|
2490
|
+
getCollectionItems(siteName: string, collectionId: number, cachePolicy?: CachePolicy): Promise<ApiResponse<BundleCollectionItemWithProduct[]>>;
|
|
2491
|
+
addCollectionItem(siteName: string, collectionId: number, data: AddCollectionItemRequest): Promise<ApiResponse<BundleCollectionItem>>;
|
|
2492
|
+
removeCollectionItem(siteName: string, collectionId: number, itemId: number): Promise<ApiResponse<{
|
|
2493
|
+
message: string;
|
|
2494
|
+
}>>;
|
|
2495
|
+
private buildBundleTags;
|
|
2496
|
+
private buildCollectionTags;
|
|
2332
2497
|
}
|
|
2333
2498
|
|
|
2334
2499
|
/**
|
|
@@ -2351,6 +2516,7 @@ declare class PerspectApiClient {
|
|
|
2351
2516
|
readonly contact: ContactClient;
|
|
2352
2517
|
readonly newsletter: NewsletterClient;
|
|
2353
2518
|
readonly siteUsers: SiteUsersClient;
|
|
2519
|
+
readonly bundles: BundlesClient;
|
|
2354
2520
|
constructor(config: PerspectApiConfig);
|
|
2355
2521
|
/**
|
|
2356
2522
|
* Update authentication token
|
|
@@ -2755,4 +2921,4 @@ declare function createCheckoutSession(options: CheckoutSessionOptions): Promise
|
|
|
2755
2921
|
error: string;
|
|
2756
2922
|
}>;
|
|
2757
2923
|
|
|
2758
|
-
export { type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, DEFAULT_IMAGE_SIZES, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|
|
2924
|
+
export { type AddCollectionItemRequest, type ApiError, type ApiKey, ApiKeysClient, type ApiResponse, AuthClient, BaseClient, type BlogPost, type BundleCollection, type BundleCollectionItem, type BundleCollectionItemWithProduct, BundlesClient, type CacheConfig, CacheManager, CategoriesClient, type Category, type CategorySummary, type CheckoutAddress, CheckoutClient, type CheckoutMetadata, type CheckoutMetadataValue, type CheckoutSession, type CheckoutSessionOptions, type CheckoutSessionTax, type CheckoutTaxBreakdownItem, type CheckoutTaxCustomerExemptionRequest, type CheckoutTaxExemptionStatus, type CheckoutTaxRequest, type CheckoutTaxStrategy, ContactClient, type ContactStatusResponse, type ContactSubmission, type ContactSubmitResponse, type Content, type ContentCategoryResponse, ContentClient, type ContentQueryParams, type ContentStatus, type ContentType, type CreateApiKeyRequest, type CreateBundleCollectionRequest, type CreateBundleGroupRequest, type CreateCategoryRequest, type CreateCheckoutSessionRequest, type CreateContactRequest, type CreateContentRequest, type CreateNewsletterSubscriptionRequest, type CreateOrganizationRequest, type CreatePaymentGatewayRequest, type CreateProductRequest, type CreateSiteRequest, type CreateWebhookRequest, type CreditBalance, type CreditBalanceWithTransactions, type CreditTransaction, DEFAULT_IMAGE_SIZES, type GrantCreditRequest, HttpClient, type HttpMethod, type ImageTransformOptions, InMemoryCacheAdapter, type LoadContentBySlugOptions, type LoadContentOptions, type LoadProductBySlugOptions, type LoadProductsOptions, type LoaderLogger, type LoaderOptions, type MediaItem, NewsletterClient, type NewsletterConfirmResponse, type NewsletterList, type NewsletterPreferences, type NewsletterStatusResponse, type NewsletterSubscribeResponse, type NewsletterSubscription, type NewsletterUnsubscribeRequest, type NewsletterUnsubscribeResponse, NoopCacheAdapter, type Organization, OrganizationsClient, type PaginatedResponse, type PaginationParams, type PaymentGateway, PerspectApiClient, type PerspectApiConfig, type Product, type ProductBundleGroup, type ProductQueryParams, ProductsClient, type RequestOptions, type RequestOtpRequest, type ResponsiveImageSizes, type SetProfileValueRequest, type Site, type SiteUser, type SiteUserOrder, type SiteUserProfile, type SiteUserSubscription, SiteUsersClient, SitesClient, type UpdateApiKeyRequest, type UpdateContentRequest, type UpdateSiteUserRequest, type User, type VerifyOtpRequest, type VerifyOtpResponse, type Webhook, WebhooksClient, buildImageUrl, createApiError, createCheckoutSession, createPerspectApiClient, PerspectApiClient as default, generateResponsiveImageHtml, generateResponsiveUrls, generateSizesAttribute, generateSrcSet, loadAllContent, loadContentBySlug, loadPages, loadPosts, loadProductBySlug, loadProducts, transformContent, transformMediaItem, transformProduct };
|