Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 15, 2024
1 parent a7f3601 commit a99ab5a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 12
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/midday%2Fmidday-f3344c282c6f9927685318f4decaca8749941be8c7f0a90a57e038f6f4e9a897.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/midday%2Fmidday-b093a3bf1c7b59afde3878dd25af89b0864516bcdcec5b43d993427053062ada.yml
15 changes: 12 additions & 3 deletions src/resources/auth/plaid.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '@midday-ai/engine/resource';
import { isRequestOptions } from '@midday-ai/engine/core';
import * as Core from '@midday-ai/engine/core';
import * as PlaidAPI from '@midday-ai/engine/resources/auth/plaid';

Expand All @@ -15,7 +16,15 @@ export class Plaid extends APIResource {
/**
* Auth Link (Plaid)
*/
link(body: PlaidLinkParams, options?: Core.RequestOptions): Core.APIPromise<PlaidLink> {
link(body?: PlaidLinkParams, options?: Core.RequestOptions): Core.APIPromise<PlaidLink>;
link(options?: Core.RequestOptions): Core.APIPromise<PlaidLink>;
link(
body: PlaidLinkParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<PlaidLink> {
if (isRequestOptions(body)) {
return this.link({}, body);
}
return this._client.post('/auth/plaid/link', { body, ...options });
}
}
Expand Down Expand Up @@ -47,9 +56,9 @@ export interface PlaidExchangeParams {
}

export interface PlaidLinkParams {
language: string;
language?: string;

userId: string;
userId?: string;
}

export namespace Plaid {
Expand Down
27 changes: 17 additions & 10 deletions tests/api-resources/auth/plaid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ describe('resource plaid', () => {
});
});

test('link: only required params', async () => {
const responsePromise = midday.auth.plaid.link({
language: 'en',
userId: '9293961c-df93-4d6d-a2cc-fc3e353b2d10',
});
test('link', async () => {
const responsePromise = midday.auth.plaid.link();
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -42,10 +39,20 @@ describe('resource plaid', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

test('link: required and optional params', async () => {
const response = await midday.auth.plaid.link({
language: 'en',
userId: '9293961c-df93-4d6d-a2cc-fc3e353b2d10',
});
test('link: 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(midday.auth.plaid.link({ path: '/_stainless_unknown_path' })).rejects.toThrow(
Midday.NotFoundError,
);
});

test('link: 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(
midday.auth.plaid.link(
{ language: 'en', userId: '9293961c-df93-4d6d-a2cc-fc3e353b2d10' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Midday.NotFoundError);
});
});

0 comments on commit a99ab5a

Please sign in to comment.