inventora-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.
46 lines (39 loc) • 1.35 kB
text/typescript
import * as Options from '../options';
import { Location } from '../interfaces';
import { BaseService } from '../infrastructure';
/**
* A service for manipulating a shops Locations API.
*/
export class Locations extends BaseService {
constructor(shopDomain: string, accessToken: string) {
super(shopDomain, accessToken, "locations");
}
/**
* Gets a location with the given id.
* @param id Id of the location being retrieved.
* @param options Options for filtering the result.
*/
public get(id: number, options?: Options.FieldOptions) {
return this.createRequest<Location>("GET", `${id}.json`, "location", options);
}
/**
* Lists up to 250 locations.
* @param options Options for filtering the results.
*/
public list(options?: Options.FieldOptions) {
return this.createRequest<Location[]>("GET", `.json`, "locations", options);
}
/**
* Counts the amount of locations.
*/
public count() {
return this.createRequest<number>("GET", `count.json`, "count");
}
/**
* Lists all the inventory levels on a location.
*/
public inventoryLevels(locationId: number) {
return this.createRequest<Location>("GET", `${locationId}/inventory_levels.json`, "inventory_levels");
}
}
export default Locations;