Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): OpenAPI spec update via Stainless API #109

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-c2288c6a60ac4804016ea90592c280d11c7d5b52b63752bacf3519441595bcfb.yml
configured_endpoints: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-c4ec65355a30c07306ddff2c4a97411c2eb631a878583ce8bdd876a4fe2a5c96.yml
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ Types:
- <code><a href="./src/resources/customers/invoices.ts">Invoice</a></code>
- <code><a href="./src/resources/customers/invoices.ts">InvoiceRetrieveResponse</a></code>
- <code><a href="./src/resources/customers/invoices.ts">InvoiceAddChargeResponse</a></code>
- <code><a href="./src/resources/customers/invoices.ts">InvoiceListBreakdownsResponse</a></code>

Methods:

- <code title="get /customers/{customer_id}/invoices/{invoice_id}">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">retrieve</a>(customerId, invoiceId, { ...params }) -> InvoiceRetrieveResponse</code>
- <code title="get /customers/{customer_id}/invoices">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">list</a>(customerId, { ...params }) -> InvoicesCursorPage</code>
- <code title="post /customers/{customer_id}/addCharge">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">addCharge</a>(customerId, { ...params }) -> InvoiceAddChargeResponse</code>
- <code title="get /customers/{customer_id}/invoices/breakdowns">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">listBreakdowns</a>(customerId, { ...params }) -> InvoiceListBreakdownsResponsesCursorPage</code>

## BillingConfig

Expand Down
3 changes: 3 additions & 0 deletions src/resources/customers/customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,13 @@ export namespace Customers {
export import Invoice = InvoicesAPI.Invoice;
export import InvoiceRetrieveResponse = InvoicesAPI.InvoiceRetrieveResponse;
export import InvoiceAddChargeResponse = InvoicesAPI.InvoiceAddChargeResponse;
export import InvoiceListBreakdownsResponse = InvoicesAPI.InvoiceListBreakdownsResponse;
export import InvoicesCursorPage = InvoicesAPI.InvoicesCursorPage;
export import InvoiceListBreakdownsResponsesCursorPage = InvoicesAPI.InvoiceListBreakdownsResponsesCursorPage;
export import InvoiceRetrieveParams = InvoicesAPI.InvoiceRetrieveParams;
export import InvoiceListParams = InvoicesAPI.InvoiceListParams;
export import InvoiceAddChargeParams = InvoicesAPI.InvoiceAddChargeParams;
export import InvoiceListBreakdownsParams = InvoicesAPI.InvoiceListBreakdownsParams;
export import BillingConfig = BillingConfigAPI.BillingConfig;
export import BillingConfigRetrieveResponse = BillingConfigAPI.BillingConfigRetrieveResponse;
export import BillingConfigCreateParams = BillingConfigAPI.BillingConfigCreateParams;
Expand Down
3 changes: 3 additions & 0 deletions src/resources/customers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ export {
Invoice,
InvoiceRetrieveResponse,
InvoiceAddChargeResponse,
InvoiceListBreakdownsResponse,
InvoiceRetrieveParams,
InvoiceListParams,
InvoiceAddChargeParams,
InvoiceListBreakdownsParams,
InvoicesCursorPage,
InvoiceListBreakdownsResponsesCursorPage,
Invoices,
} from './invoices';
export {
Expand Down
67 changes: 67 additions & 0 deletions src/resources/customers/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,28 @@ export class Invoices extends APIResource {
): Core.APIPromise<InvoiceAddChargeResponse> {
return this._client.post(`/customers/${customerId}/addCharge`, { body, ...options });
}

/**
* List daily or hourly breakdown invoices for a given customer, optionally
* filtered by status, date range, and/or credit type.
*/
listBreakdowns(
customerId: string,
query: InvoiceListBreakdownsParams,
options?: Core.RequestOptions,
): Core.PagePromise<InvoiceListBreakdownsResponsesCursorPage, InvoiceListBreakdownsResponse> {
return this._client.getAPIList(
`/customers/${customerId}/invoices/breakdowns`,
InvoiceListBreakdownsResponsesCursorPage,
{ query, ...options },
);
}
}

export class InvoicesCursorPage extends CursorPage<Invoice> {}

export class InvoiceListBreakdownsResponsesCursorPage extends CursorPage<InvoiceListBreakdownsResponse> {}

export interface Invoice {
id: string;

Expand Down Expand Up @@ -477,6 +495,12 @@ export interface InvoiceRetrieveResponse {

export interface InvoiceAddChargeResponse {}

export interface InvoiceListBreakdownsResponse extends Invoice {
breakdown_end_timestamp: string;

breakdown_start_timestamp: string;
}

export interface InvoiceRetrieveParams {
/**
* If set, all zero quantity line items will be filtered out of the response
Expand Down Expand Up @@ -548,12 +572,55 @@ export interface InvoiceAddChargeParams {
quantity: number;
}

export interface InvoiceListBreakdownsParams extends CursorPageParams {
/**
* RFC 3339 timestamp. Breakdowns will only be returned for time windows that end
* on or before this time.
*/
ending_before: string;

/**
* RFC 3339 timestamp. Breakdowns will only be returned for time windows that start
* on or after this time.
*/
starting_on: string;

/**
* Only return invoices for the specified credit type
*/
credit_type_id?: string;

/**
* If set, all zero quantity line items will be filtered out of the response
*/
skip_zero_qty_line_items?: boolean;

/**
* Invoice sort order by issued_at, e.g. date_asc or date_desc. Defaults to
* date_asc.
*/
sort?: 'date_asc' | 'date_desc';

/**
* Invoice status, e.g. DRAFT or FINALIZED
*/
status?: string;

/**
* The granularity of the breakdowns to return. Defaults to day.
*/
window_size?: 'HOUR' | 'DAY';
}

export namespace Invoices {
export import Invoice = InvoicesAPI.Invoice;
export import InvoiceRetrieveResponse = InvoicesAPI.InvoiceRetrieveResponse;
export import InvoiceAddChargeResponse = InvoicesAPI.InvoiceAddChargeResponse;
export import InvoiceListBreakdownsResponse = InvoicesAPI.InvoiceListBreakdownsResponse;
export import InvoicesCursorPage = InvoicesAPI.InvoicesCursorPage;
export import InvoiceListBreakdownsResponsesCursorPage = InvoicesAPI.InvoiceListBreakdownsResponsesCursorPage;
export import InvoiceRetrieveParams = InvoicesAPI.InvoiceRetrieveParams;
export import InvoiceListParams = InvoicesAPI.InvoiceListParams;
export import InvoiceAddChargeParams = InvoicesAPI.InvoiceAddChargeParams;
export import InvoiceListBreakdownsParams = InvoicesAPI.InvoiceListBreakdownsParams;
}
28 changes: 28 additions & 0 deletions tests/api-resources/customers/invoices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,32 @@ describe('resource invoices', () => {
quantity: 1,
});
});

test('listBreakdowns: only required params', async () => {
const responsePromise = client.customers.invoices.listBreakdowns('d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', {
ending_before: '2019-12-27T18:11:19.117Z',
starting_on: '2019-12-27T18:11:19.117Z',
});
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('listBreakdowns: required and optional params', async () => {
const response = await client.customers.invoices.listBreakdowns('d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', {
ending_before: '2019-12-27T18:11:19.117Z',
starting_on: '2019-12-27T18:11:19.117Z',
credit_type_id: 'credit_type_id',
limit: 1,
next_page: 'next_page',
skip_zero_qty_line_items: true,
sort: 'date_asc',
status: 'status',
window_size: 'HOUR',
});
});
});