Class

ProjectManager

ProjectManager(env)

Constructor

# new ProjectManager(env)

Create ProjectManager module

Parameters:
Name Type Description
env EnvTypes

Environment type (DEV / STAGING / PREPROD / PROD)

View Source modules/ProjectManager.ts, line 3

Example

ProjectManager Instantiation

  const projectManager = new ProjectManager(EnvTypes.STAGING);

Methods

# async createProject(payload) → {ProjectResponse|undefined}

Create the project by using a Stark key

Parameters:
Name Type Description
payload CreateProjectParams

create project request input (companyName / name / contactEmail / Stark key)

View Source modules/ProjectManager.ts, line 476

Exception: CompanyName is required

string

Exception: Name is required

string

Exception: Contact email address is required

string

Exception: StarkKey is required

string

Exception: Create project failed with internal server error

string

Project information data

ProjectResponse | undefined
Example

Sample of createProject() on testnet environment

    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));

# async createProjectByApiKey(payload) → {ProjectResponse}

Create project by using Myria user Id and API key

Parameters:
Name Type Description
payload CreateProjectParamsByAPIKey

Create project request params with API Key

View Source modules/ProjectManager.ts, line 385

Exception: API Key is required

string

Exception: Company name is required

string

Exception: Contact email is required

string

Exception: Myria User ID is required

string

Exception: Name is required

string

Project details (project basic info, number of collections allow....)

Example

Sample of createProjectByApiKey({}) on Staging env

    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));

# async getCollectionListByProjectId(id) → {CollectionListResponseData}

Function to get the list of collections by project ID

Parameters:
Name Type Description
id number

unique ID of project

View Source modules/ProjectManager.ts, line 532

Exception: Project id is required

string

Exception: Get collection list failed with internal server error

string

Exception: Get collection list failed with ${serverError}

string

Project details information which include collection list

Example

Sample of getCollectionListByProjectId() on Staging env

    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));

# async getProjectDetail(id) → {ProjectResponse}

Get project details information by project ID

Parameters:
Name Type Description
id number

unique ID of project

View Source modules/ProjectManager.ts, line 354

Exception: Project id is required

string

Project details information (basic info of project, number of collections allow....)

Example

Sample of getProjectDetails(id) on Staging env

    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 project details information...");
    const data: CollectionListResponseData = await projectManager.getProjectDetail(projectId);

    console.log("Project details response:");
    console.log(JSON.stringify(data, null, 2));

# async getProjectsByUserIDAndApiKey(userID, apiKey) → {Promise.<(ProjectResponse|undefined)>}

Get Project List By Myria User ID and API Key

Parameters:
Name Type Description
userID string

Unique ID (uuid) of myria user

apiKey string

Partner's API key

View Source modules/ProjectManager.ts, line 445

Exception: User ID is required

string

Exception: Partner API Key is required

string

Http Status Code 401: x-api-key is not found (x-api-key is required to secure the call to Myria marketplace service)

string

Http Status Code 403: The API KEY (example: aed.....) is unavailable means the API key is invalid or has been deactivated

string
Promise.<(ProjectResponse|undefined)>
Example

Sample of getProjectsByUserIDAndApiKey({}) on Staging env

    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));

# async updateProject(payload) → {ProjectResponse|undefined}

Update the project by using project ID and the stark key

Parameters:
Name Type Description
payload UpdateProjectParams

update projects request input (id / companyName / name / contactEmail / Stark key)

View Source modules/ProjectManager.ts, line 508

Exception: Project Id is required

string

Exception: Company name is required

string

Exception: Name is required

string

Exception: Contact email address is required

string

Exception: StarkKey is required

string

Project information data

ProjectResponse | undefined
Example

Sample of updateProject({}) on Staging testnet environment

    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));

# async updateProjectByApiKey(payload) → {ProjectResponse}

Update project by using Myria user Id and API key

Parameters:
Name Type Description
payload UpdateProjectByAPIKey

Update project request params

View Source modules/ProjectManager.ts, line 418

Exception: API Key is required

string

Exception: Company name is required

string

Exception: Contact email is required

string

Exception: Myria User ID is required

string

Exception: Name is required

string

Http Status Code 500: Create project failure => ${server error}

string

Project details information (basic info of project, number of collections allow....)

Example

Sample of updateProjectByApiKey({}) on Staging env

    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));