Skip to content

Commit

Permalink
fix: update getCredentialGroupJoinUrl baseUrl type to DashboardUrl type
Browse files Browse the repository at this point in the history
  • Loading branch information
waddaboo committed Jun 26, 2024
1 parent 2286677 commit a85fccf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
6 changes: 4 additions & 2 deletions libs/api-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,16 @@ const invite = await apiSdk.getInvite(inviteCode)
Returns a custom URL string for joining a credential group.

```ts
const baseUrl = "http://localhost:3000"
import { DashboardUrl } from "@bandada/api-sdk"

const dashboardUrl = DashboardUrl.DEV
const groupId = "10402173435763029700781503965100"
const commitment = "1"
const providerName = "github"
const redirectUri = "http://localhost:3003"

const url = apiSdk.getCredentialGroupJoinUrl(
baseUrl,
dashboardUrl,
groupId,
commitment,
providerName,
Expand Down
9 changes: 5 additions & 4 deletions libs/api-sdk/src/apiSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
Group,
Invite,
GroupCreationDetails,
GroupUpdateDetails
GroupUpdateDetails,
DashboardUrl
} from "./types"
import checkParameter from "./checkParameter"
import {
Expand Down Expand Up @@ -354,22 +355,22 @@ export default class ApiSdk {

/**
* Generate a custom url for joining a credential group.
* @param baseUrl Base url.
* @param dashboardUrl Dashboard base url.
* @param groupId Group id.
* @param commitment Identity commitment.
* @param providerName Group credential provider name.
* @param redirectUri Redirect uri.
* @returns Url string.
*/
getCredentialGroupJoinUrl(
baseUrl: string,
dashboardUrl: DashboardUrl,
groupId: string,
commitment: string,
providerName: string,
redirectUri?: string
): string {
const url = getCredentialGroupJoinUrl(
baseUrl,
dashboardUrl,
groupId,
commitment,
providerName,
Expand Down
13 changes: 9 additions & 4 deletions libs/api-sdk/src/groups.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { request } from "@bandada/utils"
import type { GroupCreationDetails, Group, GroupUpdateDetails } from "./types"
import type {
GroupCreationDetails,
Group,
GroupUpdateDetails,
DashboardUrl
} from "./types"

const url = "/groups"

Expand Down Expand Up @@ -374,21 +379,21 @@ export async function removeMembersByApiKey(

/**
* Generate a custorm url for joining a credential group.
* @param baseUrl Base url.
* @param dashboardUrl Dashboard url.
* @param groupId Group id.
* @param commitment Identity commitment.
* @param providerName Group credential provider name.
* @param redirectUri Redirect uri.
* @returns Url string.
*/
export function getCredentialGroupJoinUrl(
baseUrl: string,
dashboardUrl: DashboardUrl,
groupId: string,
commitment: string,
providerName: string,
redirectUri?: string
): string {
let resultUrl = `${baseUrl}/credentials?group=${groupId}&member=${commitment}&provider=${providerName}`
let resultUrl = `${dashboardUrl}/credentials?group=${groupId}&member=${commitment}&provider=${providerName}`

if (redirectUri) {
resultUrl += `&redirect_uri=${redirectUri}?redirect=true`
Expand Down
9 changes: 5 additions & 4 deletions libs/api-sdk/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Group,
GroupUpdateDetails,
Invite,
SupportedUrl
SupportedUrl,
DashboardUrl
} from "./types"
import checkParameter from "./checkParameter"

Expand Down Expand Up @@ -585,22 +586,22 @@ describe("Bandada API SDK", () => {

describe("#getCredentialGroupJoinUrl", () => {
it("Should generate a custom url for joining a credential group", async () => {
const baseUrl = "http://localhost:3000"
const dashboardUrl = DashboardUrl.DEV
const groupId = "10402173435763029700781503965100"
const commitment = "1"
const providerName = "github"
const redirectUri = "http://localhost:3003"

apiSdk = new ApiSdk(SupportedUrl.DEV)
const res = apiSdk.getCredentialGroupJoinUrl(
baseUrl,
dashboardUrl,
groupId,
commitment,
providerName,
redirectUri
)

const url = `${baseUrl}/credentials?group=${groupId}&member=${commitment}&provider=${providerName}&redirect_uri=${redirectUri}?redirect=true`
const url = `${dashboardUrl}/credentials?group=${groupId}&member=${commitment}&provider=${providerName}&redirect_uri=${redirectUri}?redirect=true`

expect(res).toBe(url)
})
Expand Down

0 comments on commit a85fccf

Please sign in to comment.