UNPKG

@mentaport/certificates-projects

Version:

Mentaport certificate-projects SDK, for certificate admins.

158 lines (152 loc) 5.58 kB
import { ContractStatus, BlockchainTypes, ContractEnvironment, Base, IResults, ICertificateProject, Environment } from '@mentaport/common'; export { BlockchainTypes, ContractEnvironment, ContractStatus, Environment, ICertificateProject, IResults, MentaportUtils } from '@mentaport/common'; interface ICreateCertProject { contractId: string; ownerName: string; projectName: string; email?: string; ownerWallet?: string; projectBaseURI?: string; customerId?: string; } interface IUpdateCertProject { contractId: string; projectId: string; status?: ContractStatus; projectName?: string; ownerWallet?: string; ownerName?: string; maxSupply?: number; projectBaseURI?: string; customerId?: string; } interface IUpdateCertProjectStatus { contractId: string; projectId: string; status: ContractStatus; customerId?: string; } interface IProjectActivate { contractId: string; projectId: string; } interface IProjectsArg { contractId?: string; projectId?: string; customerId?: string; } interface IContractProject { blockchain: BlockchainTypes; environment: ContractEnvironment; contractId: string; address: string; name: string; status: ContractStatus; } type RequestWithoutParams = { url: string; method: string; data?: object; params?: object; }; declare class ProjectsSDK extends Base { /** * Function to create a new project for certificates for a user * * @param {project.contractId} ContractId of contract where adding projcect * @param {project.projectName} Name of project * @param {project.ownerName} Name of project user * @param {project.email} Email of project user (optional) * @param {project.ownerWallet} Owner wallet of user (optional) * @param {project.projectBaseURI} projectBaseURI of contract (optional) * @param {customerId} CustomerId (optional if have more than one customer) * * @returns {IResults<ICertificateProject>} Returns if succeded the contract created */ createNewCertificateProject(newProject: ICreateCertProject): Promise<IResults<ICertificateProject>>; /** * Function to activate a project in a contract * * @param {contractId} ContractId * @param {projectId} ProjectId * * @returns {IResults<boolean>} Returns contract activated status */ activateProject(contractId: string, projectId: string): Promise<IResults<boolean>>; /** * Function to retrieve projects from customer in contracts * - most of users only have one contract with multiple projects * @param {contractId} ContractId (optional to get project just from one contract) * @param {customerId} CustomerId (optional if have more than one customer) * * @returns {IResults<T>} Returns all contract */ getProjects<T = ICertificateProject[]>(contractId?: string, customerId?: string): Promise<IResults<T>>; /** * Function to retrieve project by its Id * @param {contractId} ContractId * @param {projectId} ProjectId * @param {customerId} CustomerId (optional if have more than one customer) * * @returns {IResults<ICertificateProject>} Returns contract */ getProjectById<T = ICertificateProject>(contractId: string, projectId: string, customerId?: string): Promise<IResults<T>>; /** * Function to update project before it is activated. * * @param {updateProject} Information to update * @param {customerId} CustomerId (optional if have more than one customer) * * @returns {IResults<ICertificateProject>} Returns updated contract */ updateProjectById<T = ICertificateProject>(updateProject: IUpdateCertProject): Promise<IResults<T>>; /** * Function to update project status after being activated * * @param {updateProjectStatus} Status to update * @param {customerId} CustomerId (optional if have more than one customer) * * @returns {IResults<ICertificateProject>} Returns updated contract */ updateProjectStatusById<T = ICertificateProject>(updateProjectStatus: IUpdateCertProjectStatus): Promise<IResults<T>>; /** * Function to retrieve contracts from customer * All contracts will be return if all is true (active and non active) * @param {allContracts} Boolean to get all contracts, not just active * * @returns {IResults<T>} Returns contract */ getContracts<T = IContractProject[]>(allContracts: boolean): Promise<IResults<T>>; } declare class CertificateProjectsSDK extends Base { /** * Constructor for Supplement SDK * * @param {apiKey} APIKey * * @returns {} */ constructor(apiKey: string); /** * Function to set the client with default env Production * All users have to call this function * * @param {url} urlPath (optional) * * @returns {void} */ setClient(): void; /** * Function to set the client environment. * All users have to call this function * * @param {environment} Environment to run sdk in * @param {url} urlPath (optional-only for testing) * * @returns {void} */ setClientEnv(environment: Environment, url?: string): void; } interface CertificateProjectsSDK extends Base, ProjectsSDK { } export { CertificateProjectsSDK, IContractProject, ICreateCertProject, IProjectActivate, IProjectsArg, IUpdateCertProject, IUpdateCertProjectStatus, RequestWithoutParams };