# All files / codegen/apis InvoicesApi.ts

40.57% Statements 142/350
100% Branches 0/0
0% Functions 0/12
40.57% Lines 142/350

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    3511x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
     /* 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.
     */

    import * as runtime from '../runtime';
    import {
        Invoice,
        InvoiceFromJSON,
        InvoiceToJSON,
        PastInvoices,
        PastInvoicesFromJSON,
        PastInvoicesToJSON,
        Retry,
        RetryFromJSON,
        RetryToJSON,
        UpdateInvoiceStatusArgs,
        UpdateInvoiceStatusArgsFromJSON,
        UpdateInvoiceStatusArgsToJSON,
    } from '../models';

    export interface InvoicesGetRequest {
        startTime?: Date;
        sortDirection?: string;
        forwardSecondarySortOffset?: string;
        limit?: number;
        forwardSortOffset?: string;
        status?: string;
        customerName?: string;
        sortColumn?: string;
    }

    export interface InvoicesInvoiceUuidDeleteRequest {
        invoiceUuid: string;
    }

    export interface InvoicesInvoiceUuidGetRequest {
        invoiceUuid: string;
    }

    export interface InvoicesInvoiceUuidRetriesPostRequest {
        invoiceUuid: string;
        body: object;
    }

    export interface InvoicesInvoiceUuidStatusPostRequest {
        invoiceUuid: string;
        updateInvoiceStatusArgs: UpdateInvoiceStatusArgs;
    }

    export interface InvoicesInvoiceUuidTokenPdfGetRequest {
        invoiceUuidToken: string;
    }

    /**
     *
     */
    export class InvoicesApi extends runtime.BaseAPI {

        /**
         * Fetch a list of historical invoices generated by Octane.
         * Get Past Invoices
         */
        async invoicesGetRaw(requestParameters: InvoicesGetRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<PastInvoices>> {
            const queryParameters: any = {};

            if (requestParameters.startTime !== undefined) {
                queryParameters['start_time'] = (requestParameters.startTime as any).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: runtime.HTTPHeaders = {};

            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) => PastInvoicesFromJSON(jsonValue));
        }

        /**
         * Fetch a list of historical invoices generated by Octane.
         * Get Past Invoices
         */
        async invoicesGet(requestParameters: InvoicesGetRequest = {}, initOverrides?: RequestInit): Promise<PastInvoices> {
            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: InvoicesInvoiceUuidDeleteRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
            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: any = {};

            const headerParameters: runtime.HTTPHeaders = {};

            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: InvoicesInvoiceUuidDeleteRequest, initOverrides?: RequestInit): Promise<void> {
            await this.invoicesInvoiceUuidDeleteRaw(requestParameters, initOverrides);
        }

        /**
         * Get a specific invoice via it\'s UUID.
         * Get Invoice
         */
        async invoicesInvoiceUuidGetRaw(requestParameters: InvoicesInvoiceUuidGetRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Invoice>> {
            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: any = {};

            const headerParameters: runtime.HTTPHeaders = {};

            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) => InvoiceFromJSON(jsonValue));
        }

        /**
         * Get a specific invoice via it\'s UUID.
         * Get Invoice
         */
        async invoicesInvoiceUuidGet(requestParameters: InvoicesInvoiceUuidGetRequest, initOverrides?: RequestInit): Promise<Invoice> {
            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: InvoicesInvoiceUuidRetriesPostRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Retry>> {
            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: any = {};

            const headerParameters: runtime.HTTPHeaders = {};

            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 as any,
            }, initOverrides);

            return new runtime.JSONApiResponse(response, (jsonValue) => 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: InvoicesInvoiceUuidRetriesPostRequest, initOverrides?: RequestInit): Promise<Retry> {
            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: InvoicesInvoiceUuidStatusPostRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<void>> {
            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: any = {};

            const headerParameters: runtime.HTTPHeaders = {};

            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: 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: InvoicesInvoiceUuidStatusPostRequest, initOverrides?: RequestInit): Promise<void> {
            await this.invoicesInvoiceUuidStatusPostRaw(requestParameters, initOverrides);
        }

        /**
         * Return the invoice pdf for the given invoice_uuid, first validating token.
         * Return Invoice PDF
         */
        async invoicesInvoiceUuidTokenPdfGetRaw(requestParameters: InvoicesInvoiceUuidTokenPdfGetRequest, initOverrides?: RequestInit): Promise<runtime.ApiResponse<Error>> {
            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: any = {};

            const headerParameters: runtime.HTTPHeaders = {};

            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) as any;
        }

        /**
         * Return the invoice pdf for the given invoice_uuid, first validating token.
         * Return Invoice PDF
         */
        async invoicesInvoiceUuidTokenPdfGet(requestParameters: InvoicesInvoiceUuidTokenPdfGetRequest, initOverrides?: RequestInit): Promise<Error> {
            const response = await this.invoicesInvoiceUuidTokenPdfGetRaw(requestParameters, initOverrides);
            return await response.value();
        }

    }