@djangocfg/api 1.0.4 → 1.0.6
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.cjs +15856 -34128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15274 -34396
- package/dist/index.d.ts +15274 -34396
- package/dist/index.mjs +15853 -33956
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/cfg/contexts/payments/ApiKeysContext.tsx +21 -58
- package/src/cfg/contexts/payments/BalancesContext.tsx +19 -72
- package/src/cfg/contexts/payments/CurrenciesContext.tsx +5 -18
- package/src/cfg/contexts/payments/OverviewContext.tsx +78 -124
- package/src/cfg/contexts/payments/PaymentsContext.tsx +37 -36
- package/src/cfg/contexts/payments/RootPaymentsContext.tsx +7 -76
- package/src/cfg/contexts/payments/index.ts +5 -24
- package/src/cfg/generated/_utils/fetchers/cfg__payments.ts +38 -2380
- package/src/cfg/generated/_utils/fetchers/index.ts +0 -1
- package/src/cfg/generated/_utils/hooks/cfg__payments.ts +41 -2615
- package/src/cfg/generated/_utils/hooks/index.ts +0 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItem.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunk.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunkDetail.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunkRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemDetail.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ChatMessage.schema.ts +2 -2
- package/src/cfg/generated/_utils/schemas/ChatSession.schema.ts +3 -3
- package/src/cfg/generated/_utils/schemas/ChatSessionRequest.schema.ts +3 -3
- package/src/cfg/generated/_utils/schemas/Document.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/DocumentRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PatchedArchiveItemChunkRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PatchedArchiveItemRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PatchedChatSessionRequest.schema.ts +3 -3
- package/src/cfg/generated/_utils/schemas/PatchedDocumentRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PaymentDetail.schema.ts +44 -0
- package/src/cfg/generated/_utils/schemas/PaymentList.schema.ts +7 -11
- package/src/cfg/generated/_utils/schemas/index.ts +1 -81
- package/src/cfg/generated/cfg__payments/client.ts +40 -1732
- package/src/cfg/generated/cfg__payments/models.ts +50 -1795
- package/src/cfg/generated/client.ts +0 -3
- package/src/cfg/generated/enums.ts +5 -347
- package/src/cfg/generated/index.ts +0 -5
- package/src/cfg/generated/schema.ts +5918 -18352
- package/src/cfg/services/payments/ApiKeysService.ts +34 -116
- package/src/cfg/services/payments/DashboardService.ts +37 -122
- package/src/cfg/services/payments/PaymentsService.ts +36 -69
- package/src/cfg/services/payments/SubscriptionsService.ts +35 -136
- package/src/cfg/services/webhooks/WebhooksService.ts +24 -66
- package/src/index.ts +1 -6
- package/src/cfg/generated/_utils/fetchers/cfg__payments__webhooks.ts +0 -109
- package/src/cfg/generated/_utils/hooks/cfg__payments__webhooks.ts +0 -100
- package/src/cfg/generated/_utils/schemas/APIKeyCreate.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyCreateRequest.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyDetail.schema.ts +0 -35
- package/src/cfg/generated/_utils/schemas/APIKeyList.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/APIKeyUpdate.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyUpdateRequest.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyValidationRequest.schema.ts +0 -23
- package/src/cfg/generated/_utils/schemas/APIKeyValidationResponse.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/APIKeysOverview.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/AdminPaymentCreate.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/AdminPaymentCreateRequest.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/AdminPaymentDetail.schema.ts +0 -50
- package/src/cfg/generated/_utils/schemas/AdminPaymentList.schema.ts +0 -38
- package/src/cfg/generated/_utils/schemas/AdminPaymentStats.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/AdminPaymentUpdate.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/AdminPaymentUpdateRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/AdminUser.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/BalanceOverview.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/ChartDataPoint.schema.ts +0 -20
- package/src/cfg/generated/_utils/schemas/ChartSeries.schema.ts +0 -22
- package/src/cfg/generated/_utils/schemas/Currency.schema.ts +0 -35
- package/src/cfg/generated/_utils/schemas/CurrencyAnalyticsItem.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/CurrencyList.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/EndpointGroup.schema.ts +0 -28
- package/src/cfg/generated/_utils/schemas/Network.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/PaginatedAPIKeyListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentStatsList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedAdminUserList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedCurrencyListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedEndpointGroupList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedNetworkList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedProviderCurrencyList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedRecentPaymentList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedRecentTransactionList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedSubscriptionListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedTariffList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedTransactionList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedUserBalanceList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedWebhookEventListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedWebhookStatsList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PatchedAPIKeyUpdateRequest.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PatchedAdminPaymentUpdateRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/PatchedPaymentRequest.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/PatchedSubscriptionRequest.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/Payment.schema.ts +0 -49
- package/src/cfg/generated/_utils/schemas/PaymentAnalyticsResponse.schema.ts +0 -22
- package/src/cfg/generated/_utils/schemas/PaymentCreate.schema.ts +0 -28
- package/src/cfg/generated/_utils/schemas/PaymentCreateRequest.schema.ts +0 -28
- package/src/cfg/generated/_utils/schemas/PaymentOverview.schema.ts +0 -31
- package/src/cfg/generated/_utils/schemas/PaymentRequest.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/PaymentsChartResponse.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaymentsDashboardOverview.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/PaymentsMetrics.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/ProviderAnalyticsItem.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/ProviderCurrency.schema.ts +0 -36
- package/src/cfg/generated/_utils/schemas/RecentPayment.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/RecentTransaction.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/Subscription.schema.ts +0 -41
- package/src/cfg/generated/_utils/schemas/SubscriptionCreate.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/SubscriptionCreateRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/SubscriptionList.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/SubscriptionOverview.schema.ts +0 -37
- package/src/cfg/generated/_utils/schemas/SubscriptionRequest.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/SupportedCurrencies.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/SupportedProviders.schema.ts +0 -22
- package/src/cfg/generated/_utils/schemas/Tariff.schema.ts +0 -34
- package/src/cfg/generated/_utils/schemas/Transaction.schema.ts +0 -35
- package/src/cfg/generated/_utils/schemas/UserBalance.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/WebhookEvent.schema.ts +0 -31
- package/src/cfg/generated/_utils/schemas/WebhookEventList.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/WebhookEventListRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/WebhookEventRequest.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/WebhookHealth.schema.ts +0 -21
- package/src/cfg/generated/_utils/schemas/WebhookProviderStats.schema.ts +0 -23
- package/src/cfg/generated/_utils/schemas/WebhookProviderStatsRequest.schema.ts +0 -23
- package/src/cfg/generated/_utils/schemas/WebhookResponse.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/WebhookResponseRequest.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/WebhookStats.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/WebhookStatsRequest.schema.ts +0 -27
- package/src/cfg/generated/cfg__payments__webhooks/client.ts +0 -75
- package/src/cfg/generated/cfg__payments__webhooks/index.ts +0 -2
- package/src/cfg/generated/cfg__payments__webhooks/models.ts +0 -87
|
@@ -1,202 +1,101 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Subscriptions Service
|
|
2
|
+
* Subscriptions Service (DEPRECATED)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Subscriptions functionality has been removed in Payments v2.0
|
|
5
|
+
* This service is kept as a stub for backward compatibility
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import { BaseClient } from '../../BaseClient';
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
const DEPRECATED_ERROR = 'Subscriptions feature has been removed in Payments v2.0';
|
|
9
11
|
|
|
10
12
|
export class SubscriptionsService extends BaseClient {
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* @deprecated Subscriptions removed in v2.0
|
|
13
15
|
*/
|
|
14
|
-
static async list(
|
|
15
|
-
ordering?: string;
|
|
16
|
-
page?: number;
|
|
17
|
-
page_size?: number;
|
|
18
|
-
search?: string;
|
|
19
|
-
status?: string;
|
|
20
|
-
tier?: string;
|
|
21
|
-
user?: number;
|
|
22
|
-
}): Promise<{
|
|
16
|
+
static async list(): Promise<{
|
|
23
17
|
success: boolean;
|
|
24
|
-
subscriptions?:
|
|
18
|
+
subscriptions?: never;
|
|
25
19
|
error?: string;
|
|
26
20
|
}> {
|
|
27
|
-
|
|
28
|
-
const response = await this.api.cfg_payments.subscriptionsList(
|
|
29
|
-
params?.ordering,
|
|
30
|
-
params?.page,
|
|
31
|
-
params?.page_size,
|
|
32
|
-
params?.search,
|
|
33
|
-
params?.status,
|
|
34
|
-
params?.tier,
|
|
35
|
-
params?.user
|
|
36
|
-
);
|
|
37
|
-
return { success: true, subscriptions: response };
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error instanceof APIError) {
|
|
40
|
-
return { success: false, error: error.errorMessage };
|
|
41
|
-
}
|
|
42
|
-
return { success: false, error: 'Network error' };
|
|
43
|
-
}
|
|
21
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
44
22
|
}
|
|
45
23
|
|
|
46
24
|
/**
|
|
47
|
-
*
|
|
25
|
+
* @deprecated Subscriptions removed in v2.0
|
|
48
26
|
*/
|
|
49
|
-
static async create(
|
|
50
|
-
data: CfgPaymentsTypes.SubscriptionCreateRequest
|
|
51
|
-
): Promise<{
|
|
27
|
+
static async create(): Promise<{
|
|
52
28
|
success: boolean;
|
|
53
|
-
subscription?:
|
|
29
|
+
subscription?: never;
|
|
54
30
|
error?: string;
|
|
55
31
|
fieldErrors?: Record<string, string[]>;
|
|
56
32
|
}> {
|
|
57
|
-
|
|
58
|
-
const subscription = await this.api.cfg_payments.subscriptionsCreate(data);
|
|
59
|
-
return { success: true, subscription };
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (error instanceof APIError) {
|
|
62
|
-
if (error.isValidationError && error.fieldErrors) {
|
|
63
|
-
return { success: false, fieldErrors: error.fieldErrors };
|
|
64
|
-
}
|
|
65
|
-
return { success: false, error: error.errorMessage };
|
|
66
|
-
}
|
|
67
|
-
return { success: false, error: 'Network error' };
|
|
68
|
-
}
|
|
33
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
69
34
|
}
|
|
70
35
|
|
|
71
36
|
/**
|
|
72
|
-
*
|
|
37
|
+
* @deprecated Subscriptions removed in v2.0
|
|
73
38
|
*/
|
|
74
|
-
static async get(
|
|
39
|
+
static async get(): Promise<{
|
|
75
40
|
success: boolean;
|
|
76
|
-
subscription?:
|
|
41
|
+
subscription?: never;
|
|
77
42
|
error?: string;
|
|
78
43
|
}> {
|
|
79
|
-
|
|
80
|
-
const subscription = await this.api.cfg_payments.subscriptionsRetrieve(id);
|
|
81
|
-
return { success: true, subscription };
|
|
82
|
-
} catch (error) {
|
|
83
|
-
if (error instanceof APIError) {
|
|
84
|
-
return { success: false, error: error.errorMessage };
|
|
85
|
-
}
|
|
86
|
-
return { success: false, error: 'Network error' };
|
|
87
|
-
}
|
|
44
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
88
45
|
}
|
|
89
46
|
|
|
90
47
|
/**
|
|
91
|
-
*
|
|
48
|
+
* @deprecated Subscriptions removed in v2.0
|
|
92
49
|
*/
|
|
93
|
-
static async update(
|
|
94
|
-
id: string,
|
|
95
|
-
data: CfgPaymentsTypes.PatchedSubscriptionRequest
|
|
96
|
-
): Promise<{
|
|
50
|
+
static async update(): Promise<{
|
|
97
51
|
success: boolean;
|
|
98
|
-
subscription?:
|
|
52
|
+
subscription?: never;
|
|
99
53
|
error?: string;
|
|
100
54
|
fieldErrors?: Record<string, string[]>;
|
|
101
55
|
}> {
|
|
102
|
-
|
|
103
|
-
const subscription = await this.api.cfg_payments.subscriptionsPartialUpdate(id, data);
|
|
104
|
-
return { success: true, subscription };
|
|
105
|
-
} catch (error) {
|
|
106
|
-
if (error instanceof APIError) {
|
|
107
|
-
if (error.isValidationError && error.fieldErrors) {
|
|
108
|
-
return { success: false, fieldErrors: error.fieldErrors };
|
|
109
|
-
}
|
|
110
|
-
return { success: false, error: error.errorMessage };
|
|
111
|
-
}
|
|
112
|
-
return { success: false, error: 'Network error' };
|
|
113
|
-
}
|
|
56
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
114
57
|
}
|
|
115
58
|
|
|
116
59
|
/**
|
|
117
|
-
*
|
|
60
|
+
* @deprecated Subscriptions removed in v2.0
|
|
118
61
|
*/
|
|
119
|
-
static async delete(
|
|
62
|
+
static async delete(): Promise<{
|
|
120
63
|
success: boolean;
|
|
121
64
|
error?: string;
|
|
122
65
|
}> {
|
|
123
|
-
|
|
124
|
-
await this.api.cfg_payments.subscriptionsDestroy(id);
|
|
125
|
-
return { success: true };
|
|
126
|
-
} catch (error) {
|
|
127
|
-
if (error instanceof APIError) {
|
|
128
|
-
return { success: false, error: error.errorMessage };
|
|
129
|
-
}
|
|
130
|
-
return { success: false, error: 'Network error' };
|
|
131
|
-
}
|
|
66
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
132
67
|
}
|
|
133
68
|
|
|
134
69
|
/**
|
|
135
|
-
*
|
|
70
|
+
* @deprecated Subscriptions removed in v2.0
|
|
136
71
|
*/
|
|
137
72
|
static async getAnalytics(): Promise<{
|
|
138
73
|
success: boolean;
|
|
139
|
-
analytics?:
|
|
74
|
+
analytics?: never;
|
|
140
75
|
error?: string;
|
|
141
76
|
}> {
|
|
142
|
-
|
|
143
|
-
const analytics = await this.api.cfg_payments.subscriptionsAnalyticsRetrieve();
|
|
144
|
-
return { success: true, analytics };
|
|
145
|
-
} catch (error) {
|
|
146
|
-
if (error instanceof APIError) {
|
|
147
|
-
return { success: false, error: error.errorMessage };
|
|
148
|
-
}
|
|
149
|
-
return { success: false, error: 'Network error' };
|
|
150
|
-
}
|
|
77
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
151
78
|
}
|
|
152
79
|
|
|
153
80
|
/**
|
|
154
|
-
*
|
|
81
|
+
* @deprecated Subscriptions removed in v2.0
|
|
155
82
|
*/
|
|
156
|
-
static async listTariffs(
|
|
157
|
-
is_active?: boolean;
|
|
158
|
-
ordering?: string;
|
|
159
|
-
page?: number;
|
|
160
|
-
page_size?: number;
|
|
161
|
-
search?: string;
|
|
162
|
-
}): Promise<{
|
|
83
|
+
static async listTariffs(): Promise<{
|
|
163
84
|
success: boolean;
|
|
164
|
-
tariffs?:
|
|
85
|
+
tariffs?: never;
|
|
165
86
|
error?: string;
|
|
166
87
|
}> {
|
|
167
|
-
|
|
168
|
-
const response = await this.api.cfg_payments.tariffsList(
|
|
169
|
-
params?.is_active,
|
|
170
|
-
params?.ordering,
|
|
171
|
-
params?.page,
|
|
172
|
-
params?.page_size,
|
|
173
|
-
params?.search
|
|
174
|
-
);
|
|
175
|
-
return { success: true, tariffs: response };
|
|
176
|
-
} catch (error) {
|
|
177
|
-
if (error instanceof APIError) {
|
|
178
|
-
return { success: false, error: error.errorMessage };
|
|
179
|
-
}
|
|
180
|
-
return { success: false, error: 'Network error' };
|
|
181
|
-
}
|
|
88
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
182
89
|
}
|
|
183
90
|
|
|
184
91
|
/**
|
|
185
|
-
*
|
|
92
|
+
* @deprecated Subscriptions removed in v2.0
|
|
186
93
|
*/
|
|
187
|
-
static async getTariff(
|
|
94
|
+
static async getTariff(): Promise<{
|
|
188
95
|
success: boolean;
|
|
189
|
-
tariff?:
|
|
96
|
+
tariff?: never;
|
|
190
97
|
error?: string;
|
|
191
98
|
}> {
|
|
192
|
-
|
|
193
|
-
const tariff = await this.api.cfg_payments.tariffsRetrieve(id);
|
|
194
|
-
return { success: true, tariff };
|
|
195
|
-
} catch (error) {
|
|
196
|
-
if (error instanceof APIError) {
|
|
197
|
-
return { success: false, error: error.errorMessage };
|
|
198
|
-
}
|
|
199
|
-
return { success: false, error: 'Network error' };
|
|
200
|
-
}
|
|
99
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
201
100
|
}
|
|
202
101
|
}
|
|
@@ -1,108 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Webhooks Service
|
|
2
|
+
* Webhooks Service (DEPRECATED)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Webhooks functionality has been integrated into main Payments API in v2.0
|
|
5
|
+
* This service is kept as a stub for backward compatibility
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
8
|
import { BaseClient } from '../../BaseClient';
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
const DEPRECATED_ERROR = 'Webhooks feature has been integrated into Payments API in v2.0';
|
|
9
11
|
|
|
10
12
|
export class WebhooksService extends BaseClient {
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* @deprecated Webhooks integrated into Payments API in v2.0
|
|
13
15
|
*/
|
|
14
|
-
static async
|
|
16
|
+
static async list(): Promise<{
|
|
15
17
|
success: boolean;
|
|
16
|
-
|
|
18
|
+
events?: never;
|
|
17
19
|
error?: string;
|
|
18
20
|
}> {
|
|
19
|
-
|
|
20
|
-
const webhook = await this.api.cfg_webhooks.paymentsWebhooksRetrieve(provider);
|
|
21
|
-
return { success: true, webhook };
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (error instanceof APIError) {
|
|
24
|
-
return { success: false, error: error.errorMessage };
|
|
25
|
-
}
|
|
26
|
-
return { success: false, error: 'Network error' };
|
|
27
|
-
}
|
|
21
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
/**
|
|
31
|
-
*
|
|
25
|
+
* @deprecated Webhooks integrated into Payments API in v2.0
|
|
32
26
|
*/
|
|
33
|
-
static async
|
|
34
|
-
provider: string,
|
|
35
|
-
data: CfgWebhooksTypes.WebhookResponseRequest
|
|
36
|
-
): Promise<{
|
|
27
|
+
static async get(): Promise<{
|
|
37
28
|
success: boolean;
|
|
38
|
-
|
|
29
|
+
event?: never;
|
|
39
30
|
error?: string;
|
|
40
31
|
}> {
|
|
41
|
-
|
|
42
|
-
const response = await this.api.cfg_webhooks.paymentsWebhooksCreate(provider, data);
|
|
43
|
-
return { success: true, response };
|
|
44
|
-
} catch (error) {
|
|
45
|
-
if (error instanceof APIError) {
|
|
46
|
-
return { success: false, error: error.errorMessage };
|
|
47
|
-
}
|
|
48
|
-
return { success: false, error: 'Network error' };
|
|
49
|
-
}
|
|
32
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
50
33
|
}
|
|
51
34
|
|
|
52
35
|
/**
|
|
53
|
-
*
|
|
36
|
+
* @deprecated Webhooks integrated into Payments API in v2.0
|
|
54
37
|
*/
|
|
55
|
-
static async
|
|
38
|
+
static async getStats(): Promise<{
|
|
56
39
|
success: boolean;
|
|
57
|
-
|
|
40
|
+
stats?: never;
|
|
58
41
|
error?: string;
|
|
59
42
|
}> {
|
|
60
|
-
|
|
61
|
-
const health = await this.api.cfg_webhooks.paymentsWebhooksHealthRetrieve();
|
|
62
|
-
return { success: true, health };
|
|
63
|
-
} catch (error) {
|
|
64
|
-
if (error instanceof APIError) {
|
|
65
|
-
return { success: false, error: error.errorMessage };
|
|
66
|
-
}
|
|
67
|
-
return { success: false, error: 'Network error' };
|
|
68
|
-
}
|
|
43
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
69
44
|
}
|
|
70
45
|
|
|
71
46
|
/**
|
|
72
|
-
*
|
|
47
|
+
* @deprecated Webhooks integrated into Payments API in v2.0
|
|
73
48
|
*/
|
|
74
|
-
static async
|
|
49
|
+
static async getHealth(): Promise<{
|
|
75
50
|
success: boolean;
|
|
76
|
-
|
|
51
|
+
health?: never;
|
|
77
52
|
error?: string;
|
|
78
53
|
}> {
|
|
79
|
-
|
|
80
|
-
const providers = await this.api.cfg_webhooks.paymentsWebhooksProvidersRetrieve();
|
|
81
|
-
return { success: true, providers };
|
|
82
|
-
} catch (error) {
|
|
83
|
-
if (error instanceof APIError) {
|
|
84
|
-
return { success: false, error: error.errorMessage };
|
|
85
|
-
}
|
|
86
|
-
return { success: false, error: 'Network error' };
|
|
87
|
-
}
|
|
54
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
88
55
|
}
|
|
89
56
|
|
|
90
57
|
/**
|
|
91
|
-
*
|
|
58
|
+
* @deprecated Webhooks integrated into Payments API in v2.0
|
|
92
59
|
*/
|
|
93
|
-
static async
|
|
60
|
+
static async retry(): Promise<{
|
|
94
61
|
success: boolean;
|
|
95
|
-
stats?: CfgWebhooksTypes.WebhookStats;
|
|
96
62
|
error?: string;
|
|
97
63
|
}> {
|
|
98
|
-
|
|
99
|
-
const stats = await this.api.cfg_webhooks.paymentsWebhooksStatsRetrieve({ days });
|
|
100
|
-
return { success: true, stats };
|
|
101
|
-
} catch (error) {
|
|
102
|
-
if (error instanceof APIError) {
|
|
103
|
-
return { success: false, error: error.errorMessage };
|
|
104
|
-
}
|
|
105
|
-
return { success: false, error: 'Network error' };
|
|
106
|
-
}
|
|
64
|
+
return { success: false, error: DEPRECATED_ERROR };
|
|
107
65
|
}
|
|
108
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,13 +42,8 @@ export * from './cfg/contexts';
|
|
|
42
42
|
export { Schemas, Fetchers } from './cfg/generated';
|
|
43
43
|
|
|
44
44
|
// Re-export commonly used types directly for convenience
|
|
45
|
-
// Usage: import type {
|
|
45
|
+
// Usage: import type { User } from '@djangocfg/api'
|
|
46
46
|
export type {
|
|
47
|
-
// API Keys
|
|
48
|
-
APIKeyList,
|
|
49
|
-
APIKeyDetail,
|
|
50
|
-
APIKeyCreate,
|
|
51
|
-
PaginatedAPIKeyListList,
|
|
52
47
|
// Auth
|
|
53
48
|
OTPRequestResponse,
|
|
54
49
|
OTPVerifyResponse,
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed fetchers for Webhooks
|
|
3
|
-
*
|
|
4
|
-
* Universal functions that work in any environment:
|
|
5
|
-
* - Next.js (App Router / Pages Router / Server Components)
|
|
6
|
-
* - React Native
|
|
7
|
-
* - Node.js backend
|
|
8
|
-
*
|
|
9
|
-
* These fetchers use Zod schemas for runtime validation.
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Configure API once (in your app entry point)
|
|
14
|
-
* import { configureAPI } from '../../api-instance'
|
|
15
|
-
* configureAPI({ baseUrl: 'https://api.example.com' })
|
|
16
|
-
*
|
|
17
|
-
* // Then use fetchers anywhere
|
|
18
|
-
* const users = await getUsers({ page: 1 })
|
|
19
|
-
*
|
|
20
|
-
* // With SWR
|
|
21
|
-
* const { data } = useSWR(['users', params], () => getUsers(params))
|
|
22
|
-
*
|
|
23
|
-
* // With React Query
|
|
24
|
-
* const { data } = useQuery(['users', params], () => getUsers(params))
|
|
25
|
-
*
|
|
26
|
-
* // In Server Component or SSR (pass custom client)
|
|
27
|
-
* import { API } from '../../index'
|
|
28
|
-
* const api = new API('https://api.example.com')
|
|
29
|
-
* const users = await getUsers({ page: 1 }, api)
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
import { SupportedProvidersSchema, type SupportedProviders } from '../schemas/SupportedProviders.schema'
|
|
33
|
-
import { WebhookHealthSchema, type WebhookHealth } from '../schemas/WebhookHealth.schema'
|
|
34
|
-
import { WebhookResponseSchema, type WebhookResponse } from '../schemas/WebhookResponse.schema'
|
|
35
|
-
import { WebhookResponseRequestSchema, type WebhookResponseRequest } from '../schemas/WebhookResponseRequest.schema'
|
|
36
|
-
import { WebhookStatsSchema, type WebhookStats } from '../schemas/WebhookStats.schema'
|
|
37
|
-
import { getAPIInstance } from '../../api-instance'
|
|
38
|
-
import type { API } from '../../index'
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Webhook Endpoint Info
|
|
42
|
-
*
|
|
43
|
-
* @method GET
|
|
44
|
-
* @path /cfg/payments/webhooks/{provider}/
|
|
45
|
-
*/
|
|
46
|
-
export async function getPaymentsWebhooksRetrieve( provider: string, client?
|
|
47
|
-
): Promise<WebhookResponse> {
|
|
48
|
-
const api = client || getAPIInstance()
|
|
49
|
-
const response = await api.cfg_webhooks.paymentsWebhooksRetrieve(provider)
|
|
50
|
-
return WebhookResponseSchema.parse(response)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Process Webhook
|
|
56
|
-
*
|
|
57
|
-
* @method POST
|
|
58
|
-
* @path /cfg/payments/webhooks/{provider}/
|
|
59
|
-
*/
|
|
60
|
-
export async function createPaymentsWebhooksCreate( provider: string, data: WebhookResponseRequest, client?
|
|
61
|
-
): Promise<WebhookResponse> {
|
|
62
|
-
const api = client || getAPIInstance()
|
|
63
|
-
const response = await api.cfg_webhooks.paymentsWebhooksCreate(provider, data)
|
|
64
|
-
return WebhookResponseSchema.parse(response)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Webhook Health Check
|
|
70
|
-
*
|
|
71
|
-
* @method GET
|
|
72
|
-
* @path /cfg/payments/webhooks/health/
|
|
73
|
-
*/
|
|
74
|
-
export async function getPaymentsWebhooksHealthRetrieve( client?
|
|
75
|
-
): Promise<WebhookHealth> {
|
|
76
|
-
const api = client || getAPIInstance()
|
|
77
|
-
const response = await api.cfg_webhooks.paymentsWebhooksHealthRetrieve()
|
|
78
|
-
return WebhookHealthSchema.parse(response)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Supported Webhook Providers
|
|
84
|
-
*
|
|
85
|
-
* @method GET
|
|
86
|
-
* @path /cfg/payments/webhooks/providers/
|
|
87
|
-
*/
|
|
88
|
-
export async function getPaymentsWebhooksProvidersRetrieve( client?
|
|
89
|
-
): Promise<SupportedProviders> {
|
|
90
|
-
const api = client || getAPIInstance()
|
|
91
|
-
const response = await api.cfg_webhooks.paymentsWebhooksProvidersRetrieve()
|
|
92
|
-
return SupportedProvidersSchema.parse(response)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Webhook Statistics
|
|
98
|
-
*
|
|
99
|
-
* @method GET
|
|
100
|
-
* @path /cfg/payments/webhooks/stats/
|
|
101
|
-
*/
|
|
102
|
-
export async function getPaymentsWebhooksStatsRetrieve( params?: { days?: number }, client?
|
|
103
|
-
): Promise<WebhookStats> {
|
|
104
|
-
const api = client || getAPIInstance()
|
|
105
|
-
const response = await api.cfg_webhooks.paymentsWebhooksStatsRetrieve(params?.days)
|
|
106
|
-
return WebhookStatsSchema.parse(response)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SWR Hooks for Webhooks
|
|
3
|
-
*
|
|
4
|
-
* React hooks powered by SWR for data fetching with automatic caching,
|
|
5
|
-
* revalidation, and optimistic updates.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* // Query hooks (GET)
|
|
10
|
-
* const { data, error, isLoading } = useUsers({ page: 1 })
|
|
11
|
-
*
|
|
12
|
-
* // Mutation hooks (POST/PUT/PATCH/DELETE)
|
|
13
|
-
* const createUser = useCreateUser()
|
|
14
|
-
* await createUser({ name: 'John', email: 'john@example.com' })
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
import useSWR from 'swr'
|
|
18
|
-
import { useSWRConfig } from 'swr'
|
|
19
|
-
import * as Fetchers from '../fetchers/cfg__payments__webhooks'
|
|
20
|
-
import type { API } from '../../index'
|
|
21
|
-
import type { SupportedProviders } from '../schemas/SupportedProviders.schema'
|
|
22
|
-
import type { WebhookHealth } from '../schemas/WebhookHealth.schema'
|
|
23
|
-
import type { WebhookResponse } from '../schemas/WebhookResponse.schema'
|
|
24
|
-
import type { WebhookResponseRequest } from '../schemas/WebhookResponseRequest.schema'
|
|
25
|
-
import type { WebhookStats } from '../schemas/WebhookStats.schema'
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Webhook Endpoint Info
|
|
29
|
-
*
|
|
30
|
-
* @method GET
|
|
31
|
-
* @path /cfg/payments/webhooks/{provider}/
|
|
32
|
-
*/
|
|
33
|
-
export function usePaymentsWebhooksRetrieve(provider: string, client?: API): ReturnType<typeof useSWR<WebhookResponse>> {
|
|
34
|
-
return useSWR<WebhookResponse>(
|
|
35
|
-
['cfg-payments-webhook', provider],
|
|
36
|
-
() => Fetchers.getPaymentsWebhooksRetrieve(provider, client)
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Process Webhook
|
|
43
|
-
*
|
|
44
|
-
* @method POST
|
|
45
|
-
* @path /cfg/payments/webhooks/{provider}/
|
|
46
|
-
*/
|
|
47
|
-
export function useCreatePaymentsWebhooksCreate() {
|
|
48
|
-
const { mutate } = useSWRConfig()
|
|
49
|
-
|
|
50
|
-
return async (provider: string, data: WebhookResponseRequest, client?: API): Promise<WebhookResponse> => {
|
|
51
|
-
const result = await Fetchers.createPaymentsWebhooksCreate(provider, data, client)
|
|
52
|
-
// Revalidate related queries
|
|
53
|
-
mutate('cfg-payments-webhooks')
|
|
54
|
-
return result
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Webhook Health Check
|
|
61
|
-
*
|
|
62
|
-
* @method GET
|
|
63
|
-
* @path /cfg/payments/webhooks/health/
|
|
64
|
-
*/
|
|
65
|
-
export function usePaymentsWebhooksHealthRetrieve(client?: API): ReturnType<typeof useSWR<WebhookHealth>> {
|
|
66
|
-
return useSWR<WebhookHealth>(
|
|
67
|
-
'cfg-payments-webhooks-health',
|
|
68
|
-
() => Fetchers.getPaymentsWebhooksHealthRetrieve(client)
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Supported Webhook Providers
|
|
75
|
-
*
|
|
76
|
-
* @method GET
|
|
77
|
-
* @path /cfg/payments/webhooks/providers/
|
|
78
|
-
*/
|
|
79
|
-
export function usePaymentsWebhooksProvidersRetrieve(client?: API): ReturnType<typeof useSWR<SupportedProviders>> {
|
|
80
|
-
return useSWR<SupportedProviders>(
|
|
81
|
-
'cfg-payments-webhooks-provider',
|
|
82
|
-
() => Fetchers.getPaymentsWebhooksProvidersRetrieve(client)
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Webhook Statistics
|
|
89
|
-
*
|
|
90
|
-
* @method GET
|
|
91
|
-
* @path /cfg/payments/webhooks/stats/
|
|
92
|
-
*/
|
|
93
|
-
export function usePaymentsWebhooksStatsRetrieve(params?: { days?: number }, client?: API): ReturnType<typeof useSWR<WebhookStats>> {
|
|
94
|
-
return useSWR<WebhookStats>(
|
|
95
|
-
params ? ['cfg-payments-webhooks-stat', params] : 'cfg-payments-webhooks-stat',
|
|
96
|
-
() => Fetchers.getPaymentsWebhooksStatsRetrieve(params, client)
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod schema for APIKeyCreate
|
|
3
|
-
*
|
|
4
|
-
* This schema provides runtime validation and type inference.
|
|
5
|
-
* * API key creation serializer with service integration.
|
|
6
|
-
|
|
7
|
-
Creates new API keys and returns the full key value (only once).
|
|
8
|
-
* */
|
|
9
|
-
import { z } from 'zod'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* API key creation serializer with service integration.
|
|
13
|
-
|
|
14
|
-
Creates new API keys and returns the full key value (only once).
|
|
15
|
-
*/
|
|
16
|
-
export const APIKeyCreateSchema = z.object({
|
|
17
|
-
name: z.string().max(100),
|
|
18
|
-
expires_in_days: z.int().min(1.0).max(365.0).nullable().optional(),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Infer TypeScript type from Zod schema
|
|
23
|
-
*/
|
|
24
|
-
export type APIKeyCreate = z.infer<typeof APIKeyCreateSchema>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod schema for APIKeyCreateRequest
|
|
3
|
-
*
|
|
4
|
-
* This schema provides runtime validation and type inference.
|
|
5
|
-
* * API key creation serializer with service integration.
|
|
6
|
-
|
|
7
|
-
Creates new API keys and returns the full key value (only once).
|
|
8
|
-
* */
|
|
9
|
-
import { z } from 'zod'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* API key creation serializer with service integration.
|
|
13
|
-
|
|
14
|
-
Creates new API keys and returns the full key value (only once).
|
|
15
|
-
*/
|
|
16
|
-
export const APIKeyCreateRequestSchema = z.object({
|
|
17
|
-
name: z.string().min(1).max(100),
|
|
18
|
-
expires_in_days: z.int().min(1.0).max(365.0).nullable().optional(),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Infer TypeScript type from Zod schema
|
|
23
|
-
*/
|
|
24
|
-
export type APIKeyCreateRequest = z.infer<typeof APIKeyCreateRequestSchema>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod schema for APIKeyDetail
|
|
3
|
-
*
|
|
4
|
-
* This schema provides runtime validation and type inference.
|
|
5
|
-
* * Complete API key serializer with full details.
|
|
6
|
-
|
|
7
|
-
Used for API key detail views (no key value for security).
|
|
8
|
-
* */
|
|
9
|
-
import { z } from 'zod'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Complete API key serializer with full details.
|
|
13
|
-
|
|
14
|
-
Used for API key detail views (no key value for security).
|
|
15
|
-
*/
|
|
16
|
-
export const APIKeyDetailSchema = z.object({
|
|
17
|
-
id: z.uuid(),
|
|
18
|
-
user: z.string(),
|
|
19
|
-
name: z.string(),
|
|
20
|
-
key_preview: z.string(),
|
|
21
|
-
is_active: z.boolean(),
|
|
22
|
-
is_expired: z.boolean(),
|
|
23
|
-
is_valid: z.boolean(),
|
|
24
|
-
days_until_expiry: z.int(),
|
|
25
|
-
total_requests: z.int(),
|
|
26
|
-
last_used_at: z.iso.datetime().nullable(),
|
|
27
|
-
expires_at: z.iso.datetime().nullable(),
|
|
28
|
-
created_at: z.iso.datetime(),
|
|
29
|
-
updated_at: z.iso.datetime(),
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Infer TypeScript type from Zod schema
|
|
34
|
-
*/
|
|
35
|
-
export type APIKeyDetail = z.infer<typeof APIKeyDetailSchema>
|