import { ApiResponse , RequestOptions } from '../core' ; import { CancelInvoiceRequest , cancelInvoiceRequestSchema , } from '../models/cancelInvoiceRequest' ; import { CancelInvoiceResponse , cancelInvoiceResponseSchema , } from '../models/cancelInvoiceResponse' ; import { CreateInvoiceRequest , createInvoiceRequestSchema , } from '../models/createInvoiceRequest' ; import { CreateInvoiceResponse , createInvoiceResponseSchema , } from '../models/createInvoiceResponse' ; import { DeleteInvoiceResponse , deleteInvoiceResponseSchema , } from '../models/deleteInvoiceResponse' ; import { GetInvoiceResponse , getInvoiceResponseSchema , } from '../models/getInvoiceResponse' ; import { ListInvoicesResponse , listInvoicesResponseSchema , } from '../models/listInvoicesResponse' ; import { PublishInvoiceRequest , publishInvoiceRequestSchema , } from '../models/publishInvoiceRequest' ; import { PublishInvoiceResponse , publishInvoiceResponseSchema , } from '../models/publishInvoiceResponse' ; import { SearchInvoicesRequest , searchInvoicesRequestSchema , } from '../models/searchInvoicesRequest' ; import { SearchInvoicesResponse , searchInvoicesResponseSchema , } from '../models/searchInvoicesResponse' ; import { UpdateInvoiceRequest , updateInvoiceRequestSchema , } from '../models/updateInvoiceRequest' ; import { UpdateInvoiceResponse , updateInvoiceResponseSchema , } from '../models/updateInvoiceResponse' ; import { number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class InvoicesApi extends BaseApi { param locationId param cursor param limit return async listInvoices ( locationId , cursor ? , limit ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/invoices' ) ; const mapped = req . prepareArgs ( { locationId : [ locationId , string ( ) ] , cursor : [ cursor , optional ( string ( ) ) ] , limit : [ limit , optional ( number ( ) ) ] , } ) ; req . query ( 'location_id' , mapped . locationId ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'limit' , mapped . limit ) ; return req . callAsJson ( listInvoicesResponseSchema , requestOptions ) ; } param body return async createInvoice ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/invoices' ) ; const mapped = req . prepareArgs ( { body : [ body , createInvoiceRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createInvoiceResponseSchema , requestOptions ) ; } param body return async searchInvoices ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/invoices/search' ) ; const mapped = req . prepareArgs ( { body : [ body , searchInvoicesRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( searchInvoicesResponseSchema , requestOptions ) ; } param invoiceId param version return async deleteInvoice ( invoiceId , version ? , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { invoiceId : [ invoiceId , string ( ) ] , version : [ version , optional ( number ( ) ) ] , } ) ; req . query ( 'version' , mapped . version ) ; req . appendTemplatePath `/v2/invoices/${ mapped . invoiceId }` ; return req . callAsJson ( deleteInvoiceResponseSchema , requestOptions ) ; } param invoiceId return async getInvoice ( invoiceId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { invoiceId : [ invoiceId , string ( ) ] } ) ; req . appendTemplatePath `/v2/invoices/${ mapped . invoiceId }` ; return req . callAsJson ( getInvoiceResponseSchema , requestOptions ) ; } param invoiceId param body return async updateInvoice ( invoiceId , body , requestOptions ? ) { const req = this . createRequest ( 'PUT' ) ; const mapped = req . prepareArgs ( { invoiceId : [ invoiceId , string ( ) ] , body : [ body , updateInvoiceRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/invoices/${ mapped . invoiceId }` ; return req . callAsJson ( updateInvoiceResponseSchema , requestOptions ) ; } param invoiceId param body return async cancelInvoice ( invoiceId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { invoiceId : [ invoiceId , string ( ) ] , body : [ body , cancelInvoiceRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/invoices/${ mapped . invoiceId }/cancel` ; return req . callAsJson ( cancelInvoiceResponseSchema , requestOptions ) ; } param invoiceId param body return async publishInvoice ( invoiceId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { invoiceId : [ invoiceId , string ( ) ] , body : [ body , publishInvoiceRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/invoices/${ mapped . invoiceId }/publish` ; return req . callAsJson ( publishInvoiceResponseSchema , requestOptions ) ; } }