kobana 0.1.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/README.md +230 -0
- package/dist/index.d.mts +443 -0
- package/dist/index.d.ts +443 -0
- package/dist/index.js +863 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +843 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Kobana Node.js SDK
|
|
2
|
+
|
|
3
|
+
Node.js SDK client for the [Kobana API](https://kobana.com.br) - Financial automation platform for Brazil.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install kobana
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Global Configuration
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Kobana } from 'kobana';
|
|
17
|
+
|
|
18
|
+
// Configure once at application startup
|
|
19
|
+
Kobana.configure({
|
|
20
|
+
apiToken: 'your-api-token',
|
|
21
|
+
environment: 'sandbox', // or 'production'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Create a PIX charge
|
|
25
|
+
const pix = await Kobana.charge.pix.create({
|
|
26
|
+
amount: 1000, // R$ 10.00 in cents
|
|
27
|
+
customerPersonName: 'John Doe',
|
|
28
|
+
customerCnpjCpf: '12345678901',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log(pix.qrCode);
|
|
32
|
+
console.log(pix.copyPaste);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Multi-Client Configuration
|
|
36
|
+
|
|
37
|
+
For multi-tenant applications or when you need multiple configurations:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { KobanaClient } from 'kobana';
|
|
41
|
+
|
|
42
|
+
const client = new KobanaClient({
|
|
43
|
+
apiToken: 'tenant-specific-token',
|
|
44
|
+
environment: 'production',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const billets = await client.charge.bankBillet.all({ page: 1, perPage: 20 });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Configuration Options
|
|
51
|
+
|
|
52
|
+
| Option | Type | Default | Description |
|
|
53
|
+
|--------|------|---------|-------------|
|
|
54
|
+
| `apiToken` | string | (required) | Your Kobana API token |
|
|
55
|
+
| `environment` | `'sandbox'` \| `'production'` | `'sandbox'` | API environment |
|
|
56
|
+
| `apiVersion` | `'v1'` \| `'v2'` | `'v1'` | API version |
|
|
57
|
+
| `customHeaders` | object | `{}` | Additional HTTP headers |
|
|
58
|
+
| `debug` | boolean | `false` | Enable debug mode |
|
|
59
|
+
|
|
60
|
+
## Available Resources
|
|
61
|
+
|
|
62
|
+
### Charge Resources
|
|
63
|
+
|
|
64
|
+
#### PIX
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// Create a PIX charge
|
|
68
|
+
const pix = await Kobana.charge.pix.create({
|
|
69
|
+
amount: 5000, // R$ 50.00
|
|
70
|
+
customerPersonName: 'Customer Name',
|
|
71
|
+
customerCnpjCpf: '12345678901',
|
|
72
|
+
description: 'Payment for order #123',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Find a PIX charge by ID
|
|
76
|
+
const pixCharge = await Kobana.charge.pix.find(123);
|
|
77
|
+
|
|
78
|
+
// List PIX charges
|
|
79
|
+
const charges = await Kobana.charge.pix.all({
|
|
80
|
+
page: 1,
|
|
81
|
+
perPage: 50,
|
|
82
|
+
status: 'pending',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Check status
|
|
86
|
+
if (pix.isPaid()) {
|
|
87
|
+
console.log('Payment received!');
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Bank Billet (Boleto)
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Create a bank billet
|
|
95
|
+
const billet = await Kobana.charge.bankBillet.create({
|
|
96
|
+
amount: 10000, // R$ 100.00
|
|
97
|
+
expireAt: '2024-12-31',
|
|
98
|
+
customerPersonName: 'Customer Name',
|
|
99
|
+
customerCnpjCpf: '12345678901',
|
|
100
|
+
customerAddress: 'Av Paulista, 1000',
|
|
101
|
+
customerCityName: 'Sao Paulo',
|
|
102
|
+
customerState: 'SP',
|
|
103
|
+
customerZipcode: '01310100',
|
|
104
|
+
customerNeighborhood: 'Bela Vista',
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Find a billet by ID
|
|
108
|
+
const found = await Kobana.charge.bankBillet.find(456);
|
|
109
|
+
|
|
110
|
+
// List billets with filters
|
|
111
|
+
const billets = await Kobana.charge.bankBillet.all({
|
|
112
|
+
status: 'opened',
|
|
113
|
+
expireFrom: '2024-01-01',
|
|
114
|
+
expireTo: '2024-12-31',
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Financial Resources
|
|
119
|
+
|
|
120
|
+
#### Bank Billet Account
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// Create a bank billet account
|
|
124
|
+
const account = await Kobana.financial.bankBilletAccount.create({
|
|
125
|
+
bankContractSlug: 'bradesco-bs-9',
|
|
126
|
+
agencyNumber: '1234',
|
|
127
|
+
accountNumber: '12345',
|
|
128
|
+
accountDigit: '6',
|
|
129
|
+
beneficiaryName: 'My Company',
|
|
130
|
+
beneficiaryCnpjCpf: '12345678000199',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// List accounts
|
|
134
|
+
const accounts = await Kobana.financial.bankBilletAccount.all();
|
|
135
|
+
|
|
136
|
+
// Request homologation
|
|
137
|
+
await account.askHomologation();
|
|
138
|
+
|
|
139
|
+
// Validate after homologation
|
|
140
|
+
await account.validate();
|
|
141
|
+
|
|
142
|
+
// Set as default account
|
|
143
|
+
await account.setDefault();
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Resource Methods
|
|
147
|
+
|
|
148
|
+
All resources support the following methods:
|
|
149
|
+
|
|
150
|
+
| Method | Description |
|
|
151
|
+
|--------|-------------|
|
|
152
|
+
| `create(attributes)` | Create a new resource |
|
|
153
|
+
| `find(id)` | Find a resource by ID |
|
|
154
|
+
| `all(params)` | List all resources with pagination |
|
|
155
|
+
| `findBy(params)` | Find first matching resource |
|
|
156
|
+
| `findOrCreateBy(params, attributes)` | Find or create a resource |
|
|
157
|
+
|
|
158
|
+
Instance methods:
|
|
159
|
+
|
|
160
|
+
| Method | Description |
|
|
161
|
+
|--------|-------------|
|
|
162
|
+
| `save()` | Save a new or update existing resource |
|
|
163
|
+
| `update(attributes)` | Update resource with new attributes |
|
|
164
|
+
| `delete()` | Delete the resource |
|
|
165
|
+
|
|
166
|
+
## Error Handling
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import {
|
|
170
|
+
KobanaError,
|
|
171
|
+
APIError,
|
|
172
|
+
UnauthorizedError,
|
|
173
|
+
ResourceNotFoundError,
|
|
174
|
+
ValidationError,
|
|
175
|
+
} from 'kobana';
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
const pix = await Kobana.charge.pix.create({ amount: 1000 });
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error instanceof UnauthorizedError) {
|
|
181
|
+
console.error('Invalid API token');
|
|
182
|
+
} else if (error instanceof ValidationError) {
|
|
183
|
+
console.error('Validation errors:', error.errors);
|
|
184
|
+
} else if (error instanceof APIError) {
|
|
185
|
+
console.error(`API error ${error.status}:`, error.errors);
|
|
186
|
+
} else if (error instanceof KobanaError) {
|
|
187
|
+
console.error('Kobana error:', error.message);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## TypeScript Support
|
|
193
|
+
|
|
194
|
+
This SDK is written in TypeScript and provides full type definitions:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import type {
|
|
198
|
+
PixChargeCreateParams,
|
|
199
|
+
BankBilletCreateParams,
|
|
200
|
+
BankBilletAccountCreateParams,
|
|
201
|
+
} from 'kobana';
|
|
202
|
+
|
|
203
|
+
const params: PixChargeCreateParams = {
|
|
204
|
+
amount: 1000,
|
|
205
|
+
customerPersonName: 'John Doe',
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Development
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Install dependencies
|
|
213
|
+
npm install
|
|
214
|
+
|
|
215
|
+
# Run tests
|
|
216
|
+
npm test
|
|
217
|
+
|
|
218
|
+
# Run tests once
|
|
219
|
+
npm run test:run
|
|
220
|
+
|
|
221
|
+
# Type check
|
|
222
|
+
npm run typecheck
|
|
223
|
+
|
|
224
|
+
# Build
|
|
225
|
+
npm run build
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
type Environment = 'sandbox' | 'production';
|
|
2
|
+
type ApiVersion = 'v1' | 'v2';
|
|
3
|
+
interface ConfigurationOptions {
|
|
4
|
+
apiToken: string;
|
|
5
|
+
environment?: Environment;
|
|
6
|
+
apiVersion?: ApiVersion;
|
|
7
|
+
customHeaders?: Record<string, string>;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ConfigurationInterface {
|
|
11
|
+
apiToken: string;
|
|
12
|
+
environment: Environment;
|
|
13
|
+
apiVersion: ApiVersion;
|
|
14
|
+
customHeaders: Record<string, string>;
|
|
15
|
+
debug: boolean;
|
|
16
|
+
getBaseUrl(): string;
|
|
17
|
+
getHeaders(): Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class Configuration implements ConfigurationInterface {
|
|
21
|
+
apiToken: string;
|
|
22
|
+
environment: Environment;
|
|
23
|
+
apiVersion: ApiVersion;
|
|
24
|
+
customHeaders: Record<string, string>;
|
|
25
|
+
debug: boolean;
|
|
26
|
+
constructor(options: ConfigurationOptions);
|
|
27
|
+
getBaseUrl(): string;
|
|
28
|
+
getHeaders(): Record<string, string>;
|
|
29
|
+
toString(): string;
|
|
30
|
+
toJSON(): Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ApiResponse<T> {
|
|
34
|
+
data: T;
|
|
35
|
+
status: number;
|
|
36
|
+
headers: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
interface ApiErrorResponse {
|
|
39
|
+
errors?: Array<{
|
|
40
|
+
message: string;
|
|
41
|
+
field?: string;
|
|
42
|
+
code?: string;
|
|
43
|
+
}>;
|
|
44
|
+
error?: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
}
|
|
47
|
+
interface PaginationParams {
|
|
48
|
+
page?: number;
|
|
49
|
+
perPage?: number;
|
|
50
|
+
}
|
|
51
|
+
interface RequestOptions {
|
|
52
|
+
idempotencyKey?: string;
|
|
53
|
+
multipart?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare class Connection {
|
|
57
|
+
private axiosInstance;
|
|
58
|
+
private configuration;
|
|
59
|
+
constructor(configuration: Configuration);
|
|
60
|
+
private getAxiosInstance;
|
|
61
|
+
request<T>(method: 'get' | 'post' | 'put' | 'patch' | 'delete', url: string, data?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
62
|
+
get<T>(url: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
63
|
+
post<T>(url: string, data?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
64
|
+
put<T>(url: string, data?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
65
|
+
patch<T>(url: string, data?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
66
|
+
delete<T>(url: string, options?: RequestOptions): Promise<ApiResponse<T>>;
|
|
67
|
+
private handleError;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type ResourceAttributes = Record<string, unknown>;
|
|
71
|
+
interface ResourceMeta {
|
|
72
|
+
id?: string | number;
|
|
73
|
+
createdAt?: string;
|
|
74
|
+
updatedAt?: string;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
interface BankBilletAccountAttributes extends ResourceMeta {
|
|
78
|
+
bankContractSlug?: string;
|
|
79
|
+
nextOurNumber?: string;
|
|
80
|
+
agencyNumber?: string;
|
|
81
|
+
agencyDigit?: string;
|
|
82
|
+
accountNumber?: string;
|
|
83
|
+
accountDigit?: string;
|
|
84
|
+
extra1?: string;
|
|
85
|
+
extra1Digit?: string;
|
|
86
|
+
extra2?: string;
|
|
87
|
+
extra2Digit?: string;
|
|
88
|
+
beneficiaryName?: string;
|
|
89
|
+
beneficiaryCnpjCpf?: string;
|
|
90
|
+
beneficiaryAddress?: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
status?: string;
|
|
93
|
+
homologatedAt?: string;
|
|
94
|
+
nextRemittanceNumber?: number;
|
|
95
|
+
configuration?: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
interface BankBilletAccountCreateParams {
|
|
98
|
+
bankContractSlug: string;
|
|
99
|
+
nextOurNumber?: string;
|
|
100
|
+
agencyNumber: string;
|
|
101
|
+
agencyDigit?: string;
|
|
102
|
+
accountNumber: string;
|
|
103
|
+
accountDigit?: string;
|
|
104
|
+
extra1?: string;
|
|
105
|
+
extra1Digit?: string;
|
|
106
|
+
extra2?: string;
|
|
107
|
+
extra2Digit?: string;
|
|
108
|
+
beneficiaryName?: string;
|
|
109
|
+
beneficiaryCnpjCpf?: string;
|
|
110
|
+
beneficiaryAddress?: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
configuration?: Record<string, unknown>;
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
}
|
|
115
|
+
interface BankBilletAccountListParams {
|
|
116
|
+
page?: number;
|
|
117
|
+
perPage?: number;
|
|
118
|
+
[key: string]: unknown;
|
|
119
|
+
}
|
|
120
|
+
interface BankBilletAttributes extends ResourceMeta {
|
|
121
|
+
amount?: number;
|
|
122
|
+
expireAt?: string;
|
|
123
|
+
customerPersonName?: string;
|
|
124
|
+
customerCnpjCpf?: string;
|
|
125
|
+
customerState?: string;
|
|
126
|
+
customerCityName?: string;
|
|
127
|
+
customerZipcode?: string;
|
|
128
|
+
customerAddress?: string;
|
|
129
|
+
customerNeighborhood?: string;
|
|
130
|
+
customerAddressNumber?: string;
|
|
131
|
+
customerAddressComplement?: string;
|
|
132
|
+
customerPhoneNumber?: string;
|
|
133
|
+
customerEmail?: string;
|
|
134
|
+
bankBilletAccountId?: number;
|
|
135
|
+
ourNumber?: string;
|
|
136
|
+
status?: string;
|
|
137
|
+
shippingStatus?: string;
|
|
138
|
+
meta?: Record<string, unknown>;
|
|
139
|
+
notes?: string;
|
|
140
|
+
instructions?: string;
|
|
141
|
+
demonstrative?: string;
|
|
142
|
+
acceptAfterDueDateDays?: number;
|
|
143
|
+
fineType?: number;
|
|
144
|
+
finePercentage?: number;
|
|
145
|
+
fineValue?: number;
|
|
146
|
+
interestType?: number;
|
|
147
|
+
interestDailyPercentage?: number;
|
|
148
|
+
interestDailyValue?: number;
|
|
149
|
+
interestMonthlyPercentage?: number;
|
|
150
|
+
discountType?: number;
|
|
151
|
+
discountLimitDate?: string;
|
|
152
|
+
discountValue?: number;
|
|
153
|
+
discountPercentage?: number;
|
|
154
|
+
discount2Type?: number;
|
|
155
|
+
discount2LimitDate?: string;
|
|
156
|
+
discount2Value?: number;
|
|
157
|
+
discount2Percentage?: number;
|
|
158
|
+
discount3Type?: number;
|
|
159
|
+
discount3LimitDate?: string;
|
|
160
|
+
discount3Value?: number;
|
|
161
|
+
discount3Percentage?: number;
|
|
162
|
+
guarantor?: Record<string, unknown>;
|
|
163
|
+
splitRules?: Array<Record<string, unknown>>;
|
|
164
|
+
pixEnabled?: boolean;
|
|
165
|
+
}
|
|
166
|
+
interface BankBilletCreateParams {
|
|
167
|
+
amount: number;
|
|
168
|
+
expireAt: string;
|
|
169
|
+
customerPersonName: string;
|
|
170
|
+
customerCnpjCpf: string;
|
|
171
|
+
customerState?: string;
|
|
172
|
+
customerCityName?: string;
|
|
173
|
+
customerZipcode?: string;
|
|
174
|
+
customerAddress?: string;
|
|
175
|
+
customerNeighborhood?: string;
|
|
176
|
+
customerAddressNumber?: string;
|
|
177
|
+
customerAddressComplement?: string;
|
|
178
|
+
customerPhoneNumber?: string;
|
|
179
|
+
customerEmail?: string;
|
|
180
|
+
bankBilletAccountId?: number;
|
|
181
|
+
meta?: Record<string, unknown>;
|
|
182
|
+
notes?: string;
|
|
183
|
+
instructions?: string;
|
|
184
|
+
demonstrative?: string;
|
|
185
|
+
acceptAfterDueDateDays?: number;
|
|
186
|
+
fineType?: number;
|
|
187
|
+
finePercentage?: number;
|
|
188
|
+
fineValue?: number;
|
|
189
|
+
interestType?: number;
|
|
190
|
+
interestDailyPercentage?: number;
|
|
191
|
+
interestDailyValue?: number;
|
|
192
|
+
interestMonthlyPercentage?: number;
|
|
193
|
+
discountType?: number;
|
|
194
|
+
discountLimitDate?: string;
|
|
195
|
+
discountValue?: number;
|
|
196
|
+
discountPercentage?: number;
|
|
197
|
+
pixEnabled?: boolean;
|
|
198
|
+
[key: string]: unknown;
|
|
199
|
+
}
|
|
200
|
+
interface BankBilletListParams {
|
|
201
|
+
page?: number;
|
|
202
|
+
perPage?: number;
|
|
203
|
+
status?: string;
|
|
204
|
+
customerCnpjCpf?: string;
|
|
205
|
+
ourNumber?: string;
|
|
206
|
+
createdFrom?: string;
|
|
207
|
+
createdTo?: string;
|
|
208
|
+
expireFrom?: string;
|
|
209
|
+
expireTo?: string;
|
|
210
|
+
paidFrom?: string;
|
|
211
|
+
paidTo?: string;
|
|
212
|
+
[key: string]: unknown;
|
|
213
|
+
}
|
|
214
|
+
interface PixChargeAttributes extends ResourceMeta {
|
|
215
|
+
amount?: number;
|
|
216
|
+
expireAt?: string;
|
|
217
|
+
status?: string;
|
|
218
|
+
customerPersonName?: string;
|
|
219
|
+
customerCnpjCpf?: string;
|
|
220
|
+
customerEmail?: string;
|
|
221
|
+
customerPhoneNumber?: string;
|
|
222
|
+
description?: string;
|
|
223
|
+
meta?: Record<string, unknown>;
|
|
224
|
+
qrCode?: string;
|
|
225
|
+
qrCodeUrl?: string;
|
|
226
|
+
copyPaste?: string;
|
|
227
|
+
txid?: string;
|
|
228
|
+
paidAt?: string;
|
|
229
|
+
paidAmount?: number;
|
|
230
|
+
}
|
|
231
|
+
interface PixChargeCreateParams {
|
|
232
|
+
amount: number;
|
|
233
|
+
expireAt?: string;
|
|
234
|
+
customerPersonName?: string;
|
|
235
|
+
customerCnpjCpf?: string;
|
|
236
|
+
customerEmail?: string;
|
|
237
|
+
customerPhoneNumber?: string;
|
|
238
|
+
description?: string;
|
|
239
|
+
meta?: Record<string, unknown>;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
interface PixChargeListParams {
|
|
243
|
+
page?: number;
|
|
244
|
+
perPage?: number;
|
|
245
|
+
status?: string;
|
|
246
|
+
createdFrom?: string;
|
|
247
|
+
createdTo?: string;
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
declare class BaseResource {
|
|
252
|
+
static resourceEndpoint: string;
|
|
253
|
+
static primaryKeyField: string;
|
|
254
|
+
static _connection: Connection | undefined;
|
|
255
|
+
protected _connection: Connection | undefined;
|
|
256
|
+
protected _attributes: ResourceAttributes;
|
|
257
|
+
protected _errors: string[];
|
|
258
|
+
protected _created: boolean;
|
|
259
|
+
protected _updated: boolean;
|
|
260
|
+
constructor(attributes?: ResourceAttributes, connection?: Connection);
|
|
261
|
+
static withConnection(connection: Connection): typeof BaseResource;
|
|
262
|
+
protected static getConnection(): Connection;
|
|
263
|
+
static getUri(attributes?: ResourceAttributes): string;
|
|
264
|
+
static create(attributes: ResourceAttributes, options?: RequestOptions): Promise<BaseResource>;
|
|
265
|
+
static find(id: string | number, params?: ResourceAttributes): Promise<BaseResource | null>;
|
|
266
|
+
static all(params?: ResourceAttributes): Promise<BaseResource[]>;
|
|
267
|
+
static findBy(params: ResourceAttributes): Promise<BaseResource | null>;
|
|
268
|
+
static findOrCreateBy(params: ResourceAttributes, attributes?: ResourceAttributes, options?: RequestOptions): Promise<BaseResource>;
|
|
269
|
+
get attributes(): ResourceAttributes;
|
|
270
|
+
get errors(): string[];
|
|
271
|
+
get(key: string): unknown;
|
|
272
|
+
set(key: string, value: unknown): void;
|
|
273
|
+
get id(): string | number | undefined;
|
|
274
|
+
isNewRecord(): boolean;
|
|
275
|
+
isCreated(): boolean;
|
|
276
|
+
isUpdated(): boolean;
|
|
277
|
+
isValid(): boolean;
|
|
278
|
+
getUri(): string;
|
|
279
|
+
protected getConnection(): Connection;
|
|
280
|
+
save(options?: RequestOptions): Promise<this>;
|
|
281
|
+
update(newAttributes: ResourceAttributes, options?: RequestOptions): Promise<this>;
|
|
282
|
+
delete(): Promise<boolean>;
|
|
283
|
+
toJSON(): ResourceAttributes;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
declare class Pix extends BaseResource {
|
|
287
|
+
static resourceEndpoint: string;
|
|
288
|
+
get amount(): number | undefined;
|
|
289
|
+
get expireAt(): string | undefined;
|
|
290
|
+
get status(): string | undefined;
|
|
291
|
+
get customerPersonName(): string | undefined;
|
|
292
|
+
get customerCnpjCpf(): string | undefined;
|
|
293
|
+
get customerEmail(): string | undefined;
|
|
294
|
+
get customerPhoneNumber(): string | undefined;
|
|
295
|
+
get description(): string | undefined;
|
|
296
|
+
get meta(): Record<string, unknown> | undefined;
|
|
297
|
+
get qrCode(): string | undefined;
|
|
298
|
+
get qrCodeUrl(): string | undefined;
|
|
299
|
+
get copyPaste(): string | undefined;
|
|
300
|
+
get txid(): string | undefined;
|
|
301
|
+
get paidAt(): string | undefined;
|
|
302
|
+
get paidAmount(): number | undefined;
|
|
303
|
+
get createdAt(): string | undefined;
|
|
304
|
+
get updatedAt(): string | undefined;
|
|
305
|
+
static create(attributes: PixChargeCreateParams, options?: RequestOptions): Promise<Pix>;
|
|
306
|
+
static find(id: string | number, params?: PixChargeListParams): Promise<Pix | null>;
|
|
307
|
+
static all(params?: PixChargeListParams): Promise<Pix[]>;
|
|
308
|
+
static findBy(params: PixChargeListParams): Promise<Pix | null>;
|
|
309
|
+
isPending(): boolean;
|
|
310
|
+
isPaid(): boolean;
|
|
311
|
+
isCanceled(): boolean;
|
|
312
|
+
isExpired(): boolean;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare class BankBillet extends BaseResource {
|
|
316
|
+
static resourceEndpoint: string;
|
|
317
|
+
get amount(): number | undefined;
|
|
318
|
+
get expireAt(): string | undefined;
|
|
319
|
+
get customerPersonName(): string | undefined;
|
|
320
|
+
get customerCnpjCpf(): string | undefined;
|
|
321
|
+
get customerState(): string | undefined;
|
|
322
|
+
get customerCityName(): string | undefined;
|
|
323
|
+
get customerZipcode(): string | undefined;
|
|
324
|
+
get customerAddress(): string | undefined;
|
|
325
|
+
get customerNeighborhood(): string | undefined;
|
|
326
|
+
get customerAddressNumber(): string | undefined;
|
|
327
|
+
get customerAddressComplement(): string | undefined;
|
|
328
|
+
get customerPhoneNumber(): string | undefined;
|
|
329
|
+
get customerEmail(): string | undefined;
|
|
330
|
+
get bankBilletAccountId(): number | undefined;
|
|
331
|
+
get ourNumber(): string | undefined;
|
|
332
|
+
get status(): string | undefined;
|
|
333
|
+
get shippingStatus(): string | undefined;
|
|
334
|
+
get meta(): Record<string, unknown> | undefined;
|
|
335
|
+
get notes(): string | undefined;
|
|
336
|
+
get instructions(): string | undefined;
|
|
337
|
+
get pixEnabled(): boolean | undefined;
|
|
338
|
+
get createdAt(): string | undefined;
|
|
339
|
+
get updatedAt(): string | undefined;
|
|
340
|
+
static create(attributes: BankBilletCreateParams, options?: RequestOptions): Promise<BankBillet>;
|
|
341
|
+
static find(id: string | number, params?: BankBilletListParams): Promise<BankBillet | null>;
|
|
342
|
+
static all(params?: BankBilletListParams): Promise<BankBillet[]>;
|
|
343
|
+
static findBy(params: BankBilletListParams): Promise<BankBillet | null>;
|
|
344
|
+
isPending(): boolean;
|
|
345
|
+
isOpened(): boolean;
|
|
346
|
+
isPaid(): boolean;
|
|
347
|
+
isCanceled(): boolean;
|
|
348
|
+
isExpired(): boolean;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
declare class BankBilletAccount extends BaseResource {
|
|
352
|
+
static resourceEndpoint: string;
|
|
353
|
+
get bankContractSlug(): string | undefined;
|
|
354
|
+
get nextOurNumber(): string | undefined;
|
|
355
|
+
get agencyNumber(): string | undefined;
|
|
356
|
+
get agencyDigit(): string | undefined;
|
|
357
|
+
get accountNumber(): string | undefined;
|
|
358
|
+
get accountDigit(): string | undefined;
|
|
359
|
+
get extra1(): string | undefined;
|
|
360
|
+
get extra1Digit(): string | undefined;
|
|
361
|
+
get extra2(): string | undefined;
|
|
362
|
+
get extra2Digit(): string | undefined;
|
|
363
|
+
get beneficiaryName(): string | undefined;
|
|
364
|
+
get beneficiaryCnpjCpf(): string | undefined;
|
|
365
|
+
get beneficiaryAddress(): string | undefined;
|
|
366
|
+
get name(): string | undefined;
|
|
367
|
+
get status(): string | undefined;
|
|
368
|
+
get homologatedAt(): string | undefined;
|
|
369
|
+
get nextRemittanceNumber(): number | undefined;
|
|
370
|
+
get configuration(): Record<string, unknown> | undefined;
|
|
371
|
+
get createdAt(): string | undefined;
|
|
372
|
+
get updatedAt(): string | undefined;
|
|
373
|
+
static create(attributes: BankBilletAccountCreateParams, options?: RequestOptions): Promise<BankBilletAccount>;
|
|
374
|
+
static find(id: string | number, params?: BankBilletAccountListParams): Promise<BankBilletAccount | null>;
|
|
375
|
+
static all(params?: BankBilletAccountListParams): Promise<BankBilletAccount[]>;
|
|
376
|
+
static findBy(params: BankBilletAccountListParams): Promise<BankBilletAccount | null>;
|
|
377
|
+
askHomologation(): Promise<this>;
|
|
378
|
+
validate(): Promise<this>;
|
|
379
|
+
setDefault(): Promise<this>;
|
|
380
|
+
isPending(): boolean;
|
|
381
|
+
isHomologating(): boolean;
|
|
382
|
+
isActive(): boolean;
|
|
383
|
+
isHomologated(): boolean;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
interface ChargeProxy {
|
|
387
|
+
readonly pix: typeof Pix;
|
|
388
|
+
readonly bankBillet: typeof BankBillet;
|
|
389
|
+
}
|
|
390
|
+
interface FinancialProxy {
|
|
391
|
+
readonly bankBilletAccount: typeof BankBilletAccount;
|
|
392
|
+
}
|
|
393
|
+
declare class KobanaClient {
|
|
394
|
+
private _configuration;
|
|
395
|
+
private _connection;
|
|
396
|
+
private _chargeProxy;
|
|
397
|
+
private _financialProxy;
|
|
398
|
+
constructor(options: ConfigurationOptions);
|
|
399
|
+
get configuration(): Configuration;
|
|
400
|
+
configure(options: Partial<ConfigurationOptions>): void;
|
|
401
|
+
get charge(): ChargeProxy;
|
|
402
|
+
get financial(): FinancialProxy;
|
|
403
|
+
}
|
|
404
|
+
declare const Kobana: {
|
|
405
|
+
configure(options: ConfigurationOptions): void;
|
|
406
|
+
readonly configuration: Configuration | null;
|
|
407
|
+
readonly charge: ChargeProxy;
|
|
408
|
+
readonly financial: FinancialProxy;
|
|
409
|
+
Client: typeof KobanaClient;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
declare class KobanaError extends Error {
|
|
413
|
+
constructor(message: string);
|
|
414
|
+
}
|
|
415
|
+
declare class ConfigurationError extends KobanaError {
|
|
416
|
+
constructor(message: string);
|
|
417
|
+
}
|
|
418
|
+
declare class ConnectionError extends KobanaError {
|
|
419
|
+
constructor(message: string);
|
|
420
|
+
}
|
|
421
|
+
declare class ResourceNotFoundError extends KobanaError {
|
|
422
|
+
constructor(message?: string);
|
|
423
|
+
}
|
|
424
|
+
declare class UnauthorizedError extends KobanaError {
|
|
425
|
+
constructor(message?: string);
|
|
426
|
+
}
|
|
427
|
+
declare class ValidationError extends KobanaError {
|
|
428
|
+
readonly errors: string[];
|
|
429
|
+
constructor(message: string, errors?: string[]);
|
|
430
|
+
}
|
|
431
|
+
declare class APIError extends KobanaError {
|
|
432
|
+
readonly status: number;
|
|
433
|
+
readonly responseBody: unknown;
|
|
434
|
+
readonly errors: string[];
|
|
435
|
+
constructor(options: {
|
|
436
|
+
message?: string;
|
|
437
|
+
status: number;
|
|
438
|
+
responseBody?: unknown;
|
|
439
|
+
errors?: string[];
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export { APIError, type ApiErrorResponse, type ApiResponse, type ApiVersion, BankBillet, BankBilletAccount, type BankBilletAccountAttributes, type BankBilletAccountCreateParams, type BankBilletAccountListParams, type BankBilletAttributes, type BankBilletCreateParams, type BankBilletListParams, BaseResource, Configuration, ConfigurationError, type ConfigurationInterface, type ConfigurationOptions, Connection, ConnectionError, type Environment, Kobana, KobanaClient, KobanaError, type PaginationParams, Pix, type PixChargeAttributes, type PixChargeCreateParams, type PixChargeListParams, type RequestOptions, type ResourceAttributes, type ResourceMeta, ResourceNotFoundError, UnauthorizedError, ValidationError };
|