@abacatepay/types 2.0.1 → 2.0.2
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 +27 -25
- package/dist/v1/rest.d.ts +0 -1
- package/dist/v2/entities/coupon.d.ts +1 -1
- package/dist/v2/entities/subscription.d.ts +1 -1
- package/dist/v2/rest.d.ts +24 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -2,41 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
## AbacatePay API Types
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
O [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types) fornece **tipagens oficiais** e **helpers modernos** para trabalhar com a API da AbacatePay de forma **segura**, **previsível** e **alinhada** à documentação oficial.
|
|
6
|
+
|
|
7
|
+
O pacote é **TypeScript-first** e serve como base para integrações diretas via **fetch**, **SDKs** internos, **CLIs** e validações em **aplicações** backend.
|
|
6
8
|
|
|
7
9
|
<img src="https://res.cloudinary.com/dkok1obj5/image/upload/v1767631413/avo_clhmaf.png" width="100%" alt="AbacatePay Open Source"/>
|
|
8
10
|
|
|
9
11
|
## Instalação
|
|
10
12
|
|
|
11
|
-
Use
|
|
13
|
+
Use o *package manager* da sua preferência:
|
|
12
14
|
|
|
13
15
|
</div>
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
18
|
bun add @abacatepay/types
|
|
19
|
+
# ou
|
|
17
20
|
pnpm add @abacatepay/types
|
|
21
|
+
# ou
|
|
18
22
|
npm install @abacatepay/types
|
|
19
23
|
```
|
|
20
24
|
|
|
21
25
|
<div align="center">
|
|
22
26
|
|
|
23
|
-
##
|
|
27
|
+
## Versionamento dos Tipos
|
|
24
28
|
|
|
25
|
-
Antes de tudo, você deve
|
|
29
|
+
Antes de tudo, você deve especificar a versão da API que deseja usar, adicionando **/v*** na importação:
|
|
26
30
|
|
|
27
31
|
</div>
|
|
28
32
|
|
|
29
33
|
```ts
|
|
30
|
-
import { APICustomer } from '@abacatepay/types/
|
|
34
|
+
import { APICustomer } from '@abacatepay/types/v2';
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
<p align="center">Para tipos globais como <code>API_BASE_URL</code>, <code>API_VERSION</code>, <code>version</code> e <code>Routes</code>, apenas import normalmente sem a versão.</p>
|
|
37
|
+
<p align="center">Tipos e constantes globais não são versionados e devem ser importados diretamente sem a versão:</p>
|
|
35
38
|
|
|
36
39
|
```ts
|
|
37
|
-
import { version } from '@abacatepay/types'
|
|
40
|
+
import { version, API_BASE_URL, API_VERSION } from '@abacatepay/types';
|
|
38
41
|
```
|
|
39
42
|
|
|
43
|
+
## Como a AbacatePay API Types documenta
|
|
44
|
+
|
|
40
45
|
- Prefixo `API*`
|
|
41
46
|
Representa estruturas gerais da API (Objetos retornados, modelos internos etc.).
|
|
42
47
|
|
|
@@ -69,36 +74,33 @@ São campos que não têm definição formal na documentação, mas cujo tipo fo
|
|
|
69
74
|
|
|
70
75
|
```ts
|
|
71
76
|
import {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} from '@abacatepay/types/v1';
|
|
78
|
-
|
|
79
|
-
async function createCoupon(body: RESTPostCreateCouponBody) {
|
|
80
|
-
const path = `${API_BASE_URL}/${API_VERSION}/${Routes.coupon.create}`;
|
|
77
|
+
Routes,
|
|
78
|
+
type APICoupon,
|
|
79
|
+
type RESTPostCreateCouponBody,
|
|
80
|
+
} from '@abacatepay/types/v2';
|
|
81
|
+
import { REST } from '@abacatepay/rest';
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
method: 'POST',
|
|
84
|
-
body: JSON.stringify(body),
|
|
85
|
-
});
|
|
83
|
+
const client = new REST({ secret });
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
async function createCoupon(body: RESTPostCreateCouponBody) {
|
|
86
|
+
const data = await client.post<APICoupon>(Routes.coupons.create, { body });
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
return data;
|
|
90
89
|
}
|
|
91
90
|
```
|
|
92
91
|
|
|
93
92
|
<p align="center"><strong>Crie um servidor e escute eventos de Webhooks do Aabacate</strong></p>
|
|
94
93
|
|
|
95
94
|
```ts
|
|
96
|
-
import {
|
|
95
|
+
import { WebhookEvent } from '@abacatepay/zod/v2';
|
|
96
|
+
import { WebhookEventType } from '@abacatepay/types/v2';
|
|
97
97
|
|
|
98
98
|
Bun.serve({
|
|
99
99
|
routes: {
|
|
100
100
|
async '/webhooks/abacate'(request) {
|
|
101
|
-
const
|
|
101
|
+
const raw = await request.json();
|
|
102
|
+
|
|
103
|
+
const { data, event } = WebhookEvent.parse(raw);
|
|
102
104
|
|
|
103
105
|
switch (event) {
|
|
104
106
|
case WebhookEventType.BillingPaid:
|
package/dist/v1/rest.d.ts
CHANGED
|
@@ -86,7 +86,6 @@ export interface RESTPostCreateNewChargeBody {
|
|
|
86
86
|
*/
|
|
87
87
|
customerId?: string;
|
|
88
88
|
/**
|
|
89
|
-
* /**
|
|
90
89
|
* Your customer's data to create it.
|
|
91
90
|
* The customer object is not mandatory, but when entering any `customer` information, all `name`, `cellphone`, `email` and `taxId` fields are mandatory.
|
|
92
91
|
*/
|
|
@@ -27,7 +27,7 @@ export interface APICoupon {
|
|
|
27
27
|
/**
|
|
28
28
|
* Counter of how many times the coupon has been used by customers.
|
|
29
29
|
*/
|
|
30
|
-
redeemsCount:
|
|
30
|
+
redeemsCount: number;
|
|
31
31
|
/**
|
|
32
32
|
* Indicates whether the coupon was created in a development (true) or production (false) environment.
|
|
33
33
|
*/
|
package/dist/v2/rest.d.ts
CHANGED
|
@@ -10,12 +10,20 @@ export type APIResponse<Data> = {
|
|
|
10
10
|
*/
|
|
11
11
|
data: Data;
|
|
12
12
|
error: null;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the request was successful or not.
|
|
15
|
+
*/
|
|
16
|
+
success: true;
|
|
13
17
|
} | {
|
|
14
18
|
data: null;
|
|
15
19
|
/**
|
|
16
20
|
* Error message returned from the API.
|
|
17
21
|
*/
|
|
18
22
|
error: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the request was successful or not.
|
|
25
|
+
*/
|
|
26
|
+
success: false;
|
|
19
27
|
};
|
|
20
28
|
/**
|
|
21
29
|
* Any response returned by the AbacatePay API that has a `pagination` field (Not cursor based).
|
|
@@ -26,6 +34,10 @@ export type APIResponseWithPagination<Data> = {
|
|
|
26
34
|
*/
|
|
27
35
|
data: Data;
|
|
28
36
|
error: null;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the request was successful or not.
|
|
39
|
+
*/
|
|
40
|
+
success: true;
|
|
29
41
|
/**
|
|
30
42
|
* Pagination info.
|
|
31
43
|
*/
|
|
@@ -53,6 +65,10 @@ export type APIResponseWithPagination<Data> = {
|
|
|
53
65
|
* Error message returned from the API.
|
|
54
66
|
*/
|
|
55
67
|
error: string;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the request was successful or not.
|
|
70
|
+
*/
|
|
71
|
+
success: false;
|
|
56
72
|
};
|
|
57
73
|
/**
|
|
58
74
|
* Any response returned by the AbacatePay API that has a `pagination` field and is cursor-based.
|
|
@@ -63,6 +79,10 @@ export type APIResponseWithCursorBasedPagination<Data> = {
|
|
|
63
79
|
*/
|
|
64
80
|
data: Data;
|
|
65
81
|
error: null;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the request was successful or not.
|
|
84
|
+
*/
|
|
85
|
+
success: true;
|
|
66
86
|
/**
|
|
67
87
|
* Pagination info.
|
|
68
88
|
*/
|
|
@@ -90,6 +110,10 @@ export type APIResponseWithCursorBasedPagination<Data> = {
|
|
|
90
110
|
* Error message returned from the API.
|
|
91
111
|
*/
|
|
92
112
|
error: string;
|
|
113
|
+
/**
|
|
114
|
+
* Whether the request was successful or not.
|
|
115
|
+
*/
|
|
116
|
+
success: false;
|
|
93
117
|
};
|
|
94
118
|
/**
|
|
95
119
|
* https://api.abacatepay.com/v2/customers/create
|
package/dist/version.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Current version of [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types).
|
|
3
3
|
*/
|
|
4
|
-
export declare const version: "2.0.
|
|
4
|
+
export declare const version: "2.0.2";
|
|
5
5
|
/**
|
|
6
|
-
* Current version of the AbacatePay API
|
|
6
|
+
* Current version of the AbacatePay API.
|
|
7
7
|
*/
|
|
8
8
|
export declare const API_VERSION: "2";
|
package/dist/version.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Current version of [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types).
|
|
4
4
|
*/
|
|
5
|
-
export const version = '2.0.
|
|
5
|
+
export const version = '2.0.2';
|
|
6
6
|
/**
|
|
7
|
-
* Current version of the AbacatePay API
|
|
7
|
+
* Current version of the AbacatePay API.
|
|
8
8
|
*/
|
|
9
9
|
export const API_VERSION = '2';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
2
|
+
"version": "2.0.2",
|
|
3
3
|
"name": "@abacatepay/types",
|
|
4
4
|
"description": "Abacate Pay API typings that are always up to date.",
|
|
5
5
|
"type": "module",
|
|
@@ -46,12 +46,24 @@
|
|
|
46
46
|
"build": "bun run gen:version && tsc",
|
|
47
47
|
"prepublishOnly": "bun run build",
|
|
48
48
|
"gen:version": "bun run scripts/version.ts",
|
|
49
|
+
"test": "bun test",
|
|
49
50
|
"fmt": "bunx biome check --write package.json types && clear"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@biomejs/biome": "^2.3.8",
|
|
53
54
|
"typescript": "^5.9.3"
|
|
54
55
|
},
|
|
56
|
+
"author": {
|
|
57
|
+
"name": "AbacatePay",
|
|
58
|
+
"email": "opensource@abacatepay.com",
|
|
59
|
+
"url": "https://abacatepay.com"
|
|
60
|
+
},
|
|
61
|
+
"maintainers": [
|
|
62
|
+
{
|
|
63
|
+
"name": "Almeida",
|
|
64
|
+
"url": "https://github.com/almeidazs"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
55
67
|
"keywords": [
|
|
56
68
|
"api",
|
|
57
69
|
"abacatepay",
|
|
@@ -63,6 +75,6 @@
|
|
|
63
75
|
},
|
|
64
76
|
"repository": {
|
|
65
77
|
"type": "git",
|
|
66
|
-
"url": "https://github.com/
|
|
78
|
+
"url": "git+https://github.com/AbacatePay/ecosystem.git"
|
|
67
79
|
}
|
|
68
80
|
}
|