@zennify/sdk-js 1.0.0 → 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.
@@ -1,9 +1,8 @@
1
- name: Publish to npm
1
+ name: Publish to npm (Stable)
2
2
 
3
3
  on:
4
- push:
5
- branches:
6
- - main
4
+ release:
5
+ types: [published]
7
6
 
8
7
  jobs:
9
8
  build:
@@ -16,7 +15,7 @@ jobs:
16
15
  - run: npm ci
17
16
  - run: npm run build
18
17
 
19
- publish-gpr:
18
+ publish-npm:
20
19
  needs: build
21
20
  runs-on: ubuntu-latest
22
21
  permissions:
@@ -30,6 +29,6 @@ jobs:
30
29
  registry-url: https://registry.npmjs.org/
31
30
  - run: npm ci
32
31
  - run: npm run build
33
- - run: npm publish --access public --tag beta
32
+ - run: npm publish --access public
34
33
  env:
35
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
34
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -20,24 +20,35 @@ class ZennifyAPIRequestError extends Error {
20
20
  super();
21
21
  this.body = body;
22
22
  this.status = response.status;
23
- if (this.status === 403) {
23
+ if (this.status === 401) {
24
24
  this.name = "Usuário inválido";
25
25
  this.message = "Por favor, se re-autentique";
26
+ return;
26
27
  }
27
- if (this.status === 503) {
28
+ else if (this.status === 503) {
28
29
  this.name = "API em atualização.";
29
30
  this.message = "Por favor, tente novamente em alguns minutos.";
31
+ return;
30
32
  }
31
- if (this.status === 429) {
33
+ else if (this.status === 429) {
32
34
  this.name = "Calma ai!";
33
35
  this.message = "Suas ações estão sendo limitadas!";
36
+ return;
37
+ }
38
+ else if (body.code) {
39
+ const error = errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
40
+ errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
41
+ this.name = error.name
42
+ .replace(match_regex, (value) => replacer(body, value));
43
+ this.message = error.message
44
+ .replace(match_regex, (value) => replacer(body, value));
45
+ return;
46
+ }
47
+ else if (this.status === 401) {
48
+ this.name = "Sem permissões";
49
+ this.message = "Por favor, se re-autentique";
50
+ return;
34
51
  }
35
- const error = errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
36
- errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
37
- this.name = error.name
38
- .replace(match_regex, (value) => replacer(body, value));
39
- this.message = error.message
40
- .replace(match_regex, (value) => replacer(body, value));
41
52
  }
42
53
  }
43
54
  exports.ZennifyAPIRequestError = ZennifyAPIRequestError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zennify/sdk-js",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "A simple package to work with https://api.zennify.app",
5
5
  "main": "dist/main.js",
6
6
  "keywords": [],
@@ -26,31 +26,40 @@ export class ZennifyAPIRequestError extends Error {
26
26
  this.body = body;
27
27
  this.status = response.status;
28
28
 
29
- if (this.status === 403) {
29
+ if (this.status === 401) {
30
30
  this.name = "Usuário inválido";
31
- this.message = "Por favor, se re-autentique"
31
+ this.message = "Por favor, se re-autentique";
32
+ return;
32
33
  }
33
-
34
- if (this.status === 503) {
34
+ else if (this.status === 503) {
35
35
  this.name = "API em atualização.";
36
36
  this.message = "Por favor, tente novamente em alguns minutos.";
37
+ return;
37
38
  }
38
-
39
- if (this.status === 429) {
39
+ else if (this.status === 429) {
40
40
  this.name = "Calma ai!";
41
41
  this.message = "Suas ações estão sendo limitadas!";
42
+ return;
42
43
  }
44
+ else if (body.code) {
43
45
 
44
- const error: { name: string, message: string } =
45
- errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
46
- errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
46
+ const error: { name: string, message: string } =
47
+ errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
48
+ errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
47
49
 
48
- this.name = error.name
49
- .replace(match_regex, (value) => replacer(body, value));
50
+ this.name = error.name
51
+ .replace(match_regex, (value) => replacer(body, value));
50
52
 
51
- this.message = error.message
52
- .replace(match_regex, (value) => replacer(body, value));
53
+ this.message = error.message
54
+ .replace(match_regex, (value) => replacer(body, value));
53
55
 
56
+ return;
57
+ }
58
+ else if (this.status === 401) {
59
+ this.name = "Sem permissões";
60
+ this.message = "Por favor, se re-autentique"
61
+ return;
62
+ }
54
63
  }
55
64
 
56
65
  }
package/src/errors.ts CHANGED
@@ -76,6 +76,10 @@ export interface APIErrors {
76
76
  'UNKNOWN_ORDER': {}
77
77
  'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {}
78
78
  'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {}
79
+ // MP errors
80
+ 'MP_ACCOUNT_OFFLINE': {};
81
+ 'MP_PIX_KEY_NOT_CONFIGURED': {}
82
+ 'MP_NOT_ALLOWED_TO_SELL': {}
79
83
  /// bad preference configuration
80
84
  'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
81
85
  'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
@@ -106,6 +110,7 @@ export interface APIErrors {
106
110
  'INVALID_DISCORD_BOT_TOKEN': {};
107
111
  'DISABLE_REQUIRE_CODE_GRANT': {};
108
112
  'UNKNOWN_DISCORD_CHANNEL': {};
113
+ 'ANOTHER_STORE_HAS_THIS_BOT': {}
109
114
  // product errors
110
115
  'UNKNOWN_PRODUCT': {};
111
116
  'INVALID_PRODUCT_NAME': {};
@@ -149,8 +154,6 @@ export interface APIErrors {
149
154
  'PANEL_NAME_ALREADY_EXIST': {};
150
155
  'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
151
156
  'STORE_ALREADY_CONFIGURED': {};
152
- 'MP_ACCOUNT_OFFLINE': {};
153
- 'MP_PIX_KEY_NOT_CONFIGURED': {}
154
157
  }
155
158
 
156
159
  type ExpectedAdditionalData = {
@@ -195,6 +195,10 @@
195
195
  "name": "PIX key not configured",
196
196
  "message": "The seller must configure a PIX key in Mercado Pago."
197
197
  },
198
+ "MP_NOT_ALLOWED_TO_SELL": {
199
+ "name": "Not authorized by Mercado Pago to sell",
200
+ "message": "Please contact Mercado Pago support."
201
+ },
198
202
  "INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS": {
199
203
  "name": "Invalid operation for this transaction.",
200
204
  "message": "The current status doesn't allow this operation."
@@ -275,6 +279,10 @@
275
279
  "name": "Disable \"Require code grant\"",
276
280
  "message": "With it enabled, you won't be able to invite the bot."
277
281
  },
282
+ "ANOTHER_STORE_HAS_THIS_BOT": {
283
+ "name": "Another store has already configured this bot!",
284
+ "message": "Please configure a different bot."
285
+ },
278
286
  "UNKNOWN_DISCORD_CHANNEL": {
279
287
  "name": "Unknown Discord channel",
280
288
  "message": "Perhaps this channel no longer exists."
@@ -191,6 +191,10 @@
191
191
  "name": "Chave PIX não configurada",
192
192
  "message": "O vendedor deve configurar uma chave pix no Mercado Pago."
193
193
  },
194
+ "MP_NOT_ALLOWED_TO_SELL": {
195
+ "name": "Sem autorização do Mercado Pago para vender",
196
+ "message": "Entre em contato com o Mercado Pago."
197
+ },
194
198
  "INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS": {
195
199
  "name": "Operação inválida para essa transação.",
196
200
  "message": "O estado atual não permite que a operação seja realizada."
@@ -275,6 +279,10 @@
275
279
  "name": "Desabilite o \"Require code grant\"",
276
280
  "message": "Com ele ativado você não conseguirá convidar o bot"
277
281
  },
282
+ "ANOTHER_STORE_HAS_THIS_BOT": {
283
+ "name": "Outra loja já configurou este bot!",
284
+ "message": "Configure um bot diferente"
285
+ },
278
286
  "UNKNOWN_DISCORD_CHANNEL": {
279
287
  "name": "Canal do Discord desconhecido",
280
288
  "message": "Talvez esse canal não exista mais."
package/types/errors.d.ts CHANGED
@@ -68,6 +68,9 @@ export interface APIErrors {
68
68
  'UNKNOWN_ORDER': {};
69
69
  'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {};
70
70
  'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {};
71
+ 'MP_ACCOUNT_OFFLINE': {};
72
+ 'MP_PIX_KEY_NOT_CONFIGURED': {};
73
+ 'MP_NOT_ALLOWED_TO_SELL': {};
71
74
  'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
72
75
  'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
73
76
  'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO': {};
@@ -93,6 +96,7 @@ export interface APIErrors {
93
96
  'INVALID_DISCORD_BOT_TOKEN': {};
94
97
  'DISABLE_REQUIRE_CODE_GRANT': {};
95
98
  'UNKNOWN_DISCORD_CHANNEL': {};
99
+ 'ANOTHER_STORE_HAS_THIS_BOT': {};
96
100
  'UNKNOWN_PRODUCT': {};
97
101
  'INVALID_PRODUCT_NAME': {};
98
102
  'INVALID_PRODUCT_VALUE': {};
@@ -130,8 +134,6 @@ export interface APIErrors {
130
134
  'PANEL_NAME_ALREADY_EXIST': {};
131
135
  'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
132
136
  'STORE_ALREADY_CONFIGURED': {};
133
- 'MP_ACCOUNT_OFFLINE': {};
134
- 'MP_PIX_KEY_NOT_CONFIGURED': {};
135
137
  }
136
138
  type ExpectedAdditionalData = {
137
139
  field: string;