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.
48 lines (47 loc) • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Assets = void 0;
const infrastructure_1 = require("../infrastructure");
/**
* A service for manipulating a Shopify shop's theme asset.
*/
class Assets extends infrastructure_1.BaseService {
constructor(shopDomain, accessToken) {
super(shopDomain, accessToken, "themes");
}
/**
* Retrieves a single asset for a theme
* @param id Id of the theme.
* @param key he path to the asset within a theme.
* @param options Options for filtering the result.
*/
get(id, key, options) {
return this.createRequest("GET", `${id}/assets.json?asset[key]=${key}&theme_id=${id}`, "asset", options);
}
/**
* Creates or updates an asset for a theme.
* You can include the `src` or `source_key` property to create the asset from an existing file.
* @param id Id of the assets being updated.
* @param assets The updated asset.
*/
update(id, asset) {
return this.createRequest("PUT", `${id}/assets.json`, "asset", { asset });
}
/**
* Retrieves a list of assets for a theme
* @param id Id of the theme.
* @param options Options for filtering the results.
*/
list(id, options) {
return this.createRequest("GET", `${id}/assets.json`, "assets", options);
}
/**
* Deletes the assets with the given id.
* @param id Id of the asset being deleted.
*/
delete(id) {
return this.createRequest("DELETE", `${id}/assets.json`, "");
}
}
exports.Assets = Assets;
exports.default = Assets;