8000 refactor: modified bulk issuance payload by bhavanakarwade · Pull Request #683 · credebl/studio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: modified bulk issuance payload #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/api/BulkIssuance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
import type { IConnectionListAPIParameter } from './connection';

export const getSchemaCredDef = async () => {
export const getSchemaCredDef = async (schemaType: string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.credefList}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.credefList}?schemaType=${schemaType}`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand All @@ -24,17 +24,21 @@ export const getSchemaCredDef = async () => {
}
};

export const DownloadCsvTemplate = async (credDefId: string) => {
export const DownloadCsvTemplate = async (templateId: string, schemaType: string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}/${credDefId}${apiRoutes.Issuance.download}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.download}`;

const axiosPayload = {
url,
payload: {
templateId,
schemaType
},
config: await getHeaderConfigs(),
};

try {
return await axiosGet(axiosPayload);
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
Expand All @@ -43,10 +47,11 @@ export const DownloadCsvTemplate = async (credDefId: string) => {

export const uploadCsvFile = async (
payload: { file: Uint8Array | Blob; fileName: string },
credefId: string,
templateId: string,
schemaType: string
) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.uploadCsv}?credDefId=${credefId}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.uploadCsv}?templateId=${templateId}&schemaType=${schemaType}`;

const axiosPayload = {
url,
Expand Down
10 changes: 5 additions & 5 deletions src/components/Issuance/BulkIssuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type { ICredentials, IValues, IAttributes, IUploadMessage } from './inter
import RoleViewButton from '../RoleViewButton';
import { Features } from '../../utils/enums/features';
import { Create, SchemaEndorsement } from './Constant';
import { SchemaType } from '../../common/enums';

export interface SelectRef {
clearValue(): void;
Expand Down Expand Up @@ -60,7 +61,7 @@ const BulkIssuance = () => {
setLoading(true);
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
if (orgId) {
const response = await getSchemaCredDef();
const response = await getSchemaCredDef(SchemaType.INDY);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
Expand Down Expand Up @@ -118,10 +119,9 @@ const BulkIssuance = () => {
if (credentialSelected) {
try {
setProcess(true);

const response = await DownloadCsvTemplate(credentialSelected);
const response = await DownloadCsvTemplate(credentialSelected, SchemaType.INDY);
const { data } = response as AxiosResponse;

if (data) {
const fileUrl = data;
if (fileUrl) {
Expand Down Expand Up @@ -247,7 +247,7 @@ const BulkIssuance = () => {
setUploadedFileName(file?.name);
setUploadedFile(file);

const response = await uploadCsvFile(payload, credentialSelected);
const response = await uploadCsvFile(payload, credentialSelected, SchemaType.INDY);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes?.API_STATUS_CREATED) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Issuance/EmailIssuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import RoleViewButton from '../RoleViewButton';
import { checkEcosystem, type ICheckEcosystem } from '../../config/ecosystem';
import { Features } from '../../utils/enums/features';
import { Create, SchemaEndorsement } from './Constant';
import { SchemaType } from '../../common/enums';

const EmailIssuance = () => {
const [formData, setFormData] = useState();
Expand All @@ -47,7 +48,7 @@ const EmailIssuance = () => {
setLoading(true);
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
if (orgId) {
const response = await getSchemaCredDef();
const response = await getSchemaCredDef(SchemaType.INDY);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
Expand Down
4 changes: 2 additions & 2 deletions src/config/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ export const apiRoutes = {
issueCredential: '/credentials/offer',
issueOobEmailCredential: '/credentials/oob/email',
bulk:{
credefList:'/bulk/cred-defs',
credefList:'/credentials/bulk/template',
uploadCsv: '/bulk/upload',
preview: '/preview',
bulk: '/bulk',
files: '/bulk/files',
filesData: '/bulk/file-data',
retry: '/retry/bulk'
},
download:'/download'
download:'/credentials/bulk/template'
},
Verification: {
getAllRequestList: '/credentials/proofs',
Expand Down
Loading
0