/* tslint:disable */ /* eslint-disable */ /** * Sonatype Guide API * REST API into [Sonatype Guide](https://guide.sonatype.com). * * The version of the OpenAPI document: 202607 * * * 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 type { BillingDTO, Invoice, PlanDTO, } from '../models/index'; import { BillingDTOFromJSON, BillingDTOToJSON, InvoiceFromJSON, InvoiceToJSON, PlanDTOFromJSON, PlanDTOToJSON, } from '../models/index'; export interface BillingApiGetInvoicePdfRequest { invoiceId: string; } /** * */ export class BillingApi extends runtime.BaseAPI { /** * Retrieves billing details including cost, period, and payment method * Get billing information */ async getBillingRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/billing`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => BillingDTOFromJSON(jsonValue)); } /** * Retrieves billing details including cost, period, and payment method * Get billing information */ async getBilling(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getBillingRaw(initOverrides); return await response.value(); } /** * Redirects to a temporary Chargebee download URL for the invoice PDF. The URL is short-lived and should be consumed immediately. * Download invoice PDF */ async getInvoicePdfRaw(requestParameters: BillingApiGetInvoicePdfRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['invoiceId'] == null) { throw new runtime.RequiredError( 'invoiceId', 'Required parameter "invoiceId" was null or undefined when calling getInvoicePdf().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/billing/invoices/{invoiceId}/pdf`; urlPath = urlPath.replace(`{${"invoiceId"}}`, encodeURIComponent(String(requestParameters['invoiceId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Redirects to a temporary Chargebee download URL for the invoice PDF. The URL is short-lived and should be consumed immediately. * Download invoice PDF */ async getInvoicePdf(requestParameters: BillingApiGetInvoicePdfRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.getInvoicePdfRaw(requestParameters, initOverrides); } /** * Retrieves all active subscription plans with dynamic Chargebee pricing. Supports both authenticated and unauthenticated requests. When authenticated, the user\'s current plan is marked. * Get all available plans */ async getPlansRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/billing/plans`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PlanDTOFromJSON)); } /** * Retrieves all active subscription plans with dynamic Chargebee pricing. Supports both authenticated and unauthenticated requests. When authenticated, the user\'s current plan is marked. * Get all available plans */ async getPlans(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.getPlansRaw(initOverrides); return await response.value(); } /** * Retrieves the complete invoice history for the current user. Returns a list of all invoices with details including invoice ID, date, description, amount, payment status, PDF link, and credit usage for each billing period. * Get user invoice history */ async getUserInvoiceHistoryRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/billing/invoices`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response) as any; } } /** * Retrieves the complete invoice history for the current user. Returns a list of all invoices with details including invoice ID, date, description, amount, payment status, PDF link, and credit usage for each billing period. * Get user invoice history */ async getUserInvoiceHistory(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getUserInvoiceHistoryRaw(initOverrides); return await response.value(); } }