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.

52 lines (51 loc) 1.83 kB
/** * @fileoverview Client for querying and sending messages in the Sharetribe Marketplace API. * * Use this to read conversation history and send messages in transactions. * Messages are tied to a specific transaction (order/inquiry). * * @see https://www.sharetribe.com/api-reference/marketplace.html#messages */ import type { AxiosResponse } from "axios"; import MarketplaceApi from "./index"; import { ExtraParameter, MessagesQueryParameter, MessagesResponse, MessagesSendParameter } from "../../types"; /** * Messages API client */ declare class Messages { readonly authRequired = true; private readonly axios; private readonly endpoint; private readonly headers; constructor(api: MarketplaceApi); /** * Query messages in a transaction * * @template P * @param {P & MessagesQueryParameter} params * @returns {Promise<AxiosResponse<MessagesResponse<"query", P>>>} * * @example * const { data } = await sdk.messages.query({ * transactionId: "tx-abc123" * }); */ query<P extends MessagesQueryParameter>(params: P): Promise<AxiosResponse<MessagesResponse<"query", P>>>; /** * Send a new message in a transaction * * @template P * @template EP * @param {P & MessagesSendParameter} params * @param {EP} [extraParams] - Optional extra parameters (e.g. `expand: true`) * @returns {Promise<AxiosResponse<MessagesResponse<"send", P, EP>>>} * * @example * await sdk.messages.send({ * transactionId: "tx-abc123", * content: "Hi! When are you available?" * }); */ send<P extends MessagesSendParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<MessagesResponse<"send", P, EP>>>; } export default Messages;