BillingService
Import from @infrared-city/infrared-sdk/billing.
Reads the API's public price list. Available as InfraredClient.billing.
Constructors
Constructor
new BillingService(options):BillingService
Creates the service from the client's base URL, credentials and transport settings.
Parameters
| Parameter | Type |
|---|---|
options | ServiceOptions |
Returns
BillingService
Methods
getPublicPricing()
getPublicPricing():Promise<PublicPricing>
Fetches the current public price list.
Returns
Promise<PublicPricing>
The PublicPricing document.
Throws
Error when the API returns an empty response, or the request fails.
quote()
quote(analysisType):Promise<PriceQuote>
The price of one job of an analysis, from the price list. The client keeps the list for 20 minutes; pricingSource says whether the price is "live", "cached" or "stale" (the list could not be fetched again).
Parameters
| Parameter | Type | Description |
|---|---|---|
analysisType | string | The analysis to price. |
Returns
Promise<PriceQuote>
Throws
when the list cannot be fetched and the client has none.
estimateWorkflowRunTokens
Import from @infrared-city/infrared-sdk/billing.
estimateWorkflowRunTokens(pricing,workflowId,areaKm2): \{bracket:string;tokens:number; \} \|null
The tokens a workflow run over an area costs, according to a price list.
Parameters
| Parameter | Type | Description |
|---|---|---|
pricing | PublicPricing | The price list from BillingService.getPublicPricing. |
workflowId | string | The workflow to price. |
areaKm2 | number | The area in square kilometres. |
Returns
\{ bracket: string; tokens: number; \} \| null
The token cost and the bracket it was priced in, or null when no bracket fits the area or the workflow has no price for that bracket.
PriceQuote
Import from @infrared-city/infrared-sdk.
One job's price for an analysis, with where the price came from.
Extended by
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
pricingSource | readonly | PricingSource | Where the price came from. |
pricingVersion? | readonly | string | The version of the price list, when it has one. |
tokensPerJob | readonly | number | The tokens charged for one job of the analysis. |
PricingSource
Import from @infrared-city/infrared-sdk.
PricingSource ="live"\|"cached"\|"stale"
Where a price came from: "live" (just fetched), "cached" (fetched less than 20 minutes ago) or "stale" (older, because the fetch failed).
PublicPricing
Import from @infrared-city/infrared-sdk/billing.
The price list the API publishes, as returned by BillingService.getPublicPricing. Every section is optional, and any further fields the API adds are kept under their own names.
Indexable
\[extra:string\]:unknown
Properties
resolveBracketName
Import from @infrared-city/infrared-sdk/billing.
resolveBracketName(pricing,areaKm2):string\|null
The name of the area bracket that an area falls in, according to a price list. Brackets are checked from the smallest upper limit up, and a bracket with no upper limit matches any area.
Parameters
| Parameter | Type | Description |
|---|---|---|
pricing | PublicPricing | The price list from BillingService.getPublicPricing. |
areaKm2 | number | The area in square kilometres. |
Returns
string \| null
The bracket name, or null when the price list has no bracket that fits.
resolveTokensPerJob
Import from @infrared-city/infrared-sdk.
resolveTokensPerJob(pricing,analysisType):number
The tokens one job of an analysis costs, from a price list you already hold.
Parameters
| Parameter | Type | Description |
|---|---|---|
pricing | PublicPricing | The price list from BillingService.getPublicPricing. |
analysisType | AnalysesName | The analysis to price. |
Returns
number
The tokens for one job, from analysisType..
Deprecated
Use await client.billing.quote(analysisType), which reads and keeps the price list itself. Removed in 2.0.
Throws
Error when the list has no price for the analysis. The 1.0.x call returned 10 here; the SDK has no built-in price now.
RunEstimate
Import from @infrared-city/infrared-sdk.
The cost and time estimate of a planned run, with the price it used.
Extends
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
estimatedCostTokens | readonly | number | - | - |
estimatedTimeS | readonly | number | - | - |
pricingSource | readonly | PricingSource | Where the price came from. | PriceQuote.pricingSource |
pricingVersion? | readonly | string | The version of the price list, when it has one. | PriceQuote.pricingVersion |
tokensPerJob | readonly | number | The tokens charged for one job of the analysis. | PriceQuote.tokensPerJob |