@sonoransoftware/sonoran.js 1.0.26 → 1.0.28
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/constants.d.ts +5 -0
- package/dist/libs/rest/src/lib/REST.js +10 -0
- package/dist/libs/rest/src/lib/handlers/SequentialHandler.js +6 -1
- package/dist/libs/rest/src/lib/utils/constants.d.ts +9 -1
- package/dist/libs/rest/src/lib/utils/constants.js +6 -0
- package/dist/managers/CMSManager.d.ts +12 -0
- package/dist/managers/CMSManager.js +28 -0
- package/package.json +1 -1
- package/readme.md +127 -1
- package/src/constants.ts +6 -0
- package/src/libs/rest/src/lib/REST.ts +10 -0
- package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +6 -2
- package/src/libs/rest/src/lib/utils/constants.ts +15 -1
- package/src/managers/CMSManager.ts +26 -0
package/dist/constants.d.ts
CHANGED
|
@@ -174,6 +174,16 @@ class REST extends events_1.EventEmitter {
|
|
|
174
174
|
profileFields: args[5]
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
+
case 'SET_ACCOUNT_NAME': {
|
|
178
|
+
return {
|
|
179
|
+
apiId: args[0],
|
|
180
|
+
username: args[1],
|
|
181
|
+
accId: args[2],
|
|
182
|
+
discordId: args[3],
|
|
183
|
+
uniqueId: args[4],
|
|
184
|
+
newName: args[5]
|
|
185
|
+
};
|
|
186
|
+
}
|
|
177
187
|
default: {
|
|
178
188
|
return args;
|
|
179
189
|
}
|
|
@@ -113,7 +113,12 @@ class SequentialHandler {
|
|
|
113
113
|
return parsedRes;
|
|
114
114
|
}
|
|
115
115
|
else if (res.status === 400 || res.status === 401 || res.status === 404) {
|
|
116
|
-
|
|
116
|
+
if (typeof parsedRes === 'object' && !(parsedRes === null || parsedRes === void 0 ? void 0 : parsedRes.authorized)) {
|
|
117
|
+
return parsedRes;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new errors_1.APIError(parsedRes, data.type, data.fullUrl, res.status, data);
|
|
121
|
+
}
|
|
117
122
|
}
|
|
118
123
|
else if (res.status === 429) {
|
|
119
124
|
const timeout = setTimeout(() => {
|
|
@@ -35,7 +35,7 @@ export declare const EventsCMSAPITypes: APITypeData[];
|
|
|
35
35
|
export declare const FormsCMSAPITypes: APITypeData[];
|
|
36
36
|
export declare const CommunitiesCMSAPITypes: APITypeData[];
|
|
37
37
|
export declare const AllAPITypes: AllAPITypeData[];
|
|
38
|
-
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS';
|
|
38
|
+
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME';
|
|
39
39
|
export interface CMSServerAPIStruct {
|
|
40
40
|
id: number;
|
|
41
41
|
name: string;
|
|
@@ -424,6 +424,14 @@ export interface RESTTypedAPIDataStructs {
|
|
|
424
424
|
discord?: string,
|
|
425
425
|
uniqueId?: string
|
|
426
426
|
];
|
|
427
|
+
SET_ACCOUNT_NAME: [
|
|
428
|
+
apiId: string | undefined,
|
|
429
|
+
username: string | undefined,
|
|
430
|
+
accId: string | undefined,
|
|
431
|
+
discordId: string | undefined,
|
|
432
|
+
uniqueId: string | undefined,
|
|
433
|
+
newName: string
|
|
434
|
+
];
|
|
427
435
|
GET_GAME_SERVERS: [];
|
|
428
436
|
VERIFY_WHITELIST: [
|
|
429
437
|
apiId: string | undefined,
|
|
@@ -369,6 +369,12 @@ exports.GeneralCMSAPITypes = [
|
|
|
369
369
|
path: 'general/edit_acc_profile_fields',
|
|
370
370
|
method: 'POST',
|
|
371
371
|
minVersion: 0
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
type: 'SET_ACCOUNT_NAME',
|
|
375
|
+
path: 'general/set_account_name',
|
|
376
|
+
method: 'POST',
|
|
377
|
+
minVersion: 0
|
|
372
378
|
}
|
|
373
379
|
];
|
|
374
380
|
exports.ServersCMSAPITypes = [
|
|
@@ -107,4 +107,16 @@ export declare class CMSManager extends BaseManager {
|
|
|
107
107
|
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
108
108
|
*/
|
|
109
109
|
setAccountRanks(changes: globalTypes.CMSSetAccountRanksChangesObject, apiId?: string, accId?: string, username?: string, discord?: string, uniqueId?: string): Promise<globalTypes.CMSSetAccountRanksPromiseResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Sets a community account's name for the CMS community.
|
|
112
|
+
* @param {Object} data The object that contains critical data to set an account's name.
|
|
113
|
+
* @param {string} [data.apiId] (Optional) The api id to set the account name.
|
|
114
|
+
* @param {string} [data.username] (Optional) The username to set the account name.
|
|
115
|
+
* @param {string} [data.accId] (Optional) The account id to set the account name.
|
|
116
|
+
* @param {string} [data.discordId] (Optional) The discord id to set the account name.
|
|
117
|
+
* @param {string} [data.uniqueId] (Optional) The unique id to set the account name.
|
|
118
|
+
* @param {string} [data.newName] (Optional) The new name to set the account name.
|
|
119
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
120
|
+
*/
|
|
121
|
+
setAccountName(apiId: string | undefined, username: string | undefined, accId: string | undefined, discordId: string | undefined, uniqueId: string | undefined, newName: string): Promise<globalTypes.CMSSetAccountNamePromiseResult>;
|
|
110
122
|
}
|
|
@@ -264,5 +264,33 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
264
264
|
}
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Sets a community account's name for the CMS community.
|
|
269
|
+
* @param {Object} data The object that contains critical data to set an account's name.
|
|
270
|
+
* @param {string} [data.apiId] (Optional) The api id to set the account name.
|
|
271
|
+
* @param {string} [data.username] (Optional) The username to set the account name.
|
|
272
|
+
* @param {string} [data.accId] (Optional) The account id to set the account name.
|
|
273
|
+
* @param {string} [data.discordId] (Optional) The discord id to set the account name.
|
|
274
|
+
* @param {string} [data.uniqueId] (Optional) The unique id to set the account name.
|
|
275
|
+
* @param {string} [data.newName] (Optional) The new name to set the account name.
|
|
276
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
277
|
+
*/
|
|
278
|
+
async setAccountName(apiId, username, accId, discordId, uniqueId, newName) {
|
|
279
|
+
return new Promise(async (resolve, reject) => {
|
|
280
|
+
var _a;
|
|
281
|
+
try {
|
|
282
|
+
const setAccountNameRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('SET_ACCOUNT_NAME', apiId, username, accId, discordId, uniqueId, newName));
|
|
283
|
+
resolve({ success: true, data: setAccountNameRequest });
|
|
284
|
+
}
|
|
285
|
+
catch (err) {
|
|
286
|
+
if (err instanceof src_1.APIError) {
|
|
287
|
+
resolve({ success: false, reason: err.response });
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
reject(err);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
267
295
|
}
|
|
268
296
|
exports.CMSManager = CMSManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonoransoftware/sonoran.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/readme.md
CHANGED
|
@@ -50,5 +50,131 @@ instance.cms.verifyWhitelist({
|
|
|
50
50
|
});
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
## CAD Functions
|
|
54
|
+
### getAccount
|
|
55
|
+
Returns the user's account object.
|
|
56
|
+
#### Argument `params`
|
|
57
|
+
##### Type: `object` `{apiId?, username?}`
|
|
58
|
+
```js
|
|
59
|
+
const params = {
|
|
60
|
+
apiId: '',
|
|
61
|
+
username: 'SomeUser',
|
|
62
|
+
};
|
|
63
|
+
// Get user account object
|
|
64
|
+
const account = await instance.cad.getAccount(params);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## CMS Functions
|
|
68
|
+
### verifyWhitelist(obj)
|
|
69
|
+
Verifies that a user is whitelisted in the specified server.
|
|
70
|
+
#### Arugment `params`
|
|
71
|
+
##### Type `object` `{accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: number, serverId?: number}`
|
|
72
|
+
##### Type `string` (Account UUID or API ID as a string)
|
|
73
|
+
*Note: If passing a `string` for data (Account UUID or API ID) the `serverId` will default to `1`*
|
|
74
|
+
```js
|
|
75
|
+
const params = {
|
|
76
|
+
accId: '',
|
|
77
|
+
apiId: '',
|
|
78
|
+
username: '',
|
|
79
|
+
discord: '',
|
|
80
|
+
uniqueId: 1234,
|
|
81
|
+
serverId: 1
|
|
82
|
+
};
|
|
83
|
+
// Check if user with Unique ID 1234 is whitelisted on Server ID 1
|
|
84
|
+
const isWhitelisted = await instance.cms.verifyWhitelist(params);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### getFullWhitelist()
|
|
88
|
+
Returns a full list of whitelisted users in the specified server.
|
|
89
|
+
#### Arugment `serverId`
|
|
90
|
+
##### Type `number` `1`
|
|
91
|
+
```js
|
|
92
|
+
// Get the full whitelist for server ID 1
|
|
93
|
+
const fullWhitelist = await instance.cms.getFullWhitelist(1);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### getComAccount(obj)
|
|
97
|
+
Returns the user's account object
|
|
98
|
+
#### Arugment `params`
|
|
99
|
+
##### Type `object` `{accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: string}`
|
|
100
|
+
```js
|
|
101
|
+
const params = {
|
|
102
|
+
accId: '',
|
|
103
|
+
apiId: '',
|
|
104
|
+
username: '',
|
|
105
|
+
discord: '',
|
|
106
|
+
uniqueId: '1234',
|
|
107
|
+
};
|
|
108
|
+
// Get a user's account as an object
|
|
109
|
+
const getAccount = await instance.cms.getComAccount(params);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### getAccountRanks(obj)
|
|
113
|
+
Returns a user account's ranks
|
|
114
|
+
#### Arugment `params`
|
|
115
|
+
##### Type `object` `{accId?: string, apiId?: string, username?: string, discord?: string, uniqueId?: string}`
|
|
116
|
+
```js
|
|
117
|
+
const params = {
|
|
118
|
+
accId: '',
|
|
119
|
+
apiId: '',
|
|
120
|
+
username: '',
|
|
121
|
+
discord: '',
|
|
122
|
+
uniqueId: '1234',
|
|
123
|
+
};
|
|
124
|
+
// Get a user's ranks
|
|
125
|
+
const getRanks = await instance.cms.getAccountRanks(params);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### clockInOut(obj)
|
|
129
|
+
Clock a user in or out in the CMS system
|
|
130
|
+
#### Arugment `obj`
|
|
131
|
+
##### Type `object` `{accId?: string, apiId?: string, forceClockIn?: boolean, discord?: string, uniqueId?: string}`
|
|
132
|
+
```js
|
|
133
|
+
const params = {
|
|
134
|
+
accId: '',
|
|
135
|
+
apiId: '',
|
|
136
|
+
forceClockIn: true,
|
|
137
|
+
discord: '',
|
|
138
|
+
uniqueId: '1234',
|
|
139
|
+
};
|
|
140
|
+
// Clocks a user in or out
|
|
141
|
+
const clock = await instance.cms.clockInOut(params);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### checkComApiId(apiId)
|
|
145
|
+
Checks if a given API ID is attatched to any account within the community, and if true, returns the username of the associated account.
|
|
146
|
+
#### Arugment `apiId`
|
|
147
|
+
##### Type `string` `1234`
|
|
148
|
+
```js
|
|
149
|
+
// Checks if API ID is attatched to a user, returns username if true
|
|
150
|
+
const apiIdUsername = await instance.cms.checkComApiId('1234');
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### getDepartments()
|
|
154
|
+
Gets all department information for a CMS community
|
|
155
|
+
```js
|
|
156
|
+
// Gets department information for community
|
|
157
|
+
const getDepts = await instance.cms.getDepartments();
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### setAccountRanks(obj, apiId, accId, username, discord, uniqueId)
|
|
161
|
+
Gets all department information for a CMS community
|
|
162
|
+
#### Arugment `params`
|
|
163
|
+
##### Type `object` `{set?: string[]; add?: string[]; remove?: string[]}`
|
|
164
|
+
#### Arguments `apiId`, `accId`, `username`, `discord`, `uniqueId`
|
|
165
|
+
##### Type `string` or `undefined`
|
|
166
|
+
*Note: Only one identifier is required (Discord, accID, etc.) pass in undefined for variables you are not searching by*
|
|
167
|
+
```js
|
|
168
|
+
const params = {
|
|
169
|
+
set: ['9ad00ded-93d1-422e-8470-d2515f02652c'],
|
|
170
|
+
add: undefined,
|
|
171
|
+
remove: undefined
|
|
172
|
+
};
|
|
173
|
+
// Wipe users existing ranks, and set ones provided
|
|
174
|
+
// Add and Remove are undefined as we don't want to call them here
|
|
175
|
+
// Sets account ranks by the discord ID parameter
|
|
176
|
+
const setRanks = await instance.cms.setAccountRanks(params, undefined, undefined, undefined, '12345678', undefined);
|
|
177
|
+
```
|
|
178
|
+
|
|
53
179
|
## Further Documentation
|
|
54
|
-
More documentation for Sonoran CAD specific methods and usage can be found [here](/docs/CAD-Methods-and-Usage.md), Sonoran CMS specific methods and usage can be found [here](/docs/CMS-Methods-and-Usage.md), and usage information for the REST class [here](/docs/REST-Methods-and-Usage.md).
|
|
180
|
+
More documentation for Sonoran CAD specific methods and usage can be found [here](/docs/CAD-Methods-and-Usage.md), Sonoran CMS specific methods and usage can be found [here](/docs/CMS-Methods-and-Usage.md), and usage information for the REST class [here](/docs/REST-Methods-and-Usage.md).
|
package/src/constants.ts
CHANGED
|
@@ -280,6 +280,16 @@ export class REST extends EventEmitter {
|
|
|
280
280
|
profileFields: args[5]
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
+
case 'SET_ACCOUNT_NAME': {
|
|
284
|
+
return {
|
|
285
|
+
apiId: args[0],
|
|
286
|
+
username: args[1],
|
|
287
|
+
accId: args[2],
|
|
288
|
+
discordId: args[3],
|
|
289
|
+
uniqueId: args[4],
|
|
290
|
+
newName: args[5]
|
|
291
|
+
}
|
|
292
|
+
}
|
|
283
293
|
default: {
|
|
284
294
|
return args;
|
|
285
295
|
}
|
|
@@ -134,7 +134,11 @@ export class SequentialHandler implements IHandler {
|
|
|
134
134
|
if (res.ok) {
|
|
135
135
|
return parsedRes;
|
|
136
136
|
} else if (res.status === 400 || res.status === 401 || res.status === 404) {
|
|
137
|
-
|
|
137
|
+
if (typeof parsedRes === 'object' && !(parsedRes as any)?.authorized) {
|
|
138
|
+
return parsedRes;
|
|
139
|
+
} else {
|
|
140
|
+
throw new APIError(parsedRes as string, data.type, data.fullUrl, res.status, data);
|
|
141
|
+
}
|
|
138
142
|
} else if (res.status === 429) {
|
|
139
143
|
const timeout = setTimeout(() => {
|
|
140
144
|
this.manager.removeRateLimit(data.requestTypeId);
|
|
@@ -155,7 +159,7 @@ export class SequentialHandler implements IHandler {
|
|
|
155
159
|
if (res.headers.get('Content-Type')?.startsWith('application/json')) {
|
|
156
160
|
return res.json();
|
|
157
161
|
}
|
|
158
|
-
|
|
162
|
+
|
|
159
163
|
return res.text();
|
|
160
164
|
}
|
|
161
165
|
}
|
|
@@ -400,6 +400,12 @@ export const GeneralCMSAPITypes: APITypeData[] = [
|
|
|
400
400
|
path: 'general/edit_acc_profile_fields',
|
|
401
401
|
method: 'POST',
|
|
402
402
|
minVersion: 0
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
type: 'SET_ACCOUNT_NAME',
|
|
406
|
+
path: 'general/set_account_name',
|
|
407
|
+
method: 'POST',
|
|
408
|
+
minVersion: 0
|
|
403
409
|
}
|
|
404
410
|
];
|
|
405
411
|
|
|
@@ -462,7 +468,7 @@ function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeDa
|
|
|
462
468
|
|
|
463
469
|
export const AllAPITypes: AllAPITypeData[] = [ ...formatForAll(GeneralCADAPITypes, productEnums.CAD), ...formatForAll(CivilianCADAPITypes, productEnums.CAD), ...formatForAll(EmergencyCADAPITypes, productEnums.CAD), ...formatForAll(GeneralCMSAPITypes, productEnums.CMS), ...formatForAll(ServersCMSAPITypes, productEnums.CMS), ...formatForAll(EventsCMSAPITypes, productEnums.CMS), ...formatForAll(FormsCMSAPITypes, productEnums.CMS), ...formatForAll(CommunitiesCMSAPITypes, productEnums.CMS) ];
|
|
464
470
|
|
|
465
|
-
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS';
|
|
471
|
+
export type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE' | 'KICK_ACCOUNT' | 'BAN_ACCOUNT' | 'LOOKUP' | 'EDIT_ACC_PROFLIE_FIELDS' | 'SET_ACCOUNT_NAME';
|
|
466
472
|
|
|
467
473
|
export interface CMSServerAPIStruct {
|
|
468
474
|
id: number;
|
|
@@ -886,6 +892,14 @@ export interface RESTTypedAPIDataStructs {
|
|
|
886
892
|
discord?: string,
|
|
887
893
|
uniqueId?: string,
|
|
888
894
|
],
|
|
895
|
+
SET_ACCOUNT_NAME: [
|
|
896
|
+
apiId: string | undefined,
|
|
897
|
+
username: string | undefined,
|
|
898
|
+
accId: string | undefined,
|
|
899
|
+
discordId: string | undefined,
|
|
900
|
+
uniqueId: string | undefined,
|
|
901
|
+
newName: string,
|
|
902
|
+
],
|
|
889
903
|
// CMS - Servers
|
|
890
904
|
GET_GAME_SERVERS: [];
|
|
891
905
|
VERIFY_WHITELIST: [
|
|
@@ -226,4 +226,30 @@ export class CMSManager extends BaseManager {
|
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Sets a community account's name for the CMS community.
|
|
232
|
+
* @param {Object} data The object that contains critical data to set an account's name.
|
|
233
|
+
* @param {string} [data.apiId] (Optional) The api id to set the account name.
|
|
234
|
+
* @param {string} [data.username] (Optional) The username to set the account name.
|
|
235
|
+
* @param {string} [data.accId] (Optional) The account id to set the account name.
|
|
236
|
+
* @param {string} [data.discordId] (Optional) The discord id to set the account name.
|
|
237
|
+
* @param {string} [data.uniqueId] (Optional) The unique id to set the account name.
|
|
238
|
+
* @param {string} [data.newName] (Optional) The new name to set the account name.
|
|
239
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
240
|
+
*/
|
|
241
|
+
public async setAccountName(apiId: string | undefined, username: string | undefined, accId: string | undefined, discordId: string | undefined, uniqueId: string | undefined, newName: string ): Promise<globalTypes.CMSSetAccountNamePromiseResult> {
|
|
242
|
+
return new Promise(async (resolve, reject) => {
|
|
243
|
+
try {
|
|
244
|
+
const setAccountNameRequest: any = await this.rest?.request('SET_ACCOUNT_NAME', apiId, username, accId, discordId, uniqueId, newName);
|
|
245
|
+
resolve({ success: true, data: setAccountNameRequest });
|
|
246
|
+
} catch (err) {
|
|
247
|
+
if (err instanceof APIError) {
|
|
248
|
+
resolve({ success: false, reason: err.response });
|
|
249
|
+
} else {
|
|
250
|
+
reject(err);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
229
255
|
}
|