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

Add types for extra request options #1448

Merged
merged 2 commits into from
Jun 9, 2022
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
18 changes: 18 additions & 0 deletions test/StripeResource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ describe('StripeResource', () => {
}
);
});

it('allows overriding host', (done) => {
const scope = nock('https://myhost')
.get('/v1/accounts/acct_123')
.reply(200, '{}');

realStripe.accounts.retrieve(
'acct_123',
{},
{
host: 'myhost',
},
(err, response) => {
done(err);
scope.done();
}
);
});
});
});

Expand Down
14 changes: 14 additions & 0 deletions types/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,19 @@ declare module 'stripe' {
*/
timeout?: number;

/**
* Specify the host to use for API Requests.
*/
host?: string;

/**
* Specify the port to use for API Requests.
*/
port?: string | number;

/**
* Specify the HTTP protool to use for API Requests.
*/
protocol?: HttpProtocol;

/**
Expand Down Expand Up @@ -170,6 +179,11 @@ declare module 'stripe' {
* Specify a timeout for this request in milliseconds.
*/
timeout?: number;

/**
* Specify the host for this request.
*/
host?: string;
}

export type Response<T> = T & {
Expand Down
4 changes: 4 additions & 0 deletions types/test/typescriptTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,7 @@ Stripe.StripeError.generate({
Stripe.errors.StripeError.generate({
type: 'card_error',
});

stripe.accounts.retrieve('123', {
host: 'my_host',
});