Skip to content

Commit

Permalink
feat: refactor api's for connection verification and issuance module
Browse files Browse the repository at this point in the history
Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
bhavanakarwade committed Sep 18, 2023
1 parent d2d8b3a commit 5c8163c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/api/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getFromLocalStorage } from './Auth';

export const getConnectionsByOrg = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Issuance.getAllConnections}?orgId=${orgId}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getAllConnections}`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand Down
7 changes: 3 additions & 4 deletions src/api/issuance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { getFromLocalStorage } from './Auth';

export const getIssuedCredentials = async (state: IssueCredential) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Issuance.getIssuedCredentials}?orgId=${orgId}`;

const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getIssuedCredentials}`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand Down Expand Up @@ -40,8 +39,8 @@ export const getCredentialDefinitions = async (schemaId: string) => {


export const issueCredential = async (data: object) => {
const url = apiRoutes.Issuance.issueCredential;
const payload = data;
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueCredential}`; const payload = data;
const axiosPayload = {
url,
payload,
Expand Down
4 changes: 1 addition & 3 deletions src/api/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,8 @@ export const editOrganizationUserRole = async (userId: number, roles: number[])


export const createConnection = async (orgName: string) => {

const url = apiRoutes.connection.create

const orgId = await getFromLocalStorage(storageKeys.ORG_ID)
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.connection.create}`

const data = {
label: orgName,
Expand Down
17 changes: 7 additions & 10 deletions src/api/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';

export const verifyCredential = async (payload: any) => {
const url = apiRoutes.Verification.verifyCredential;
const axiosPayload = {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}`; const axiosPayload = {
url,
payload,
config: await getHeaderConfigs(),
Expand Down Expand Up @@ -40,8 +40,7 @@ export const getVerificationCredential = async (state: IssueCredential) => {

export const getVerificationList = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Verification.getAllRequestList}?orgId=${orgId}`;

const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.getAllRequestList}`
const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand All @@ -55,10 +54,9 @@ export const getVerificationList = async () => {
}
};

export const verifyPresentation = async (id:string) => {
export const verifyPresentation = async (proofId:string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Verification.presentationVerification}?orgId=${orgId}&id=${id}`;

const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.presentationVerification}/${proofId}/verify`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand All @@ -73,10 +71,9 @@ export const verifyPresentation = async (id:string) => {
};


export const getProofAttributes=async (id:string)=>{
export const getProofAttributes=async (proofId:string)=>{
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Verification.proofRequestAttributesVerification}?id=${id}&orgId=${orgId}`;

const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.proofRequestAttributesVerification}/${proofId}/form`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand Down
24 changes: 12 additions & 12 deletions src/config/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const apiRoutes = {
recentActivity: '/users/activity',
},
organizations: {
root: '/orgs',
create: '/organization',
update: '/organization',
getAll: '/organization',
Expand Down Expand Up @@ -51,18 +52,17 @@ export const apiRoutes = {
fidoVerifyAuthentication: 'Fido/verify-authentication/'

},
Issuance:{
getIssuedCredentials:'/issue-credentials',
getCredDefBySchemaId :'/schemas/credential-definitions',
getAllConnections:'/connections',
issueCredential:'/issue-credentials/create-offer'
},
Verification:{
getAllRequestList: '/proofs',
verifyCredential:'/proofs/request-proof',
presentationVerification:'/proofs/verify-presentation',
proofRequestAttributesVerification:'/proofs/form-data'
},
Issuance: {
getIssuedCredentials: '/credentials',
getAllConnections: '/connections',
issueCredential: '/credentials/offer',
},
Verification: {
getAllRequestList: '/credentials/proofs',
verifyCredential: '/proofs',
presentationVerification: '/proofs',
proofRequestAttributesVerification: '/proofs'
},
Agent:{
checkAgentHealth: '/agent-service/health',
},
Expand Down

0 comments on commit 5c8163c

Please sign in to comment.