Skip to content

Commit

Permalink
feat(api): adds PrimeRates API (#566)
Browse files Browse the repository at this point in the history
- renames `credit_product_id` to `credit_product_token` for retrieving an ExtendedCredit
  • Loading branch information
Stainless Bot committed Nov 19, 2024
1 parent 65e4f11 commit 70adc94
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 149
configured_endpoints: 151
23 changes: 23 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,29 @@ Methods:
- <code title="get /v1/book_transfers">client.bookTransfers.<a href="./src/resources/book-transfers.ts">list</a>({ ...params }) -> BookTransferResponsesCursorPage</code>
- <code title="post /v1/book_transfers/{book_transfer_token}/reverse">client.bookTransfers.<a href="./src/resources/book-transfers.ts">reverse</a>(bookTransferToken, { ...params }) -> BookTransferResponse</code>

# CreditProducts

## ExtendedCredit

Types:

- <code><a href="./src/resources/credit-products/extended-credit.ts">ExtendedCredit</a></code>

Methods:

- <code title="get /v1/credit_products/{credit_product_token}/extended_credit">client.creditProducts.extendedCredit.<a href="./src/resources/credit-products/extended-credit.ts">retrieve</a>(creditProductToken) -> ExtendedCredit</code>

## PrimeRates

Types:

- <code><a href="./src/resources/credit-products/prime-rates.ts">PrimeRateRetrieveResponse</a></code>

Methods:

- <code title="post /v1/credit_products/{credit_product_token}/prime_rates">client.creditProducts.primeRates.<a href="./src/resources/credit-products/prime-rates.ts">create</a>(creditProductToken, { ...params }) -> void</code>
- <code title="get /v1/credit_products/{credit_product_token}/prime_rates">client.creditProducts.primeRates.<a href="./src/resources/credit-products/prime-rates.ts">retrieve</a>(creditProductToken, { ...params }) -> PrimeRateRetrieveResponse</code>

# ExternalPayments

Types:
Expand Down
16 changes: 16 additions & 0 deletions src/resources/credit-products/credit-products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@
import { APIResource } from '../../resource';
import * as ExtendedCreditAPI from './extended-credit';
import { ExtendedCredit, ExtendedCreditResource } from './extended-credit';
import * as PrimeRatesAPI from './prime-rates';
import {
PrimeRateCreateParams,
PrimeRateRetrieveParams,
PrimeRateRetrieveResponse,
PrimeRates,
} from './prime-rates';

export class CreditProducts extends APIResource {
extendedCredit: ExtendedCreditAPI.ExtendedCreditResource = new ExtendedCreditAPI.ExtendedCreditResource(
this._client,
);
primeRates: PrimeRatesAPI.PrimeRates = new PrimeRatesAPI.PrimeRates(this._client);
}

CreditProducts.ExtendedCreditResource = ExtendedCreditResource;
CreditProducts.PrimeRates = PrimeRates;

export declare namespace CreditProducts {
export { ExtendedCreditResource as ExtendedCreditResource, type ExtendedCredit as ExtendedCredit };

export {
PrimeRates as PrimeRates,
type PrimeRateRetrieveResponse as PrimeRateRetrieveResponse,
type PrimeRateCreateParams as PrimeRateCreateParams,
type PrimeRateRetrieveParams as PrimeRateRetrieveParams,
};
}
4 changes: 2 additions & 2 deletions src/resources/credit-products/extended-credit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export class ExtendedCreditResource extends APIResource {
/**
* Get the extended credit for a given credit product under a program
*/
retrieve(creditProductId: string, options?: Core.RequestOptions): Core.APIPromise<ExtendedCredit> {
return this._client.get(`/v1/credit_products/${creditProductId}/extended_credit`, options);
retrieve(creditProductToken: string, options?: Core.RequestOptions): Core.APIPromise<ExtendedCredit> {
return this._client.get(`/v1/credit_products/${creditProductToken}/extended_credit`, options);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/resources/credit-products/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

export { CreditProducts } from './credit-products';
export { ExtendedCreditResource, type ExtendedCredit } from './extended-credit';
export {
PrimeRates,
type PrimeRateRetrieveResponse,
type PrimeRateCreateParams,
type PrimeRateRetrieveParams,
} from './prime-rates';
99 changes: 99 additions & 0 deletions src/resources/credit-products/prime-rates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';

export class PrimeRates extends APIResource {
/**
* Post Credit Product Prime Rate
*/
create(
creditProductToken: string,
body: PrimeRateCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<void> {
return this._client.post(`/v1/credit_products/${creditProductToken}/prime_rates`, { body, ...options });
}

/**
* Get Credit Product Prime Rates
*/
retrieve(
creditProductToken: string,
query?: PrimeRateRetrieveParams,
options?: Core.RequestOptions,
): Core.APIPromise<PrimeRateRetrieveResponse>;
retrieve(
creditProductToken: string,
options?: Core.RequestOptions,
): Core.APIPromise<PrimeRateRetrieveResponse>;
retrieve(
creditProductToken: string,
query: PrimeRateRetrieveParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<PrimeRateRetrieveResponse> {
if (isRequestOptions(query)) {
return this.retrieve(creditProductToken, {}, query);
}
return this._client.get(`/v1/credit_products/${creditProductToken}/prime_rates`, { query, ...options });
}
}

export interface PrimeRateRetrieveResponse {
/**
* List of prime rates
*/
data: Array<PrimeRateRetrieveResponse.Data>;

/**
* Whether there are more prime rates
*/
has_more: boolean;
}

export namespace PrimeRateRetrieveResponse {
export interface Data {
/**
* Date the rate goes into effect
*/
effective_date: string;

/**
* The rate in decimal format
*/
rate: string;
}
}

export interface PrimeRateCreateParams {
/**
* Date the rate goes into effect
*/
effective_date: string;

/**
* The rate in decimal format
*/
rate: string;
}

export interface PrimeRateRetrieveParams {
/**
* The effective date that the prime rates ends before
*/
ending_before?: string;

/**
* The effective date that the prime rate starts after
*/
starting_after?: string;
}

export declare namespace PrimeRates {
export {
type PrimeRateRetrieveResponse as PrimeRateRetrieveResponse,
type PrimeRateCreateParams as PrimeRateCreateParams,
type PrimeRateRetrieveParams as PrimeRateRetrieveParams,
};
}
1 change: 1 addition & 0 deletions src/resources/financial-accounts/financial-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export namespace FinancialTransaction {
| 'BALANCE_INQUIRY'
| 'BILLING_ERROR'
| 'BILLING_ERROR_REVERSAL'
| 'CARD_TO_CARD'
| 'CASH_BACK'
| 'CASH_BACK_REVERSAL'
| 'CLEARING'
Expand Down
4 changes: 4 additions & 0 deletions src/resources/financial-accounts/statements/line-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export namespace StatementLineItems {

category:
| 'ACH'
| 'BALANCE_OR_FUNDING'
| 'CARD'
| 'EXTERNAL_ACH'
| 'EXTERNAL_CHECK'
Expand Down Expand Up @@ -102,6 +103,7 @@ export namespace StatementLineItems {
| 'BALANCE_INQUIRY'
| 'BILLING_ERROR'
| 'BILLING_ERROR_REVERSAL'
| 'CARD_TO_CARD'
| 'CASH_BACK'
| 'CASH_BACK_REVERSAL'
| 'CLEARING'
Expand Down Expand Up @@ -182,6 +184,7 @@ export interface LineItemListResponse {

category:
| 'ACH'
| 'BALANCE_OR_FUNDING'
| 'CARD'
| 'EXTERNAL_ACH'
| 'EXTERNAL_CHECK'
Expand Down Expand Up @@ -225,6 +228,7 @@ export interface LineItemListResponse {
| 'BALANCE_INQUIRY'
| 'BILLING_ERROR'
| 'BILLING_ERROR_REVERSAL'
| 'CARD_TO_CARD'
| 'CASH_BACK'
| 'CASH_BACK_REVERSAL'
| 'CLEARING'
Expand Down
1 change: 1 addition & 0 deletions src/resources/transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export namespace Transfer {
| 'BALANCE_INQUIRY'
| 'BILLING_ERROR'
| 'BILLING_ERROR_REVERSAL'
| 'CARD_TO_CARD'
| 'CASH_BACK'
| 'CASH_BACK_REVERSAL'
| 'CLEARING'
Expand Down
31 changes: 31 additions & 0 deletions tests/api-resources/credit-products/extended-credit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import Lithic from 'lithic';
import { Response } from 'node-fetch';

const client = new Lithic({
apiKey: 'My Lithic API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource extendedCredit', () => {
test('retrieve', async () => {
const responsePromise = client.creditProducts.extendedCredit.retrieve('credit_product_token');
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(
client.creditProducts.extendedCredit.retrieve('credit_product_token', {
path: '/_stainless_unknown_path',
}),
).rejects.toThrow(Lithic.NotFoundError);
});
});
61 changes: 61 additions & 0 deletions tests/api-resources/credit-products/prime-rates.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import Lithic from 'lithic';
import { Response } from 'node-fetch';

const client = new Lithic({
apiKey: 'My Lithic API Key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource primeRates', () => {
test('create: only required params', async () => {
const responsePromise = client.creditProducts.primeRates.create('credit_product_token', {
effective_date: '2019-12-27',
rate: 'rate',
});
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('create: required and optional params', async () => {
const response = await client.creditProducts.primeRates.create('credit_product_token', {
effective_date: '2019-12-27',
rate: 'rate',
});
});

test('retrieve', async () => {
const responsePromise = client.creditProducts.primeRates.retrieve('credit_product_token');
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(
client.creditProducts.primeRates.retrieve('credit_product_token', { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Lithic.NotFoundError);
});

test('retrieve: 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(
client.creditProducts.primeRates.retrieve(
'credit_product_token',
{ ending_before: '2019-12-27', starting_after: '2019-12-27' },
{ path: '/_stainless_unknown_path' },
),
).rejects.toThrow(Lithic.NotFoundError);
});
});

0 comments on commit 70adc94

Please sign in to comment.