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.
@@ -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 };