@bandada/api-sdk
Advanced tools
Comparing version 1.0.0-alpha to 1.0.0-beta
/** | ||
* @module @bandada/api-sdk | ||
* @version 1.0.0-alpha | ||
* @version 1.0.0-beta | ||
* @file A Typescript SDK for the Bandada API. | ||
@@ -185,2 +185,28 @@ * @copyright Ethereum Foundation 2023 | ||
/** | ||
* Adds members to a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
function addMembersByApiKey(config, groupId, memberIds, apiKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var requestUrl, newConfig; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
requestUrl = "".concat(url$1, "/").concat(groupId, "/members"); | ||
newConfig = __assign({ method: "post", data: { | ||
memberIds: memberIds | ||
} }, config); | ||
newConfig.headers["x-api-key"] = apiKey; | ||
return [4 /*yield*/, utils.request(requestUrl, newConfig)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
/** | ||
* Adds a member to a group using an Invite Code. | ||
@@ -234,2 +260,28 @@ * @param groupId Group id. | ||
} | ||
/** | ||
* Removes multiple members from a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
function removeMembersByApiKey(config, groupId, memberIds, apiKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var requestUrl, newConfig; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
requestUrl = "".concat(url$1, "/").concat(groupId, "/members"); | ||
newConfig = __assign({ method: "delete", data: { | ||
memberIds: memberIds | ||
} }, config); | ||
newConfig.headers["x-api-key"] = apiKey; | ||
return [4 /*yield*/, utils.request(requestUrl, newConfig)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -269,8 +321,7 @@ var url = "/invites"; | ||
if (config) { | ||
checkParameter(config, "config", "object"); | ||
if (!config["baseURL"]) { | ||
if (!config.baseURL) { | ||
this._config = __assign({ baseURL: url }, config); | ||
} | ||
else { | ||
if (url !== config["baseURL"]) | ||
if (url !== config.baseURL) | ||
throw new Error("The url and baseURL should be the same"); | ||
@@ -405,2 +456,21 @@ this._config = config; | ||
/** | ||
* Adds several members to a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
ApiSdk.prototype.addMembersByApiKey = function (groupId, memberIds, apiKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, addMembersByApiKey(this._config, groupId, memberIds, apiKey)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Adds a member to a group using an Invite Code. | ||
@@ -444,2 +514,21 @@ * @param groupId Group id. | ||
/** | ||
* Removes multiple members from a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
ApiSdk.prototype.removeMembersByApiKey = function (groupId, memberIds, apiKey) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, removeMembersByApiKey(this._config, groupId, memberIds, apiKey)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Returns a specific invite. | ||
@@ -446,0 +535,0 @@ * @param inviteCode Invite code. |
@@ -10,3 +10,3 @@ import { SupportedUrl, GroupResponse, InviteResponse } from "./types"; | ||
*/ | ||
constructor(url?: SupportedUrl | string, config?: object); | ||
constructor(url?: SupportedUrl | string, config?: any); | ||
/** | ||
@@ -56,2 +56,10 @@ * Returns the API URL. | ||
/** | ||
* Adds several members to a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
addMembersByApiKey(groupId: string, memberIds: string[], apiKey: string): Promise<void>; | ||
/** | ||
* Adds a member to a group using an Invite Code. | ||
@@ -73,2 +81,10 @@ * @param groupId Group id. | ||
/** | ||
* Removes multiple members from a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
removeMembersByApiKey(groupId: string, memberIds: string[], apiKey: string): Promise<void>; | ||
/** | ||
* Returns a specific invite. | ||
@@ -75,0 +91,0 @@ * @param inviteCode Invite code. |
@@ -36,2 +36,10 @@ import { GroupResponse } from "./types"; | ||
/** | ||
* Adds members to a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
export declare function addMembersByApiKey(config: object, groupId: string, memberIds: string[], apiKey: string): Promise<void>; | ||
/** | ||
* Adds a member to a group using an Invite Code. | ||
@@ -52,1 +60,9 @@ * @param groupId Group id. | ||
export declare function removeMemberByApiKey(config: object, groupId: string, memberId: string, apiKey: string): Promise<void>; | ||
/** | ||
* Removes multiple members from a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
export declare function removeMembersByApiKey(config: object, groupId: string, memberIds: string[], apiKey: string): Promise<void>; |
{ | ||
"name": "@bandada/api-sdk", | ||
"version": "1.0.0-alpha", | ||
"version": "1.0.0-beta", | ||
"description": "A Typescript SDK for the Bandada API.", | ||
@@ -32,3 +32,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@bandada/utils": "1.0.0-alpha" | ||
"@bandada/utils": "1.0.0-beta" | ||
}, | ||
@@ -41,3 +41,4 @@ "devDependencies": { | ||
"typescript": "^4.9.5" | ||
} | ||
}, | ||
"stableVersion": "1.0.0-alpha" | ||
} |
@@ -150,2 +150,14 @@ <p align="center"> | ||
\# **addMembersByApiKey**(): _Promise\<void>_ | ||
Adds multiple members to a group using an API Key. | ||
```ts | ||
const groupId = "10402173435763029700781503965100" | ||
const memberIds = ["1", "2", "3"] | ||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc" | ||
await apiSdk.addMembersByApiKey(groupId, memberIds, apiKey) | ||
``` | ||
\# **addMemberByInviteCode**(): _Promise\<void>_ | ||
@@ -174,1 +186,13 @@ | ||
``` | ||
\# **removeMembersByApiKey**(): _Promise\<void>_ | ||
Removes multiple members from a group using an API Key. | ||
```ts | ||
const groupId = "10402173435763029700781503965100" | ||
const memberIds = ["1", "2", "3"] | ||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc" | ||
await apiSdk.removeMembersByApiKey(groupId, memberIds, apiKey) | ||
``` |
@@ -9,4 +9,6 @@ import { SupportedUrl, GroupResponse, InviteResponse } from "./types" | ||
addMemberByApiKey, | ||
addMembersByApiKey, | ||
addMemberByInviteCode, | ||
removeMemberByApiKey | ||
removeMemberByApiKey, | ||
removeMembersByApiKey | ||
} from "./groups" | ||
@@ -24,11 +26,7 @@ import { getInvite } from "./invites" | ||
*/ | ||
constructor( | ||
url: SupportedUrl | string = SupportedUrl.PROD, | ||
config?: object | ||
) { | ||
constructor(url: SupportedUrl | string = SupportedUrl.PROD, config?: any) { | ||
checkParameter(url, "url", "string") | ||
if (config) { | ||
checkParameter(config, "config", "object") | ||
if (!config["baseURL"]) { | ||
if (!config.baseURL) { | ||
this._config = { | ||
@@ -39,3 +37,3 @@ baseURL: url, | ||
} else { | ||
if (url !== config["baseURL"]) | ||
if (url !== config.baseURL) | ||
throw new Error("The url and baseURL should be the same") | ||
@@ -140,2 +138,17 @@ this._config = config | ||
/** | ||
* Adds several members to a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
async addMembersByApiKey( | ||
groupId: string, | ||
memberIds: string[], | ||
apiKey: string | ||
): Promise<void> { | ||
await addMembersByApiKey(this._config, groupId, memberIds, apiKey) | ||
} | ||
/** | ||
* Adds a member to a group using an Invite Code. | ||
@@ -171,2 +184,17 @@ * @param groupId Group id. | ||
/** | ||
* Removes multiple members from a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
async removeMembersByApiKey( | ||
groupId: string, | ||
memberIds: string[], | ||
apiKey: string | ||
): Promise<void> { | ||
await removeMembersByApiKey(this._config, groupId, memberIds, apiKey) | ||
} | ||
/** | ||
* Returns a specific invite. | ||
@@ -173,0 +201,0 @@ * @param inviteCode Invite code. |
@@ -101,2 +101,30 @@ import { request } from "@bandada/utils" | ||
/** | ||
* Adds members to a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
export async function addMembersByApiKey( | ||
config: object, | ||
groupId: string, | ||
memberIds: string[], | ||
apiKey: string | ||
): Promise<void> { | ||
const requestUrl = `${url}/${groupId}/members` | ||
const newConfig: any = { | ||
method: "post", | ||
data: { | ||
memberIds | ||
}, | ||
...config | ||
} | ||
newConfig.headers["x-api-key"] = apiKey | ||
await request(requestUrl, newConfig) | ||
} | ||
/** | ||
* Adds a member to a group using an Invite Code. | ||
@@ -151,1 +179,29 @@ * @param groupId Group id. | ||
} | ||
/** | ||
* Removes multiple members from a group using an API Key. | ||
* @param groupId Group id. | ||
* @param memberIds Member ids. | ||
* @param apiKey API Key. | ||
* @returns undefined. | ||
*/ | ||
export async function removeMembersByApiKey( | ||
config: object, | ||
groupId: string, | ||
memberIds: string[], | ||
apiKey: string | ||
): Promise<void> { | ||
const requestUrl = `${url}/${groupId}/members` | ||
const newConfig: any = { | ||
method: "delete", | ||
data: { | ||
memberIds | ||
}, | ||
...config | ||
} | ||
newConfig.headers["x-api-key"] = apiKey | ||
await request(requestUrl, newConfig) | ||
} |
@@ -220,14 +220,14 @@ import { request } from "@bandada/utils" | ||
}) | ||
describe("#removeMemberByApiKey", () => { | ||
it("Should remove a member from a group using an API Key", async () => { | ||
describe("#addMembers", () => { | ||
it("Should add multiple members to the group using an API Key", async () => { | ||
requestMocked.mockImplementationOnce(() => Promise.resolve()) | ||
const groupId = "10402173435763029700781503965100" | ||
const memberId = "1" | ||
const memberIds = ["1", "2", "3"] | ||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc" | ||
apiSdk = new ApiSdk(SupportedUrl.DEV) | ||
const res = await apiSdk.removeMemberByApiKey( | ||
const res = await apiSdk.addMembersByApiKey( | ||
groupId, | ||
memberId, | ||
memberIds, | ||
apiKey | ||
@@ -237,2 +237,41 @@ ) | ||
}) | ||
describe("#removeMemberByApiKey", () => { | ||
it("Should remove a member from a group using an API Key", async () => { | ||
requestMocked.mockImplementationOnce(() => | ||
Promise.resolve() | ||
) | ||
const groupId = "10402173435763029700781503965100" | ||
const memberId = "1" | ||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc" | ||
apiSdk = new ApiSdk(SupportedUrl.DEV) | ||
const res = await apiSdk.removeMemberByApiKey( | ||
groupId, | ||
memberId, | ||
apiKey | ||
) | ||
expect(res).toBeUndefined() | ||
}) | ||
}) | ||
describe("#removeMembersByApiKey", () => { | ||
it("Should remove multiple members from a group using an API Key", async () => { | ||
requestMocked.mockImplementationOnce(() => | ||
Promise.resolve() | ||
) | ||
const groupId = "10402173435763029700781503965100" | ||
const memberIds = ["1", "2", "3"] | ||
const apiKey = "70f07d0d-6aa2-4fe1-b4b9-06c271a641dc" | ||
apiSdk = new ApiSdk(SupportedUrl.DEV) | ||
const res = await apiSdk.removeMembersByApiKey( | ||
groupId, | ||
memberIds, | ||
apiKey | ||
) | ||
expect(res).toBeUndefined() | ||
}) | ||
}) | ||
}) | ||
@@ -239,0 +278,0 @@ }) |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
79431
2016
197
1
+ Added@bandada/utils@1.0.0-beta(transitive)
- Removed@bandada/utils@1.0.0-alpha(transitive)
Updated@bandada/utils@1.0.0-beta