Skip to content

Commit

Permalink
feat(api): updates (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jun 6, 2024
1 parent 6f1339e commit a879391
Show file tree
Hide file tree
Showing 10 changed files with 331 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 35
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch-69265939ed1aa33d9890c86a334730210985961db56757efc28ff43696fbd1a7.yml
configured_endpoints: 37
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch-f1001da4ad3c1503330eebc1e61319a1a5db5e2da9fec98bc8682cb0967894d2.yml
14 changes: 14 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,17 @@ Methods:

- <code title="get /sandbox/jobs/configuration">client.sandbox.jobs.configuration.<a href="./src/resources/sandbox/jobs/configuration.ts">retrieve</a>() -> ConfigurationRetrieveResponse</code>
- <code title="put /sandbox/jobs/configuration">client.sandbox.jobs.configuration.<a href="./src/resources/sandbox/jobs/configuration.ts">update</a>({ ...params }) -> SandboxJobConfiguration</code>

# Payroll

## PayGroups

Types:

- <code><a href="./src/resources/payroll/pay-groups.ts">PayGroupRetrieveResponse</a></code>
- <code><a href="./src/resources/payroll/pay-groups.ts">PayGroupListResponse</a></code>

Methods:

- <code title="get /employer/pay-group/{pay_group_id}">client.payroll.payGroups.<a href="./src/resources/payroll/pay-groups.ts">retrieve</a>(payGroupId) -> PayGroupRetrieveResponse</code>
- <code title="get /employer/pay-groups">client.payroll.payGroups.<a href="./src/resources/payroll/pay-groups.ts">list</a>({ ...params }) -> PayGroupListResponsesSinglePage</code>
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"@types/qs": "^6.9.7",
"abort-controller": "^3.0.0",
"agentkeepalive": "^4.2.1",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
"node-fetch": "^2.6.7",
"qs": "^6.10.3",
"web-streams-polyfill": "^3.2.1"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as Core from './core';
import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import * as qs from 'qs';
import * as Pagination from '@tryfinch/finch-api/pagination';
import * as API from '@tryfinch/finch-api/resources/index';

Expand Down Expand Up @@ -166,6 +167,7 @@ export class Finch extends Core.APIClient {
requestForwarding: API.RequestForwarding = new API.RequestForwarding(this);
jobs: API.Jobs = new API.Jobs(this);
sandbox: API.Sandbox = new API.Sandbox(this);
payroll: API.Payroll = new API.Payroll(this);

/**
* DEPRECATED: use client.accessTokens.create instead.
Expand Down Expand Up @@ -288,6 +290,10 @@ export class Finch extends Core.APIClient {
return { Authorization };
}

protected override stringifyQuery(query: Record<string, unknown>): string {
return qs.stringify(query, { arrayFormat: 'comma' });
}

static Finch = this;

static FinchError = Errors.FinchError;
Expand Down Expand Up @@ -381,6 +387,8 @@ export namespace Finch {

export import Sandbox = API.Sandbox;

export import Payroll = API.Payroll;

export import ConnectionStatusType = API.ConnectionStatusType;
export import OperationSupport = API.OperationSupport;
export import OperationSupportMatrix = API.OperationSupportMatrix;
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export { CreateAccessTokenResponse, AccessTokenCreateParams, AccessTokens } from
export { DisconnectResponse, Introspection, Account } from './account';
export { Income, Location, Money, HRIS } from './hris/hris';
export { Jobs } from './jobs/jobs';
export { Payroll } from './payroll/payroll';
export { Provider, ProvidersSinglePage, Providers } from './providers';
export {
RequestForwardingForwardResponse,
Expand Down
10 changes: 10 additions & 0 deletions src/resources/payroll/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export {
PayGroupRetrieveResponse,
PayGroupListResponse,
PayGroupListParams,
PayGroupListResponsesSinglePage,
PayGroups,
} from './pay-groups';
export { Payroll } from './payroll';
110 changes: 110 additions & 0 deletions src/resources/payroll/pay-groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from '@tryfinch/finch-api/core';
import { APIResource } from '@tryfinch/finch-api/resource';
import { isRequestOptions } from '@tryfinch/finch-api/core';
import * as PayGroupsAPI from '@tryfinch/finch-api/resources/payroll/pay-groups';
import { SinglePage } from '@tryfinch/finch-api/pagination';

export class PayGroups extends APIResource {
/**
* Read information from a single pay group
*/
retrieve(payGroupId: string, options?: Core.RequestOptions): Core.APIPromise<PayGroupRetrieveResponse> {
return this._client.get(`/employer/pay-group/${payGroupId}`, options);
}

/**
* Read company pay groups and frequencies
*/
list(
query?: PayGroupListParams,
options?: Core.RequestOptions,
): Core.PagePromise<PayGroupListResponsesSinglePage, PayGroupListResponse>;
list(
options?: Core.RequestOptions,
): Core.PagePromise<PayGroupListResponsesSinglePage, PayGroupListResponse>;
list(
query: PayGroupListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<PayGroupListResponsesSinglePage, PayGroupListResponse> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/employer/pay-groups', PayGroupListResponsesSinglePage, {
query,
...options,
});
}
}

