@djangocfg/ext-payments 1.0.17 → 1.0.19

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.
Files changed (46) hide show
  1. package/dist/config.cjs +1 -1
  2. package/dist/config.js +1 -1
  3. package/dist/index.cjs +1175 -290
  4. package/dist/index.d.cts +226 -80
  5. package/dist/index.d.ts +226 -80
  6. package/dist/index.js +1157 -255
  7. package/package.json +9 -9
  8. package/src/WalletPage.tsx +100 -0
  9. package/src/api/generated/ext_payments/CLAUDE.md +6 -4
  10. package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +37 -6
  11. package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +34 -3
  12. package/src/api/generated/ext_payments/_utils/schemas/Balance.schema.ts +1 -1
  13. package/src/api/generated/ext_payments/_utils/schemas/PaymentCreateResponse.schema.ts +22 -0
  14. package/src/api/generated/ext_payments/_utils/schemas/PaymentDetail.schema.ts +3 -3
  15. package/src/api/generated/ext_payments/_utils/schemas/PaymentList.schema.ts +2 -2
  16. package/src/api/generated/ext_payments/_utils/schemas/Transaction.schema.ts +1 -1
  17. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCancelResponse.schema.ts +22 -0
  18. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateResponse.schema.ts +22 -0
  19. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalDetail.schema.ts +5 -5
  20. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalList.schema.ts +2 -2
  21. package/src/api/generated/ext_payments/_utils/schemas/index.ts +3 -0
  22. package/src/api/generated/ext_payments/client.ts +1 -1
  23. package/src/api/generated/ext_payments/ext_payments__payments/client.ts +49 -4
  24. package/src/api/generated/ext_payments/ext_payments__payments/models.ts +33 -14
  25. package/src/api/generated/ext_payments/index.ts +1 -1
  26. package/src/api/generated/ext_payments/schema.json +167 -33
  27. package/src/components/AddFundsSheet.tsx +157 -73
  28. package/src/components/CurrencyCombobox.tsx +49 -0
  29. package/src/components/PaymentSheet.tsx +94 -32
  30. package/src/components/WithdrawSheet.tsx +121 -95
  31. package/src/components/WithdrawalSheet.tsx +332 -0
  32. package/src/components/index.ts +1 -8
  33. package/src/config.ts +1 -0
  34. package/src/contexts/WalletContext.tsx +10 -9
  35. package/src/contexts/index.ts +5 -1
  36. package/src/contexts/types.ts +46 -0
  37. package/src/hooks/index.ts +3 -0
  38. package/src/hooks/useCurrencyOptions.ts +79 -0
  39. package/src/hooks/useEstimate.ts +113 -0
  40. package/src/hooks/useWithdrawalEstimate.ts +117 -0
  41. package/src/index.ts +3 -0
  42. package/src/types/index.ts +78 -0
  43. package/src/utils/errors.ts +36 -0
  44. package/src/utils/format.ts +65 -0
  45. package/src/utils/index.ts +3 -0
  46. package/src/components/ResponsiveSheet.tsx +0 -151
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ext-payments",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Payments system extension for DjangoCFG",
5
5
  "keywords": [
6
6
  "django",
@@ -54,10 +54,10 @@
54
54
  "check": "tsc --noEmit"
55
55
  },
56
56
  "peerDependencies": {
57
- "@djangocfg/api": "^2.1.108",
58
- "@djangocfg/ext-base": "^1.0.12",
59
- "@djangocfg/ui-core": "^2.1.108",
60
- "@djangocfg/ui-nextjs": "^2.1.108",
57
+ "@djangocfg/api": "^2.1.109",
58
+ "@djangocfg/ext-base": "^1.0.14",
59
+ "@djangocfg/ui-core": "^2.1.109",
60
+ "@djangocfg/ui-nextjs": "^2.1.109",
61
61
  "consola": "^3.4.2",
62
62
  "lucide-react": "^0.545.0",
63
63
  "next": "^16",
@@ -70,10 +70,10 @@
70
70
  "@hookform/resolvers": "^5.2.2"
71
71
  },
