Meters
The 6 operations under meters, as typed calls on the generated REST client.
Available from @codespar/sdk 0.12.0; the version on npm is 0.16.11. Every example on this page is compiled against the installed package when these docs build: a call that does not type-check fails the build.
Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.
import { } from "@codespar/sdk";
const = new ({ : .. });GET /v1/meters
List the project's meters with their cycle figures
const result = await cs.api.get("/v1/meters");This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/meters in the HTTP reference.
POST /v1/meters
Define a meter on a usage event
const result = await cs.api.post("/v1/meters", {
body: {
event_name: "Example",
aggregation: "count",
price: 0,
per_units: 1,
unit_label: "Example",
description: "string",
channel: "invoice"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/meters in the HTTP reference.
GET /v1/meters/cycle
The meter cycle: progress, totals and totals by channel
const result = await cs.api.get("/v1/meters/cycle");This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/meters/cycle in the HTTP reference.
GET /v1/meters/{meterId}
Read one meter with its cycle figures
const result = await cs.api.get("/v1/meters/{meterId}", {
path: {
meterId: "meter_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/meters/{meterId} in the HTTP reference.
GET /v1/meters/{meterId}/events
A meter's latest events
const result = await cs.api.get("/v1/meters/{meterId}/events", {
path: {
meterId: "meter_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/meters/{meterId}/events in the HTTP reference.
GET /v1/meters/{meterId}/usage
A meter's usage on each day of the cycle
const result = await cs.api.get("/v1/meters/{meterId}/usage", {
path: {
meterId: "meter_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/meters/{meterId}/usage in the HTTP reference.