UNPKG

xsolla

Version:

A Node.js client for working with the Xsolla Merchant API

41 lines (40 loc) 1.37 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Collection_1 = __importDefault(require("./Collection")); const Project_1 = __importDefault(require("../Models/Project")); class ProjectCollection extends Collection_1.default { constructor() { super(...arguments); /** * Model this collection is responsible for. */ this.model = Project_1.default; } /** * Create a project. */ create(data) { return this.client.post(`/merchants/${data.merchant_id || this.client.merchantId}/projects`, { method: 'POST', data, }).then(({ data }) => this.get({ project_id: data.id })); } /** * Get a single project by ID. */ get(data) { return this.client.get(`/projects/${data.project_id}`) .then(({ data }) => this.createModel(data)); } /** * Fetch all projects for the current merchant. */ all(merchantId = this.client.merchantId) { return this.client.get(`/merchant/${merchantId}/projects`) .then(({ data }) => this.createModelList(data)); } } exports.default = ProjectCollection;