UNPKG

shopify-admin-api

Version:

Shopify Admin API is a NodeJS library built to help developers easily authenticate and make calls against the Shopify API. It was inspired by and borrows heavily from ShopifySharp.

92 lines (91 loc) 2.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Comments = void 0; const infrastructure_1 = require("../infrastructure"); /** * A service for manipulating Shopify's Blog Comments API. */ class Comments extends infrastructure_1.BaseService { constructor(shopDomain, accessToken) { super(shopDomain, accessToken, "comments"); } /** * Creates a comment for an article. * @param comment partial comment object with properties for creation * * required fields: * * body (is rendered from Textile markup into HTML in `body_html` field), * * author * * email */ create(comment) { return this.createRequest("POST", ".json", "comment", { comment }); } /** * Updates a comment of an article. * @param id The id of the comment to update. * @param comment partial comment object with properties to update */ update(id, comment) { return this.createRequest("PUT", `${id}.json`, "comment", { comment }); } /** * Gets a count of comments * @param options Options for filtering the result. */ count(options) { return this.createRequest("GET", "count.json", "count", options); } /** * Gets a commect with the given id. * @param id The id of the comment to get. * @param options Options for filtering the result. */ get(id, options) { return this.createRequest("GET", `${id}.json`, "comment", options); } /** * Retrieves a list of up to 250 comments. * @param options Options for pagination and filtering the result. */ list(options) { return this.createRequest("GET", ".json", "comments", options); } /** * Marks the commect with the given id as spam. * @param id The id of the comment to mark as spam. */ spam(id) { return this.createRequest("POST", `${id}/spam.json`); } /** * Marks the commect with the given id as not spam. * @param id The id of the comment to mark as not spam. */ notSpam(id) { return this.createRequest("POST", `${id}/not_spam.json`); } /** * Approves the comment with the given id. * @param id The id of the comment to approve. */ approve(id) { return this.createRequest("POST", `${id}/approve.json`); } /** * Removes the comment with the given id. * @param id The id of the comment to remove. */ remove(id) { return this.createRequest("POST", `${id}/remove.json`); } /** * Restores the removed comment with the given id. * @param id The id of the removed comment to restore. */ restore(id) { return this.createRequest("POST", `${id}/restore.json`); } } exports.Comments = Comments; exports.default = Comments;