mirror of
https://github.com/AtHeartEngineering/bandada.git
synced 2026-01-10 14:28:13 -05:00
refactor: update some variable names and api sdk function docs
This commit is contained in:
@@ -203,16 +203,16 @@ export class GroupsService {
|
||||
|
||||
/**
|
||||
* Remove groups using API Key.
|
||||
* @param groupsIds Groups identifiers.
|
||||
* @param groupIds Groups identifiers.
|
||||
* @param apiKey the api key.
|
||||
*/
|
||||
async removeGroupsWithAPIKey(
|
||||
groupsIds: Array<string>,
|
||||
groupIds: Array<string>,
|
||||
apiKey: string
|
||||
): Promise<void> {
|
||||
const admin = await getAndCheckAdmin(this.adminsService, apiKey)
|
||||
|
||||
for await (const groupId of groupsIds) {
|
||||
for await (const groupId of groupIds) {
|
||||
await this.removeGroup(groupId, admin.id)
|
||||
}
|
||||
}
|
||||
@@ -228,14 +228,14 @@ export class GroupsService {
|
||||
|
||||
/**
|
||||
* Remove groups manually without using API Key.
|
||||
* @param groupsIds Groups identifiers.
|
||||
* @param groupIds Groups identifiers.
|
||||
* @param adminId Admin id.
|
||||
*/
|
||||
async removeGroupsManually(
|
||||
groupsIds: Array<string>,
|
||||
groupIds: Array<string>,
|
||||
adminId: string
|
||||
): Promise<void> {
|
||||
for await (const groupId of groupsIds) {
|
||||
for await (const groupId of groupIds) {
|
||||
await this.removeGroup(groupId, adminId)
|
||||
}
|
||||
}
|
||||
@@ -285,13 +285,13 @@ export class GroupsService {
|
||||
|
||||
/**
|
||||
* Update groups using API Key.
|
||||
* @param groupsIds Groups ids.
|
||||
* @param groupIds Group ids.
|
||||
* @param dtos External parameters used to update groups.
|
||||
* @param apiKey the API Key.
|
||||
* @returns Updated group.
|
||||
*/
|
||||
async updateGroupsWithApiKey(
|
||||
groupsIds: Array<string>,
|
||||
groupIds: Array<string>,
|
||||
dtos: Array<UpdateGroupDto>,
|
||||
apiKey: string
|
||||
): Promise<Array<Group>> {
|
||||
@@ -299,7 +299,7 @@ export class GroupsService {
|
||||
|
||||
const admin = await getAndCheckAdmin(this.adminsService, apiKey)
|
||||
|
||||
for await (const [index, groupId] of groupsIds.entries()) {
|
||||
for await (const [index, groupId] of groupIds.entries()) {
|
||||
const dto = dtos[index]
|
||||
const group = await this.updateGroup(groupId, dto, admin.id)
|
||||
updatedGroups.push(group)
|
||||
@@ -325,19 +325,19 @@ export class GroupsService {
|
||||
|
||||
/**
|
||||
* Update groups manually without using API Key.
|
||||
* @param groupsIds Groups ids.
|
||||
* @param groupIds Group ids.
|
||||
* @param dtos External parameters used to update groups.
|
||||
* @param adminId Group admin id.
|
||||
* @returns Updated groups.
|
||||
*/
|
||||
async updateGroupsManually(
|
||||
groupsIds: Array<string>,
|
||||
groupIds: Array<string>,
|
||||
dtos: Array<UpdateGroupDto>,
|
||||
adminId: string
|
||||
): Promise<Array<Group>> {
|
||||
const updatedGroups: Array<Group> = []
|
||||
|
||||
for await (const [index, groupId] of groupsIds.entries()) {
|
||||
for await (const [index, groupId] of groupIds.entries()) {
|
||||
const dto = dtos[index]
|
||||
const group = await this.updateGroup(groupId, dto, adminId)
|
||||
updatedGroups.push(group)
|
||||
|
||||
@@ -88,30 +88,30 @@ export default class ApiSdk {
|
||||
|
||||
/**
|
||||
* Creates a group using the API key.
|
||||
* @param dto The data of the group.
|
||||
* @param groupData Data to create the group.
|
||||
* @param apiKey The API key of the admin of the group.
|
||||
* @returns The created group.
|
||||
*/
|
||||
async createGroup(
|
||||
dto: GroupRequest,
|
||||
groupData: GroupRequest,
|
||||
apiKey: string
|
||||
): Promise<GroupResponse> {
|
||||
const group = await createGroup(this._config, dto, apiKey)
|
||||
const group = await createGroup(this._config, groupData, apiKey)
|
||||
|
||||
return group
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates one or more groups using the API key.
|
||||
* @param dtos The data of one or more groups.
|
||||
* @param apiKey The API key of the admin of the group.
|
||||
* @param groupsData Data to create the groups.
|
||||
* @param apiKey The API key of the admin of the groups.
|
||||
* @returns The created groups.
|
||||
*/
|
||||
async createGroups(
|
||||
dtos: Array<GroupRequest>,
|
||||
groupsData: Array<GroupRequest>,
|
||||
apiKey: string
|
||||
): Promise<Array<GroupResponse>> {
|
||||
const groups = await createGroups(this._config, dtos, apiKey)
|
||||
const groups = await createGroups(this._config, groupsData, apiKey)
|
||||
|
||||
return groups
|
||||
}
|
||||
@@ -120,6 +120,7 @@ export default class ApiSdk {
|
||||
* Removes a group using the API key.
|
||||
* @param groupId The group id.
|
||||
* @param apiKey The API key of the admin of the group.
|
||||
* @returns undefined.
|
||||
*/
|
||||
async removeGroup(groupId: string, apiKey: string): Promise<void> {
|
||||
return removeGroup(this._config, groupId, apiKey)
|
||||
@@ -127,46 +128,54 @@ export default class ApiSdk {
|
||||
|
||||
/**
|
||||
* Removes one or more group using the API key.
|
||||
* @param groupsIds The groups ids.
|
||||
* @param apiKey The API key of the admin of the group.
|
||||
* @param groupIds The group ids.
|
||||
* @param apiKey The API key of the admin of the groups.
|
||||
* @returns undefined.
|
||||
*/
|
||||
async removeGroups(
|
||||
groupsIds: Array<string>,
|
||||
apiKey: string
|
||||
): Promise<void> {
|
||||
return removeGroups(this._config, groupsIds, apiKey)
|
||||
async removeGroups(groupIds: Array<string>, apiKey: string): Promise<void> {
|
||||
return removeGroups(this._config, groupIds, apiKey)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a specific group using the API key.
|
||||
* @param groupId The group id.
|
||||
* @param dto The data to update the group.
|
||||
* @param groupData Data to update the group.
|
||||
* @param apiKey The API key of the admin of the group.
|
||||
* @returns The updated group.
|
||||
*/
|
||||
async updateGroup(
|
||||
groupId: string,
|
||||
dto: GroupUpdateRequest,
|
||||
groupData: GroupUpdateRequest,
|
||||
apiKey: string
|
||||
): Promise<GroupResponse> {
|
||||
const group = await updateGroup(this._config, groupId, dto, apiKey)
|
||||
const group = await updateGroup(
|
||||
this._config,
|
||||
groupId,
|
||||
groupData,
|
||||
apiKey
|
||||
)
|
||||
|
||||
return group
|
||||
}
|
||||
|
||||
/**
|
||||
* Updats one or more groups using the API key.
|
||||
* @param groupsIds The groups ids.
|
||||
* @param dtos The data to update the groups.
|
||||
* @param apiKey The API key of the admin of the group.
|
||||
* @param groupIds The group ids.
|
||||
* @param groupsData Data to update the groups.
|
||||
* @param apiKey The API key of the admin of the groups.
|
||||
* @returns The updated groups.
|
||||
*/
|
||||
async updateGroups(
|
||||
groupsIds: Array<string>,
|
||||
dtos: Array<GroupUpdateRequest>,
|
||||
groupIds: Array<string>,
|
||||
groupsData: Array<GroupUpdateRequest>,
|
||||
apiKey: string
|
||||
): Promise<Array<GroupResponse>> {
|
||||
const groups = await updateGroups(this._config, groupsIds, dtos, apiKey)
|
||||
const groups = await updateGroups(
|
||||
this._config,
|
||||
groupIds,
|
||||
groupsData,
|
||||
apiKey
|
||||
)
|
||||
|
||||
return groups
|
||||
}
|
||||
@@ -217,7 +226,7 @@ export default class ApiSdk {
|
||||
* Adds a member to a group using an API Key.
|
||||
* @param groupId Group id.
|
||||
* @param memberId Member id.
|
||||
* @param apiKey API Key.
|
||||
* @param apiKey API Key of the admin of the group.
|
||||
* @returns undefined.
|
||||
*/
|
||||
async addMemberByApiKey(
|
||||
@@ -232,7 +241,7 @@ export default class ApiSdk {
|
||||
* Adds several members to a group using an API Key.
|
||||
* @param groupId Group id.
|
||||
* @param memberIds Member ids.
|
||||
* @param apiKey API Key.
|
||||
* @param apiKey API Key of the admin of the group.
|
||||
* @returns undefined.
|
||||
*/
|
||||
async addMembersByApiKey(
|
||||
@@ -262,7 +271,7 @@ export default class ApiSdk {
|
||||
* Removes a member from a group using an API Key.
|
||||
* @param groupId Group id.
|
||||
* @param memberId Member id.
|
||||
* @param apiKey API Key.
|
||||
* @param apiKey API Key of the admin of the group.
|
||||
* @returns undefined.
|
||||
*/
|
||||
async removeMemberByApiKey(
|
||||
@@ -277,7 +286,7 @@ export default class ApiSdk {
|
||||
* Removes multiple members from a group using an API Key.
|
||||
* @param groupId Group id.
|
||||
* @param memberIds Member ids.
|
||||
* @param apiKey API Key.
|
||||
* @param apiKey API Key of the admin of the group.
|
||||
* @returns undefined.
|
||||
*/
|
||||
async removeMembersByApiKey(
|
||||
|
||||
@@ -20,18 +20,18 @@ export async function getGroups(config: object): Promise<GroupResponse[]> {
|
||||
|
||||
/**
|
||||
* Creates a group with the provided details.
|
||||
* @param dto Object containing the details for the group to be created.
|
||||
* @param groupData Data to create the group.
|
||||
* @param apiKey API Key of the admin.
|
||||
* @returns The created group.
|
||||
*/
|
||||
export async function createGroup(
|
||||
config: object,
|
||||
dto: GroupRequest,
|
||||
groupData: GroupRequest,
|
||||
apiKey: string
|
||||
): Promise<GroupResponse> {
|
||||
const newConfig: any = {
|
||||
method: "post",
|
||||
data: [dto],
|
||||
data: [groupData],
|
||||
...config
|
||||
}
|
||||
|
||||
@@ -44,19 +44,19 @@ export async function createGroup(
|
||||
|
||||
/**
|
||||
* Creates one or more groups with the provided details.
|
||||
* @param dtos Array of objects containing the details for the groups to be created.
|
||||
* @param groupsData Data to create the groups.
|
||||
* @param apiKey API Key of the admin.
|
||||
* @returns Array of the created groups.
|
||||
*/
|
||||
export async function createGroups(
|
||||
config: object,
|
||||
dtos: Array<GroupRequest>,
|
||||
groupsData: Array<GroupRequest>,
|
||||
apiKey: string
|
||||
): Promise<Array<GroupResponse>> {
|
||||
const newConfig: any = {
|
||||
method: "post",
|
||||
data: {
|
||||
dtos
|
||||
groupsData
|
||||
},
|
||||
...config
|
||||
}
|
||||
@@ -97,18 +97,18 @@ export async function removeGroup(
|
||||
|
||||
/**
|
||||
* Removes one or more groups.
|
||||
* @param groupsIds The groups ids.
|
||||
* @param groupIds The group ids.
|
||||
* @param apiKey API Key of the admin.
|
||||
*/
|
||||
export async function removeGroups(
|
||||
config: object,
|
||||
groupsIds: Array<string>,
|
||||
groupIds: Array<string>,
|
||||
apiKey: string
|
||||
): Promise<void> {
|
||||
const newConfig: any = {
|
||||
method: "delete",
|
||||
data: {
|
||||
groupsIds,
|
||||
groupIds,
|
||||
apiKey
|
||||
},
|
||||
...config
|
||||
@@ -124,14 +124,14 @@ export async function removeGroups(
|
||||
/**
|
||||
* Updates the group.
|
||||
* @param groupId The group id.
|
||||
* @param dto The data to update for the group.
|
||||
* @param groupData Data to update the group.
|
||||
* @param apiKey API Key of the admin.
|
||||
* @return The updated group.
|
||||
*/
|
||||
export async function updateGroup(
|
||||
config: object,
|
||||
groupId: string,
|
||||
dto: GroupUpdateRequest,
|
||||
groupData: GroupUpdateRequest,
|
||||
apiKey: string
|
||||
): Promise<GroupResponse> {
|
||||
const requestUrl = `${url}/${groupId}`
|
||||
@@ -140,7 +140,7 @@ export async function updateGroup(
|
||||
method: "put",
|
||||
data: {
|
||||
groupId,
|
||||
dto,
|
||||
groupData,
|
||||
apiKey
|
||||
},
|
||||
...config
|
||||
@@ -155,22 +155,22 @@ export async function updateGroup(
|
||||
|
||||
/**
|
||||
* Updates the groups.
|
||||
* @param groupsIds The groups ids.
|
||||
* @param dtos The data to update for the groups.
|
||||
* @param groupIds The group ids.
|
||||
* @param groupsData Data to update the groups.
|
||||
* @param apiKey API Key of the admin.
|
||||
* @return The updated groups.
|
||||
*/
|
||||
export async function updateGroups(
|
||||
config: object,
|
||||
groupsIds: Array<string>,
|
||||
dtos: Array<GroupUpdateRequest>,
|
||||
groupIds: Array<string>,
|
||||
groupsData: Array<GroupUpdateRequest>,
|
||||
apiKey: string
|
||||
): Promise<Array<GroupResponse>> {
|
||||
const newConfig: any = {
|
||||
method: "put",
|
||||
data: {
|
||||
groupsIds,
|
||||
dtos,
|
||||
groupIds,
|
||||
groupsData,
|
||||
apiKey
|
||||
},
|
||||
...config
|
||||
|
||||
@@ -206,7 +206,7 @@ describe("Bandada API SDK", () => {
|
||||
})
|
||||
describe("#removeGroups", () => {
|
||||
it("Should create a group", async () => {
|
||||
const groupsIds = [
|
||||
const groupIds = [
|
||||
"10402173435763029700781503965100",
|
||||
"20402173435763029700781503965200"
|
||||
]
|
||||
@@ -215,7 +215,7 @@ describe("Bandada API SDK", () => {
|
||||
requestMocked.mockImplementationOnce(() => Promise.resolve())
|
||||
|
||||
apiSdk = new ApiSdk(SupportedUrl.DEV)
|
||||
const res = await apiSdk.removeGroups(groupsIds, apiKey)
|
||||
const res = await apiSdk.removeGroups(groupIds, apiKey)
|
||||
expect(res).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -259,7 +259,7 @@ describe("Bandada API SDK", () => {
|
||||
})
|
||||
describe("#updateGroups", () => {
|
||||
it("Should update some groups", async () => {
|
||||
const groupsIds = [
|
||||
const groupIds = [
|
||||
"10402173435763029700781503965100",
|
||||
"20402173435763029700781503965200"
|
||||
]
|
||||
@@ -306,7 +306,7 @@ describe("Bandada API SDK", () => {
|
||||
|
||||
apiSdk = new ApiSdk(SupportedUrl.DEV)
|
||||
const groups: Array<GroupResponse> = await apiSdk.updateGroups(
|
||||
groupsIds,
|
||||
groupIds,
|
||||
updatedGroups,
|
||||
apiKey
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user