@vansite/ts-sharetribe-flex-sdk
Version:
This is a TypeScript SDK for Sharetribe Flex API. It reduces the complexity of the API and provides a more user-friendly interface.
65 lines (64 loc) • 2.33 kB
TypeScript
/**
* @fileoverview Client for managing manual stock adjustments in the Sharetribe Marketplace API.
*
* Stock adjustments are used for restocking, write-offs, corrections, or any manual change
* that doesn’t come from a booking or reservation.
*
* @see https://www.sharetribe.com/api-reference/marketplace.html#stock-adjustments
*/
import type { AxiosResponse } from "axios";
import MarketplaceApi from "./index";
import { ExtraParameter, StockAdjustmentsCreateParameter, StockAdjustmentsQueryParameter, StockAdjustmentsResponse } from "../../types";
/**
* Stock Adjustments API client (own listings only)
*/
declare class StockAdjustments {
readonly authRequired = true;
private readonly axios;
private readonly endpoint;
private readonly headers;
constructor(api: MarketplaceApi);
/**
* Query stock adjustment history
*
* @template P
* @param {P & StockAdjustmentsQueryParameter} params
* @returns {Promise<AxiosResponse<StockAdjustmentsResponse<"query", P>>>}
*
* @example
* const { data } = await sdk.stockAdjustments.query({
* listingId: "listing-abc123",
* start: "2025-01-01",
* end: "2025-01-31"
* });
*/
query<P extends StockAdjustmentsQueryParameter>(params: P): Promise<AxiosResponse<StockAdjustmentsResponse<"query", P>>>;
/**
* Create a manual stock adjustment
*
* Positive quantity → add stock
* Negative quantity → remove stock
*
* @template P
* @template EP
* @param {P & StockAdjustmentsCreateParameter} params
* @param {EP} [extraParams] - Optional extra parameters (e.g. `expand: true`)
* @returns {Promise<AxiosResponse<StockAdjustmentsResponse<"create", P, EP>>>}
*
* @example
* // Restock 50 units
* await sdk.stockAdjustments.create({
* listingId: "listing-abc123",
* quantity: 50
* });
*
* @example
* // Write off 3 damaged units
* await sdk.stockAdjustments.create({
* listingId: "listing-abc123",
* quantity: -3
* });
*/
create<P extends StockAdjustmentsCreateParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<StockAdjustmentsResponse<"create", P, EP>>>;
}
export default StockAdjustments;