72
72
  "devDependencies": {
73
- "@djangocfg/api": "^2.1.108",
74
- "@djangocfg/ext-base": "^1.0.12",
75
- "@djangocfg/typescript-config": "^2.1.108",
76
- "@djangocfg/ui-nextjs": "^2.1.108",
73
+ "@djangocfg/api": "^2.1.109",
74
+ "@djangocfg/ext-base": "^1.0.14",
75
+ "@djangocfg/typescript-config": "^2.1.109",
76
+ "@djangocfg/ui-nextjs": "^2.1.109",
77
77
  "@types/node": "^24.7.2",
78
78
  "@types/react": "^19.0.0",
79
79
  "consola": "^3.4.2",
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Wallet Page Component (Apple-style)
3
+ *
4
+ * Single page with balance hero + activity list
5
+ */
6
+
7
+ 'use client';
8
+
9
+ import { useState, useCallback } from 'react';
10
+
11
+ import { WalletProvider, type ActivityItem } from './contexts/WalletContext';
12
+ import type { PaymentDetail } from './contexts/types';
13
+ import {
14
+ BalanceHero,
15
+ ActivityList,
16
+ AddFundsSheet,
17
+ WithdrawSheet,
18
+ WithdrawalSheet,
19
+ PaymentSheet,
20
+ } from './components';
21
+
22
+ export const WalletContent = () => {
23
+ const [addFundsOpen, setAddFundsOpen] = useState(false);
24
+ const [withdrawOpen, setWithdrawOpen] = useState(false);
25
+ const [selectedPaymentId, setSelectedPaymentId] = useState<string | null>(null);
26
+ const [paymentSheetOpen, setPaymentSheetOpen] = useState(false);
27
+ const [selectedWithdrawalId, setSelectedWithdrawalId] = useState<string | null>(null);
28
+ const [withdrawalSheetOpen, setWithdrawalSheetOpen] = useState(false);
29
+
30
+ // Handle activity item click
31
+ const handleActivityClick = useCallback((item: ActivityItem) => {
32
+ if (item.payment) {
33
+ setSelectedPaymentId(item.payment.id);
34
+ setPaymentSheetOpen(true);
35
+ } else if (item.withdrawal) {
36
+ setSelectedWithdrawalId(item.withdrawal.id);
37
+ setWithdrawalSheetOpen(true);
38
+ }
39
+ }, []);
40
+
41
+ // Handle successful payment creation
42
+ const handlePaymentCreated = useCallback((payment: PaymentDetail) => {
43
+ setSelectedPaymentId(payment.id);
44
+ setPaymentSheetOpen(true);
45
+ }, []);
46
+
47
+ return (
48
+ <div className="min-h-screen">
49
+ {/* Balance Hero */}
50
+ <BalanceHero
51
+ onAddFunds={() => setAddFundsOpen(true)}
52
+ onWithdraw={() => setWithdrawOpen(true)}
53
+ className="bg-muted/30 border-b"
54
+ />
55
+
56
+ {/* Activity List */}
57
+ <ActivityList
58
+ onItemClick={handleActivityClick}
59
+ limit={20}
60
+ className="max-w-2xl mx-auto pb-12"
61
+ />
62
+
63
+ {/* Add Funds Sheet */}
64
+ <AddFundsSheet
65
+ open={addFundsOpen}
66
+ onOpenChange={setAddFundsOpen}
67
+ onSuccess={handlePaymentCreated}
68
+ />
69
+
70
+ {/* Withdraw Sheet */}
71
+ <WithdrawSheet
72
+ open={withdrawOpen}
73
+ onOpenChange={setWithdrawOpen}
74
+ />
75
+
76
+ {/* Payment Details Sheet */}
77
+ <PaymentSheet
78
+ paymentId={selectedPaymentId}
79
+ open={paymentSheetOpen}
80
+ onOpenChange={setPaymentSheetOpen}
81
+ onCreateNew={() => setAddFundsOpen(true)}
82
+ />
83
+
84
+ {/* Withdrawal Details Sheet */}
85
+ <WithdrawalSheet
86
+ withdrawalId={selectedWithdrawalId}
87
+ open={withdrawalSheetOpen}
88
+ onOpenChange={setWithdrawalSheetOpen}
89
+ />
90
+ </div>
91
+ );
92
+ }
93
+
94
+ export function WalletPage() {
95
+ return (
96
+ <WalletProvider>
97
+ <WalletContent />
98
+ </WalletProvider>
99
+ );
100
+ }
@@ -1,4 +1,4 @@
1
- # Django CFG API - Typescript Client
1
+ # Cmdop API - Typescript Client
2
2
 
3
3
  Auto-generated. **Do not edit manually.**
4
4
 
@@ -11,18 +11,20 @@ python manage.py generate_client --groups ext_payments --typescript
11
11
  | | |
12
12
  |---|---|
13
13
  | Version | 3.0.3 |
14
- | Operations | 12 |
15
- | Schemas | 11 |
14
+ | Operations | 14 |
15
+ | Schemas | 14 |
16
16
 
17
17
  ## Resources
18
18
 
19
- - **payments** (12 ops)
19
+ - **payments** (14 ops)
20
20
 
21
21
  ## Operations
22
22
 
23
23
  **payments:**
24
24
  - `GET` /cfg/payments/balance/ → `cfg_payments_balance_retrieve`
25
+ - `GET` /cfg/payments/currencies/{code}/estimate/ → `cfg_payments_currencies_estimate_retrieve`
25
26
  - `GET` /cfg/payments/currencies/ → `cfg_payments_currencies_list`
27
+ - `GET` /cfg/payments/currencies/{code}/withdrawal-estimate/ → `cfg_payments_currencies_withdrawal_estimate_retrieve`
26
28
  - `POST` /cfg/payments/payments/{id}/confirm/ → `cfg_payments_payments_confirm_create`
27
29
  - `POST` /cfg/payments/payments/create/ → `cfg_payments_payments_create_create`
28
30
  - `GET` /cfg/payments/payments/ → `cfg_payments_payments_list`
@@ -35,9 +35,12 @@ import { BalanceSchema, type Balance } from '../schemas/Balance.schema'
35
35
  import { PaginatedPaymentListListSchema, type PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
36
36
  import { PaginatedWithdrawalListListSchema, type PaginatedWithdrawalListList } from '../schemas/PaginatedWithdrawalListList.schema'
37
37
  import { PaymentCreateRequestSchema, type PaymentCreateRequest } from '../schemas/PaymentCreateRequest.schema'
38
+ import { PaymentCreateResponseSchema, type PaymentCreateResponse } from '../schemas/PaymentCreateResponse.schema'
38
39
  import { PaymentDetailSchema, type PaymentDetail } from '../schemas/PaymentDetail.schema'
39
40
  import { PaymentListSchema, type PaymentList } from '../schemas/PaymentList.schema'
41
+ import { WithdrawalCancelResponseSchema, type WithdrawalCancelResponse } from '../schemas/WithdrawalCancelResponse.schema'
40
42
  import { WithdrawalCreateRequestSchema, type WithdrawalCreateRequest } from '../schemas/WithdrawalCreateRequest.schema'
43
+ import { WithdrawalCreateResponseSchema, type WithdrawalCreateResponse } from '../schemas/WithdrawalCreateResponse.schema'
41
44
  import { WithdrawalDetailSchema, type WithdrawalDetail } from '../schemas/WithdrawalDetail.schema'
42
45
  import { getAPIInstance } from '../../api-instance'
43
46
 
@@ -112,6 +115,34 @@ export async function getPaymentsCurrenciesList( client?: any
112
115
  }
113
116
 
114
117
 
118
+ /**
119
+ * Get currency estimate
120
+ *
121
+ * @method GET
122
+ * @path /cfg/payments/currencies/{code}/estimate/
123
+ */
124
+ export async function getPaymentsCurrenciesEstimateRetrieve( code: string, params?: { amount?: number }, client?: any
125
+ ): Promise<any> {
126
+ const api = client || getAPIInstance()
127
+ const response = await api.ext_payments_payments.currenciesEstimateRetrieve(code, params?.amount)
128
+ return response
129
+ }
130
+
131
+
132
+ /**
133
+ * Get withdrawal estimate
134
+ *
135
+ * @method GET
136
+ * @path /cfg/payments/currencies/{code}/withdrawal-estimate/
137
+ */
138
+ export async function getPaymentsCurrenciesWithdrawalEstimateRetrieve( code: string, params?: { amount?: number }, client?: any
139
+ ): Promise<any> {
140
+ const api = client || getAPIInstance()
141
+ const response = await api.ext_payments_payments.currenciesWithdrawalEstimateRetrieve(code, params?.amount)
142
+ return response
143
+ }
144
+
145
+
115
146
  /**
116
147
  * API operation
117
148
  *
@@ -347,11 +378,11 @@ export async function getPaymentsPaymentsStatusRetrieve( id: string, client?:
347
378
  * @path /cfg/payments/payments/create/
348
379
  */
349
380
  export async function createPaymentsPaymentsCreateCreate( data: PaymentCreateRequest, client?: any
350
- ): Promise<PaymentDetail> {
381
+ ): Promise<PaymentCreateResponse> {
351
382
  const api = client || getAPIInstance()
352
383
  const response = await api.ext_payments_payments.paymentsCreateCreate(data)
353
384
  try {
354
- return PaymentDetailSchema.parse(response)
385
+ return PaymentCreateResponseSchema.parse(response)
355
386
  } catch (error) {
356
387
  // Zod validation error - log detailed information
357
388
  consola.error('❌ Zod Validation Failed');
@@ -532,11 +563,11 @@ export async function getPaymentsWithdrawalsRetrieve( id: string, client?: any
532
563
  * @path /cfg/payments/withdrawals/{id}/cancel/
533
564
  */
534
565
  export async function createPaymentsWithdrawalsCancelCreate( id: string, client?: any
535
- ): Promise<WithdrawalDetail> {
566
+ ): Promise<WithdrawalCancelResponse> {
536
567
  const api = client || getAPIInstance()
537
568
  const response = await api.ext_payments_payments.withdrawalsCancelCreate(id)
538
569
  try {
539
- return WithdrawalDetailSchema.parse(response)
570
+ return WithdrawalCancelResponseSchema.parse(response)
540
571
  } catch (error) {
541
572
  // Zod validation error - log detailed information
542
573
  consola.error('❌ Zod Validation Failed');
@@ -589,11 +620,11 @@ export async function createPaymentsWithdrawalsCancelCreate( id: string, clien
589
620
  * @path /cfg/payments/withdrawals/create/
590
621
  */
591
622
  export async function createPaymentsWithdrawalsCreateCreate( data: WithdrawalCreateRequest, client?: any
592
- ): Promise<WithdrawalDetail> {
623
+ ): Promise<WithdrawalCreateResponse> {
593
624
  const api = client || getAPIInstance()
594
625
  const response = await api.ext_payments_payments.withdrawalsCreateCreate(data)
595
626
  try {
596
- return WithdrawalDetailSchema.parse(response)
627
+ return WithdrawalCreateResponseSchema.parse(response)
597
628
  } catch (error) {
598
629
  // Zod validation error - log detailed information
599
630
  consola.error('❌ Zod Validation Failed');
@@ -25,9 +25,12 @@ import type { Balance } from '../schemas/Balance.schema'
25
25
  import type { PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
26
26
  import type { PaginatedWithdrawalListList } from '../schemas/PaginatedWithdrawalListList.schema'
27
27
  import type { PaymentCreateRequest } from '../schemas/PaymentCreateRequest.schema'
28
+ import type { PaymentCreateResponse } from '../schemas/PaymentCreateResponse.schema'
28
29
  import type { PaymentDetail } from '../schemas/PaymentDetail.schema'
29
30
  import type { PaymentList } from '../schemas/PaymentList.schema'
31
+ import type { WithdrawalCancelResponse } from '../schemas/WithdrawalCancelResponse.schema'
30
32
  import type { WithdrawalCreateRequest } from '../schemas/WithdrawalCreateRequest.schema'
33
+ import type { WithdrawalCreateResponse } from '../schemas/WithdrawalCreateResponse.schema'
31
34
  import type { WithdrawalDetail } from '../schemas/WithdrawalDetail.schema'
32
35
 
33
36
  /**
@@ -58,6 +61,34 @@ export function usePaymentsCurrenciesList(client?: API): ReturnType<typeof useSW
58
61
  }
59
62
 
60
63
 
64
+ /**
65
+ * Get currency estimate
66
+ *
67
+ * @method GET
68
+ * @path /cfg/payments/currencies/{code}/estimate/
69
+ */
70
+ export function usePaymentsCurrenciesEstimateRetrieve(code: string, params?: { amount?: number }, client?: API): ReturnType<typeof useSWR<any>> {
71
+ return useSWR<any>(
72
+ ['cfg-payments-currencies-estimate', code],
73
+ () => Fetchers.getPaymentsCurrenciesEstimateRetrieve(code, params, client)
74
+ )
75
+ }
76
+
77
+
78
+ /**
79
+ * Get withdrawal estimate
80
+ *
81
+ * @method GET
82
+ * @path /cfg/payments/currencies/{code}/withdrawal-estimate/
83
+ */
84
+ export function usePaymentsCurrenciesWithdrawalEstimateRetrieve(code: string, params?: { amount?: number }, client?: API): ReturnType<typeof useSWR<any>> {
85
+ return useSWR<any>(
86
+ ['cfg-payments-currencies-withdrawal-estimate', code],
87
+ () => Fetchers.getPaymentsCurrenciesWithdrawalEstimateRetrieve(code, params, client)
88
+ )
89
+ }
90
+
91
+
61
92
  /**
62
93
  * API operation
63
94
  *
@@ -127,7 +158,7 @@ export function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): Ret
127
158
  export function useCreatePaymentsPaymentsCreateCreate() {
128
159
  const { mutate } = useSWRConfig()
129
160
 
130
- return async (data: PaymentCreateRequest, client?: API): Promise<PaymentDetail> => {
161
+ return async (data: PaymentCreateRequest, client?: API): Promise<PaymentCreateResponse> => {
131
162
  const result = await Fetchers.createPaymentsPaymentsCreateCreate(data, client)
132
163
  // Revalidate related queries
133
164
  mutate('cfg-payments-payments')
@@ -187,7 +218,7 @@ export function usePaymentsWithdrawalsRetrieve(id: string, client?: API): Return
187
218
  export function useCreatePaymentsWithdrawalsCancelCreate() {
188
219
  const { mutate } = useSWRConfig()
189
220
 
190
- return async (id: string, client?: API): Promise<WithdrawalDetail> => {
221
+ return async (id: string, client?: API): Promise<WithdrawalCancelResponse> => {
191
222
  const result = await Fetchers.createPaymentsWithdrawalsCancelCreate(id, client)
192
223
  // Revalidate related queries
193
224
  mutate('cfg-payments-withdrawals-cancel')
@@ -205,7 +236,7 @@ export function useCreatePaymentsWithdrawalsCancelCreate() {
205
236
  export function useCreatePaymentsWithdrawalsCreateCreate() {
206
237
  const { mutate } = useSWRConfig()
207
238
 
208
- return async (data: WithdrawalCreateRequest, client?: API): Promise<WithdrawalDetail> => {
239
+ return async (data: WithdrawalCreateRequest, client?: API): Promise<WithdrawalCreateResponse> => {
209
240
  const result = await Fetchers.createPaymentsWithdrawalsCreateCreate(data, client)
210
241
  // Revalidate related queries
211
242
  mutate('cfg-payments-withdrawals')
@@ -14,7 +14,7 @@ export const BalanceSchema = z.object({
14
14
  balance_display: z.string(),
15
15
  total_deposited: z.string(),
16
16
  total_withdrawn: z.string(),
17
- last_transaction_at: z.iso.datetime().nullable(),
17
+ last_transaction_at: z.string().datetime({ offset: true }).nullable(),
18
18
  })
19
19
 
20
20
  /**
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Zod schema for PaymentCreateResponse
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Response for payment creation.
6
+ * */
7
+ import { z } from 'zod'
8
+ import { PaymentDetailSchema } from './PaymentDetail.schema'
9
+
10
+ /**
11
+ * Response for payment creation.
12
+ */
13
+ export const PaymentCreateResponseSchema = z.object({
14
+ success: z.boolean(),
15
+ payment: PaymentDetailSchema,
16
+ qr_code_url: z.union([z.url(), z.literal('')]).nullable(),
17
+ })
18
+
19
+ /**
20
+ * Infer TypeScript type from Zod schema
21
+ */
22
+ export type PaymentCreateResponse = z.infer<typeof PaymentCreateResponseSchema>
@@ -29,9 +29,9 @@ export const PaymentDetailSchema = z.object({
29
29
  transaction_hash: z.string().nullable(),
30
30
  explorer_link: z.string().nullable(),
31
31
  confirmations_count: z.int(),
32
- expires_at: z.iso.datetime().nullable(),
33
- completed_at: z.iso.datetime().nullable(),
34
- created_at: z.iso.datetime(),
32
+ expires_at: z.string().datetime({ offset: true }).nullable(),
33
+ completed_at: z.string().datetime({ offset: true }).nullable(),
34
+ created_at: z.string().datetime({ offset: true }),
35
35
  is_completed: z.boolean(),
36
36
  is_failed: z.boolean(),
37
37
  is_expired: z.boolean(),
@@ -18,8 +18,8 @@ export const PaymentListSchema = z.object({
18
18
  currency_token: z.string(),
19
19
  status: z.nativeEnum(Enums.PaymentListStatus),
20
20
  status_display: z.string(),
21
- created_at: z.iso.datetime(),
22
- completed_at: z.iso.datetime().nullable(),
21
+ created_at: z.string().datetime({ offset: true }),
22
+ completed_at: z.string().datetime({ offset: true }).nullable(),
23
23
  })
24
24
 
25
25
  /**
@@ -19,7 +19,7 @@ export const TransactionSchema = z.object({
19
19
  balance_after: z.string(),
20
20
  payment_id: z.string().nullable(),
21
21
  description: z.string(),
22
- created_at: z.iso.datetime(),
22
+ created_at: z.string().datetime({ offset: true }),
23
23
  })
24
24
 
25
25
  /**
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Zod schema for WithdrawalCancelResponse
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Response for withdrawal cancellation.
6
+ * */
7
+ import { z } from 'zod'
8
+ import { WithdrawalDetailSchema } from './WithdrawalDetail.schema'
9
+
10
+ /**
11
+ * Response for withdrawal cancellation.
12
+ */
13
+ export const WithdrawalCancelResponseSchema = z.object({
14
+ success: z.boolean(),
15
+ withdrawal: WithdrawalDetailSchema,
16
+ message: z.string(),
17
+ })
18
+
19
+ /**
20
+ * Infer TypeScript type from Zod schema
21
+ */
22
+ export type WithdrawalCancelResponse = z.infer<typeof WithdrawalCancelResponseSchema>
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Zod schema for WithdrawalCreateResponse
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Response for withdrawal creation.
6
+ * */
7
+ import { z } from 'zod'
8
+ import { WithdrawalDetailSchema } from './WithdrawalDetail.schema'
9
+
10
+ /**
11
+ * Response for withdrawal creation.
12
+ */
13
+ export const WithdrawalCreateResponseSchema = z.object({
14
+ success: z.boolean(),
15
+ withdrawal: WithdrawalDetailSchema,
16
+ message: z.string(),
17
+ })
18
+
19
+ /**
20
+ * Infer TypeScript type from Zod schema
21
+ */
22
+ export type WithdrawalCreateResponse = z.infer<typeof WithdrawalCreateResponseSchema>
@@ -29,11 +29,11 @@ export const WithdrawalDetailSchema = z.object({
29
29
  transaction_hash: z.string().nullable(),
30
30
  explorer_link: z.string().nullable(),
31
31
  admin_notes: z.string(),
32
- created_at: z.iso.datetime(),
33
- approved_at: z.iso.datetime().nullable(),
34
- completed_at: z.iso.datetime().nullable(),
35
- rejected_at: z.iso.datetime().nullable(),
36
- cancelled_at: z.iso.datetime().nullable(),
32
+ created_at: z.string().datetime({ offset: true }),
33
+ approved_at: z.string().datetime({ offset: true }).nullable(),
34
+ completed_at: z.string().datetime({ offset: true }).nullable(),
35
+ rejected_at: z.string().datetime({ offset: true }).nullable(),
36
+ cancelled_at: z.string().datetime({ offset: true }).nullable(),
37
37
  })
38
38
 
39
39
  /**
@@ -19,8 +19,8 @@ export const WithdrawalListSchema = z.object({
19
19
  currency_token: z.string(),
20
20
  status: z.nativeEnum(Enums.WithdrawalListStatus),
21
21
  status_display: z.string(),
22
- created_at: z.iso.datetime(),
23
- completed_at: z.iso.datetime().nullable(),
22
+ created_at: z.string().datetime({ offset: true }),
23
+ completed_at: z.string().datetime({ offset: true }).nullable(),
24
24
  })
25
25
 
26
26
  /**
@@ -22,9 +22,12 @@ export * from './Currency.schema'
22
22
  export * from './PaginatedPaymentListList.schema'
23
23
  export * from './PaginatedWithdrawalListList.schema'
24
24
  export * from './PaymentCreateRequest.schema'
25
+ export * from './PaymentCreateResponse.schema'
25
26
  export * from './PaymentDetail.schema'
26
27
  export * from './PaymentList.schema'
27
28
  export * from './Transaction.schema'
29
+ export * from './WithdrawalCancelResponse.schema'
28
30
  export * from './WithdrawalCreateRequest.schema'
31
+ export * from './WithdrawalCreateResponse.schema'
29
32
  export * from './WithdrawalDetail.schema'
30
33
  export * from './WithdrawalList.schema'
@@ -6,7 +6,7 @@ import { withRetry, type RetryConfig } from "./retry";
6
6
 
7
7
 
8
8
  /**
9
- * Async API client for Django CFG API.
9
+ * Async API client for Cmdop API.
10
10
  *
11
11
  * Usage:
12
12
  * ```typescript
@@ -24,13 +24,58 @@ export class ExtPaymentsPayments {
24
24
  /**
25
25
  * Get available currencies
26
26
  *
27
- * Returns list of available currencies with token+network info
27
+ * Returns list of available currencies with token+network info, popular
28
+ * first
28
29
  */
29
30
  async currenciesList(): Promise<any> {
30
31
  const response = await this.client.request('GET', "/cfg/payments/currencies/");
31
32
  return response;
32
33
  }
33
34
 
35
+ async currenciesEstimateRetrieve(code: string, amount?: number): Promise<any>;
36
+ async currenciesEstimateRetrieve(code: string, params?: { amount?: number }): Promise<any>;
37
+
38
+ /**
39
+ * Get currency estimate
40
+ *
41
+ * Get estimated crypto amount for a given USD amount, including min amount
42
+ */
43
+ async currenciesEstimateRetrieve(...args: any[]): Promise<any> {
44
+ const code = args[0];
45
+ const isParamsObject = args.length === 2 && typeof args[1] === 'object' && args[1] !== null && !Array.isArray(args[1]);
46
+
47
+ let params;
48
+ if (isParamsObject) {
49
+ params = args[1];
50
+ } else {
51
+ params = { amount: args[1] };
52
+ }
53
+ const response = await this.client.request('GET', `/cfg/payments/currencies/${code}/estimate/`, { params });
54
+ return response;
55
+ }
56
+
57
+ async currenciesWithdrawalEstimateRetrieve(code: string, amount?: number): Promise<any>;
58
+ async currenciesWithdrawalEstimateRetrieve(code: string, params?: { amount?: number }): Promise<any>;
59
+
60
+ /**
61
+ * Get withdrawal estimate
62
+ *
63
+ * Get estimated crypto amount for withdrawal with fee breakdown
64
+ */
65
+ async currenciesWithdrawalEstimateRetrieve(...args: any[]): Promise<any> {
66
+ const code = args[0];
67
+ const isParamsObject = args.length === 2 && typeof args[1] === 'object' && args[1] !== null && !Array.isArray(args[1]);
68
+
69
+ let params;
70
+ if (isParamsObject) {
71
+ params = args[1];
72
+ } else {
73
+ params = { amount: args[1] };
74
+ }
75
+ const response = await this.client.request('GET', `/cfg/payments/currencies/${code}/withdrawal-estimate/`, { params });
76
+ return response;
77
+ }
78
+
34
79
  async paymentsList(page?: number, page_size?: number): Promise<Models.PaginatedPaymentListList>;
35
80
  async paymentsList(params?: { page?: number; page_size?: number }): Promise<Models.PaginatedPaymentListList>;
36
81
 
@@ -89,7 +134,7 @@ export class ExtPaymentsPayments {
89
134
  *
90
135
  * Create a new payment with specified amount and currency
91
136
  */
92
- async paymentsCreateCreate(data: Models.PaymentCreateRequest): Promise<Models.PaymentDetail> {
137
+ async paymentsCreateCreate(data: Models.PaymentCreateRequest): Promise<Models.PaymentCreateResponse> {
93
138
  const response = await this.client.request('POST', "/cfg/payments/payments/create/", { body: data });
94
139
  return response;
95
140
  }
@@ -153,7 +198,7 @@ export class ExtPaymentsPayments {
153
198
  *
154
199
  * Cancel a pending withdrawal request
155
200
  */
156
- async withdrawalsCancelCreate(id: string): Promise<Models.WithdrawalDetail> {
201
+ async withdrawalsCancelCreate(id: string): Promise<Models.WithdrawalCancelResponse> {
157
202
  const response = await this.client.request('POST', `/cfg/payments/withdrawals/${id}/cancel/`);
158
203
  return response;
159
204
  }
@@ -163,7 +208,7 @@ export class ExtPaymentsPayments {
163
208
  *
164
209
  * Create a new withdrawal request (requires admin approval)
165
210
  */
166
- async withdrawalsCreateCreate(data: Models.WithdrawalCreateRequest): Promise<Models.WithdrawalDetail> {
211
+ async withdrawalsCreateCreate(data: Models.WithdrawalCreateRequest): Promise<Models.WithdrawalCreateResponse> {
167
212
  const response = await this.client.request('POST', "/cfg/payments/withdrawals/create/", { body: data });
168
213
  return response;
169
214
  }