/**
 * Billing Center Gateway API
 * This site describes all the Rest endpoints of Billing Center Gateway.
 * OpenAPI spec version: 20191001
 * Contact: osp_team_oci_cam_ww_grp@oracle.com
 *
 * NOTE: This class is auto generated by OracleSDKGenerator.
 * Do not edit the class manually.
 *
 * Copyright (c) 2020, 2022, Oracle and/or its affiliates.  All rights reserved.
 * This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
 */ import common = require ( "oci-common" ) ; import * as requests from "./request" ; import * as model from "./model" ; import * as responses from "./response" ; import { composeResponse , composeRequest , GenericRetrier } from "oci-common" ; export enum InvoiceServiceApiKeys { } /**
 * This service client uses  common . CircuitBreaker . DefaultConfiguration for all the operations by default if no circuit breaker configuration is defined by the user.
  export class InvoiceServiceClient { protected static serviceEndpointTemplate = "https://ospap.oracle.com" ; protected "_endpoint" : string = "" ; protected "_defaultHeaders" : any = { } ; protected "_clientConfiguration" : common . ClientConfiguration ; protected _circuitBreaker = null ; protected _httpClient : common . HttpClient ; constructor ( params , clientConfiguration ? ) { const requestSigner = params . authenticationDetailsProvider ? new common . DefaultRequestSigner ( params . authenticationDetailsProvider ) : null ; if ( clientConfiguration ) { this . _clientConfiguration = clientConfiguration ; this . _circuitBreaker = clientConfiguration . circuitBreaker ? clientConfiguration . circuitBreaker ! . circuit : null ; } const specCircuitBreakerEnabled = true ; if ( ! this . _circuitBreaker && common . utils . isCircuitBreakerSystemEnabled ( clientConfiguration ! ) && ( specCircuitBreakerEnabled || common . CircuitBreaker . DefaultCircuitBreakerOverriden ) ) { this . _circuitBreaker = new common . CircuitBreaker ( ) . circuit ; } this . _httpClient = params . httpClient || new common . FetchHttpClient ( requestSigner , this . _circuitBreaker ) ; if ( params . authenticationDetailsProvider && common . isRegionProvider ( params . authenticationDetailsProvider ) ) { const provider = params . authenticationDetailsProvider ; if ( provider . getRegion ( ) ) { this . region = provider . getRegion ( ) ; } } } /**
     * Get the endpoint that is being used to call (ex, https://www.example.com).
     */ public get endpoint ( ) { return this . _endpoint ; } param endpoint public set endpoint ( endpoint ) { this . _endpoint = endpoint ; this . _endpoint = this . _endpoint + "/20191001" ; if ( this . logger ) this . logger . info ( `InvoiceServiceClient endpoint set to ${ this . _endpoint }` ) ; } public get logger ( ) { return common . LOG . logger ; } /**
     * Sets the region to call (ex, Region.US_PHOENIX_1).
     * Note, this will call  {@link #endpoint(String) endpoint} after resolving the endpoint.
     *  param region public set region ( region ) { this . endpoint = common . EndpointBuilder . createEndpointFromRegion ( InvoiceServiceClient . serviceEndpointTemplate , region ) ; } /**
     * Sets the regionId to call (ex, 'us-phoenix-1').
     *
     * Note, this will first try to map the region ID to a known Region and call  {@link #region(Region) region} .
     * If no known Region could be determined, it will create an endpoint assuming its in default Realm OC1
     * and then call  {@link #endpoint(String) endpoint} .
     *  param regionId public set regionId ( regionId ) { this . endpoint = common . EndpointBuilder . createEndpointFromRegionId ( InvoiceServiceClient . serviceEndpointTemplate , regionId ) ; } param DownloadPdfContentRequest return throws example Click  https to see how to use DownloadPdfContent API.
      public async downloadPdfContent ( downloadPdfContentRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation InvoiceServiceClient#downloadPdfContent." ) ; const pathParams = { "{internalInvoiceId}" : downloadPdfContentRequest . internalInvoiceId } ; const queryParams = { "ospHomeRegion" : downloadPdfContentRequest . ospHomeRegion , "compartmentId" : downloadPdfContentRequest . compartmentId } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : downloadPdfContentRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , downloadPdfContentRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/invoices/{internalInvoiceId}/actions/downloadPdfContent" , method : "POST" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . DownloadPdfContentResponse > { } , body : response . body ! , bodyKey : "value" , bodyModel : "string" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "Content-Disposition" ) , key : "contentDisposition" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param GetInvoiceRequest return throws example Click  https to see how to use GetInvoice API.
      public async getInvoice ( getInvoiceRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation InvoiceServiceClient#getInvoice." ) ; const pathParams = { "{internalInvoiceId}" : getInvoiceRequest . internalInvoiceId } ; const queryParams = { "ospHomeRegion" : getInvoiceRequest . ospHomeRegion , "compartmentId" : getInvoiceRequest . compartmentId } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : getInvoiceRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , getInvoiceRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/invoices/{internalInvoiceId}" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . GetInvoiceResponse > { } , body : await response . json ( ) , bodyKey : "invoice" , bodyModel : model . Invoice , type : "model.Invoice" , responseHeaders : [ { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } , { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ListInvoiceLinesRequest return throws example Click  https to see how to use ListInvoiceLines API.
      public async listInvoiceLines ( listInvoiceLinesRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation InvoiceServiceClient#listInvoiceLines." ) ; const pathParams = { "{internalInvoiceId}" : listInvoiceLinesRequest . internalInvoiceId } ; const queryParams = { "ospHomeRegion" : listInvoiceLinesRequest . ospHomeRegion , "compartmentId" : listInvoiceLinesRequest . compartmentId , "page" : listInvoiceLinesRequest . page , "limit" : listInvoiceLinesRequest . limit } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listInvoiceLinesRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listInvoiceLinesRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/invoices/{internalInvoiceId}/invoiceLines" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListInvoiceLinesResponse > { } , body : await response . json ( ) , bodyKey : "invoiceLineCollection" , bodyModel : model . InvoiceLineCollection , type : "model.InvoiceLineCollection" , responseHeaders : [ { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } , { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } , { value : response . headers . get ( "opc-total-items" ) , key : "opcTotalItems" , dataType : "number" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param ListInvoicesRequest return throws example Click  https to see how to use ListInvoices API.
      public async listInvoices ( listInvoicesRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation InvoiceServiceClient#listInvoices." ) ; const pathParams = { } ; const queryParams = { "ospHomeRegion" : listInvoicesRequest . ospHomeRegion , "compartmentId" : listInvoicesRequest . compartmentId , "invoiceId" : listInvoicesRequest . invoiceId , "type" : listInvoicesRequest . type , "searchText" : listInvoicesRequest . searchText , "timeInvoiceStart" : listInvoicesRequest . timeInvoiceStart , "timeInvoiceEnd" : listInvoicesRequest . timeInvoiceEnd , "timePaymentStart" : listInvoicesRequest . timePaymentStart , "timePaymentEnd" : listInvoicesRequest . timePaymentEnd , "status" : listInvoicesRequest . status , "page" : listInvoicesRequest . page , "limit" : listInvoicesRequest . limit , "sortBy" : listInvoicesRequest . sortBy , "sortOrder" : listInvoicesRequest . sortOrder } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "opc-request-id" : listInvoicesRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , listInvoicesRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/invoices" , method : "GET" , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . ListInvoicesResponse > { } , body : await response . json ( ) , bodyKey : "invoiceCollection" , bodyModel : model . InvoiceCollection , type : "model.InvoiceCollection" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "opc-next-page" ) , key : "opcNextPage" , dataType : "string" } , { value : response . headers . get ( "opc-total-items" ) , key : "opcTotalItems" , dataType : "number" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } param PayInvoiceRequest return throws example Click  https to see how to use PayInvoice API.
      public async payInvoice ( payInvoiceRequest ) { if ( this . logger ) this . logger . debug ( "Calling operation InvoiceServiceClient#payInvoice." ) ; const pathParams = { "{internalInvoiceId}" : payInvoiceRequest . internalInvoiceId } ; const queryParams = { "ospHomeRegion" : payInvoiceRequest . ospHomeRegion , "compartmentId" : payInvoiceRequest . compartmentId } ; let headerParams = { "Content-Type" : common . Constants . APPLICATION_JSON , "if-match" : payInvoiceRequest . ifMatch , "opc-retry-token" : payInvoiceRequest . opcRetryToken , "opc-request-id" : payInvoiceRequest . opcRequestId } ; const specRetryConfiguration = common . NoRetryConfigurationDetails ; const retrier = GenericRetrier . createPreferredRetrier ( this . _clientConfiguration ? this . _clientConfiguration . retryConfiguration : undefined , payInvoiceRequest . retryConfiguration , specRetryConfiguration ) ; if ( this . logger ) retrier . logger = this . logger ; const request = await composeRequest ( { baseEndpoint : this . _endpoint , defaultHeaders : this . _defaultHeaders , path : "/invoices/{internalInvoiceId}/actions/pay" , method : "POST" , bodyContent : common . ObjectSerializer . serialize ( payInvoiceRequest . payInvoiceDetails , "PayInvoiceDetails" , model . PayInvoiceDetails . getJsonObj ) , pathParams : pathParams , headerParams : headerParams , queryParams : queryParams } ) ; try { const response = await retrier . makeServiceCall ( this . _httpClient , request ) ; const sdkResponse = composeResponse ( { responseObject : < responses . PayInvoiceResponse > { } , body : await response . json ( ) , bodyKey : "payInvoiceReceipt" , bodyModel : model . PayInvoiceReceipt , type : "model.PayInvoiceReceipt" , responseHeaders : [ { value : response . headers . get ( "opc-request-id" ) , key : "opcRequestId" , dataType : "string" } , { value : response . headers . get ( "etag" ) , key : "etag" , dataType : "string" } ] } ) ; return sdkResponse ; } catch ( err ) { throw err ; } } }