diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d791adb..e3530dc 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,11 +22,30 @@ jobs: with: node-version: '18' - - name: Install dependencies - run: yarn install + - name: Bootstrap + run: ./scripts/bootstrap - name: Check types run: ./scripts/lint + + build: + name: build + runs-on: ubuntu-latest + + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Bootstrap + run: ./scripts/bootstrap + + - name: Check build + run: ./scripts/build test: name: test runs-on: ubuntu-latest diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fd083fc..1779fa5 100755 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-beta.1" + ".": "0.1.0-beta.2" } diff --git a/.stats.yml b/.stats.yml index 95c6e35..91f715c 100755 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 88 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-085bb8699d222fd7950750078c4ea00fb8728477809a8ebc74521a7ad5f32038.yml +configured_endpoints: 90 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-c23134402bb47d1637feabf3d4058720571d9d5d90253a11e2ea818b3add064a.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ab3b4a..827e902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## 0.1.0-beta.2 (2024-09-05) + +Full Changelog: [v0.1.0-beta.1...v0.1.0-beta.2](https://github.com/Metronome-Industries/metronome-node/compare/v0.1.0-beta.1...v0.1.0-beta.2) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#80](https://github.com/Metronome-Industries/metronome-node/issues/80)) ([64ca167](https://github.com/Metronome-Industries/metronome-node/commit/64ca167d1a58a2019335e66f6ce865eddd89a5e0)) +* **api:** OpenAPI spec update via Stainless API ([#83](https://github.com/Metronome-Industries/metronome-node/issues/83)) ([b9b40f8](https://github.com/Metronome-Industries/metronome-node/commit/b9b40f8238a9df6b0a40e46484cf7dd2a37fdf29)) +* **api:** OpenAPI spec update via Stainless API ([#89](https://github.com/Metronome-Industries/metronome-node/issues/89)) ([2189fbb](https://github.com/Metronome-Industries/metronome-node/commit/2189fbbacc85fba4dd92fff6a233fcbde4e2416a)) + + +### Bug Fixes + +* **client:** correct File construction from node-fetch Responses ([#86](https://github.com/Metronome-Industries/metronome-node/issues/86)) ([bd542df](https://github.com/Metronome-Industries/metronome-node/commit/bd542df2dd247dfaec1b7dfb69917bbb7e1eac54)) + + +### Chores + +* **ci:** check for build errors ([#82](https://github.com/Metronome-Industries/metronome-node/issues/82)) ([40011a9](https://github.com/Metronome-Industries/metronome-node/commit/40011a999f06ff27d38e2e854f68ae223249e51f)) +* **ci:** install deps via ./script/bootstrap ([#85](https://github.com/Metronome-Industries/metronome-node/issues/85)) ([14ee02d](https://github.com/Metronome-Industries/metronome-node/commit/14ee02d3651d5038a640676be79dad9f22825140)) +* **internal:** codegen related update ([#84](https://github.com/Metronome-Industries/metronome-node/issues/84)) ([f0753f2](https://github.com/Metronome-Industries/metronome-node/commit/f0753f272509d79b0b6d3be01393dd61c41ecbc2)) +* **internal:** dependency updates ([#87](https://github.com/Metronome-Industries/metronome-node/issues/87)) ([1f4dd86](https://github.com/Metronome-Industries/metronome-node/commit/1f4dd860ab54c4a20eeb15018e6008c667a42dfc)) +* **internal:** minor bump qs version ([#88](https://github.com/Metronome-Industries/metronome-node/issues/88)) ([603491f](https://github.com/Metronome-Industries/metronome-node/commit/603491fecaed5a8004e6ab19ea7d7fbf0f471c0b)) + ## 0.1.0-beta.1 (2024-08-23) Full Changelog: [v0.1.0-beta.0...v0.1.0-beta.1](https://github.com/Metronome-Industries/metronome-node/compare/v0.1.0-beta.0...v0.1.0-beta.1) diff --git a/api.md b/api.md index 9125d3b..1dc0dfb 100755 --- a/api.md +++ b/api.md @@ -258,7 +258,7 @@ Methods: - client.billableMetrics.create({ ...params }) -> BillableMetricCreateResponse - client.billableMetrics.retrieve(billableMetricId) -> BillableMetricRetrieveResponse -- client.billableMetrics.list(customerId, { ...params }) -> BillableMetricListResponsesCursorPage +- client.billableMetrics.list({ ...params }) -> BillableMetricListResponsesCursorPage - client.billableMetrics.archive({ ...params }) -> BillableMetricArchiveResponse # Services @@ -292,6 +292,7 @@ Types: - ContractListResponse - ContractAmendResponse - ContractArchiveResponse +- ContractCreateHistoricalInvoicesResponse - ContractListBalancesResponse - ContractRetrieveRateScheduleResponse - ContractScheduleProServicesInvoiceResponse @@ -305,6 +306,7 @@ Methods: - client.contracts.addManualBalanceEntry({ ...params }) -> void - client.contracts.amend({ ...params }) -> ContractAmendResponse - client.contracts.archive({ ...params }) -> ContractArchiveResponse +- client.contracts.createHistoricalInvoices({ ...params }) -> ContractCreateHistoricalInvoicesResponse - client.contracts.listBalances({ ...params }) -> ContractListBalancesResponse - client.contracts.retrieveRateSchedule({ ...params }) -> ContractRetrieveRateScheduleResponse - client.contracts.scheduleProServicesInvoice({ ...params }) -> ContractScheduleProServicesInvoiceResponse diff --git a/package.json b/package.json index 9ab1c71..afdb5bf 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metronome/sdk", - "version": "0.1.0-beta.1", + "version": "0.1.0-beta.2", "description": "The official TypeScript library for the Metronome API", "author": "Metronome ", "types": "dist/index.d.ts", @@ -26,7 +26,7 @@ "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", - "@types/qs": "^6.9.7", + "@types/qs": "^6.9.15", "abort-controller": "^3.0.0", "agentkeepalive": "^4.2.1", "form-data-encoder": "1.7.2", diff --git a/scripts/lint b/scripts/lint index 4af1de0..6ba75df 100755 --- a/scripts/lint +++ b/scripts/lint @@ -6,3 +6,6 @@ cd "$(dirname "$0")/.." echo "==> Running eslint" ESLINT_USE_FLAT_CONFIG="false" ./node_modules/.bin/eslint --ext ts,js . + +echo "==> Running tsc" +./node_modules/.bin/tsc --noEmit diff --git a/src/index.ts b/src/index.ts index 68ac4ae..f56e78a 100755 --- a/src/index.ts +++ b/src/index.ts @@ -322,6 +322,7 @@ export namespace Metronome { export import ContractListResponse = API.ContractListResponse; export import ContractAmendResponse = API.ContractAmendResponse; export import ContractArchiveResponse = API.ContractArchiveResponse; + export import ContractCreateHistoricalInvoicesResponse = API.ContractCreateHistoricalInvoicesResponse; export import ContractListBalancesResponse = API.ContractListBalancesResponse; export import ContractRetrieveRateScheduleResponse = API.ContractRetrieveRateScheduleResponse; export import ContractScheduleProServicesInvoiceResponse = API.ContractScheduleProServicesInvoiceResponse; @@ -332,6 +333,7 @@ export namespace Metronome { export import ContractAddManualBalanceEntryParams = API.ContractAddManualBalanceEntryParams; export import ContractAmendParams = API.ContractAmendParams; export import ContractArchiveParams = API.ContractArchiveParams; + export import ContractCreateHistoricalInvoicesParams = API.ContractCreateHistoricalInvoicesParams; export import ContractListBalancesParams = API.ContractListBalancesParams; export import ContractRetrieveRateScheduleParams = API.ContractRetrieveRateScheduleParams; export import ContractScheduleProServicesInvoiceParams = API.ContractScheduleProServicesInvoiceParams; diff --git a/src/resources/billable-metrics.ts b/src/resources/billable-metrics.ts index 1dc72c5..d488208 100755 --- a/src/resources/billable-metrics.ts +++ b/src/resources/billable-metrics.ts @@ -29,30 +29,26 @@ export class BillableMetrics extends APIResource { } /** - * Get all billable metrics for a given customer. + * List all billable metrics. */ list( - customerId: string, query?: BillableMetricListParams, options?: Core.RequestOptions, ): Core.PagePromise; list( - customerId: string, options?: Core.RequestOptions, ): Core.PagePromise; list( - customerId: string, query: BillableMetricListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.PagePromise { if (isRequestOptions(query)) { - return this.list(customerId, {}, query); + return this.list({}, query); } - return this._client.getAPIList( - `/customers/${customerId}/billable-metrics`, - BillableMetricListResponsesCursorPage, - { query, ...options }, - ); + return this._client.getAPIList('/billable-metrics', BillableMetricListResponsesCursorPage, { + query, + ...options, + }); } /** @@ -128,19 +124,15 @@ export namespace BillableMetricRetrieveResponse { } export interface BillableMetricListResponse { - id: string; - - name: string; - /** - * (DEPRECATED) use aggregation_type instead + * ID of the billable metric */ - aggregate?: string; + id: string; /** - * (DEPRECATED) use aggregation_key instead + * The display name of the billable metric. */ - aggregate_keys?: Array; + name: string; /** * A key that specifies which property of the event is used to aggregate data. This @@ -161,16 +153,6 @@ export interface BillableMetricListResponse { */ event_type_filter?: Shared.EventTypeFilter; - /** - * (DEPRECATED) use property_filters & event_type_filter instead - */ - filter?: Record; - - /** - * (DEPRECATED) use group_keys instead - */ - group_by?: Array; - /** * Property names that are used to group usage costs on an invoice. Each entry * represents a set of properties used to slice events into distinct buckets. @@ -236,13 +218,7 @@ export interface BillableMetricCreateParams { property_filters?: Array; } -export interface BillableMetricListParams extends CursorPageParams { - /** - * If true, the list of metrics will be filtered to just ones that are on the - * customer's current plan - */ - on_current_plan?: boolean; -} +export interface BillableMetricListParams extends CursorPageParams {} export interface BillableMetricArchiveParams { id: string; diff --git a/src/resources/contracts/contracts.ts b/src/resources/contracts/contracts.ts index 8887e7d..8733d9d 100755 --- a/src/resources/contracts/contracts.ts +++ b/src/resources/contracts/contracts.ts @@ -69,6 +69,16 @@ export class Contracts extends APIResource { return this._client.post('/contracts/archive', { body, ...options }); } + /** + * Creates historical usage invoices for a contract + */ + createHistoricalInvoices( + body: ContractCreateHistoricalInvoicesParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post('/contracts/createHistoricalInvoices', { body, ...options }); + } + /** * List balances (commits and credits). */ @@ -379,6 +389,10 @@ export interface ContractArchiveResponse { data: Shared.ID; } +export interface ContractCreateHistoricalInvoicesResponse { + data: Array; +} + export interface ContractListBalancesResponse { data: Array; @@ -2120,6 +2134,67 @@ export interface ContractArchiveParams { void_invoices: boolean; } +export interface ContractCreateHistoricalInvoicesParams { + invoices: Array; + + preview: boolean; +} + +export namespace ContractCreateHistoricalInvoicesParams { + export interface Invoice { + contract_id: string; + + credit_type_id: string; + + customer_id: string; + + exclusive_end_date: string; + + inclusive_start_date: string; + + issue_date: string; + + usage_line_items: Array; + + /** + * This field's availability is dependent on your client's configuration. + */ + billable_status?: 'billable' | 'unbillable'; + + breakdown_granularity?: 'HOUR' | 'DAY'; + + custom_fields?: Record; + } + + export namespace Invoice { + export interface UsageLineItem { + exclusive_end_date: string; + + inclusive_start_date: string; + + product_id: string; + + presentation_group_values?: Record; + + pricing_group_values?: Record; + + quantity?: number; + + subtotals_with_quantity?: Array; + } + + export namespace UsageLineItem { + export interface SubtotalsWithQuantity { + exclusive_end_date: string; + + inclusive_start_date: string; + + quantity: number; + } + } + } +} + export interface ContractListBalancesParams { customer_id: string; @@ -2332,6 +2407,7 @@ export namespace Contracts { export import ContractListResponse = ContractsAPI.ContractListResponse; export import ContractAmendResponse = ContractsAPI.ContractAmendResponse; export import ContractArchiveResponse = ContractsAPI.ContractArchiveResponse; + export import ContractCreateHistoricalInvoicesResponse = ContractsAPI.ContractCreateHistoricalInvoicesResponse; export import ContractListBalancesResponse = ContractsAPI.ContractListBalancesResponse; export import ContractRetrieveRateScheduleResponse = ContractsAPI.ContractRetrieveRateScheduleResponse; export import ContractScheduleProServicesInvoiceResponse = ContractsAPI.ContractScheduleProServicesInvoiceResponse; @@ -2342,6 +2418,7 @@ export namespace Contracts { export import ContractAddManualBalanceEntryParams = ContractsAPI.ContractAddManualBalanceEntryParams; export import ContractAmendParams = ContractsAPI.ContractAmendParams; export import ContractArchiveParams = ContractsAPI.ContractArchiveParams; + export import ContractCreateHistoricalInvoicesParams = ContractsAPI.ContractCreateHistoricalInvoicesParams; export import ContractListBalancesParams = ContractsAPI.ContractListBalancesParams; export import ContractRetrieveRateScheduleParams = ContractsAPI.ContractRetrieveRateScheduleParams; export import ContractScheduleProServicesInvoiceParams = ContractsAPI.ContractScheduleProServicesInvoiceParams; diff --git a/src/resources/contracts/index.ts b/src/resources/contracts/index.ts index 210eb28..79ed1e8 100755 --- a/src/resources/contracts/index.ts +++ b/src/resources/contracts/index.ts @@ -6,6 +6,7 @@ export { ContractListResponse, ContractAmendResponse, ContractArchiveResponse, + ContractCreateHistoricalInvoicesResponse, ContractListBalancesResponse, ContractRetrieveRateScheduleResponse, ContractScheduleProServicesInvoiceResponse, @@ -16,6 +17,7 @@ export { ContractAddManualBalanceEntryParams, ContractAmendParams, ContractArchiveParams, + ContractCreateHistoricalInvoicesParams, ContractListBalancesParams, ContractRetrieveRateScheduleParams, ContractScheduleProServicesInvoiceParams, diff --git a/src/resources/customers/invoices.ts b/src/resources/customers/invoices.ts index 503c1e8..7c65c85 100755 --- a/src/resources/customers/invoices.ts +++ b/src/resources/customers/invoices.ts @@ -208,6 +208,13 @@ export namespace Invoice { */ is_prorated?: boolean; + /** + * only present for contract invoices and when the include_list_prices query + * parameter is set to true. This will include the list rate for the charge if + * applicable. Only present for usage and subscription line items. + */ + list_price?: Shared.Rate; + metadata?: string; /** diff --git a/src/resources/dashboards.ts b/src/resources/dashboards.ts index 5754fd2..7687cf8 100755 --- a/src/resources/dashboards.ts +++ b/src/resources/dashboards.ts @@ -36,6 +36,10 @@ export interface DashboardGetEmbeddableURLParams { */ dashboard: 'invoices' | 'usage' | 'credits'; + bm_group_key_display_name_overrides?: DashboardGetEmbeddableURLParams.BmGroupKeyDisplayNameOverrides; + + bm_group_key_values_display_name_overrides?: DashboardGetEmbeddableURLParams.BmGroupKeyValuesDisplayNameOverrides; + /** * Optional list of colors to override */ @@ -48,6 +52,50 @@ export interface DashboardGetEmbeddableURLParams { } export namespace DashboardGetEmbeddableURLParams { + export interface BmGroupKeyDisplayNameOverrides { + /** + * The new display name for the group key. e.g. "Tenant ID" + */ + display_name?: string; + + /** + * The current name of the group key. e.g. "tenant_id" + */ + group_key_name?: string; + } + + export interface BmGroupKeyValuesDisplayNameOverrides { + /** + * The actual value of the group key. e.g. "123-xyz-abc". If group key is not used, + * it is the BM's name. + */ + group_key_name?: string; + + /** + * An object containing the group key value and the new display name for the group + * key value. + */ + value_display_name?: BmGroupKeyValuesDisplayNameOverrides.ValueDisplayName; + } + + export namespace BmGroupKeyValuesDisplayNameOverrides { + /** + * An object containing the group key value and the new display name for the group + * key value. + */ + export interface ValueDisplayName { + /** + * The new display name for the group key value. e.g. "EU-Cluster-A" + */ + display_name?: string; + + /** + * The actual value of the group key. e.g. "123-xyz-abc" + */ + group_key_value?: string; + } + } + export interface ColorOverride { /** * The color to override diff --git a/src/resources/index.ts b/src/resources/index.ts index 75311d4..151b6b3 100755 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -31,6 +31,7 @@ export { ContractListResponse, ContractAmendResponse, ContractArchiveResponse, + ContractCreateHistoricalInvoicesResponse, ContractListBalancesResponse, ContractRetrieveRateScheduleResponse, ContractScheduleProServicesInvoiceResponse, @@ -41,6 +42,7 @@ export { ContractAddManualBalanceEntryParams, ContractAmendParams, ContractArchiveParams, + ContractCreateHistoricalInvoicesParams, ContractListBalancesParams, ContractRetrieveRateScheduleParams, ContractScheduleProServicesInvoiceParams, diff --git a/src/uploads.ts b/src/uploads.ts index 081827c..a920351 100755 --- a/src/uploads.ts +++ b/src/uploads.ts @@ -114,7 +114,12 @@ export async function toFile( const blob = await value.blob(); name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file'; - return new File([blob as any], name, options); + // we need to convert the `Blob` into an array buffer because the `Blob` class + // that `node-fetch` defines is incompatible with the web standard which results + // in `new File` interpreting it as a string instead of binary data. + const data = isBlobLike(blob) ? [(await blob.arrayBuffer()) as any] : [blob]; + + return new File(data, name, options); } const bits = await getBytes(value); diff --git a/src/version.ts b/src/version.ts index b68d2ec..5296a0f 100755 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-beta.1'; // x-release-please-version +export const VERSION = '0.1.0-beta.2'; // x-release-please-version diff --git a/tests/api-resources/billable-metrics.test.ts b/tests/api-resources/billable-metrics.test.ts index 18acdd0..1b9c47c 100755 --- a/tests/api-resources/billable-metrics.test.ts +++ b/tests/api-resources/billable-metrics.test.ts @@ -72,7 +72,7 @@ describe('resource billableMetrics', () => { }); test('list', async () => { - const responsePromise = client.billableMetrics.list('d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc'); + const responsePromise = client.billableMetrics.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -84,21 +84,15 @@ describe('resource billableMetrics', () => { test('list: request options instead of params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.billableMetrics.list('d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', { - path: '/_stainless_unknown_path', - }), - ).rejects.toThrow(Metronome.NotFoundError); + await expect(client.billableMetrics.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Metronome.NotFoundError, + ); }); test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( - client.billableMetrics.list( - 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', - { limit: 1, next_page: 'next_page', on_current_plan: true }, - { path: '/_stainless_unknown_path' }, - ), + client.billableMetrics.list({ limit: 1, next_page: 'next_page' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Metronome.NotFoundError); }); diff --git a/tests/api-resources/contracts/contracts.test.ts b/tests/api-resources/contracts/contracts.test.ts index 31ee37c..a9c37eb 100755 --- a/tests/api-resources/contracts/contracts.test.ts +++ b/tests/api-resources/contracts/contracts.test.ts @@ -1465,6 +1465,368 @@ describe('resource contracts', () => { }); }); + test('createHistoricalInvoices: only required params', async () => { + const responsePromise = client.contracts.createHistoricalInvoices({ + invoices: [ + { + contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + credit_type_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + issue_date: '2019-12-27T18:11:19.117Z', + usage_line_items: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + ], + }, + { + contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + credit_type_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + issue_date: '2019-12-27T18:11:19.117Z', + usage_line_items: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + ], + }, + { + contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + credit_type_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + issue_date: '2019-12-27T18:11:19.117Z', + usage_line_items: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, + ], + }, + ], + preview: true, + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('createHistoricalInvoices: required and optional params', async () => { + const response = await client.contracts.createHistoricalInvoices({ + invoices: [ + { + contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + credit_type_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + issue_date: '2019-12-27T18:11:19.117Z', + usage_line_items: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + ], + billable_status: 'billable', + breakdown_granularity: 'HOUR', + custom_fields: { foo: 'string' }, + }, + { + contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + credit_type_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + issue_date: '2019-12-27T18:11:19.117Z', + usage_line_items: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + ], + billable_status: 'billable', + breakdown_granularity: 'HOUR', + custom_fields: { foo: 'string' }, + }, + { + contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + credit_type_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + issue_date: '2019-12-27T18:11:19.117Z', + usage_line_items: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + product_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + presentation_group_values: { foo: 'string' }, + pricing_group_values: { foo: 'string' }, + quantity: 0, + subtotals_with_quantity: [ + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + { + exclusive_end_date: '2019-12-27T18:11:19.117Z', + inclusive_start_date: '2019-12-27T18:11:19.117Z', + quantity: 0, + }, + ], + }, + ], + billable_status: 'billable', + breakdown_granularity: 'HOUR', + custom_fields: { foo: 'string' }, + }, + ], + preview: true, + }); + }); + test('listBalances: only required params', async () => { const responsePromise = client.contracts.listBalances({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', diff --git a/tests/api-resources/dashboards.test.ts b/tests/api-resources/dashboards.test.ts index 72af3df..22037eb 100755 --- a/tests/api-resources/dashboards.test.ts +++ b/tests/api-resources/dashboards.test.ts @@ -27,6 +27,11 @@ describe('resource dashboards', () => { const response = await client.dashboards.getEmbeddableURL({ customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491', dashboard: 'invoices', + bm_group_key_display_name_overrides: { display_name: 'display_name', group_key_name: 'group_key_name' }, + bm_group_key_values_display_name_overrides: { + group_key_name: 'group_key_name', + value_display_name: { display_name: 'display_name', group_key_value: 'group_key_value' }, + }, color_overrides: [{ name: 'Gray_dark', value: '#ff0000' }], dashboard_options: [ { key: 'key', value: 'value' }, diff --git a/yarn.lock b/yarn.lock index 8439aa5..98db779 100755 --- a/yarn.lock +++ b/yarn.lock @@ -881,7 +881,7 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== -"@types/qs@^6.9.7": +"@types/qs@^6.9.15": version "6.9.15" resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce" integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==