@djangocfg/api 1.0.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "1.0.6",
3
+ "version": "1.2.0",
4
4
  "author": {
5
5
  "name": "DjangoCFG",
6
6
  "url": "https://djangocfg.com"
@@ -68,7 +68,7 @@
68
68
  "@types/node": "^22.15.3",
69
69
  "@types/react": "19.2.2",
70
70
  "@types/react-dom": "19.2.1",
71
- "@djangocfg/typescript-config": "^1.0.6",
71
+ "@djangocfg/typescript-config": "^1.2.0",
72
72
  "react": "^19.1.0",
73
73
  "react-dom": "^19.1.0",
74
74
  "tsup": "^8.5.0",
@@ -3,7 +3,7 @@
3
3
  import React, { createContext, useContext, type ReactNode } from 'react';
4
4
  import { api } from '../../BaseClient';
5
5
  import {
6
- usePaymentsCurrenciesRetrieve,
6
+ usePaymentsCurrenciesList,
7
7
  } from '../../generated/_utils/hooks';
8
8
  import type { API } from '../../generated';
9
9
 
@@ -36,7 +36,7 @@ export function CurrenciesProvider({ children }: { children: ReactNode }) {
36
36
  error: currenciesError,
37
37
  isLoading: isLoadingCurrencies,
38
38
  mutate: mutateCurrencies,
39
- } = usePaymentsCurrenciesRetrieve(api as unknown as API);
39
+ } = usePaymentsCurrenciesList(api as unknown as API);
40
40
 
41
41
  const refreshCurrencies = async () => {
42
42
  await mutateCurrencies();
@@ -6,7 +6,7 @@ import { api } from '../../BaseClient';
6
6
  import {
7
7
  usePaymentsBalanceRetrieve,
8
8
  usePaymentsPaymentsList,
9
- usePaymentsTransactionsRetrieve,
9
+ usePaymentsTransactionsList,
10
10
  useCreatePaymentsPaymentsCreateCreate,
11
11
  } from '../../generated/_utils/hooks';
12
12
  import type { API } from '../../generated';
@@ -89,7 +89,7 @@ export function OverviewProvider({ children }: { children: ReactNode }) {
89
89
  error: transactionsError,
90
90
  isLoading: isLoadingTransactions,
91
91
  mutate: mutateTransactions,
92
- } = usePaymentsTransactionsRetrieve(api as unknown as API);
92
+ } = usePaymentsTransactionsList({}, api as unknown as API);
93
93
 
94
94
  // Payment mutations
95
95
  const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
@@ -3,7 +3,7 @@
3
3
  import React, { createContext, useContext, type ReactNode } from 'react';
4
4
  import { api } from '../../BaseClient';
5
5
  import {
6
- usePaymentsCurrenciesRetrieve,
6
+ usePaymentsCurrenciesList,
7
7
  } from '../../generated/_utils/hooks';
8
8
  import type { API } from '../../generated';
9
9
 
@@ -37,7 +37,7 @@ export function RootPaymentsProvider({ children }: { children: ReactNode }) {
37
37
  error: currenciesError,
38
38
  isLoading: isLoadingCurrencies,
39
39
  mutate: mutateCurrencies,
40
- } = usePaymentsCurrenciesRetrieve(api as unknown as API);
40
+ } = usePaymentsCurrenciesList(api as unknown as API);
41
41
 
