"use strict";
/* tslint:disable */
/* eslint-disable */
/**
 * Octane API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvoicesApi = void 0;
const runtime = __importStar(require("../runtime"));
const models_1 = require("../models");
/**
 *
 */
class InvoicesApi extends runtime.BaseAPI {
    /**
     * Fetch a list of historical invoices generated by Octane.
     * Get Past Invoices
     */
    async invoicesGetRaw(requestParameters, initOverrides) {
        const queryParameters = {};
        if (requestParameters.startTime !== undefined) {
            queryParameters['start_time'] = requestParameters.startTime.toISOString();
        }
        if (requestParameters.sortDirection !== undefined) {
            queryParameters['sort_direction'] = requestParameters.sortDirection;
        }
        if (requestParameters.forwardSecondarySortOffset !== undefined) {
            queryParameters['forward_secondary_sort_offset'] = requestParameters.forwardSecondarySortOffset;
        }
        if (requestParameters.limit !== undefined) {
            queryParameters['limit'] = requestParameters.limit;
        }
        if (requestParameters.forwardSortOffset !== undefined) {
            queryParameters['forward_sort_offset'] = requestParameters.forwardSortOffset;
        }
        if (requestParameters.status !== undefined) {
            queryParameters['status'] = requestParameters.status;
        }
        if (requestParameters.customerName !== undefined) {
            queryParameters['customer_name'] = requestParameters.customerName;
        }
        if (requestParameters.sortColumn !== undefined) {
            queryParameters['sort_column'] = requestParameters.sortColumn;
        }
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("BearerApiKeyAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/invoices/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.PastInvoicesFromJSON)(jsonValue));
    }
    /**
     * Fetch a list of historical invoices generated by Octane.
     * Get Past Invoices
     */
    async invoicesGet(requestParameters = {}, initOverrides) {
        const response = await this.invoicesGetRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Delete a specific invoice via it\'s UUID. Invoices can only be deleted if they have not been issued.
     * Delete Invoice
     */
    async invoicesInvoiceUuidDeleteRaw(requestParameters, initOverrides) {
        if (requestParameters.invoiceUuid === null || requestParameters.invoiceUuid === undefined) {
            throw new runtime.RequiredError('invoiceUuid', 'Required parameter requestParameters.invoiceUuid was null or undefined when calling invoicesInvoiceUuidDelete.');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("BearerApiKeyAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/invoices/{invoice_uuid}`.replace(`{${"invoice_uuid"}}`, encodeURIComponent(String(requestParameters.invoiceUuid))),
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Delete a specific invoice via it\'s UUID. Invoices can only be deleted if they have not been issued.
     * Delete Invoice
     */
    async invoicesInvoiceUuidDelete(requestParameters, initOverrides) {
        await this.invoicesInvoiceUuidDeleteRaw(requestParameters, initOverrides);
    }
    /**
     * Get a specific invoice via it\'s UUID.
     * Get Invoice
     */
    async invoicesInvoiceUuidGetRaw(requestParameters, initOverrides) {
        if (requestParameters.invoiceUuid === null || requestParameters.invoiceUuid === undefined) {
            throw new runtime.RequiredError('invoiceUuid', 'Required parameter requestParameters.invoiceUuid was null or undefined when calling invoicesInvoiceUuidGet.');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("BearerApiKeyAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/invoices/{invoice_uuid}`.replace(`{${"invoice_uuid"}}`, encodeURIComponent(String(requestParameters.invoiceUuid))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.InvoiceFromJSON)(jsonValue));
    }
    /**
     * Get a specific invoice via it\'s UUID.
     * Get Invoice
     */
    async invoicesInvoiceUuidGet(requestParameters, initOverrides) {
        const response = await this.invoicesInvoiceUuidGetRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Moves the invoice into the next logical action. For example, an invoice that is generated gets moved to issued, and an invoice that is in payment error tries payment again. For more information see our docs https://docs.getoctane.io/docs/manual-invoicing-triggers.
     * Create Retry
     */
    async invoicesInvoiceUuidRetriesPostRaw(requestParameters, initOverrides) {
        if (requestParameters.invoiceUuid === null || requestParameters.invoiceUuid === undefined) {
            throw new runtime.RequiredError('invoiceUuid', 'Required parameter requestParameters.invoiceUuid was null or undefined when calling invoicesInvoiceUuidRetriesPost.');
        }
        if (requestParameters.body === null || requestParameters.body === undefined) {
            throw new runtime.RequiredError('body', 'Required parameter requestParameters.body was null or undefined when calling invoicesInvoiceUuidRetriesPost.');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("BearerApiKeyAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/invoices/{invoice_uuid}/retries`.replace(`{${"invoice_uuid"}}`, encodeURIComponent(String(requestParameters.invoiceUuid))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: requestParameters.body,
        }, initOverrides);
        return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.RetryFromJSON)(jsonValue));
    }
    /**
     * Moves the invoice into the next logical action. For example, an invoice that is generated gets moved to issued, and an invoice that is in payment error tries payment again. For more information see our docs https://docs.getoctane.io/docs/manual-invoicing-triggers.
     * Create Retry
     */
    async invoicesInvoiceUuidRetriesPost(requestParameters, initOverrides) {
        const response = await this.invoicesInvoiceUuidRetriesPostRaw(requestParameters, initOverrides);
        return await response.value();
    }
    /**
     * Manually change the status of an invoice in Octane. For example, if an invoice was paid outside of Octane\'s payment providers, you can reflect that in Octane by setting the status to paid.
     * Update Invoice Status
     */
    async invoicesInvoiceUuidStatusPostRaw(requestParameters, initOverrides) {
        if (requestParameters.invoiceUuid === null || requestParameters.invoiceUuid === undefined) {
            throw new runtime.RequiredError('invoiceUuid', 'Required parameter requestParameters.invoiceUuid was null or undefined when calling invoicesInvoiceUuidStatusPost.');
        }
        if (requestParameters.updateInvoiceStatusArgs === null || requestParameters.updateInvoiceStatusArgs === undefined) {
            throw new runtime.RequiredError('updateInvoiceStatusArgs', 'Required parameter requestParameters.updateInvoiceStatusArgs was null or undefined when calling invoicesInvoiceUuidStatusPost.');
        }
        const queryParameters = {};
        const headerParameters = {};
        headerParameters['Content-Type'] = 'application/json';
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("BearerApiKeyAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/invoices/{invoice_uuid}/status/`.replace(`{${"invoice_uuid"}}`, encodeURIComponent(String(requestParameters.invoiceUuid))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: (0, models_1.UpdateInvoiceStatusArgsToJSON)(requestParameters.updateInvoiceStatusArgs),
        }, initOverrides);
        return new runtime.VoidApiResponse(response);
    }
    /**
     * Manually change the status of an invoice in Octane. For example, if an invoice was paid outside of Octane\'s payment providers, you can reflect that in Octane by setting the status to paid.
     * Update Invoice Status
     */
    async invoicesInvoiceUuidStatusPost(requestParameters, initOverrides) {
        await this.invoicesInvoiceUuidStatusPostRaw(requestParameters, initOverrides);
    }
    /**
     * Return the invoice pdf for the given invoice_uuid, first validating token.
     * Return Invoice PDF
     */
    async invoicesInvoiceUuidTokenPdfGetRaw(requestParameters, initOverrides) {
        if (requestParameters.invoiceUuidToken === null || requestParameters.invoiceUuidToken === undefined) {
            throw new runtime.RequiredError('invoiceUuidToken', 'Required parameter requestParameters.invoiceUuidToken was null or undefined when calling invoicesInvoiceUuidTokenPdfGet.');
        }
        const queryParameters = {};
        const headerParameters = {};
        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("BearerApiKeyAuth", []);
            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/invoices/{invoice_uuid_token}/pdf`.replace(`{${"invoice_uuid_token"}}`, encodeURIComponent(String(requestParameters.invoiceUuidToken))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);
        return new runtime.TextApiResponse(response);
    }
    /**
     * Return the invoice pdf for the given invoice_uuid, first validating token.
     * Return Invoice PDF
     */
    async invoicesInvoiceUuidTokenPdfGet(requestParameters, initOverrides) {
        const response = await this.invoicesInvoiceUuidTokenPdfGetRaw(requestParameters, initOverrides);
        return await response.value();
    }
}
exports.InvoicesApi = InvoicesApi;
//# sourceMappingURL=data:application/json;base64, 