From a99ab5a61a00244ede6d043cb094b1c62d90f19c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:56:08 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#50) --- .stats.yml | 2 +- src/resources/auth/plaid.ts | 15 +++++++++++--- tests/api-resources/auth/plaid.test.ts | 27 ++++++++++++++++---------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0507d05..22d2b66 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/src/resources/auth/plaid.ts b/src/resources/auth/plaid.ts index 91e72c7..a888f49 100644 --- a/src/resources/auth/plaid.ts +++ b/src/resources/auth/plaid.ts @@ -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'; @@ -15,7 +16,15 @@ export class Plaid extends APIResource { /** * Auth Link (Plaid) */ - link(body: PlaidLinkParams, options?: Core.RequestOptions): Core.APIPromise { + link(body?: PlaidLinkParams, options?: Core.RequestOptions): Core.APIPromise; + link(options?: Core.RequestOptions): Core.APIPromise; + link( + body: PlaidLinkParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(body)) { + return this.link({}, body); + } return this._client.post('/auth/plaid/link', { body, ...options }); } } @@ -47,9 +56,9 @@ export interface PlaidExchangeParams { } export interface PlaidLinkParams { - language: string; + language?: string; - userId: string; + userId?: string; } export namespace Plaid { diff --git a/tests/api-resources/auth/plaid.test.ts b/tests/api-resources/auth/plaid.test.ts index 497eab9..042a769 100644 --- a/tests/api-resources/auth/plaid.test.ts +++ b/tests/api-resources/auth/plaid.test.ts @@ -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; @@ -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); }); });