"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var upload_service_1 = __importDefault(require("./upload-service"));
var UploadApi = /** @class */ (function () {
    function UploadApi(session) {
        this.uploadService = new upload_service_1.default(session);
    }
    /**
     * Fetches the metadata for a given upload by it's id.
     * The response will also contain signed urls for downloading the upload content or uploading to it.
     * The options contain optional parameters for signing these urls.
     * @param id The upload id to fetch.
     * @param options Search options.
     * @returns The found upload, or null if not found.
     */
    UploadApi.prototype.get = function (id, options) {
        return this.uploadService.get(id, options);
    };
    /**
     * Redirects to download the content of the upload object which matches the given related record.
     * @param id The upload id to fetch.
     * @returns The upload's file content buffer, or null if not found.
     */
    UploadApi.prototype.getContent = function (id) {
        return this.uploadService.getContent(id);
    };
    /**
     * Redirects to download the content of the upload object as an image, allowing to provide image processing options to get a specific image version.
     * The expiration option determines the expiration in seconds of the redirected download url, as well as how long the url will be cached on the server.
     * While cached, for the same request parameters the same redirect url will be returned, allowing better caching for the content.
     * @param id The id of the download image to fetch.
     * @param options Optionally, provide the variation of the image (for example 'thumbnail') and the expiration of the download link.
     * @returns The image content, or null if not found.
     */
    UploadApi.prototype.getImage = function (id, options) {
        return this.uploadService.getImage(id, options);
    };
    /**
     * Fetches the metadata for a given upload by the record it relates to.
     * The response will also contain signed urls for downloading the upload content or uploading to it.
     * The options contain optional parameters for signing these urls.
     * @param recordId The id of the related record.
     * @param recordType The type of the related record.
     * @param attachmentType Optional filter by the attachment type of the upload (in case the record has multiple uploads).
     * @param options Search options.
     * @returns The found upload, or null if not found.
     */
    UploadApi.prototype.getByRecord = function (recordId, recordType, attachmentType, options) {
        return this.uploadService.getByRecord(recordId, recordType, attachmentType, options);
    };
    /**
     * Downloads the content of the upload object which matches the given related record.
     * @param recordId The id of the related record.
     * @param recordType The type of the related record.
     * @param attachmentType Optional filter by the attachment type of the upload (in case the record has multiple uploads).
     * @returns The upload's file content buffer, or null if not found.
     */
    UploadApi.prototype.getContentByRecord = function (recordId, recordType, attachmentType) {
        return this.uploadService.getContentByRecord(recordId, recordType, attachmentType);
    };
    /**
     * Allows fetching multiple uploads metadata on the same request.
     * Returns an empty array if no results found.
     * Each search parameter must include the merchant id, and either the upload's id or record id and type.
     * @param params The search parameters.
     * @param options Optional signature options for the upload and download urls returned on the results.
     * @returns An array of the metadata of the found uploads, with signed urls for uploading and downloading files for it.
     */
    UploadApi.prototype.getBatch = function (params, options) {
        return this.uploadService.getBatch(params, options);
    };
    /**
     * Deletes the given upload.
     * By default, only deletes the upload's metadata which references the file. To also delete the file content, pass the 'content' argument.
     * @param id The upload's id.
     * @param content When true, will also delete the upload content from the storage.
     * @returns true if the upload was deleted; false if it was not found.
     */
    UploadApi.prototype.delete = function (id, content) {
        return this.uploadService.delete(id, content);
    };
    /**
     * Creates an upload, and optionally uploads the given file content to the created upload's destination.
     * If a file is provided and uploaded, a second request to update the upload's 'stored_at' time will be made.
     * @param request The metadata to create the upload with.
     * @param options Optional url signature and file upload options.
     * @param file Optional file content to save for the upload.
     * @returns The id of the created upload.
     */
    UploadApi.prototype.create = function (request, options, file) {
        return this.uploadService.create(request, options, file);
    };
    /**
     * Updates the given upload.
     * @param id The id of the upload to update.
     * @param request The fields to update.
     */
    UploadApi.prototype.update = function (id, request) {
        return this.uploadService.update(id, request);
    };
    return UploadApi;
}());
exports.default = UploadApi;
//# sourceMappingURL=upload-api.js.map