@b3dotfun/sdk 0.1.68 → 0.1.69-alpha.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/cjs/anyspend/platform/client.d.ts +35 -0
- package/dist/cjs/anyspend/platform/client.js +158 -0
- package/dist/cjs/anyspend/platform/errors.d.ts +38 -0
- package/dist/cjs/anyspend/platform/errors.js +77 -0
- package/dist/cjs/anyspend/platform/index.d.ts +87 -0
- package/dist/cjs/anyspend/platform/index.js +85 -0
- package/dist/cjs/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/cjs/anyspend/platform/resources/analytics.js +12 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/checkout-sessions.js +27 -0
- package/dist/cjs/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/cjs/anyspend/platform/resources/customers.js +34 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/cjs/anyspend/platform/resources/discount-codes.js +31 -0
- package/dist/cjs/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/events.js +16 -0
- package/dist/cjs/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/cjs/anyspend/platform/resources/notifications.js +27 -0
- package/dist/cjs/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/cjs/anyspend/platform/resources/organization.js +15 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/cjs/anyspend/platform/resources/payment-links.js +49 -0
- package/dist/cjs/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/cjs/anyspend/platform/resources/products.js +31 -0
- package/dist/cjs/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/cjs/anyspend/platform/resources/transactions.js +25 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/cjs/anyspend/platform/resources/webhooks.js +33 -0
- package/dist/cjs/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/cjs/anyspend/platform/resources/widgets.js +31 -0
- package/dist/cjs/anyspend/platform/types.d.ts +478 -0
- package/dist/cjs/anyspend/platform/types.js +5 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/cjs/anyspend/platform/utils/idempotency.js +17 -0
- package/dist/cjs/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/cjs/anyspend/platform/utils/pagination.js +22 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +127 -16
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +48 -16
- package/dist/cjs/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +203 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/cjs/anyspend/react/components/checkout/VariablePricingInput.js +145 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +124 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +4 -1
- package/dist/cjs/anyspend/services/anyspend.js +3 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/cjs/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useModalStore.js +2 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +17 -0
- package/dist/esm/anyspend/platform/client.d.ts +35 -0
- package/dist/esm/anyspend/platform/client.js +153 -0
- package/dist/esm/anyspend/platform/errors.d.ts +38 -0
- package/dist/esm/anyspend/platform/errors.js +67 -0
- package/dist/esm/anyspend/platform/index.d.ts +87 -0
- package/dist/esm/anyspend/platform/index.js +75 -0
- package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
- package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/esm/anyspend/platform/resources/customers.js +30 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
- package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/events.js +12 -0
- package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
- package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/esm/anyspend/platform/resources/organization.js +11 -0
- package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
- package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/esm/anyspend/platform/resources/products.js +27 -0
- package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
- package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
- package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
- package/dist/esm/anyspend/platform/types.d.ts +478 -0
- package/dist/esm/anyspend/platform/types.js +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
- package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +128 -17
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +55 -8
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckoutTrigger.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +1 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +50 -18
- package/dist/esm/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +167 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/esm/anyspend/react/components/checkout/VariablePricingInput.js +142 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +1 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/components/index.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +14 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +117 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +4 -1
- package/dist/esm/anyspend/services/anyspend.js +3 -1
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -5
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +21 -24
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/esm/global-account/react/hooks/useAuth.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +94 -24
- package/dist/esm/global-account/react/hooks/useGetAllTWSigners.js +2 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useModalStore.js +2 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +16 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/platform/client.d.ts +35 -0
- package/dist/types/anyspend/platform/errors.d.ts +38 -0
- package/dist/types/anyspend/platform/index.d.ts +87 -0
- package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
- package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
- package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
- package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
- package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
- package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
- package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
- package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
- package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
- package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
- package/dist/types/anyspend/platform/types.d.ts +478 -0
- package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
- package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +14 -6
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckoutTrigger.d.ts +3 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutPaymentPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/FiatCheckoutPanel.d.ts +5 -1
- package/dist/types/anyspend/react/components/checkout/KycGate.d.ts +11 -0
- package/dist/types/anyspend/react/components/checkout/VariablePricingInput.d.ts +17 -0
- package/dist/types/anyspend/react/components/index.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +47 -0
- package/dist/types/anyspend/services/anyspend.d.ts +4 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +18 -0
- package/package.json +7 -1
- package/src/anyspend/docs/checkout-sessions.md +20 -3
- package/src/anyspend/platform/client.ts +198 -0
- package/src/anyspend/platform/errors.ts +92 -0
- package/src/anyspend/platform/index.ts +129 -0
- package/src/anyspend/platform/resources/analytics.ts +10 -0
- package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
- package/src/anyspend/platform/resources/customers.ts +54 -0
- package/src/anyspend/platform/resources/discount-codes.ts +63 -0
- package/src/anyspend/platform/resources/events.ts +22 -0
- package/src/anyspend/platform/resources/notifications.ts +37 -0
- package/src/anyspend/platform/resources/organization.ts +24 -0
- package/src/anyspend/platform/resources/payment-links.ts +74 -0
- package/src/anyspend/platform/resources/products.ts +59 -0
- package/src/anyspend/platform/resources/transactions.ts +33 -0
- package/src/anyspend/platform/resources/webhooks.ts +47 -0
- package/src/anyspend/platform/resources/widgets.ts +63 -0
- package/src/anyspend/platform/types.ts +532 -0
- package/src/anyspend/platform/utils/idempotency.ts +15 -0
- package/src/anyspend/platform/utils/pagination.ts +32 -0
- package/src/anyspend/react/components/AnySpend.tsx +152 -18
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -4
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +81 -18
- package/src/anyspend/react/components/checkout/AnySpendCheckoutTrigger.tsx +4 -0
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +8 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +4 -13
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +86 -17
- package/src/anyspend/react/components/checkout/KycGate.tsx +387 -0
- package/src/anyspend/react/components/checkout/VariablePricingInput.tsx +247 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +1 -1
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +1 -1
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +17 -0
- package/src/anyspend/react/hooks/useKycStatus.ts +150 -0
- package/src/anyspend/services/anyspend.ts +7 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -2
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/HomeActions.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +7 -7
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -5
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +35 -25
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +1 -1
- package/src/global-account/react/hooks/useAuth.ts +2 -2
- package/src/global-account/react/hooks/useAuthentication.ts +92 -27
- package/src/global-account/react/hooks/useGetAllTWSigners.tsx +2 -1
- package/src/global-account/react/stores/useModalStore.ts +6 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +18 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnySpend Platform API Client
|
|
3
|
+
*
|
|
4
|
+
* A headless TypeScript client for the AnySpend Platform REST API.
|
|
5
|
+
* Works in any runtime with `fetch` (Node.js, browsers, Cloudflare Workers, Deno, Bun).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AnySpendPlatformClient } from '../../anyspend/platform/index.js';
|
|
10
|
+
*
|
|
11
|
+
* const platform = new AnySpendPlatformClient('asp_your_api_key_here');
|
|
12
|
+
*
|
|
13
|
+
* // Create a payment link
|
|
14
|
+
* const link = await platform.paymentLinks.create({
|
|
15
|
+
* name: 'Summer Sale',
|
|
16
|
+
* amount: '10000000',
|
|
17
|
+
* token_address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
18
|
+
* chain_id: 8453,
|
|
19
|
+
* recipient_address: '0x...',
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Quick pay (no API key needed)
|
|
23
|
+
* const quickLink = await AnySpendPlatformClient.quickPay({
|
|
24
|
+
* recipient_address: '0x...',
|
|
25
|
+
* amount: '5000000',
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { HttpClient, StaticHttpClient, DEFAULT_BASE_URL } from "./client.js";
|
|
30
|
+
import { PaymentLinksResource } from "./resources/payment-links.js";
|
|
31
|
+
import { ProductsResource } from "./resources/products.js";
|
|
32
|
+
import { CustomersResource } from "./resources/customers.js";
|
|
33
|
+
import { TransactionsResource } from "./resources/transactions.js";
|
|
34
|
+
import { CheckoutSessionsResource } from "./resources/checkout-sessions.js";
|
|
35
|
+
import { WebhooksResource } from "./resources/webhooks.js";
|
|
36
|
+
import { DiscountCodesResource } from "./resources/discount-codes.js";
|
|
37
|
+
import { NotificationsResource } from "./resources/notifications.js";
|
|
38
|
+
import { WidgetsResource } from "./resources/widgets.js";
|
|
39
|
+
import { OrganizationResource } from "./resources/organization.js";
|
|
40
|
+
import { AnalyticsResource } from "./resources/analytics.js";
|
|
41
|
+
import { EventsResource } from "./resources/events.js";
|
|
42
|
+
export class AnySpendPlatformClient {
|
|
43
|
+
/**
|
|
44
|
+
* Create a new AnySpend Platform API client.
|
|
45
|
+
*
|
|
46
|
+
* @param apiKey - Your API key (starts with `asp_`)
|
|
47
|
+
* @param config - Optional configuration
|
|
48
|
+
*/
|
|
49
|
+
constructor(apiKey, config) {
|
|
50
|
+
this.client = new HttpClient(apiKey, config);
|
|
51
|
+
this.paymentLinks = new PaymentLinksResource(this.client);
|
|
52
|
+
this.products = new ProductsResource(this.client);
|
|
53
|
+
this.customers = new CustomersResource(this.client);
|
|
54
|
+
this.transactions = new TransactionsResource(this.client);
|
|
55
|
+
this.checkoutSessions = new CheckoutSessionsResource(this.client);
|
|
56
|
+
this.webhooks = new WebhooksResource(this.client);
|
|
57
|
+
this.discountCodes = new DiscountCodesResource(this.client);
|
|
58
|
+
this.notifications = new NotificationsResource(this.client);
|
|
59
|
+
this.widgets = new WidgetsResource(this.client);
|
|
60
|
+
this.organization = new OrganizationResource(this.client);
|
|
61
|
+
this.analytics = new AnalyticsResource(this.client);
|
|
62
|
+
this.events = new EventsResource(this.client);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a quick payment link without authentication.
|
|
66
|
+
* Rate limited to 5 requests per minute per IP.
|
|
67
|
+
*
|
|
68
|
+
* @param params - Quick pay parameters
|
|
69
|
+
* @param baseUrl - Optional API base URL (defaults to production)
|
|
70
|
+
*/
|
|
71
|
+
static async quickPay(params, baseUrl = DEFAULT_BASE_URL) {
|
|
72
|
+
return StaticHttpClient.post(baseUrl, "/quick-pay", params);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export { ApiError, AuthenticationError, PermissionError, RateLimitError, NotFoundError, IdempotencyError, } from "./errors.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { AnalyticsOverview } from "../types";
|
|
3
|
+
export declare class AnalyticsResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
overview(period?: "7d" | "30d" | "90d" | "all"): Promise<AnalyticsOverview>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { CheckoutSession, ListResponse, CreateCheckoutSessionParams, PaginationParams } from "../types";
|
|
3
|
+
export interface ListCheckoutSessionsParams extends PaginationParams {
|
|
4
|
+
status?: "open" | "processing" | "completed" | "expired" | "failed";
|
|
5
|
+
payment_link_id?: string;
|
|
6
|
+
from?: number;
|
|
7
|
+
to?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class CheckoutSessionsResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: HttpClient);
|
|
12
|
+
list(params?: ListCheckoutSessionsParams): Promise<ListResponse<CheckoutSession>>;
|
|
13
|
+
listAutoPaginate(params?: Omit<ListCheckoutSessionsParams, "page">): AsyncGenerator<CheckoutSession>;
|
|
14
|
+
create(params: CreateCheckoutSessionParams): Promise<CheckoutSession>;
|
|
15
|
+
get(id: string): Promise<CheckoutSession>;
|
|
16
|
+
expire(id: string): Promise<CheckoutSession>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class CheckoutSessionsResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/checkout-sessions", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), {
|
|
11
|
+
limit: params?.limit,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async create(params) {
|
|
15
|
+
return this.client.post("/checkout-sessions", params);
|
|
16
|
+
}
|
|
17
|
+
async get(id) {
|
|
18
|
+
return this.client.get(`/checkout-sessions/${id}`);
|
|
19
|
+
}
|
|
20
|
+
async expire(id) {
|
|
21
|
+
return this.client.post(`/checkout-sessions/${id}/expire`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { Customer, Transaction, ListResponse, DeletedResponse, CreateCustomerParams, UpdateCustomerParams, ExportCustomersParams, PaginationParams } from "../types";
|
|
3
|
+
export interface ListCustomersParams extends PaginationParams {
|
|
4
|
+
search?: string;
|
|
5
|
+
sort?: "created_at" | "updated_at" | "total_paid" | "transaction_count";
|
|
6
|
+
order?: "asc" | "desc";
|
|
7
|
+
}
|
|
8
|
+
export declare class CustomersResource {
|
|
9
|
+
private client;
|
|
10
|
+
constructor(client: HttpClient);
|
|
11
|
+
list(params?: ListCustomersParams): Promise<ListResponse<Customer>>;
|
|
12
|
+
listAutoPaginate(params?: Omit<ListCustomersParams, "page">): AsyncGenerator<Customer>;
|
|
13
|
+
create(params: CreateCustomerParams): Promise<Customer>;
|
|
14
|
+
get(id: string): Promise<Customer>;
|
|
15
|
+
update(id: string, params: UpdateCustomerParams): Promise<Customer>;
|
|
16
|
+
delete(id: string): Promise<DeletedResponse>;
|
|
17
|
+
transactions(id: string, params?: PaginationParams): Promise<ListResponse<Transaction>>;
|
|
18
|
+
export(params?: ExportCustomersParams): Promise<string>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class CustomersResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/customers", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
async create(params) {
|
|
13
|
+
return this.client.post("/customers", params);
|
|
14
|
+
}
|
|
15
|
+
async get(id) {
|
|
16
|
+
return this.client.get(`/customers/${id}`);
|
|
17
|
+
}
|
|
18
|
+
async update(id, params) {
|
|
19
|
+
return this.client.patch(`/customers/${id}`, params);
|
|
20
|
+
}
|
|
21
|
+
async delete(id) {
|
|
22
|
+
return this.client.delete(`/customers/${id}`);
|
|
23
|
+
}
|
|
24
|
+
async transactions(id, params) {
|
|
25
|
+
return this.client.get(`/customers/${id}/transactions`, params);
|
|
26
|
+
}
|
|
27
|
+
async export(params) {
|
|
28
|
+
return this.client.get("/customers/export", params);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { DiscountCode, ListResponse, DeletedResponse, CreateDiscountCodeParams, BatchCreateDiscountCodesParams, ValidateDiscountResult, BatchCreateResult, PaginationParams } from "../types";
|
|
3
|
+
export interface ListDiscountCodesParams extends PaginationParams {
|
|
4
|
+
payment_link_id?: string;
|
|
5
|
+
active?: "true" | "false";
|
|
6
|
+
search?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UpdateDiscountCodeParams {
|
|
9
|
+
is_active?: boolean;
|
|
10
|
+
max_uses?: number;
|
|
11
|
+
min_order_amount?: string;
|
|
12
|
+
expires_at?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ValidateDiscountParams {
|
|
15
|
+
code: string;
|
|
16
|
+
payment_link_id?: string;
|
|
17
|
+
amount?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class DiscountCodesResource {
|
|
20
|
+
private client;
|
|
21
|
+
constructor(client: HttpClient);
|
|
22
|
+
list(params?: ListDiscountCodesParams): Promise<ListResponse<DiscountCode>>;
|
|
23
|
+
listAutoPaginate(params?: Omit<ListDiscountCodesParams, "page">): AsyncGenerator<DiscountCode>;
|
|
24
|
+
create(params: CreateDiscountCodeParams): Promise<DiscountCode>;
|
|
25
|
+
update(id: string, params: UpdateDiscountCodeParams): Promise<DiscountCode>;
|
|
26
|
+
delete(id: string): Promise<DeletedResponse>;
|
|
27
|
+
validate(params: ValidateDiscountParams): Promise<ValidateDiscountResult>;
|
|
28
|
+
batchCreate(params: BatchCreateDiscountCodesParams): Promise<BatchCreateResult>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class DiscountCodesResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/discount-codes", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
async create(params) {
|
|
13
|
+
return this.client.post("/discount-codes", params);
|
|
14
|
+
}
|
|
15
|
+
async update(id, params) {
|
|
16
|
+
return this.client.patch(`/discount-codes/${id}`, params);
|
|
17
|
+
}
|
|
18
|
+
async delete(id) {
|
|
19
|
+
return this.client.delete(`/discount-codes/${id}`);
|
|
20
|
+
}
|
|
21
|
+
async validate(params) {
|
|
22
|
+
return this.client.post("/discount-codes/validate", params);
|
|
23
|
+
}
|
|
24
|
+
async batchCreate(params) {
|
|
25
|
+
return this.client.post("/discount-codes/batch", params);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { ApiEvent, ListResponse, PaginationParams } from "../types";
|
|
3
|
+
export interface ListEventsParams extends PaginationParams {
|
|
4
|
+
event_type?: string;
|
|
5
|
+
resource_type?: string;
|
|
6
|
+
from?: number;
|
|
7
|
+
to?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class EventsResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: HttpClient);
|
|
12
|
+
list(params?: ListEventsParams): Promise<ListResponse<ApiEvent>>;
|
|
13
|
+
listAutoPaginate(params?: Omit<ListEventsParams, "page">): AsyncGenerator<ApiEvent>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class EventsResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/events", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { NotificationSettings, UpdateNotificationSettingsParams, ActionResponse } from "../types";
|
|
3
|
+
export interface TelegramLinkResult {
|
|
4
|
+
object: "telegram_link";
|
|
5
|
+
link_url: string;
|
|
6
|
+
link_code: string;
|
|
7
|
+
expires_at: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class NotificationsResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: HttpClient);
|
|
12
|
+
get(): Promise<NotificationSettings>;
|
|
13
|
+
update(params: UpdateNotificationSettingsParams): Promise<NotificationSettings>;
|
|
14
|
+
linkTelegram(): Promise<TelegramLinkResult>;
|
|
15
|
+
unlinkTelegram(): Promise<ActionResponse>;
|
|
16
|
+
testEmail(): Promise<ActionResponse>;
|
|
17
|
+
testTelegram(): Promise<ActionResponse>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class NotificationsResource {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
async get() {
|
|
6
|
+
return this.client.get("/notifications");
|
|
7
|
+
}
|
|
8
|
+
async update(params) {
|
|
9
|
+
return this.client.patch("/notifications", params);
|
|
10
|
+
}
|
|
11
|
+
async linkTelegram() {
|
|
12
|
+
return this.client.post("/notifications/telegram/link");
|
|
13
|
+
}
|
|
14
|
+
async unlinkTelegram() {
|
|
15
|
+
return this.client.post("/notifications/telegram/unlink");
|
|
16
|
+
}
|
|
17
|
+
async testEmail() {
|
|
18
|
+
return this.client.post("/notifications/test/email");
|
|
19
|
+
}
|
|
20
|
+
async testTelegram() {
|
|
21
|
+
return this.client.post("/notifications/test/telegram");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { Organization } from "../types";
|
|
3
|
+
export interface UpdateOrganizationParams {
|
|
4
|
+
name?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
logo_url?: string;
|
|
7
|
+
website_url?: string;
|
|
8
|
+
default_recipient_address?: string;
|
|
9
|
+
default_chain_id?: number;
|
|
10
|
+
default_token_address?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class OrganizationResource {
|
|
13
|
+
private client;
|
|
14
|
+
constructor(client: HttpClient);
|
|
15
|
+
get(): Promise<Organization>;
|
|
16
|
+
update(params: UpdateOrganizationParams): Promise<Organization>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { PaymentLink, PaymentLinkItem, PaymentLinkStats, CheckoutSession, ListResponse, DeletedResponse, CreatePaymentLinkParams, CreatePaymentLinkItemParams, UpdatePaymentLinkParams, ListPaymentLinksParams, PaginationParams } from "../types";
|
|
3
|
+
export declare class PaymentLinksResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
list(params?: ListPaymentLinksParams): Promise<ListResponse<PaymentLink>>;
|
|
7
|
+
listAutoPaginate(params?: Omit<ListPaymentLinksParams, "page">): AsyncGenerator<PaymentLink>;
|
|
8
|
+
create(params: CreatePaymentLinkParams): Promise<PaymentLink>;
|
|
9
|
+
get(id: string): Promise<PaymentLink>;
|
|
10
|
+
update(id: string, params: UpdatePaymentLinkParams): Promise<PaymentLink>;
|
|
11
|
+
delete(id: string): Promise<DeletedResponse>;
|
|
12
|
+
duplicate(id: string, overrides?: Partial<CreatePaymentLinkParams>): Promise<PaymentLink>;
|
|
13
|
+
stats(id: string, days?: number): Promise<PaymentLinkStats>;
|
|
14
|
+
sessions(id: string, params?: PaginationParams): Promise<ListResponse<CheckoutSession>>;
|
|
15
|
+
visitors(id: string, params?: PaginationParams & {
|
|
16
|
+
days?: number;
|
|
17
|
+
}): Promise<ListResponse<Record<string, unknown>>>;
|
|
18
|
+
items(id: string): Promise<PaymentLinkItem[]>;
|
|
19
|
+
addItem(id: string, item: CreatePaymentLinkItemParams): Promise<PaymentLinkItem>;
|
|
20
|
+
removeItem(id: string, itemId: string): Promise<DeletedResponse>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class PaymentLinksResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/payment-links", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
async create(params) {
|
|
13
|
+
return this.client.post("/payment-links", params);
|
|
14
|
+
}
|
|
15
|
+
async get(id) {
|
|
16
|
+
return this.client.get(`/payment-links/${id}`);
|
|
17
|
+
}
|
|
18
|
+
async update(id, params) {
|
|
19
|
+
return this.client.patch(`/payment-links/${id}`, params);
|
|
20
|
+
}
|
|
21
|
+
async delete(id) {
|
|
22
|
+
return this.client.delete(`/payment-links/${id}`);
|
|
23
|
+
}
|
|
24
|
+
async duplicate(id, overrides) {
|
|
25
|
+
return this.client.post(`/payment-links/${id}/duplicate`, overrides ?? {});
|
|
26
|
+
}
|
|
27
|
+
async stats(id, days) {
|
|
28
|
+
return this.client.get(`/payment-links/${id}/stats`, days !== undefined ? { days } : undefined);
|
|
29
|
+
}
|
|
30
|
+
async sessions(id, params) {
|
|
31
|
+
return this.client.get(`/payment-links/${id}/sessions`, params);
|
|
32
|
+
}
|
|
33
|
+
async visitors(id, params) {
|
|
34
|
+
return this.client.get(`/payment-links/${id}/visitors`, params);
|
|
35
|
+
}
|
|
36
|
+
async items(id) {
|
|
37
|
+
return this.client.get(`/payment-links/${id}/items`);
|
|
38
|
+
}
|
|
39
|
+
async addItem(id, item) {
|
|
40
|
+
return this.client.post(`/payment-links/${id}/items`, item);
|
|
41
|
+
}
|
|
42
|
+
async removeItem(id, itemId) {
|
|
43
|
+
return this.client.delete(`/payment-links/${id}/items/${itemId}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { Product, PaymentLink, ListResponse, DeletedResponse, CreateProductParams, UpdateProductParams, PaginationParams } from "../types";
|
|
3
|
+
export interface ListProductsParams extends PaginationParams {
|
|
4
|
+
search?: string;
|
|
5
|
+
active?: "true" | "false";
|
|
6
|
+
product_type?: "one_time" | "subscription" | "variable";
|
|
7
|
+
sort?: "created_at" | "updated_at" | "name";
|
|
8
|
+
order?: "asc" | "desc";
|
|
9
|
+
}
|
|
10
|
+
export interface GenerateLinkParams {
|
|
11
|
+
recipient_address?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
theme_color?: string;
|
|
15
|
+
button_text?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class ProductsResource {
|
|
18
|
+
private client;
|
|
19
|
+
constructor(client: HttpClient);
|
|
20
|
+
list(params?: ListProductsParams): Promise<ListResponse<Product>>;
|
|
21
|
+
listAutoPaginate(params?: Omit<ListProductsParams, "page">): AsyncGenerator<Product>;
|
|
22
|
+
create(params: CreateProductParams): Promise<Product>;
|
|
23
|
+
get(id: string): Promise<Product>;
|
|
24
|
+
update(id: string, params: UpdateProductParams): Promise<Product>;
|
|
25
|
+
delete(id: string): Promise<DeletedResponse>;
|
|
26
|
+
generateLink(id: string, params?: GenerateLinkParams): Promise<PaymentLink>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class ProductsResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/products", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
async create(params) {
|
|
13
|
+
return this.client.post("/products", params);
|
|
14
|
+
}
|
|
15
|
+
async get(id) {
|
|
16
|
+
return this.client.get(`/products/${id}`);
|
|
17
|
+
}
|
|
18
|
+
async update(id, params) {
|
|
19
|
+
return this.client.patch(`/products/${id}`, params);
|
|
20
|
+
}
|
|
21
|
+
async delete(id) {
|
|
22
|
+
return this.client.delete(`/products/${id}`);
|
|
23
|
+
}
|
|
24
|
+
async generateLink(id, params) {
|
|
25
|
+
return this.client.post(`/products/${id}/generate-link`, params ?? {});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { Transaction, TransactionStats, ListResponse, ListTransactionsParams, ExportTransactionsParams } from "../types";
|
|
3
|
+
export declare class TransactionsResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
list(params?: ListTransactionsParams): Promise<ListResponse<Transaction>>;
|
|
7
|
+
listAutoPaginate(params?: Omit<ListTransactionsParams, "page">): AsyncGenerator<Transaction>;
|
|
8
|
+
get(id: string): Promise<Transaction>;
|
|
9
|
+
stats(): Promise<TransactionStats>;
|
|
10
|
+
export(params?: ExportTransactionsParams): Promise<string>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class TransactionsResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/transactions", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
async get(id) {
|
|
13
|
+
return this.client.get(`/transactions/${id}`);
|
|
14
|
+
}
|
|
15
|
+
async stats() {
|
|
16
|
+
return this.client.get("/transactions/stats");
|
|
17
|
+
}
|
|
18
|
+
async export(params) {
|
|
19
|
+
return this.client.get("/transactions/export", params);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { Webhook, WebhookDelivery, ListResponse, DeletedResponse, ActionResponse, CreateWebhookParams, UpdateWebhookParams, PaginationParams } from "../types";
|
|
3
|
+
export declare class WebhooksResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
list(): Promise<ListResponse<Webhook>>;
|
|
7
|
+
create(params: CreateWebhookParams): Promise<Webhook>;
|
|
8
|
+
get(id: string): Promise<Webhook>;
|
|
9
|
+
update(id: string, params: UpdateWebhookParams): Promise<Webhook>;
|
|
10
|
+
delete(id: string): Promise<DeletedResponse>;
|
|
11
|
+
test(id: string): Promise<ActionResponse>;
|
|
12
|
+
deliveries(id: string, params?: PaginationParams): Promise<ListResponse<WebhookDelivery>>;
|
|
13
|
+
retry(id: string, deliveryId: string): Promise<ActionResponse>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class WebhooksResource {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
async list() {
|
|
6
|
+
return this.client.get("/webhooks");
|
|
7
|
+
}
|
|
8
|
+
async create(params) {
|
|
9
|
+
return this.client.post("/webhooks", params);
|
|
10
|
+
}
|
|
11
|
+
async get(id) {
|
|
12
|
+
return this.client.get(`/webhooks/${id}`);
|
|
13
|
+
}
|
|
14
|
+
async update(id, params) {
|
|
15
|
+
return this.client.patch(`/webhooks/${id}`, params);
|
|
16
|
+
}
|
|
17
|
+
async delete(id) {
|
|
18
|
+
return this.client.delete(`/webhooks/${id}`);
|
|
19
|
+
}
|
|
20
|
+
async test(id) {
|
|
21
|
+
return this.client.post(`/webhooks/${id}/test`);
|
|
22
|
+
}
|
|
23
|
+
async deliveries(id, params) {
|
|
24
|
+
return this.client.get(`/webhooks/${id}/deliveries`, params);
|
|
25
|
+
}
|
|
26
|
+
async retry(id, deliveryId) {
|
|
27
|
+
return this.client.post(`/webhooks/${id}/deliveries/${deliveryId}/retry`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HttpClient } from "../client";
|
|
2
|
+
import type { WidgetConfig, ListResponse, DeletedResponse, CreateWidgetParams, PaginationParams } from "../types";
|
|
3
|
+
export interface ListWidgetsParams extends PaginationParams {
|
|
4
|
+
search?: string;
|
|
5
|
+
widget_type?: "swap" | "checkout" | "nft" | "deposit";
|
|
6
|
+
active?: "true" | "false";
|
|
7
|
+
sort?: "created_at" | "updated_at" | "name" | "current_views";
|
|
8
|
+
order?: "asc" | "desc";
|
|
9
|
+
}
|
|
10
|
+
export interface UpdateWidgetParams extends Partial<CreateWidgetParams> {
|
|
11
|
+
is_active?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface WidgetStats {
|
|
14
|
+
object: "widget_stats";
|
|
15
|
+
widget_id: string;
|
|
16
|
+
summary: {
|
|
17
|
+
total_views: number;
|
|
18
|
+
total_interactions: number;
|
|
19
|
+
total_completions: number;
|
|
20
|
+
};
|
|
21
|
+
daily: {
|
|
22
|
+
date: string;
|
|
23
|
+
views: number;
|
|
24
|
+
interactions: number;
|
|
25
|
+
completions: number;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
export declare class WidgetsResource {
|
|
29
|
+
private client;
|
|
30
|
+
constructor(client: HttpClient);
|
|
31
|
+
list(params?: ListWidgetsParams): Promise<ListResponse<WidgetConfig>>;
|
|
32
|
+
listAutoPaginate(params?: Omit<ListWidgetsParams, "page">): AsyncGenerator<WidgetConfig>;
|
|
33
|
+
create(params: CreateWidgetParams): Promise<WidgetConfig>;
|
|
34
|
+
get(id: string): Promise<WidgetConfig>;
|
|
35
|
+
update(id: string, params: UpdateWidgetParams): Promise<WidgetConfig>;
|
|
36
|
+
delete(id: string): Promise<DeletedResponse>;
|
|
37
|
+
stats(id: string, days?: number): Promise<WidgetStats>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { autoPaginate } from "../utils/pagination.js";
|
|
2
|
+
export class WidgetsResource {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async list(params) {
|
|
7
|
+
return this.client.get("/widgets", params);
|
|
8
|
+
}
|
|
9
|
+
async *listAutoPaginate(params) {
|
|
10
|
+
yield* autoPaginate((page, limit) => this.list({ ...params, page, limit }), { limit: params?.limit });
|
|
11
|
+
}
|
|
12
|
+
async create(params) {
|
|
13
|
+
return this.client.post("/widgets", params);
|
|
14
|
+
}
|
|
15
|
+
async get(id) {
|
|
16
|
+
return this.client.get(`/widgets/${id}`);
|
|
17
|
+
}
|
|
18
|
+
async update(id, params) {
|
|
19
|
+
return this.client.patch(`/widgets/${id}`, params);
|
|
20
|
+
}
|
|
21
|
+
async delete(id) {
|
|
22
|
+
return this.client.delete(`/widgets/${id}`);
|
|
23
|
+
}
|
|
24
|
+
async stats(id, days) {
|
|
25
|
+
return this.client.get(`/widgets/${id}/stats`, days !== undefined ? { days } : undefined);
|
|
26
|
+
}
|
|
27
|
+
}
|