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.

86 lines (85 loc) 3.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Articles = void 0; const infrastructure_1 = require("../infrastructure"); /** * A service for manipulating a blog's articles. */ class Articles extends infrastructure_1.BaseService { constructor(shopDomain, accessToken) { super(shopDomain, accessToken, ""); } /** * Creates a new article. * @param blogId Id of the blog that the article will belong to. * @param article The article being created. */ create(blogId, article) { return this.createRequest("POST", `blogs/${blogId}/articles.json`, "article", { article }); } /** * Updates an article with the given id. * @param blogId Id of the blog that the article belongs to. * @param articleId Id of the article to update. * @param article The updated article. */ update(blogId, articleId, article) { return this.createRequest("PUT", `blogs/${blogId}/articles/${articleId}.json`, "article", { article }); } /** * Gets an article with the given id. * @param blogId Id of the blog that the article belongs to. * @param articleId Id of the article being retrieved. * @param options Options for filtering the result. */ get(blogId, articleId, options) { return this.createRequest("GET", `blogs/${blogId}/articles/${articleId}.json`, "article", options); } /** * Lists up to 250 articles for the given blog. * @param blogId Id of the blog that the articles belong to. * @param options Options for filtering the results. */ list(blogId, options) { return this.createRequest("GET", `blogs/${blogId}/articles.json`, "articles", options); } /** * Counts the articles on the given blog. * @param blogId Id of the blog that the articles belong to. * @param options Options for filtering the results. */ count(blogId, options) { return this.createRequest("GET", `blogs/${blogId}/articles/count.json`, "count", options); } /** * Deletes the article with the given id. * @param blogId Id of the blog that the article belongs to. * @param articleId Id of the article to delete. */ delete(blogId, articleId) { return this.createRequest("DELETE", `blogs/${blogId}/articles/${articleId}.json`); } /** * Gets a list of all article authors. */ listAuthors(options) { return this.createRequest("GET", `articles/authors.json`, "authors", options); } /** * Gets a list of all article tags. * @param options Options for filtering the results. */ listTags(options) { return this.createRequest("GET", `articles/tags.json`, "tags", options); } /** * Gets a list of all article tags for the given blog. * @param blogId Id of the blog that the tags belong to. * @param options Options for filtering the results. */ listTagsForBlog(blogId, options) { return this.createRequest("GET", `blogs/${blogId}/articles/tags.json`, "tags", options); } } exports.Articles = Articles; exports.default = Articles;