UNPKG

@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.

46 lines (45 loc) 1.43 kB
/** * @fileoverview Client for querying bookings in the Sharetribe Marketplace API. * * Use this to fetch your own bookings or bookings for listings you own. * Only returns data the current user is authorized to see. * * @see https://www.sharetribe.com/api-reference/marketplace.html#bookings */ import type { AxiosResponse } from "axios"; import MarketplaceApi from "./index"; import { BookingsQueryParameter, BookingsResponse } from "../../types"; /** * Bookings API client (own bookings only) */ declare class Bookings { readonly authRequired = true; private readonly axios; private readonly endpoint; private readonly headers; constructor(api: MarketplaceApi); /** * Query your own bookings * * @template P * @param {P & BookingsQueryParameter} params * @returns {Promise<AxiosResponse<BookingsResponse<"query", P>>>} * * @example * // Fetch all bookings for one of your listings * const { data } = await sdk.bookings.query({ * listingId: "listing-abc123", * start: "2025-01-01", * end: "2025-01-31" * }); * * @example * // Fetch upcoming bookings * await sdk.bookings.query({ * start: new Date().toISOString(), * state: "accepted" * }); */ query<P extends BookingsQueryParameter>(params: P): Promise<AxiosResponse<BookingsResponse<"query", P>>>; } export default Bookings;