@zennify/sdk-js 1.0.0-beta.3 → 1.0.0-beta.30
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/images.js +19 -0
- package/dist/interfaces/Guild.js +2 -0
- package/dist/interfaces/Media.js +2 -0
- package/dist/interfaces/Panels.js +2 -0
- package/dist/interfaces/Products.js +2 -0
- package/dist/interfaces/Stores.js +2 -0
- package/dist/main.js +7 -0
- package/dist/utils.js +2 -4
- package/dist/var.js +4 -0
- package/package.json +3 -1
- package/src/RequestError.ts +1 -1
- package/src/errors.ts +141 -81
- package/src/images.ts +27 -0
- package/src/interfaces/Guild.ts +22 -0
- package/src/interfaces/Media.ts +6 -0
- package/src/interfaces/Panels.ts +15 -0
- package/src/interfaces/Products.ts +29 -0
- package/src/interfaces/Stores.ts +44 -0
- package/src/main.ts +9 -1
- package/src/utils.ts +6 -23
- package/src/var.ts +5 -3
- package/translations/en_US.json +109 -17
- package/translations/pt_BR.json +114 -22
- package/types/RequestError.d.ts +1 -1
- package/types/errors.d.ts +138 -1
- package/types/images.d.ts +9 -0
- package/types/interfaces/Guild.d.ts +19 -0
- package/types/interfaces/Media.d.ts +6 -0
- package/types/interfaces/Panels.d.ts +14 -0
- package/types/interfaces/Products.d.ts +28 -0
- package/types/interfaces/Stores.d.ts +27 -0
- package/types/main.d.ts +7 -0
- package/types/utils.d.ts +3 -17
- package/types/var.d.ts +3 -3
package/dist/images.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetImageURL = GetImageURL;
|
|
4
|
+
const template = `https://cdn.zennify.app/media/{store_id}/{id}.png`;
|
|
5
|
+
const sources = {
|
|
6
|
+
'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
|
|
7
|
+
'general': `https://zennify.app/assets/images/icon.png`,
|
|
8
|
+
'void': void 0,
|
|
9
|
+
'null': null,
|
|
10
|
+
'empty': ""
|
|
11
|
+
};
|
|
12
|
+
function GetImageURL(source, store_id, id) {
|
|
13
|
+
if (!store_id || !id)
|
|
14
|
+
return sources[source];
|
|
15
|
+
else
|
|
16
|
+
return template
|
|
17
|
+
.replace("{store_id}", store_id.toString())
|
|
18
|
+
.replace("{id}", id.toString());
|
|
19
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -17,3 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./var"), exports);
|
|
18
18
|
__exportStar(require("./errors"), exports);
|
|
19
19
|
__exportStar(require("./utils"), exports);
|
|
20
|
+
__exportStar(require("./RequestError"), exports);
|
|
21
|
+
__exportStar(require("./images"), exports);
|
|
22
|
+
__exportStar(require("./interfaces/Media"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/Panels"), exports);
|
|
24
|
+
__exportStar(require("./interfaces/Products"), exports);
|
|
25
|
+
__exportStar(require("./interfaces/Guild"), exports);
|
|
26
|
+
__exportStar(require("./interfaces/Stores"), exports);
|
package/dist/utils.js
CHANGED
|
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GetResponseError = GetResponseError;
|
|
4
4
|
exports.TreatZennifyResponse = TreatZennifyResponse;
|
|
5
5
|
const RequestError_1 = require("./RequestError");
|
|
6
|
-
function GetResponseError(code, additional
|
|
7
|
-
return { code, ...additional };
|
|
8
|
-
}
|
|
6
|
+
function GetResponseError(code, additional) { return { code, ...additional }; }
|
|
9
7
|
async function TreatZennifyResponse(response) {
|
|
10
|
-
const body = await response.json();
|
|
8
|
+
const body = await response.json().catch(() => ({}));
|
|
11
9
|
if (response.ok) {
|
|
12
10
|
return body;
|
|
13
11
|
}
|
package/dist/var.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZENNIFY_API_RESPONSE_LANGUAGE = void 0;
|
|
4
|
+
exports.SetAPIResponseLanguage = SetAPIResponseLanguage;
|
|
4
5
|
exports.ZENNIFY_API_RESPONSE_LANGUAGE = 'en_US';
|
|
6
|
+
function SetAPIResponseLanguage(lang) {
|
|
7
|
+
return exports.ZENNIFY_API_RESPONSE_LANGUAGE = lang;
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zennify/sdk-js",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.30",
|
|
4
4
|
"description": "A simple package to work with https://api.zennify.app",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
"repository": {
|
|
13
13
|
"url": "git+https://github.com/zennify-ofc/sdk-js.git"
|
|
14
14
|
},
|
|
15
|
+
"types": "./types/main.d.ts",
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/node": "^20.12.12",
|
|
18
|
+
"discord.js": "^14.15.3",
|
|
17
19
|
"typescript": "^5.5.3"
|
|
18
20
|
},
|
|
19
21
|
"scripts": {
|
package/src/RequestError.ts
CHANGED
package/src/errors.ts
CHANGED
|
@@ -1,97 +1,157 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface APIErrors {
|
|
2
2
|
// = general errors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
'UNKNOWN_ERROR': {
|
|
4
|
+
id: string | number
|
|
5
|
+
};
|
|
6
|
+
'UNKNOWN_TRANSLATION': {
|
|
7
|
+
code: keyof APIErrors | string
|
|
8
|
+
};
|
|
9
|
+
'INVALID_DISCORD_CHANNEL_FOR_MESSAGE': {}
|
|
10
|
+
'MISSING_PERMISSIONS': {};
|
|
11
|
+
'METHOD_NOT_ALLOWED': {};
|
|
12
|
+
'EXPECTED_AN_OBJECT_ARRAY': ExpectedAdditionalData;
|
|
13
|
+
'EXPECTED_A_STRING_ARRAY': ExpectedAdditionalData;
|
|
14
|
+
'EXPECTED_A_NUMBER_ARRAY': ExpectedAdditionalData;
|
|
15
|
+
'EXPECTED_AN_OBJECT': ExpectedAdditionalData;
|
|
16
|
+
'EXPECTED_A_NON_EMPTY_OBJECT': ExpectedAdditionalData;
|
|
17
|
+
'EXPECTED_A_STRING': ExpectedAdditionalData;
|
|
18
|
+
'EXPECTED_A_NUMBER': ExpectedAdditionalData;
|
|
19
|
+
'EXPECTED_A_VALID_ID': ExpectedAdditionalData;
|
|
20
|
+
'DUPLICATED_VALUES_ISNT_ALLOWED': {};
|
|
15
21
|
// = oAuth errors
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
'GRANT_CODE_MISSING_IN_QUERY': {};
|
|
23
|
+
'INVALID_SCOPE': {};
|
|
24
|
+
'VERIFY_YOUR_EMAIL': {};
|
|
25
|
+
'PLEASE_REVERIFY': {};
|
|
20
26
|
// = user errors
|
|
21
|
-
|
|
27
|
+
'USER_NOT_FOUND': {};
|
|
22
28
|
/// password errors
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
'INVALID_PASSWORD': {};
|
|
30
|
+
'YOU_MUST_INSERT_THE_ACTUAL_PASSWORD': {};
|
|
31
|
+
'THE_PASSWORD_DOES_NOT_MATCH': {};
|
|
32
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_8_CHARACTERS': {};
|
|
33
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_NUMBER': {};
|
|
34
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_LETTER': {};
|
|
35
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER': {};
|
|
30
36
|
/// pix key errors
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
'THE_EMAIL_SENDED_ISNT_VALID': {};
|
|
38
|
+
'CELLPHONE_NUMBERS_MUST_HAVE_THE_9_DIGIT': {};
|
|
39
|
+
'THE_CELLPHONE_NUMBER_MUST_HAVE_ONLY_DIGITS': {};
|
|
40
|
+
'THE_PIX_KEY_INSERTED_ISNT_VALID': {};
|
|
35
41
|
/// webhook url error
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
'INSERT_A_VALID_URL': {};
|
|
43
|
+
'THE_ONLY_ACCEPTED_PROTOCOL_IS_HTTPS': {};
|
|
44
|
+
'THIS_DOMAIN_IS_BLACKLISTED': {};
|
|
45
|
+
'THE_URL_EXTENSION_ISNT_ACCEPTED_YET': {};
|
|
46
|
+
'THE_URL_IS_INACCESSIBLE_BY_THE_WEBHOOK_SERVER': {};
|
|
47
|
+
'THE_URL_WOULD_NOT_HAVE_REDIRECTS': {};
|
|
48
|
+
'THE_URL_HAS_TIMEOUT_5S': {};
|
|
43
49
|
/// payment errors
|
|
44
|
-
|
|
50
|
+
'INVALID_PAYMENT_METHOD': {};
|
|
45
51
|
// Order Errors
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
'YOU_NEED_TO_INSERT_AT_LEAST_1_ITEM': {};
|
|
53
|
+
'ONE_PROVIDED_PRODUCT_IS_OUT_OF_STOCK': {
|
|
54
|
+
name: string
|
|
55
|
+
};
|
|
56
|
+
'WE_DONT_HAVE_THIS_AMOUNT_IN_STOCK': {
|
|
57
|
+
name: string,
|
|
58
|
+
received: string | number,
|
|
59
|
+
available: string | number
|
|
60
|
+
};
|
|
61
|
+
'THIS_SELLER_WAS_BANNED_FROM_ZENNIFY': {};
|
|
62
|
+
'WE_DO_NOT_YET_SUPPORT_MULTIPLE_USER_PRODUCTS': {
|
|
63
|
+
name: string,
|
|
64
|
+
id: string | number
|
|
65
|
+
};
|
|
66
|
+
'WE_DO_NOT_YET_SUPPORT_MULTIPLE_STORE_PRODUCTS': {
|
|
67
|
+
name: string
|
|
68
|
+
id: string | number
|
|
69
|
+
};
|
|
70
|
+
'YOU_ALREADY_HAVE_ANOTHER_ORDER_WAITING_PAYMENT': {
|
|
71
|
+
id: string | number
|
|
72
|
+
};
|
|
73
|
+
'YOU_INSERTED_AN_INVALID_ADDITIONAL': {
|
|
74
|
+
addon: string
|
|
75
|
+
};
|
|
76
|
+
'UNKNOWN_ORDER': {}
|
|
77
|
+
'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {}
|
|
78
|
+
'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {}
|
|
54
79
|
/// bad preference configuration
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
80
|
+
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
|
|
81
|
+
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
|
|
82
|
+
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO': {};
|
|
58
83
|
/// coupons
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
'THIS_COUPON_DOES_NOT_EXISTS': {
|
|
85
|
+
received: string
|
|
86
|
+
};
|
|
87
|
+
'THIS_COUPON_HAS_EXPIRED': {};
|
|
88
|
+
'THIS_COUPON_REACHED_THE_USE_LIMIT': {};
|
|
89
|
+
'SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE': {
|
|
90
|
+
formated_value: string,
|
|
91
|
+
value: number
|
|
92
|
+
};
|
|
93
|
+
'THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY': {};
|
|
64
94
|
// store errors
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
'UNKNOWN_STORE': {};
|
|
96
|
+
'UNKNOWN_BANK': {
|
|
97
|
+
received: string
|
|
98
|
+
};
|
|
99
|
+
'INVALID_STORE_NAME': {};
|
|
100
|
+
/// AUTOROLE
|
|
101
|
+
'UNKNOWN_AUTOROLE_RULE': {},
|
|
102
|
+
'AUTOROLE_RULE_ALREADY_EXISTS': {};
|
|
103
|
+
'YOU_REACHED_THE_AUTOROLE_RULE_LIMIT': {}
|
|
104
|
+
/// bot errors
|
|
105
|
+
'WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT': {};
|
|
106
|
+
'INVALID_DISCORD_BOT_TOKEN': {};
|
|
107
|
+
'DISABLE_REQUIRE_CODE_GRANT': {};
|
|
108
|
+
'UNKNOWN_DISCORD_CHANNEL': {};
|
|
68
109
|
// product errors
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
110
|
+
'UNKNOWN_PRODUCT': {};
|
|
111
|
+
'INVALID_PRODUCT_NAME': {};
|
|
112
|
+
'INVALID_PRODUCT_VALUE': {};
|
|
113
|
+
'YOU_REACHED_THE_PRODUCT_LIMIT': {};
|
|
114
|
+
'PRODUCT_NAME_ALREADY_EXIST': {};
|
|
74
115
|
/// Description errors
|
|
75
|
-
|
|
116
|
+
'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD': {};
|
|
76
117
|
/// Stock errors
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
118
|
+
'UNKNOWN_STOCK': {};
|
|
119
|
+
'INVALID_STOCK_CONTENT': {};
|
|
120
|
+
'INVALID_STOCK_COST': {};
|
|
121
|
+
// coupon errors
|
|
122
|
+
'UNKNOWN_COUPON': {},
|
|
123
|
+
'INVALID_COUPON_NAME': {},
|
|
124
|
+
'INVALID_COUPON_TYPE': {},
|
|
125
|
+
'INVALID_COUPON_VALUE': {},
|
|
126
|
+
'INVALID_COUPON_AMOUNT': {},
|
|
127
|
+
'INVALID_COUPON_MIN_VALUE': {},
|
|
128
|
+
'INVALID_COUPON_EXPIRATION': {},
|
|
129
|
+
'INVALID_COUPON_MAX_USES_PER_USER': {}
|
|
130
|
+
'INVALID_COUPON_ONLY_FIRST_BUY': {},
|
|
131
|
+
'YOU_REACHED_THE_COUPON_LIMIT': {},
|
|
132
|
+
'COUPON_NAME_ALREADY_EXIST': {}
|
|
80
133
|
// Media Errors
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
134
|
+
'UNKNOWN_FILE': {};
|
|
135
|
+
'NO_FILES_FOUND': {};
|
|
136
|
+
'INVALID_FILE_TYPE': {};
|
|
137
|
+
'INVALID_FILE_NAME': {};
|
|
138
|
+
'INVALID_FILE_SIZE': {};
|
|
139
|
+
'YOU_REACHED_STORAGE_LIMIT': {};
|
|
140
|
+
'YOU_REACHED_MEDIA_LIMIT': {};
|
|
141
|
+
'YOU_ALREADY_HAVE_THIS_MEDIA': {};
|
|
142
|
+
'MEDIA_NAME_ALREADY_EXIST': {};
|
|
90
143
|
// Discord Panels Errors
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
144
|
+
'UNKNOWN_PANEL': {};
|
|
145
|
+
'INVALID_PANEL_NAME': {};
|
|
146
|
+
'INVALID_PANEL_DESCRIPTION': {};
|
|
147
|
+
'INVALID_PANEL_PLACEHOLDER': {};
|
|
148
|
+
'YOU_REACHED_PANEL_LIMIT': {};
|
|
149
|
+
'PANEL_NAME_ALREADY_EXIST': {};
|
|
150
|
+
'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
type ExpectedAdditionalData = {
|
|
154
|
+
field: string;
|
|
155
|
+
received: any;
|
|
156
|
+
type: string
|
|
157
|
+
}
|
package/src/images.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ImageSources {
|
|
2
|
+
void: void,
|
|
3
|
+
null: null,
|
|
4
|
+
empty: string,
|
|
5
|
+
product_icon: string,
|
|
6
|
+
general: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const template = `https://cdn.zennify.app/media/{store_id}/{id}.png`
|
|
10
|
+
const sources: Record<keyof ImageSources, ImageSources[keyof ImageSources]> = {
|
|
11
|
+
'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
|
|
12
|
+
'general': `https://zennify.app/assets/images/icon.png`,
|
|
13
|
+
'void': void 0,
|
|
14
|
+
'null': null,
|
|
15
|
+
'empty': ""
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function GetImageURL<Source extends keyof ImageSources>(
|
|
19
|
+
source: Source,
|
|
20
|
+
store_id?: number | null,
|
|
21
|
+
id?: number | null
|
|
22
|
+
): ImageSources[Source] | string {
|
|
23
|
+
if (!store_id || !id) return sources[source] as ImageSources[Source];
|
|
24
|
+
else return template
|
|
25
|
+
.replace("{store_id}", store_id.toString())
|
|
26
|
+
.replace("{id}", id.toString());
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ChannelType } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
export interface DiscordGuildChannel {
|
|
4
|
+
id: string,
|
|
5
|
+
name: string,
|
|
6
|
+
type: ChannelType
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface DiscordGuildRole {
|
|
10
|
+
id: string,
|
|
11
|
+
name: string,
|
|
12
|
+
position: number,
|
|
13
|
+
color: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DiscordGuild {
|
|
17
|
+
id: string,
|
|
18
|
+
name: string,
|
|
19
|
+
icon_url: string,
|
|
20
|
+
owner_id: string,
|
|
21
|
+
channels: DiscordGuildChannel[]
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PanelProduct {
|
|
2
|
+
id: number,
|
|
3
|
+
position: number,
|
|
4
|
+
emoji: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface Panel {
|
|
8
|
+
id: number,
|
|
9
|
+
name: string,
|
|
10
|
+
placeholder: string,
|
|
11
|
+
description: string | null,
|
|
12
|
+
icon_id: number | null,
|
|
13
|
+
banner_id: number | null,
|
|
14
|
+
products: PanelProduct[]
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface PartialProduct {
|
|
2
|
+
id: number,
|
|
3
|
+
name: string,
|
|
4
|
+
value: number,
|
|
5
|
+
icon_id: number | null,
|
|
6
|
+
banner_id: number | null,
|
|
7
|
+
stock_locked: boolean | null,
|
|
8
|
+
stock_count: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Product {
|
|
12
|
+
id: number,
|
|
13
|
+
name: string,
|
|
14
|
+
created_at: string,
|
|
15
|
+
store_id: number,
|
|
16
|
+
owner_id: number,
|
|
17
|
+
icon_id?: null | number,
|
|
18
|
+
banner_id?: null | number,
|
|
19
|
+
value: number,
|
|
20
|
+
description: {
|
|
21
|
+
short: null | string,
|
|
22
|
+
discord: null | string,
|
|
23
|
+
website: null | string
|
|
24
|
+
},
|
|
25
|
+
stock: {
|
|
26
|
+
size: number,
|
|
27
|
+
locked: boolean
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DiscordGuild } from "./Guild";
|
|
2
|
+
|
|
3
|
+
export type Addons = 'custom_bot' | 'divulgation' | 'antiraid' | 'managed_automod';
|
|
4
|
+
export type Banks = 'Banco Inter S.A.'
|
|
5
|
+
| 'Nu Pagamentos S.A.'
|
|
6
|
+
| 'Picpay Serviços S.A.'
|
|
7
|
+
| 'Mercadopago.com Representações Ltda.'
|
|
8
|
+
| 'Caixa Econômica Federal'
|
|
9
|
+
| 'PagSeguro Internet S.A.'
|
|
10
|
+
| 'Banco do Brasil S.A.'
|
|
11
|
+
| 'Banco Bradesco S.A.'
|
|
12
|
+
| 'Banco Santander (Brasil) S.A.';
|
|
13
|
+
|
|
14
|
+
export interface PartialStore {
|
|
15
|
+
id: number,
|
|
16
|
+
name: string,
|
|
17
|
+
expires_at: string,
|
|
18
|
+
icon_id?: number | null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface FullStore {
|
|
22
|
+
id: number,
|
|
23
|
+
name: string,
|
|
24
|
+
created_at: string,
|
|
25
|
+
expires_at: string,
|
|
26
|
+
owner_id: number,
|
|
27
|
+
icon_id: number | null,
|
|
28
|
+
banner_id: number | null,
|
|
29
|
+
addons: Addons[],
|
|
30
|
+
blocked_banks: Banks[],
|
|
31
|
+
discord_channels: Record<
|
|
32
|
+
string /** guild id */,
|
|
33
|
+
Record<
|
|
34
|
+
'sale' | 'voice' | 'feedback' | 'carts',
|
|
35
|
+
string | null | void /** channel id */
|
|
36
|
+
>
|
|
37
|
+
>,
|
|
38
|
+
discord_bot: {
|
|
39
|
+
id: string,
|
|
40
|
+
app_id: string | null,
|
|
41
|
+
token: string | null
|
|
42
|
+
},
|
|
43
|
+
discord_bot_guilds: Record<string, DiscordGuild>
|
|
44
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export * from './var';
|
|
2
2
|
export * from './errors';
|
|
3
|
-
export * from './utils';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export * from './RequestError';
|
|
5
|
+
export * from './images'
|
|
6
|
+
|
|
7
|
+
export * from './interfaces/Media';
|
|
8
|
+
export * from './interfaces/Panels';
|
|
9
|
+
export * from './interfaces/Products';
|
|
10
|
+
export * from './interfaces/Guild';
|
|
11
|
+
export * from './interfaces/Stores';
|
package/src/utils.ts
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
import { ZennifyAPIRequestError } from './RequestError';
|
|
2
2
|
import { APIErrors } from './errors';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
APIErrors
|
|
7
|
-
|
|
8
|
-
| 'EXPECTED_A_STRING_ARRAY'
|
|
9
|
-
| 'EXPECTED_A_NUMBER_ARRAY'
|
|
10
|
-
| 'EXPECTED_AN_OBJECT'
|
|
11
|
-
| 'EXPECTED_A_NON_EMPTY_OBJECT'
|
|
12
|
-
| 'EXPECTED_A_STRING'
|
|
13
|
-
| 'EXPECTED_A_NUMBER'
|
|
14
|
-
| 'EXPECTED_A_VALID_ID'
|
|
15
|
-
>;
|
|
16
|
-
|
|
17
|
-
type CommonError = Exclude<APIErrors, ExpectedError>;
|
|
18
|
-
|
|
19
|
-
export function GetResponseError(code: CommonError): { code: CommonError };
|
|
20
|
-
export function GetResponseError(code: ExpectedError, additional: ExpectedErrorAdditional): { code: ExpectedError } & ExpectedErrorAdditional;
|
|
21
|
-
export function GetResponseError<T extends object>(code: CommonError, additional?: T): { code: CommonError } & T;
|
|
22
|
-
export function GetResponseError(code: APIErrors, additional: any = {}) {
|
|
23
|
-
return { code, ...additional };
|
|
24
|
-
}
|
|
4
|
+
export function GetResponseError<Code extends keyof APIErrors>(
|
|
5
|
+
code: Code,
|
|
6
|
+
additional: APIErrors[Code]
|
|
7
|
+
) { return { code, ...additional }; }
|
|
25
8
|
|
|
26
9
|
export async function TreatZennifyResponse<T extends any>(response: Response): Promise<T> {
|
|
27
10
|
|
|
28
|
-
const body = await response.json();
|
|
11
|
+
const body = await response.json().catch(() => ({}));
|
|
29
12
|
|
|
30
13
|
if (response.ok) {
|
|
31
14
|
return body as T;
|
|
@@ -33,4 +16,4 @@ export async function TreatZennifyResponse<T extends any>(response: Response): P
|
|
|
33
16
|
|
|
34
17
|
throw new ZennifyAPIRequestError(response, body);
|
|
35
18
|
|
|
36
|
-
}
|
|
19
|
+
}
|
package/src/var.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
export type SupportedLanguages = 'pt_BR' | 'en_US';
|
|
2
|
+
export let ZENNIFY_API_RESPONSE_LANGUAGE: SupportedLanguages = 'en_US';
|
|
3
|
+
export function SetAPIResponseLanguage(lang: SupportedLanguages) {
|
|
4
|
+
return ZENNIFY_API_RESPONSE_LANGUAGE = lang;
|
|
5
|
+
}
|