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

Multiple API changes #973

Merged
merged 2 commits into from
Aug 5, 2020
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
1 change: 1 addition & 0 deletions lib/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
Plans: require('./resources/Plans'),
Prices: require('./resources/Prices'),
Products: require('./resources/Products'),
PromotionCodes: require('./resources/PromotionCodes'),
Refunds: require('./resources/Refunds'),
Reviews: require('./resources/Reviews'),
SetupIntents: require('./resources/SetupIntents'),
Expand Down
11 changes: 11 additions & 0 deletions lib/resources/PromotionCodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// File generated from our OpenAPI spec

'use strict';

const StripeResource = require('../StripeResource');

module.exports = StripeResource.extend({
path: 'promotion_codes',

includeBasic: ['create', 'list', 'retrieve', 'update'],
});
69 changes: 69 additions & 0 deletions test/resources/PromotionCodes.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';

const stripe = require('../../testUtils').getSpyableStripe();
const expect = require('chai').expect;

describe('PromotionCodes Resource', () => {
describe('retrieve', () => {
it('Sends the correct request', () => {
stripe.promotionCodes.retrieve('promo_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/promotion_codes/promo_123',
headers: {},
data: {},
settings: {},
});
});
});

describe('update', () => {
it('Sends the correct request', () => {
stripe.promotionCodes.update('promo_123', {
metadata: {a: '1234'},
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/promotion_codes/promo_123',
headers: {},
data: {
metadata: {a: '1234'},
},
settings: {},
});
});
});

describe('create', () => {
it('Sends the correct request', () => {
stripe.promotionCodes.create({
coupon: 'co_123',
code: 'MYCODE',
});

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/promotion_codes',
headers: {},
data: {
coupon: 'co_123',
code: 'MYCODE',
},
settings: {},
});
});
});

describe('list', () => {
it('Sends the correct request', () => {
stripe.promotionCodes.list();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/promotion_codes',
headers: {},
data: {},
settings: {},
});
});
});
});
10 changes: 10 additions & 0 deletions types/2020-03-02/Checkout/Sessions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ declare module 'stripe' {
*/
object: 'checkout.session';

/**
* Enables user redeemable promotion codes.
*/
allow_promotion_codes?: boolean | null;

/**
* Total of all items before discounts or taxes are applied.
*/
Expand Down Expand Up @@ -621,6 +626,11 @@ declare module 'stripe' {
*/
success_url: string;

/**
* Enables user redeemable promotion codes.
*/
allow_promotion_codes?: boolean;

/**
* Specify whether Checkout should collect the customer's billing address.
*/
Expand Down
21 changes: 21 additions & 0 deletions types/2020-03-02/Coupons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ declare module 'stripe' {
*/
amount_off: number | null;

applies_to?: Coupon.AppliesTo;

/**
* Time at which the object was created. Measured in seconds since the Unix epoch.
*/
Expand Down Expand Up @@ -84,6 +86,13 @@ declare module 'stripe' {
}

namespace Coupon {
interface AppliesTo {
/**
* A list of product IDs this coupon applies to
*/
products: Array<string>;
}

type Duration = 'forever' | 'once' | 'repeating';
}

Expand Down Expand Up @@ -118,6 +127,11 @@ declare module 'stripe' {
*/
amount_off?: number;

/**
* A hash containing directions for what this Coupon will apply discounts to.
*/
applies_to?: CouponCreateParams.AppliesTo;

/**
* Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the `amount_off` parameter (required if `amount_off` is passed).
*/
Expand Down Expand Up @@ -165,6 +179,13 @@ declare module 'stripe' {
}

namespace CouponCreateParams {
interface AppliesTo {
/**
* An array of Product IDs that this Coupon will apply to.
*/
products: Array<string>;
}

type Duration = 'forever' | 'once' | 'repeating';
}

Expand Down
10 changes: 10 additions & 0 deletions types/2020-03-02/Customers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ declare module 'stripe' {
*/
preferred_locales?: Array<string>;

/**
* The API ID of a promotion code to apply to the customer. The customer will have a discount applied on all recurring payments. Charges you create through the API will not have the discount.
*/
promotion_code?: string;

/**
* The customer's shipping information. Appears on invoices emailed to this customer.
*/
Expand Down Expand Up @@ -466,6 +471,11 @@ declare module 'stripe' {
*/
preferred_locales?: Array<string>;

/**
* The API ID of a promotion code to apply to the customer. The customer will have a discount applied on all recurring payments. Charges you create through the API will not have the discount.
*/
promotion_code?: string;

/**
* The customer's shipping information. Appears on invoices emailed to this customer.
*/
Expand Down
10 changes: 10 additions & 0 deletions types/2020-03-02/Discounts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ declare module 'stripe' {
*/
invoice_item?: string | null;

/**
* The promotion code applied to create this discount.
*/
promotion_code?: string | Stripe.PromotionCode | null;

/**
* Date that the coupon was applied.
*/
Expand Down Expand Up @@ -96,6 +101,11 @@ declare module 'stripe' {
*/
invoice_item?: string | null;

/**
* The promotion code applied to create this discount.
*/
promotion_code?: string | Stripe.PromotionCode | null;

/**
* Date that the coupon was applied.
*/
Expand Down
Loading