-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from privacy-scaling-explorations/refactor/cl…
…ient-api-lib API lib to the client app
- Loading branch information
Showing
16 changed files
with
162 additions
and
59 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
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,76 @@ | ||
import { ApiSdk, GroupResponse, InviteResponse } from "@bandada/api-sdk" | ||
|
||
const api = new ApiSdk(import.meta.env.VITE_API_URL) | ||
|
||
export async function getInvite( | ||
inviteCode: string | ||
): Promise<InviteResponse | null> { | ||
try { | ||
return await api.getInvite(inviteCode) | ||
} catch (error: any) { | ||
console.error(error) | ||
|
||
if (error.response) { | ||
alert(error.response.statusText) | ||
} else { | ||
alert("Some error occurred!") | ||
} | ||
|
||
return null | ||
} | ||
} | ||
|
||
export async function getGroup(groupId: string): Promise<GroupResponse | null> { | ||
try { | ||
return await api.getGroup(groupId) | ||
} catch (error: any) { | ||
console.error(error) | ||
|
||
if (error.response) { | ||
alert(error.response.statusText) | ||
} else { | ||
alert("Some error occurred!") | ||
} | ||
|
||
return null | ||
} | ||
} | ||
|
||
export async function isGroupMember( | ||
groupId: string, | ||
memberId: string | ||
): Promise<boolean | null> { | ||
try { | ||
return await api.isGroupMember(groupId, memberId) | ||
} catch (error: any) { | ||
console.error(error) | ||
|
||
if (error.response) { | ||
alert(error.response.statusText) | ||
} else { | ||
alert("Some error occurred!") | ||
} | ||
|
||
return null | ||
} | ||
} | ||
|
||
export async function addMemberByInviteCode( | ||
groupId: string, | ||
memberId: string, | ||
inviteCode: string | ||
): Promise<void | null> { | ||
try { | ||
return await api.addMemberByInviteCode(groupId, memberId, inviteCode) | ||
} catch (error: any) { | ||
console.error(error) | ||
|
||
if (error.response) { | ||
alert(error.response.statusText) | ||
} else { | ||
alert("Some error occurred!") | ||
} | ||
|
||
return null | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.