myria-core-sdk
Version:
Latest version SDK
214 lines (187 loc) • 10.9 kB
TypeScript
import { APIResponseType } from "../types/APIResponseType";
import { CollectionListResponseData, CreateProjectParams, CreateProjectParamsByAPIKey, ProjectResponse, UpdateProjectParams, UpdateProjectByAPIKey, DeleteProjectByProjectId } from "../types/ProjectTypes";
import { EnvTypes } from "../typesBundle";
/**
* Create ProjectManager module
* @class ProjectManager
* @param {EnvTypes} env Environment type (DEV / STAGING / PREPROD / PROD)
* @example <caption>ProjectManager Instantiation</caption>
const projectManager = new ProjectManager(EnvTypes.STAGING);
*
*/
export declare class ProjectManager {
private projectAPI;
constructor(env: EnvTypes);
/**
* @summary Get project details information by project ID and api key
* @param {number} id unique ID of project
* @param {string} apiKey api key of project
* @returns {ProjectResponse} Project details information (basic info of project, number of collections allow....)
* @throws {string} Exception: Project id is required
* @example <caption>Sample of getProjectDetails(id) on Staging env</caption>
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const projectId = 1;
const apiKey = 'Your api key'; // could generate on the myria portal for partner
console.log("Getting project details information...");
const data: projectDetailsInfo = await projectManager.getProjectDetail(projectId, apiKey);
console.log("Project details response:");
console.log(JSON.stringify(data, null, 2));
*/
getProjectDetail(id: string, apiKey: string): Promise<ProjectResponse | undefined>;
/**
* @summary Get project details information by project ID and api key
* @param {number} id unique ID of project
* @param {string} apiKey api key of project
* @returns {ProjectResponse} Project details information (basic info of project, number of collections allow....)
* @throws {string} Exception: Project id is required
* @example <caption>Sample of getProjectDetails(id) on Staging env</caption>
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const projectPublicId = 1;
const apiKey = 'Your api key'; // could generate on the myria portal for partner
console.log("Getting project details information...");
const data: CollectionListResponseData = await projectManager.getProjectDetailByPublicID(projectPublicId, apiKey);
console.log("Project details response:");
console.log(JSON.stringify(data, null, 2));
*/
getProjectDetailByPublicID(publicId: string, apiKey: string): Promise<ProjectResponse | undefined>;
/**
* @summary Create project by using Myria user Id and API key
* @param {CreateProjectParamsByAPIKey} payload Create project request params with API Key
* @returns {ProjectResponse} Project details (project basic info, number of collections allow....)
* @throws {string} Exception: API Key is required
* @throws {string} Exception: Company name is required
* @throws {string} Exception: Contact email is required
* @throws {string} Exception: Myria User ID is required
* @throws {string} Exception: Name is required
* @example <caption>Sample of createProjectByApiKey({}) on Staging env</caption>
*
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const params: CreateProjectParamsByAPIKey = {
name: "Game Project Test",
companyName: "GamePartnerWithMyria",
contactEmail: "world.game@myria.com",
apiKey: 'Your api key', // could generate on the myria portal for partner
myriaUserID: 'your unique user ID in myria system',
};
console.log("Getting project details information...");
const data: ProjectResponse = await projectManager.createProjectByApiKey(params);
console.log("New project details response:");
console.log(JSON.stringify(data, null, 2));
*/
createProjectByApiKey(payload: CreateProjectParamsByAPIKey): Promise<ProjectResponse | undefined>;
/**
* @summary Update project by using Myria user Id and API key
* @param {UpdateProjectByAPIKey} payload Update project request params
* @returns {ProjectResponse} Project details information (basic info of project, number of collections allow....)
* @throws {string} Exception: API Key is required
* @throws {string} Exception: Company name is required
* @throws {string} Exception: Contact email is required
* @throws {string} Exception: Myria User ID is required
* @throws {string} Exception: Name is required
* @throws {string} Http Status Code 500: Create project failure => ${server error}
* @example <caption>Sample of updateProjectByApiKey({}) on Staging env</caption>
*
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const params: UpdateProjectByAPIKey = {
id: 1,
name: "Game Project Test",
companyName: "GamePartnerWithMyria",
contactEmail: "world.game@myria.com",
apiKey: 'Your api key', // could generate on the myria portal
myriaUserID: 'your unique user ID in myria system',
};
console.log("Getting project details information...");
const data: ProjectResponse = await projectManager.updateProjectByApiKey(params);
console.log("New project details response:");
console.log(JSON.stringify(data, null, 2));
*/
updateProjectByApiKey(payload: UpdateProjectByAPIKey): Promise<ProjectResponse | undefined>;
/**
* @summary Get Project List By Myria User ID and API Key
* @param {string} userID Unique ID (uuid) of myria user
* @param {string} apiKey Partner's API key
* @throws {string} Exception: User ID is required
* @throws {string} Exception: Partner API Key is required
* @throws {string} Http Status Code 401: x-api-key is not found (x-api-key is required to secure the call to Myria marketplace service)
* @throws {string} Http Status Code 403: The API KEY (example: aed.....) is unavailable means the API key is invalid or has been deactivated
* @example <caption>Sample of getProjectsByUserIDAndApiKey({}) on Staging env</caption>
*
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const myriaUserID = 'uuid myria user ID'; // 'your unique user ID in myria system';
const apiKey = 'Your api key'; // could generate on the myria portal
console.log("Getting project list data...");
const data: ProjectResponse = await projectManager.getProjectsByUserIDAndApiKey(myriaUserID, apiKey);
console.log("Data project list response:");
console.log(JSON.stringify(data, null, 2));
*/
getProjectsByUserIDAndApiKey(userID: string, apiKey: string): Promise<ProjectResponse | undefined>;
deleteProjectById(payload: DeleteProjectByProjectId): Promise<APIResponseType<boolean> | undefined>;
/**
* @summary Create the project by using a Stark key
* @param {CreateProjectParams} payload create project request input (companyName / name / contactEmail / Stark key)
* @throws {string} Exception: CompanyName is required
* @throws {string} Exception: Name is required
* @throws {string} Exception: Contact email address is required
* @throws {string} Exception: StarkKey is required
* @throws {string} Exception: Create project failed with internal server error
* @returns {ProjectResponse | undefined} Project information data
* @example <caption>Sample of createProject() on testnet environment</caption>
*
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const starkKey: string = config.stark_key; // Your stark key in Myria system
const params: CreateProjectParams = {
name: "Game Project Test",
companyName: "GamePartnerWithMyria",
contactEmail: "world.game@myria.com",
starkKey: starkKey,
};
console.log("Creating the project...");
const newProjectResponse: ProjectResponse = await projectManager.createProject(params);
console.log("Created project response:");
console.log(JSON.stringify(newProjectResponse, null, 2));
*/
createProject(payload: CreateProjectParams): Promise<ProjectResponse | undefined>;
/**
* @summary Update the project by using project ID and the stark key
* @param {UpdateProjectParams} payload update projects request input (id / companyName / name / contactEmail / Stark key)
* @throws {string} Exception: Project Id is required
* @throws {string} Exception: Company name is required
* @throws {string} Exception: Name is required
* @throws {string} Exception: Contact email address is required
* @throws {string} Exception: StarkKey is required
* @returns {ProjectResponse | undefined} Project information data
* @example <caption>Sample of updateProject({}) on Staging testnet environment</caption>
*
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const starkKey: string = config.stark_key; // Your stark key in Myria system
const params: UpdateProjectParams = {
id: 1,
name: "Update Game Project Test",
companyName: "GamePartnerWithMyria",
contactEmail: "world.game@myria.com",
starkKey: starkKey,
};
console.log("Update the project...");
const updatedProjectResponse: ProjectResponse = await projectManager.updateProject(params);
console.log("Updated project response:");
console.log(JSON.stringify(updatedProjectResponse, null, 2));
*/
updateProject(payload: UpdateProjectParams): Promise<ProjectResponse | undefined>;
/**
* @description Function to get the list of collections by project ID
* @param {number} id unique ID of project
* @returns {CollectionListResponseData} Project details information which include collection list
* @throws {string} Exception: Project id is required
* @throws {string} Exception: Get collection list failed with internal server error
* @throws {string} Exception: Get collection list failed with ${serverError}
* @example <caption>Sample of getCollectionListByProjectId() on Staging env</caption>
const projectManager: ProjectManager = new ProjectManager(EnvTypes.STAGING);
const starkKey: string = config.stark_key; // Your stark key in Myria system
const projectId = 1;
console.log("Getting list of the collection...");
const data: CollectionListResponseData = await projectManager.getCollectionListByProjectId(projectId);
console.log("List of collection response:");
console.log(JSON.stringify(data, null, 2));
*/
getCollectionListByProjectId(id: number): Promise<CollectionListResponseData>;
}