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 #11

Merged
merged 1 commit into from
Jul 5, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.prism.log
node_modules
yarn-error.log
codegen.log
Expand Down
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 9
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/midday%2Fmidday-4b6f2f46a13d867c7048c13990c576c7ecfa7869c712a3f1fe6b4f4ddcdf8c4a.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/midday%2Fmidday-b620765f266316b64aaa0d23d61721727701845e39c8ff1e65f2a2c0662ea045.yml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const midday = new Midday();

async function main() {
const transactionListResponse = await midday.transactions.list({
accountId: '5341343-4234-4c65-815c-t234213442',
accountType: 'credit',
provider: 'teller',
accessToken: 'token-123',
accountId: '5341343-4234-4c65-815c-t234213442',
});

console.log(transactionListResponse.data);
Expand Down Expand Up @@ -153,7 +153,7 @@ console.log(response.statusText); // access the underlying Response object

const { data: healthRetrieveResponse, response: raw } = await midday.health.retrieve().withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(healthRetrieveResponse.plaid);
console.log(healthRetrieveResponse.data);
```

### Making custom/undocumented requests
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from './core';
import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as Core from '@midday-ai/engine/core';
import * as API from '@midday-ai/engine/resources/index';

export interface ClientOptions {
Expand Down Expand Up @@ -69,7 +69,9 @@ export interface ClientOptions {
defaultQuery?: Core.DefaultQuery;
}

/** API Client for interfacing with the Midday API. */
/**
* API Client for interfacing with the Midday API.
*/
export class Midday extends Core.APIClient {
bearerToken: string;

Expand Down Expand Up @@ -111,6 +113,7 @@ export class Midday extends Core.APIClient {
maxRetries: options.maxRetries,
fetch: options.fetch,
});

this._options = options;

this.bearerToken = bearerToken;
Expand Down
44 changes: 12 additions & 32 deletions src/resources/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@midday-ai/engine/core';
import { APIResource } from '@midday-ai/engine/resource';
import * as Core from '@midday-ai/engine/core';
import * as AccountsAPI from '@midday-ai/engine/resources/accounts';

export class Accounts extends APIResource {
Expand Down Expand Up @@ -35,11 +35,13 @@ export namespace AccountListResponse {

enrollment_id: string | null;

institution: Data.Institution;
institution: Data.Institution | null;

name: string;

provider: 'teller' | 'plaid' | 'gocardless';

type: 'depository' | 'credit' | 'other_asset' | 'loan' | 'other_liability';
}

export namespace Data {
Expand All @@ -54,26 +56,14 @@ export namespace AccountListResponse {
}

export interface AccountBalanceResponse {
id: string;

currency: string;

enrollment_id: string | null;

institution: AccountBalanceResponse.Institution;

name: string;

provider: 'teller' | 'plaid' | 'gocardless';
data: AccountBalanceResponse.Data | null;
}

export namespace AccountBalanceResponse {
export interface Institution {
id: string;

logo: string | null;
export interface Data {
amount: number;

name: string;
currency: string;
}
}

Expand Down Expand Up @@ -102,27 +92,17 @@ export interface AccountListParams {
}

export interface AccountBalanceParams {
provider: 'teller' | 'plaid' | 'gocardless';

/**
* GoCardLess account id
* Account id
*/
id?: string;
id: string;

provider: 'teller' | 'plaid' | 'gocardless';

/**
* Teller & Plaid access token
*/
accessToken?: string;

/**
* GoCardLess country code
*/
countryCode?: string;

/**
* Plaid institution id
*/
institutionId?: string;
}

export namespace Accounts {
Expand Down
30 changes: 21 additions & 9 deletions src/resources/auth/gocardless.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

export class Gocardless extends APIResource {
Expand All @@ -24,29 +24,41 @@ export class Gocardless extends APIResource {
}

export interface GocardlessExchangeResponse {
id: string;
data: GocardlessExchangeResponse.Data;
}

export namespace GocardlessExchangeResponse {
export interface Data {
id: string;

access_valid_for_days: string;
access_valid_for_days: number;

institutionId: string;
institution_id: string;

max_historical_days: string;
max_historical_days: number;
}
}

export interface GocardlessLinkResponse {
link: string;
data: GocardlessLinkResponse.Data;
}

export namespace GocardlessLinkResponse {
export interface Data {
link: string;
}
}

export interface GocardlessExchangeParams {
institutionId: string;
institution_id: string;

transactionTotalDays: string;
transaction_total_days: number;
}

export interface GocardlessLinkParams {
agreement: string | null;

institutionId: string;
institution_id: string;

redirect: string;
}
Expand Down
20 changes: 16 additions & 4 deletions src/resources/auth/plaid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

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

export class Plaid extends APIResource {
Expand All @@ -21,13 +21,25 @@ export class Plaid extends APIResource {
}

export interface PlaidExchangeResponse {
access_token: string;
data: PlaidExchangeResponse.Data;
}

export namespace PlaidExchangeResponse {
export interface Data {
access_token: string;
}
}

export interface PlaidLinkResponse {
expiration: string;
data: PlaidLinkResponse.Data;
}

link_token: string;
export namespace PlaidLinkResponse {
export interface Data {
expiration: string;

link_token: string;
}
}

export interface PlaidExchangeParams {
Expand Down
32 changes: 19 additions & 13 deletions src/resources/health.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@midday-ai/engine/core';
import { APIResource } from '@midday-ai/engine/resource';
import * as Core from '@midday-ai/engine/core';
import * as HealthAPI from '@midday-ai/engine/resources/health';

export class Health extends APIResource {
Expand All @@ -14,24 +14,30 @@ export class Health extends APIResource {
}

export interface HealthRetrieveResponse {
gocardless: HealthRetrieveResponse.Gocardless;

plaid: HealthRetrieveResponse.Plaid;

teller: HealthRetrieveResponse.Teller;
data: HealthRetrieveResponse.Data;
}

export namespace HealthRetrieveResponse {
export interface Gocardless {
health: boolean;
}
export interface Data {
gocardless: Data.Gocardless;

plaid: Data.Plaid;

export interface Plaid {
health: boolean;
teller: Data.Teller;
}

export interface Teller {
health: boolean;
export namespace Data {
export interface Gocardless {
healthy: boolean;
}

export interface Plaid {
healthy: boolean;
}

export interface Teller {
healthy: boolean;
}
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/resources/institutions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@midday-ai/engine/core';
import { APIResource } from '@midday-ai/engine/resource';
import * as Core from '@midday-ai/engine/core';
import * as InstitutionsAPI from '@midday-ai/engine/resources/institutions';

export class Institutions extends APIResource {
Expand All @@ -14,7 +14,17 @@ export class Institutions extends APIResource {
}

export interface InstitutionSearchResponse {
query: string;
data: Array<InstitutionSearchResponse.Data | null>;
}

export namespace InstitutionSearchResponse {
export interface Data {
id: string;

logo: string | null;

name: string;
}
}

export namespace Institutions {
Expand Down
16 changes: 7 additions & 9 deletions src/resources/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@midday-ai/engine/core';
import { APIResource } from '@midday-ai/engine/resource';
import * as Core from '@midday-ai/engine/core';
import * as TransactionsAPI from '@midday-ai/engine/resources/transactions';

export class Transactions extends APIResource {
Expand Down Expand Up @@ -36,8 +36,6 @@ export namespace TransactionListResponse {

description: string | null;

internal_id: string;

method: string | null;

name: string;
Expand All @@ -47,6 +45,11 @@ export namespace TransactionListResponse {
}

export interface TransactionListParams {
/**
* Get transactions by accountId
*/
accountId: string;

/**
* Get transactions with the correct amount depending on credit or depository
*/
Expand All @@ -59,15 +62,10 @@ export interface TransactionListParams {
*/
accessToken?: string;

/**
* Get transactions by accountId
*/
accountId?: string;

/**
* Get latest transactions
*/
latest?: string;
latest?: boolean;
}

export namespace Transactions {
Expand Down
9 changes: 5 additions & 4 deletions tests/api-resources/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ describe('resource accounts', () => {
});

test('balance: only required params', async () => {
const responsePromise = midday.accounts.balance({ provider: 'teller' });
const responsePromise = midday.accounts.balance({
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
provider: 'teller',
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -43,11 +46,9 @@ describe('resource accounts', () => {

test('balance: required and optional params', async () => {
const response = await midday.accounts.balance({
provider: 'teller',
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
provider: 'teller',
accessToken: 'test_token_ky6igyqi3qxa4',
countryCode: 'SE',
institutionId: 'ins_109508',
});
});
});
Loading