@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.
37 lines (36 loc) • 1.36 kB
TypeScript
/**
* @fileoverview Client for uploading images in the Sharetribe Integration API.
*
* Images uploaded via this endpoint can be attached to listings, user profiles, or used as assets.
*
* @see https://www.sharetribe.com/api-reference/integration.html#images
*/
import type { AxiosResponse } from "axios";
import IntegrationApi from "./index";
import { ExtraParameter, ImagesResponse, ImagesUploadParameter } from "../../types";
/**
* Images API client
*/
declare class Images {
readonly authRequired = true;
private readonly axios;
private readonly endpoint;
private readonly headers;
constructor(api: IntegrationApi);
/**
* Upload an image
*
* @template P
* @template EP
* @param {P & ImagesUploadParameter} params - Upload parameters (must include `image: File`)
* @param {EP} [extraParams] - Optional extra parameters (e.g. `expand: true`)
* @returns {Promise<AxiosResponse<ImagesResponse<"upload", EP>>>}
*
* @example
* const file = input.files[0];
* const { data } = await sdk.images.upload({ image: file });
* console.log(data.id); // → "img-abc123"
*/
upload<P extends ImagesUploadParameter, EP extends ExtraParameter | undefined = undefined>(params: P, extraParams?: EP): Promise<AxiosResponse<ImagesResponse<"upload", EP>>>;
}
export default Images;