42
42
  const refreshCurrencies = async () => {
43
43
  await mutateCurrencies();
@@ -29,6 +29,7 @@
29
29
  * const users = await getUsers({ page: 1 }, api)
30
30
  * ```
31
31
  */
32
+ import { BalanceSchema, type Balance } from '../schemas/Balance.schema'
32
33
  import { PaginatedPaymentListListSchema, type PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
33
34
  import { PaymentDetailSchema, type PaymentDetail } from '../schemas/PaymentDetail.schema'
34
35
  import { PaymentListSchema, type PaymentList } from '../schemas/PaymentList.schema'
@@ -36,29 +37,29 @@ import { getAPIInstance } from '../../api-instance'
36
37
  import type { API } from '../../index'
37
38
 
38
39
  /**
39
- * API operation
40
+ * Get user balance
40
41
  *
41
42
  * @method GET
42
43
  * @path /cfg/payments/balance/
43
44
  */
44
45
  export async function getPaymentsBalanceRetrieve( client?
45
- ): Promise<any> {
46
+ ): Promise<Balance> {
46
47
  const api = client || getAPIInstance()
47
48
  const response = await api.cfg_payments.balanceRetrieve()
48
- return response
49
+ return BalanceSchema.parse(response)
49
50
  }
50
51
 
51
52
 
52
53
  /**
53
- * API operation
54
+ * Get available currencies
54
55
  *
55
56
  * @method GET
56
57
  * @path /cfg/payments/currencies/
57
58
  */
58
- export async function getPaymentsCurrenciesRetrieve( client?
59
+ export async function getPaymentsCurrenciesList( client?
59
60
  ): Promise<any> {
60
61
  const api = client || getAPIInstance()
61
- const response = await api.cfg_payments.currenciesRetrieve()
62
+ const response = await api.cfg_payments.currenciesList()
62
63
  return response
63
64
  }
64
65
 
@@ -134,15 +135,15 @@ export async function createPaymentsPaymentsCreateCreate( client?
134
135
 
135
136
 
136
137
  /**
137
- * API operation
138
+ * Get user transactions
138
139
  *
139
140
  * @method GET
140
141
  * @path /cfg/payments/transactions/
141
142
  */
142
- export async function getPaymentsTransactionsRetrieve( client?
143
+ export async function getPaymentsTransactionsList( params?: { limit?: number; offset?: number; type?: string }, client?
143
144
  ): Promise<any> {
144
145
  const api = client || getAPIInstance()
145
- const response = await api.cfg_payments.transactionsRetrieve()
146
+ const response = await api.cfg_payments.transactionsList(params?.limit, params?.offset, params?.type)
146
147
  return response
147
148
  }
148
149
 
@@ -18,18 +18,19 @@ import useSWR from 'swr'
18
18
  import { useSWRConfig } from 'swr'
19
19
  import * as Fetchers from '../fetchers/cfg__payments'
20
20
  import type { API } from '../../index'
21
+ import type { Balance } from '../schemas/Balance.schema'
21
22
  import type { PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
22
23
  import type { PaymentDetail } from '../schemas/PaymentDetail.schema'
23
24
  import type { PaymentList } from '../schemas/PaymentList.schema'
24
25
 
25
26
  /**
26
- * API operation
27
+ * Get user balance
27
28
  *
28
29
  * @method GET
29
30
  * @path /cfg/payments/balance/
30
31
  */
31
- export function usePaymentsBalanceRetrieve(client?: API): ReturnType<typeof useSWR<any>> {
32
- return useSWR<any>(
32
+ export function usePaymentsBalanceRetrieve(client?: API): ReturnType<typeof useSWR<Balance>> {
33
+ return useSWR<Balance>(
33
34
  'cfg-payments-balance',
34
35
  () => Fetchers.getPaymentsBalanceRetrieve(client)
35
36
  )
@@ -37,15 +38,15 @@ export function usePaymentsBalanceRetrieve(client?: API): ReturnType<typeof useS
37
38
 
38
39
 
39
40
  /**
40
- * API operation
41
+ * Get available currencies
41
42
  *
42
43
  * @method GET
43
44
  * @path /cfg/payments/currencies/
44
45
  */
45
- export function usePaymentsCurrenciesRetrieve(client?: API): ReturnType<typeof useSWR<any>> {
46
+ export function usePaymentsCurrenciesList(client?: API): ReturnType<typeof useSWR<any>> {
46
47
  return useSWR<any>(
47
- 'cfg-payments-currencie',
48
- () => Fetchers.getPaymentsCurrenciesRetrieve(client)
48
+ 'cfg-payments-currencies',
49
+ () => Fetchers.getPaymentsCurrenciesList(client)
49
50
  )
50
51
  }
51
52
 
@@ -129,15 +130,15 @@ export function useCreatePaymentsPaymentsCreateCreate() {
129
130
 
130
131
 
131
132
  /**
132
- * API operation
133
+ * Get user transactions
133
134
  *
134
135
  * @method GET
135
136
  * @path /cfg/payments/transactions/
136
137
  */
137
- export function usePaymentsTransactionsRetrieve(client?: API): ReturnType<typeof useSWR<any>> {
138
+ export function usePaymentsTransactionsList(params?: { limit?: number; offset?: number; type?: string }, client?: API): ReturnType<typeof useSWR<any>> {
138
139
  return useSWR<any>(
139
- 'cfg-payments-transaction',
140
- () => Fetchers.getPaymentsTransactionsRetrieve(client)
140
+ params ? ['cfg-payments-transactions', params] : 'cfg-payments-transactions',
141
+ () => Fetchers.getPaymentsTransactionsList(params, client)
141
142
  )
142
143
  }
143
144
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Zod schema for Balance
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * User balance serializer.
6
+ * */
7
+ import { z } from 'zod'
8
+
9
+ /**
10
+ * User balance serializer.
11
+ */
12
+ export const BalanceSchema = z.object({
13
+ balance_usd: z.string(),
14
+ balance_display: z.string(),
15
+ total_deposited: z.string(),
16
+ total_withdrawn: z.string(),
17
+ last_transaction_at: z.iso.datetime().nullable(),
18
+ })
19
+
20
+ /**
21
+ * Infer TypeScript type from Zod schema
22
+ */
23
+ export type Balance = z.infer<typeof BalanceSchema>
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Zod schema for Currency
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Currency list serializer.
6
+ * */
7
+ import { z } from 'zod'
8
+
9
+ /**
10
+ * Currency list serializer.
11
+ */
12
+ export const CurrencySchema = z.object({
13
+ code: z.string(),
14
+ name: z.string(),
15
+ token: z.string(),
16
+ network: z.string().nullable(),
17
+ display_name: z.string(),
18
+ symbol: z.string(),
19
+ decimal_places: z.int(),
20
+ is_active: z.boolean(),
21
+ min_amount_usd: z.string(),
22
+ sort_order: z.int(),
23
+ })
24
+
25
+ /**
26
+ * Infer TypeScript type from Zod schema
27
+ */
28
+ export type Currency = z.infer<typeof CurrencySchema>
@@ -24,10 +24,10 @@ export const PaymentDetailSchema = z.object({
24
24
  status: z.nativeEnum(Enums.PaymentDetailStatus),
25
25
  status_display: z.string(),
26
26
  pay_address: z.string().nullable(),
27
- qr_code_url: z.string(),
27
+ qr_code_url: z.string().nullable(),
28
28
  payment_url: z.url().nullable(),
29
29
  transaction_hash: z.string().nullable(),
30
- explorer_link: z.string(),
30
+ explorer_link: z.string().nullable(),
31
31
  confirmations_count: z.int(),
32
32
  expires_at: z.iso.datetime().nullable(),
33
33
  completed_at: z.iso.datetime().nullable(),
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Zod schema for Transaction
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Transaction serializer.
6
+ * */
7
+ import { z } from 'zod'
8
+ import * as Enums from '../../enums'
9
+
10
+ /**
11
+ * Transaction serializer.
12
+ */
13
+ export const TransactionSchema = z.object({
14
+ id: z.uuid(),
15
+ transaction_type: z.nativeEnum(Enums.TransactionTransactionType),
16
+ type_display: z.string(),
17
+ amount_usd: z.string(),
18
+ amount_display: z.string(),
19
+ balance_after: z.string(),
20
+ payment_id: z.string().nullable(),
21
+ description: z.string(),
22
+ created_at: z.iso.datetime(),
23
+ })
24
+
25
+ /**
26
+ * Infer TypeScript type from Zod schema
27
+ */
28
+ export type Transaction = z.infer<typeof TransactionSchema>
@@ -28,6 +28,7 @@ export * from './ArchiveProcessingResult.schema'
28
28
  export * from './ArchiveSearchRequestRequest.schema'
29
29
  export * from './ArchiveSearchResult.schema'
30
30
  export * from './ArchiveStatistics.schema'
31
+ export * from './Balance.schema'
31
32
  export * from './BulkEmailRequest.schema'
32
33
  export * from './BulkEmailResponse.schema'
33
34
  export * from './ChatHistory.schema'
@@ -41,6 +42,7 @@ export * from './ChatSessionRequest.schema'
41
42
  export * from './ChatSource.schema'
42
43
  export * from './ChatSourceRequest.schema'
43
44
  export * from './ChunkRevectorizationRequestRequest.schema'
45
+ export * from './Currency.schema'
44
46
  export * from './Document.schema'
45
47
  export * from './DocumentArchive.schema'
46
48
  export * from './DocumentArchiveDetail.schema'
@@ -124,6 +126,7 @@ export * from './Ticket.schema'
124
126
  export * from './TicketRequest.schema'
125
127
  export * from './TokenRefresh.schema'
126
128
  export * from './TokenRefreshRequest.schema'
129
+ export * from './Transaction.schema'
127
130
  export * from './Unsubscribe.schema'
128
131
  export * from './UnsubscribeRequest.schema'
129
132
  export * from './User.schema'
@@ -12,18 +12,21 @@ export class CfgPayments {
12
12
  }
13
13
 
14
14
  /**
15
- * Get current user balance.
15
+ * Get user balance
16
+ *
17
+ * Get current user balance and transaction statistics
16
18
  */
17
- async balanceRetrieve(): Promise<any> {
19
+ async balanceRetrieve(): Promise<Models.Balance> {
18
20
  const response = await this.client.request('GET', "/cfg/payments/balance/");
19
21
  return response;
20
22
  }
21
23
 
22
24
  /**
23
- * GET /api/v1/payments/currencies/ Returns list of available currencies
24
- * with token+network info.
25
+ * Get available currencies
26
+ *
27
+ * Returns list of available currencies with token+network info
25
28
  */
26
- async currenciesRetrieve(): Promise<any> {
29
+ async currenciesList(): Promise<any> {
27
30
  const response = await this.client.request('GET', "/cfg/payments/currencies/");
28
31
  return response;
29
32
  }
@@ -91,11 +94,24 @@ export class CfgPayments {
91
94
  return response;
92
95
  }
93
96
 
97
+ async transactionsList(limit?: number, offset?: number, type?: string): Promise<any>;
98
+ async transactionsList(params?: { limit?: number; offset?: number; type?: string }): Promise<any>;
99
+
94
100
  /**
95
- * Get user transactions with pagination.
101
+ * Get user transactions
102
+ *
103
+ * Get user transactions with pagination and filtering
96
104
  */
97
- async transactionsRetrieve(): Promise<any> {
98
- const response = await this.client.request('GET', "/cfg/payments/transactions/");
105
+ async transactionsList(...args: any[]): Promise<any> {
106
+ const isParamsObject = args.length === 1 && typeof args[0] === 'object' && args[0] !== null && !Array.isArray(args[0]);
107
+
108
+ let params;
109
+ if (isParamsObject) {
110
+ params = args[0];
111
+ } else {
112
+ params = { limit: args[0], offset: args[1], type: args[2] };
113
+ }
114
+ const response = await this.client.request('GET', "/cfg/payments/transactions/", { params });
99
115
  return response;
100
116
  }
101
117
 
@@ -1,5 +1,22 @@
1
1
  import * as Enums from "../enums";
2
2
 
3
+ /**
4
+ * User balance serializer.
5
+ *
6
+ * Response model (includes read-only fields).
7
+ */
8
+ export interface Balance {
9
+ /** Current balance in USD */
10
+ balance_usd: string;
11
+ balance_display: string;
12
+ /** Total amount deposited (lifetime) */
13
+ total_deposited: string;
14
+ /** Total amount withdrawn (lifetime) */
15
+ total_withdrawn: string;
16
+ /** When the last transaction occurred */
17
+ last_transaction_at: string | null;
18
+ }
19
+
3
20
  /**
4
21
  *
5
22
  * Response model (includes read-only fields).
@@ -61,12 +78,14 @@ export interface PaymentDetail {
61
78
  status_display: string;
62
79
  /** Cryptocurrency payment address */
63
80
  pay_address: string | null;
64
- qr_code_url: string;
81
+ /** Get QR code URL. */
82
+ qr_code_url: string | null;
65
83
  /** Payment page URL (if provided by provider) */
66
84
  payment_url: string | null;
67
85
  /** Blockchain transaction hash */
68
86
  transaction_hash: string | null;
69
- explorer_link: string;
87
+ /** Get blockchain explorer link. */
88
+ explorer_link: string | null;
70
89
  /** Number of blockchain confirmations */
71
90
  confirmations_count: number;
72
91
  /** When this payment expires (typically 30 minutes) */
@@ -23,7 +23,7 @@ import { withRetry, type RetryConfig } from "./retry";
23
23
 
24
24
 
25
25
  /**
26
- * Async API client for Django CFG Sample API.
26
+ * Async API client for Django CFG API.
27
27
  *
28
28
  * Usage:
29
29
  * ```typescript
@@ -449,6 +449,26 @@ export enum TicketRequestStatus {
449
449
  CLOSED = "closed",
450
450
  }
451
451
 
452
+ /**
453
+ * Type of transaction
454
+ * * `deposit` - Deposit
455
+ * * `withdrawal` - Withdrawal
456
+ * * `payment` - Payment
457
+ * * `refund` - Refund
458
+ * * `fee` - Fee
459
+ * * `bonus` - Bonus
460
+ * * `adjustment` - Adjustment
461
+ */
462
+ export enum TransactionTransactionType {
463
+ DEPOSIT = "deposit",
464
+ WITHDRAWAL = "withdrawal",
465
+ PAYMENT = "payment",
466
+ REFUND = "refund",
467
+ FEE = "fee",
468
+ BONUS = "bonus",
469
+ ADJUSTMENT = "adjustment",
470
+ }
471
+
452
472
  /**
453
473
  * Action to perform on workers
454
474
  * * `start` - start
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Django CFG Sample API - API Client with JWT Management
2
+ * Django CFG API - API Client with JWT Management
3
3
  *
4
4
  * Usage:
5
5
  * ```typescript
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "api-client",
3
3
  "version": "1.0.0",
4
- "description": "Auto-generated TypeScript client for Django CFG Sample API",
4
+ "description": "Auto-generated TypeScript client for Django CFG API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",