-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): adds PrimeRates API (#566)
- 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
Showing
11 changed files
with
245 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
configured_endpoints: 149 | ||
configured_endpoints: 151 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/api-resources/credit-products/extended-credit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |