[@types/stripe] Added config param to constructor (#40846)

* [@types/stripe] Added breaking test for constructor

* [@types/stripe] Added missing config to constructor

* [@types/stripe] Marked all StripeConfig keys as optional

* [@types/stripe] Allowed null for apiVersion & httpAgent
This commit is contained in:
Fabien O'Carroll
2019-12-17 15:10:55 +02:00
committed by Orta
parent 7408c5dffc
commit 64191b96d3
2 changed files with 25 additions and 1 deletions

View File

@@ -64,6 +64,16 @@ interface ResponseEvent {
request_end_time: number;
}
interface StripeConfig {
apiVersion?: string | null;
maxNetworkRetries?: number;
httpAgent?: Agent | null;
timeout?: number;
host?: string;
port?: number;
telemetry?: boolean;
}
declare class Stripe {
DEFAULT_HOST: string;
DEFAULT_PORT: string;
@@ -85,6 +95,7 @@ declare class Stripe {
StripeResource: typeof Stripe.StripeResource;
constructor(apiKey: string, version?: string);
constructor(apiKey: string, config?: StripeConfig);
accounts: Stripe.resources.Accounts;
balance: Stripe.resources.Balance;

View File

@@ -1,11 +1,24 @@
import Stripe = require('stripe');
import { customers } from 'stripe';
const stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K');
let stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K');
stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', 'latest');
import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';
stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', {
apiVersion: 'latest',
maxNetworkRetries: 1,
httpAgent: new HttpAgent(),
timeout: 1000,
host: 'api.example.com',
port: 123,
telemetry: true
});
stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', {});
stripe.setHttpAgent(new HttpAgent());
stripe.setHttpAgent(new HttpsAgent());