Rename stripe-node to stripe (#20644)

* Rename stripe-node to stripe

* Export class instead of function

* Rename import
This commit is contained in:
Andy
2017-10-18 08:27:08 -07:00
committed by GitHub
parent 5116960f14
commit e3f8c31b2a
3 changed files with 94 additions and 105 deletions
+68 -77
View File
@@ -1,4 +1,4 @@
// Type definitions for stripe-node 4.7
// Type definitions for stripe 4.7
// Project: https://github.com/stripe/stripe-node/
// Definitions by: William Johnston <https://github.com/wjohnsto>
// Peter Harris <https://github.com/codeanimal>
@@ -8,88 +8,79 @@
/// <reference types="node" />
declare module 'stripe' {
var out: StripeNode.StripeExport;
export = out;
declare class Stripe {
DEFAULT_HOST: string;
DEFAULT_PORT: string;
DEFAULT_BASE_PATH: string;
DEFAULT_API_VERSION: string;
DEFAULT_TIMEOUT: number;
PACKAGE_VERSION: string;
USER_AGENT: {
bindings_version: string;
lang: string;
lang_version: string;
platform: string;
publisher: string;
uname: string;
};
USER_AGENT_SERIALIZED: string;
resources: typeof Stripe.resources;
StripeResource: typeof Stripe.StripeResource;
constructor(apiKey: string, version?: string);
accounts: Stripe.resources.Accounts;
balance: Stripe.resources.Balance;
charges: Stripe.resources.Charges;
coupons: Stripe.resources.Coupons;
customers: Stripe.resources.Customers;
disputes: Stripe.resources.Disputes;
events: Stripe.resources.Events;
invoices: Stripe.resources.Invoices;
invoiceItems: Stripe.resources.InvoiceItems;
plans: Stripe.resources.Plans;
/**
* @deprecated
*/
recipientCards: Stripe.resources.RecipientCards;
/**
* @deprecated
*/
recipients: Stripe.resources.Recipients;
subscriptions: Stripe.resources.Subscriptions;
tokens: Stripe.resources.Tokens;
transfers: Stripe.resources.Transfers;
applicationFees: Stripe.resources.ApplicationFees;
fileUploads: Stripe.resources.FileUploads;
bitcoinReceivers: Stripe.resources.BitcoinReceivers;
refunds: Stripe.resources.Refunds;
countrySpecs: Stripe.resources.CountrySpecs;
orders: Stripe.resources.Orders;
products: Stripe.resources.Products;
skus: Stripe.resources.SKUs;
webhooks: Stripe.resources.WebHooks;
setHost(host: string): void;
setHost(host: string, port: string|number): void;
setHost(host: string, port: string|number, protocol: string): void;
setProtocol(protocol: string): void;
setPort(port: string|number): void;
setApiVersion(version?: string): void;
setApiKey(key?: string): void;
setTimeout(timeout?: number): void;
setHttpAgent(agent: string): void;
getConstant(c: string): any;
getClientUserAgent(response: (userAgent: string) => void): void;
}
export = Stripe;
declare namespace StripeNode {
interface StripeExport extends StripeStatic {
new (apiKey: string, version?: string): Stripe;
(apiKey: string, version?: string): Stripe;
}
interface StripeStatic {
DEFAULT_HOST: string;
DEFAULT_PORT: string;
DEFAULT_BASE_PATH: string;
DEFAULT_API_VERSION: string;
DEFAULT_TIMEOUT: number;
PACKAGE_VERSION: string;
USER_AGENT: {
bindings_version: string;
lang: string;
lang_version: string;
platform: string;
publisher: string;
uname: string;
};
USER_AGENT_SERIALIZED: string;
resources: typeof resources;
StripeResource: typeof StripeResource;
}
declare namespace Stripe {
// Helper
type IBankAccount = bankAccounts.IBankAccount;
type ICard = cards.ICard;
interface Stripe extends StripeStatic {
accounts: resources.Accounts;
balance: resources.Balance;
charges: resources.Charges;
coupons: resources.Coupons;
customers: resources.Customers;
disputes: resources.Disputes;
events: resources.Events;
invoices: resources.Invoices;
invoiceItems: resources.InvoiceItems;
plans: resources.Plans;
/**
* @deprecated
*/
recipientCards: resources.RecipientCards;
/**
* @deprecated
*/
recipients: resources.Recipients;
subscriptions: resources.Subscriptions;
tokens: resources.Tokens;
transfers: resources.Transfers;
applicationFees: resources.ApplicationFees;
fileUploads: resources.FileUploads;
bitcoinReceivers: resources.BitcoinReceivers;
refunds: resources.Refunds;
countrySpecs: resources.CountrySpecs;
orders: resources.Orders;
products: resources.Products;
skus: resources.SKUs;
webhooks: resources.WebHooks;
setHost(host: string): void;
setHost(host: string, port: string|number): void;
setHost(host: string, port: string|number, protocol: string): void;
setProtocol(protocol: string): void;
setPort(port: string|number): void;
setApiVersion(version?: string): void;
setApiKey(key?: string): void;
setTimeout(timeout?: number): void;
setHttpAgent(agent: string): void;
getConstant(c: string): any;
getClientUserAgent(response: (userAgent: string) => void): void;
}
namespace accounts {
interface IAccount extends IResourceObject, IAccountShared {
/**
@@ -1,11 +1,9 @@
import StripeNode = require('stripe');
import Stripe = require('stripe');
var stripeTor = new StripeNode("sk_test_BF573NobVn98OiIsPAv7A04K");
var stripe = StripeNode("sk_test_BF573NobVn98OiIsPAv7A04K")
var stripe = new Stripe("sk_test_BF573NobVn98OiIsPAv7A04K")
stripe.setApiVersion('2016-03-07');
//#region Balance tests
// ##################################################################################
@@ -168,7 +166,7 @@ stripe.charges.updateRefund(
"ch_15fvyXEe31JkLCeQOo0SwFk9",
"re_15jzA4Ee31JkLCeQcxbTbjaL",
{ metadata: { key: "value" } },
function (err: StripeNode.IStripeError, refund: StripeNode.refunds.IRefund) {
function (err: Stripe.IStripeError, refund: Stripe.refunds.IRefund) {
// asynchronously called
}
@@ -315,13 +313,13 @@ stripe.customers.createSource(
"cus_5rfJKDJkuxzh5Q",
{ source: "tok_15V2YhEe31JkLCeQy9iUgsJX" },
function (err, source) {
var card = <StripeNode.ICard>source;
var bankAcc = <StripeNode.IBankAccount>source;
var card = <Stripe.ICard>source;
var bankAcc = <Stripe.IBankAccount>source;
}
);
stripe.customers.createSource("cus_5rfJKDJkuxzh5Q", { source: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then(function (source) {
var card = <StripeNode.ICard>source;
var bankAcc = <StripeNode.IBankAccount>source;
var card = <Stripe.ICard>source;
var bankAcc = <Stripe.IBankAccount>source;
});
stripe.customers.createSource(
@@ -336,7 +334,7 @@ stripe.customers.createSource(
},
function (err, card) {
// asynchronously called
var obj: StripeNode.ICard = card;
var obj: Stripe.ICard = card;
}
);
stripe.customers.createSource(
@@ -351,21 +349,21 @@ stripe.customers.createSource(
}).then(
function (card) {
// asynchronously called
var obj: StripeNode.ICard = card;
var obj: Stripe.ICard = card;
}
);
stripe.customers.createSource(
"cus_5rfJKDJkuxzh5Q",
{ source: "btok_8E264Lxsbyvj3E" },
function (err: StripeNode.IStripeError, bankAcc: StripeNode.IBankAccount) {
function (err: Stripe.IStripeError, bankAcc: Stripe.IBankAccount) {
// asynchronously called
bankAcc.bank_name;
}
);
stripe.customers.createSource(
"cus_5rfJKDJkuxzh5Q",
{ source: "btok_8E264Lxsbyvj3E" }).then(function (bankAcc: StripeNode.IBankAccount) {
{ source: "btok_8E264Lxsbyvj3E" }).then(function (bankAcc: Stripe.IBankAccount) {
// asynchronously called
bankAcc.bank_name;
}
@@ -376,14 +374,14 @@ stripe.customers.retrieveCard(
"card_15fvyXEe31JkLCeQ9KMktP5S",
function (err, card) {
// asynchronously called
var obj: StripeNode.ICard = card;
var obj: Stripe.ICard = card;
}
);
stripe.customers.retrieveCard(
"cus_5rfJKDJkuxzh5Q",
"card_15fvyXEe31JkLCeQ9KMktP5S").then(function (card) {
// asynchronously called
var obj: StripeNode.ICard = card;
var obj: Stripe.ICard = card;
});
stripe.customers.updateCard(
@@ -392,7 +390,7 @@ stripe.customers.updateCard(
{ name: "Jane Austen" },
function (err, card) {
// asynchronously called
var obj: StripeNode.ICard = card;
var obj: Stripe.ICard = card;
}
);
@@ -401,7 +399,7 @@ stripe.customers.updateCard(
"card_15fvyXEe31JkLCeQ9KMktP5S",
{ name: "Jane Austen" }).then(function (card) {
// asynchronously called
var obj: StripeNode.ICard = card;
var obj: Stripe.ICard = card;
});
stripe.customers.deleteCard(
@@ -635,21 +633,21 @@ stripe.accounts.list(
// ##################################################################################
stripe.accounts.createExternalAccount("", { external_account: "btok_8E264Lxsbyvj3E" }, function (err, extAcc) {
var card = <StripeNode.ICard>extAcc;
var bankAcc = <StripeNode.IBankAccount>extAcc;
var card = <Stripe.ICard>extAcc;
var bankAcc = <Stripe.IBankAccount>extAcc;
});
stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then(function (extAcc) {
var card = <StripeNode.ICard>extAcc;
var bankAcc = <StripeNode.IBankAccount>extAcc;
var card = <Stripe.ICard>extAcc;
var bankAcc = <Stripe.IBankAccount>extAcc;
});
stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, { stripe_account: "acct_17wV8KOoqMF9a2xk" }).then(function (extAcc) {
var card = <StripeNode.ICard>extAcc;
var bankAcc = <StripeNode.IBankAccount>extAcc;
var card = <Stripe.ICard>extAcc;
var bankAcc = <Stripe.IBankAccount>extAcc;
});
stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, "acct_17wV8KOoqMF9a2xk").then(function (extAcc) {
var card = <StripeNode.ICard>extAcc;
var bankAcc = <StripeNode.IBankAccount>extAcc;
var card = <Stripe.ICard>extAcc;
var bankAcc = <Stripe.IBankAccount>extAcc;
});
//#endregion
@@ -712,7 +710,7 @@ const webhookRequest = {
};
const webhookSecret = '';
const event = stripe.webhooks.constructEvent<StripeNode.subscriptions.ISubscription>(
const event = stripe.webhooks.constructEvent<Stripe.subscriptions.ISubscription>(
webhookRequest.rawBody,
webhookRequest.headers['stripe-signature'],
webhookSecret
@@ -752,7 +750,7 @@ stripe.coupons.retrieve("25OFF").then(function (coupon) {
stripe.coupons.update("25OFF", {
metadata: { key: "value" }
}, function (err: StripeNode.IStripeError, coupon: StripeNode.coupons.ICoupon) {
}, function (err: Stripe.IStripeError, coupon: Stripe.coupons.ICoupon) {
// asynchronously called
});
stripe.coupons.update("25OFF", {
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
"stripe-node-tests.ts"
"stripe-tests.ts"
]
}