@zennify/sdk-js 1.1.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.
- package/dist/RequestError.js +11 -2
- package/package.json +1 -1
- package/src/RequestError.ts +14 -3
- package/src/errors.ts +5 -3
- package/translations/en_US.json +4 -0
- package/translations/pt_BR.json +4 -0
- package/types/errors.d.ts +4 -3
package/dist/RequestError.js
CHANGED
|
@@ -20,25 +20,34 @@ class ZennifyAPIRequestError extends Error {
|
|
|
20
20
|
super();
|
|
21
21
|
this.body = body;
|
|
22
22
|
this.status = response.status;
|
|
23
|
-
if (this.status ===
|
|
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
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
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;
|
|
34
37
|
}
|
|
35
|
-
else {
|
|
38
|
+
else if (body.code) {
|
|
36
39
|
const error = errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
|
|
37
40
|
errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
|
|
38
41
|
this.name = error.name
|
|
39
42
|
.replace(match_regex, (value) => replacer(body, value));
|
|
40
43
|
this.message = error.message
|
|
41
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;
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
53
|
}
|
package/package.json
CHANGED
package/src/RequestError.ts
CHANGED
|
@@ -26,18 +26,22 @@ export class ZennifyAPIRequestError extends Error {
|
|
|
26
26
|
this.body = body;
|
|
27
27
|
this.status = response.status;
|
|
28
28
|
|
|
29
|
-
if (this.status ===
|
|
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
|
else if (this.status === 503) {
|
|
34
35
|
this.name = "API em atualização.";
|
|
35
36
|
this.message = "Por favor, tente novamente em alguns minutos.";
|
|
37
|
+
return;
|
|
36
38
|
}
|
|
37
39
|
else if (this.status === 429) {
|
|
38
40
|
this.name = "Calma ai!";
|
|
39
41
|
this.message = "Suas ações estão sendo limitadas!";
|
|
40
|
-
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
else if (body.code) {
|
|
41
45
|
|
|
42
46
|
const error: { name: string, message: string } =
|
|
43
47
|
errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
|
|
@@ -48,6 +52,13 @@ export class ZennifyAPIRequestError extends Error {
|
|
|
48
52
|
|
|
49
53
|
this.message = error.message
|
|
50
54
|
.replace(match_regex, (value) => replacer(body, value));
|
|
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;
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
|
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,9 +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
|
-
'MP_NOT_ALLOWED_TO_SELL': {}
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
type ExpectedAdditionalData = {
|
package/translations/en_US.json
CHANGED
|
@@ -279,6 +279,10 @@
|
|
|
279
279
|
"name": "Disable \"Require code grant\"",
|
|
280
280
|
"message": "With it enabled, you won't be able to invite the bot."
|
|
281
281
|
},
|
|
282
|
+
"ANOTHER_STORE_HAS_THIS_BOT": {
|
|
283
|
+
"name": "Another store has already configured this bot!",
|
|
284
|
+
"message": "Please configure a different bot."
|
|
285
|
+
},
|
|
282
286
|
"UNKNOWN_DISCORD_CHANNEL": {
|
|
283
287
|
"name": "Unknown Discord channel",
|
|
284
288
|
"message": "Perhaps this channel no longer exists."
|
package/translations/pt_BR.json
CHANGED
|
@@ -279,6 +279,10 @@
|
|
|
279
279
|
"name": "Desabilite o \"Require code grant\"",
|
|
280
280
|
"message": "Com ele ativado você não conseguirá convidar o bot"
|
|
281
281
|
},
|
|
282
|
+
"ANOTHER_STORE_HAS_THIS_BOT": {
|
|
283
|
+
"name": "Outra loja já configurou este bot!",
|
|
284
|
+
"message": "Configure um bot diferente"
|
|
285
|
+
},
|
|
282
286
|
"UNKNOWN_DISCORD_CHANNEL": {
|
|
283
287
|
"name": "Canal do Discord desconhecido",
|
|
284
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,9 +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
|
-
'MP_NOT_ALLOWED_TO_SELL': {};
|
|
136
137
|
}
|
|
137
138
|
type ExpectedAdditionalData = {
|
|
138
139
|
field: string;
|