export class PayGroupListResponsesSinglePage extends SinglePage<PayGroupListResponse> {}

export interface PayGroupRetrieveResponse {
/**
* Finch id (uuidv4) for the pay group
*/
id: string;

individual_ids: Array<string>;

/**
* Name of the pay group
*/
name: string;

/**
* List of pay frequencies associated with this pay group
*/
pay_frequencies: Array<
| 'annually'
| 'semi_annually'
| 'quarterly'
| 'monthly'
| 'semi_monthly'
| 'bi_weekly'
| 'weekly'
| 'daily'
| 'other'
>;
}

export interface PayGroupListResponse {
/**
* Finch id (uuidv4) for the pay group
*/
id?: string;

/**
* Name of the pay group
*/
name?: string;

/**
* List of pay frequencies associated with this pay group
*/
pay_frequencies?: Array<
| 'annually'
| 'semi_annually'
| 'quarterly'
| 'monthly'
| 'semi_monthly'
| 'bi_weekly'
| 'weekly'
| 'daily'
| 'other'
>;
}

export interface PayGroupListParams {
individual_id?: string;

pay_frequencies?: Array<string>;
}

export namespace PayGroups {
export import PayGroupRetrieveResponse = PayGroupsAPI.PayGroupRetrieveResponse;
export import PayGroupListResponse = PayGroupsAPI.PayGroupListResponse;
export import PayGroupListResponsesSinglePage = PayGroupsAPI.PayGroupListResponsesSinglePage;
export import PayGroupListParams = PayGroupsAPI.PayGroupListParams;
}
16 changes: 16 additions & 0 deletions src/resources/payroll/payroll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '@tryfinch/finch-api/resource';
import * as PayGroupsAPI from '@tryfinch/finch-api/resources/payroll/pay-groups';

export class Payroll extends APIResource {
payGroups: PayGroupsAPI.PayGroups = new PayGroupsAPI.PayGroups(this._client);
}

export namespace Payroll {
export import PayGroups = PayGroupsAPI.PayGroups;
export import PayGroupRetrieveResponse = PayGroupsAPI.PayGroupRetrieveResponse;
export import PayGroupListResponse = PayGroupsAPI.PayGroupListResponse;
export import PayGroupListResponsesSinglePage = PayGroupsAPI.PayGroupListResponsesSinglePage;
export import PayGroupListParams = PayGroupsAPI.PayGroupListParams;
}
62 changes: 62 additions & 0 deletions tests/api-resources/payroll/pay-groups.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import Finch from '@tryfinch/finch-api';
import { Response } from 'node-fetch';

const finch = new Finch({
accessToken: 'My Access Token',
clientId: '4ab15e51-11ad-49f4-acae-f343b7794375',
clientSecret: 'My Client Secret',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource payGroups', () => {
test('retrieve', async () => {
const responsePromise = finch.payroll.payGroups.retrieve('string');
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('retrieve: 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(
finch.payroll.payGroups.retrieve('string', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Finch.NotFoundError);
});

test('list', async () => {
const responsePromise = finch.payroll.payGroups.list();
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('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(finch.payroll.payGroups.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
Finch.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(
finch.payroll.payGroups.list(
{
individual_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
pay_frequencies: ['string', 'string', 'string'],
},
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Finch.NotFoundError);
});
});
Loading

0 comments on commit a879391

Please sign in to comment.