CREDENTIAL TYPE MANAGEMENT WORKS
This commit is contained in:
+18
-6
@@ -2,22 +2,34 @@ import api from "./axios";
|
||||
|
||||
export const company = {
|
||||
async fetch(accessToken: string, id: string) {
|
||||
const company = await api.get(`/v1/company/${id}`, {
|
||||
const company = await api.get(`/v1/company/companies/${id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return company.data;
|
||||
},
|
||||
async fetchMany(accessToken: string, page: number = 1) {
|
||||
const companies = await api.get("/v1/companies", {
|
||||
params: {
|
||||
page,
|
||||
},
|
||||
async fetchMany(accessToken: string, page: number = 1, search?: string) {
|
||||
const params: Record<string, unknown> = { page };
|
||||
if (search && search.length > 0) params.search = search;
|
||||
|
||||
const companies = await api.get("/v1/company/companies", {
|
||||
params,
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return companies.data;
|
||||
},
|
||||
async fetchConfigurations(accessToken: string, id: string) {
|
||||
const configurations = await api.get(
|
||||
`/v1/company/companies/${id}/configurations`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
return configurations.data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import api from "./axios";
|
||||
|
||||
export interface CredentialTypeField {
|
||||
id: string;
|
||||
name: string;
|
||||
required: boolean;
|
||||
secure: boolean;
|
||||
valueType: "plain_text" | "password" | "number" | "email" | "url";
|
||||
}
|
||||
|
||||
export interface CredentialType {
|
||||
id: string;
|
||||
name: string;
|
||||
permissionScope: string;
|
||||
icon?: string;
|
||||
fields: CredentialTypeField[];
|
||||
credentialCount: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export const credentialType = {
|
||||
async fetchMany(accessToken: string) {
|
||||
const response = await api.get("/v1/credential-type", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async fetch(accessToken: string, identifier: string) {
|
||||
const response = await api.get(`/v1/credential-type/${identifier}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async create(
|
||||
accessToken: string,
|
||||
credentialType: Omit<
|
||||
CredentialType,
|
||||
"id" | "credentialCount" | "createdAt" | "updatedAt"
|
||||
>,
|
||||
) {
|
||||
const response = await api.post("/v1/credential-type", credentialType, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async update(
|
||||
accessToken: string,
|
||||
id: string,
|
||||
updates: Partial<
|
||||
Omit<CredentialType, "id" | "credentialCount" | "createdAt" | "updatedAt">
|
||||
>,
|
||||
) {
|
||||
const response = await api.patch(`/v1/credential-type/${id}`, updates, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async delete(accessToken: string, id: string) {
|
||||
const response = await api.delete(`/v1/credential-type/${id}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async fetchCredentials(accessToken: string, id: string) {
|
||||
const response = await api.get(`/v1/credential-type/${id}/credentials`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -3,6 +3,7 @@
|
||||
export * from "./axios";
|
||||
export * from "./user";
|
||||
export * from "./companies";
|
||||
export * from "./credentialTypes";
|
||||
|
||||
/**
|
||||
* @TODO
|
||||
|
||||
Reference in New Issue
Block a user