@zennify/sdk-js 1.1.0 → 1.3.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 +8 -3
- package/translations/en_US.json +16 -0
- package/translations/pt_BR.json +16 -0
- package/types/errors.d.ts +7 -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
|
@@ -17,6 +17,7 @@ export interface APIErrors {
|
|
|
17
17
|
'EXPECTED_A_STRING': ExpectedAdditionalData;
|
|
18
18
|
'EXPECTED_A_NUMBER': ExpectedAdditionalData;
|
|
19
19
|
'EXPECTED_A_VALID_ID': ExpectedAdditionalData;
|
|
20
|
+
'EXPECTED_A_VALID_SNOWFLAKE_ID': {};
|
|
20
21
|
'DUPLICATED_VALUES_ISNT_ALLOWED': {};
|
|
21
22
|
// = oAuth errors
|
|
22
23
|
'GRANT_CODE_MISSING_IN_QUERY': {};
|
|
@@ -76,6 +77,10 @@ export interface APIErrors {
|
|
|
76
77
|
'UNKNOWN_ORDER': {}
|
|
77
78
|
'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {}
|
|
78
79
|
'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {}
|
|
80
|
+
// MP errors
|
|
81
|
+
'MP_ACCOUNT_OFFLINE': {};
|
|
82
|
+
'MP_PIX_KEY_NOT_CONFIGURED': {}
|
|
83
|
+
'MP_NOT_ALLOWED_TO_SELL': {}
|
|
79
84
|
/// bad preference configuration
|
|
80
85
|
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
|
|
81
86
|
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
|
|
@@ -106,6 +111,9 @@ export interface APIErrors {
|
|
|
106
111
|
'INVALID_DISCORD_BOT_TOKEN': {};
|
|
107
112
|
'DISABLE_REQUIRE_CODE_GRANT': {};
|
|
108
113
|
'UNKNOWN_DISCORD_CHANNEL': {};
|
|
114
|
+
'ANOTHER_STORE_HAS_THIS_BOT': {}
|
|
115
|
+
'UNKNOWN_APPLICATION': {}
|
|
116
|
+
'WAIT_APPLICATION_UPLOAD': {}
|
|
109
117
|
// product errors
|
|
110
118
|
'UNKNOWN_PRODUCT': {};
|
|
111
119
|
'INVALID_PRODUCT_NAME': {};
|
|
@@ -149,9 +157,6 @@ export interface APIErrors {
|
|
|
149
157
|
'PANEL_NAME_ALREADY_EXIST': {};
|
|
150
158
|
'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
|
|
151
159
|
'STORE_ALREADY_CONFIGURED': {};
|
|
152
|
-
'MP_ACCOUNT_OFFLINE': {};
|
|
153
|
-
'MP_PIX_KEY_NOT_CONFIGURED': {}
|
|
154
|
-
'MP_NOT_ALLOWED_TO_SELL': {}
|
|
155
160
|
}
|
|
156
161
|
|
|
157
162
|
type ExpectedAdditionalData = {
|
package/translations/en_US.json
CHANGED
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
"name": "Expected a valid ID",
|
|
48
48
|
"message": "IDs must be integers between 0 and 2.147.483.647"
|
|
49
49
|
},
|
|
50
|
+
"EXPECTED_A_VALID_SNOWFLAKE_ID": {
|
|
51
|
+
"name": "A valid ID was expected",
|
|
52
|
+
"message": "Please check if the ID is valid."
|
|
53
|
+
},
|
|
50
54
|
"STORE_ALREADY_CONFIGURED": {
|
|
51
55
|
"name": "This store is already configured",
|
|
52
56
|
"message": "Go back to dashboard and access the store again"
|
|
@@ -279,6 +283,18 @@
|
|
|
279
283
|
"name": "Disable \"Require code grant\"",
|
|
280
284
|
"message": "With it enabled, you won't be able to invite the bot."
|
|
281
285
|
},
|
|
286
|
+
"ANOTHER_STORE_HAS_THIS_BOT": {
|
|
287
|
+
"name": "Another store has already configured this bot!",
|
|
288
|
+
"message": "Please configure a different bot."
|
|
289
|
+
},
|
|
290
|
+
"UNKNOWN_APPLICATION": {
|
|
291
|
+
"name": "Application not found",
|
|
292
|
+
"message": "Please contact support."
|
|
293
|
+
},
|
|
294
|
+
"WAIT_APPLICATION_UPLOAD": {
|
|
295
|
+
"name": "Please wait for your application to be uploaded!",
|
|
296
|
+
"message": "It should be uploaded in a few minutes."
|
|
297
|
+
},
|
|
282
298
|
"UNKNOWN_DISCORD_CHANNEL": {
|
|
283
299
|
"name": "Unknown Discord channel",
|
|
284
300
|
"message": "Perhaps this channel no longer exists."
|
package/translations/pt_BR.json
CHANGED
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
"name": "Era esperado um ID válido",
|
|
48
48
|
"message": "Recebido \"{received}\" com o tipo {type}, Verifique o campo \"{field}\". IDs devem ser inteiros entre 0 e 2.147.483.647"
|
|
49
49
|
},
|
|
50
|
+
"EXPECTED_A_VALID_SNOWFLAKE_ID": {
|
|
51
|
+
"name": "Era esperado um ID válido",
|
|
52
|
+
"message": "Verifique se o ID é válido"
|
|
53
|
+
},
|
|
50
54
|
"DUPLICATED_VALUES_ISNT_ALLOWED": {
|
|
51
55
|
"name": "Valores duplicados não são permitidos",
|
|
52
56
|
"message": "Recebido \"{received}\" com o tipo {type}, Verifique o campo \"{field}\""
|
|
@@ -279,6 +283,18 @@
|
|
|
279
283
|
"name": "Desabilite o \"Require code grant\"",
|
|
280
284
|
"message": "Com ele ativado você não conseguirá convidar o bot"
|
|
281
285
|
},
|
|
286
|
+
"ANOTHER_STORE_HAS_THIS_BOT": {
|
|
287
|
+
"name": "Outra loja já configurou este bot!",
|
|
288
|
+
"message": "Configure um bot diferente"
|
|
289
|
+
},
|
|
290
|
+
"UNKNOWN_APPLICATION": {
|
|
291
|
+
"name": "Aplicação não encontrada",
|
|
292
|
+
"message": "Entre em contato com o suporte."
|
|
293
|
+
},
|
|
294
|
+
"WAIT_APPLICATION_UPLOAD": {
|
|
295
|
+
"name": "Aguarde o envio da sua aplicação!",
|
|
296
|
+
"message": "Ela deve ser enviada em alguns minutos"
|
|
297
|
+
},
|
|
282
298
|
"UNKNOWN_DISCORD_CHANNEL": {
|
|
283
299
|
"name": "Canal do Discord desconhecido",
|
|
284
300
|
"message": "Talvez esse canal não exista mais."
|
package/types/errors.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface APIErrors {
|
|
|
16
16
|
'EXPECTED_A_STRING': ExpectedAdditionalData;
|
|
17
17
|
'EXPECTED_A_NUMBER': ExpectedAdditionalData;
|
|
18
18
|
'EXPECTED_A_VALID_ID': ExpectedAdditionalData;
|
|
19
|
+
'EXPECTED_A_VALID_SNOWFLAKE_ID': {};
|
|
19
20
|
'DUPLICATED_VALUES_ISNT_ALLOWED': {};
|
|
20
21
|
'GRANT_CODE_MISSING_IN_QUERY': {};
|
|
21
22
|
'INVALID_SCOPE': {};
|
|
@@ -68,6 +69,9 @@ export interface APIErrors {
|
|
|
68
69
|
'UNKNOWN_ORDER': {};
|
|
69
70
|
'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {};
|
|
70
71
|
'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {};
|
|
72
|
+
'MP_ACCOUNT_OFFLINE': {};
|
|
73
|
+
'MP_PIX_KEY_NOT_CONFIGURED': {};
|
|
74
|
+
'MP_NOT_ALLOWED_TO_SELL': {};
|
|
71
75
|
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
|
|
72
76
|
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
|
|
73
77
|
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO': {};
|
|
@@ -93,6 +97,9 @@ export interface APIErrors {
|
|
|
93
97
|
'INVALID_DISCORD_BOT_TOKEN': {};
|
|
94
98
|
'DISABLE_REQUIRE_CODE_GRANT': {};
|
|
95
99
|
'UNKNOWN_DISCORD_CHANNEL': {};
|
|
100
|
+
'ANOTHER_STORE_HAS_THIS_BOT': {};
|
|
101
|
+
'UNKNOWN_APPLICATION': {};
|
|
102
|
+
'WAIT_APPLICATION_UPLOAD': {};
|
|
96
103
|
'UNKNOWN_PRODUCT': {};
|
|
97
104
|
'INVALID_PRODUCT_NAME': {};
|
|
98
105
|
'INVALID_PRODUCT_VALUE': {};
|
|
@@ -130,9 +137,6 @@ export interface APIErrors {
|
|
|
130
137
|
'PANEL_NAME_ALREADY_EXIST': {};
|
|
131
138
|
'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
|
|
132
139
|
'STORE_ALREADY_CONFIGURED': {};
|
|
133
|
-
'MP_ACCOUNT_OFFLINE': {};
|
|
134
|
-
'MP_PIX_KEY_NOT_CONFIGURED': {};
|
|
135
|
-
'MP_NOT_ALLOWED_TO_SELL': {};
|
|
136
140
|
}
|
|
137
141
|
type ExpectedAdditionalData = {
|
|
138
142
|
field: string;
|