-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add missing APIs endpoints on ApiSdk
- Loading branch information
Showing
7 changed files
with
907 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { request } from "@bandada/utils" | ||
import { AdminRequest, AdminResponse, AdminUpdateApiKeyRequest } from "./types" | ||
|
||
const url = "/admins" | ||
|
||
/** | ||
* Create an admin with the provided details. | ||
* @param dto Array of objects containing the details for the admin to be created. | ||
* @returns Array of the created groups. | ||
*/ | ||
export async function createAdmin( | ||
config: object, | ||
dto: AdminRequest | ||
): Promise<AdminResponse> { | ||
const newConfig: any = { | ||
method: "post", | ||
data: { | ||
dto | ||
}, | ||
...config | ||
} | ||
|
||
return request(url, newConfig) | ||
} | ||
|
||
/** | ||
* Get an admin. | ||
* @param adminId The admin id. | ||
* @returns The admin with given id. | ||
*/ | ||
export async function getAdmin( | ||
config: object, | ||
adminId: string | ||
): Promise<AdminResponse> { | ||
const requestUrl = `${url}/${adminId}` | ||
|
||
const newConfig: any = { | ||
method: "get", | ||
...config | ||
} | ||
|
||
return request(requestUrl, newConfig) | ||
} | ||
|
||
/** | ||
* Update an admin API key. | ||
* @param adminId The admin id. | ||
* @param dto The action to be executed on the API key. | ||
* @returns The updated API key. | ||
*/ | ||
export async function updateApiKey( | ||
config: object, | ||
adminId: string, | ||
dto: AdminUpdateApiKeyRequest | ||
): Promise<string> { | ||
const requestUrl = `${url}/${adminId}/apikey` | ||
|
||
const newConfig: any = { | ||
method: "put", | ||
body: { | ||
adminId, | ||
dto | ||
}, | ||
...config | ||
} | ||
|
||
return request(requestUrl, newConfig) | ||
} |
Oops, something went wrong.