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

Null out empty data sent to GET/DELETE APIs #2172

Merged
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
2 changes: 1 addition & 1 deletion src/StripeResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
resourcePath: '',

// Methods that don't use the API's default '/v1' path can override it with this setting.
basePath: null!,

Check warning on line 62 in src/StripeResource.ts

View workflow job for this annotation

GitHub Actions / Build

Forbidden non-null assertion

initialize(): void {},

Expand Down Expand Up @@ -128,7 +128,7 @@

const isUsingFullPath = !!spec.fullPath;
const commandPath: UrlInterpolator = makeURLInterpolator(
isUsingFullPath ? spec.fullPath! : spec.path || ''

Check warning on line 131 in src/StripeResource.ts

View workflow job for this annotation

GitHub Actions / Build

Forbidden non-null assertion
);
// When using fullPath, we ignore the resource path as it should already be
// fully qualified.
Expand Down Expand Up @@ -178,7 +178,7 @@
}

const dataInQuery = spec.method === 'GET' || spec.method === 'DELETE';
const bodyData = dataInQuery ? {} : data;
const bodyData = dataInQuery ? null : data;
const queryData = dataInQuery ? data : {};

return {
Expand Down
4 changes: 2 additions & 2 deletions src/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type RequestOptions = {
export type RequestOpts = {
requestMethod: string;
requestPath: string;
bodyData: RequestData;
bodyData: RequestData | null;
queryData: RequestData;
auth: string | null;
headers: RequestHeaders;
Expand Down Expand Up @@ -155,7 +155,7 @@ export type RequestSender = {
method: string,
host: string | null,
path: string,
data: RequestData,
data: RequestData | null,
auth: string | null,
options: RequestOptions,
usage: Array<string>,
Expand Down
44 changes: 22 additions & 22 deletions test/resources/Account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Account Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'DELETE',
url: '/v1/accounts/acct_16Tzq6DBahdM4C8s',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -59,7 +59,7 @@ describe('Account Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/account',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -70,7 +70,7 @@ describe('Account Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/accounts/foo',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -83,7 +83,7 @@ describe('Account Resource', () => {
auth: key,
method: 'GET',
url: '/v1/account',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -96,7 +96,7 @@ describe('Account Resource', () => {
auth: params.apiKey,
method: 'GET',
url: '/v1/account',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -107,7 +107,7 @@ describe('Account Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/account',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -122,7 +122,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/capabilities',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -133,7 +133,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/capabilities',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand All @@ -147,7 +147,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/capabilities/acap_123',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -162,7 +162,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/capabilities/acap_123',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('Account Resource', () => {
url:
'/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -232,7 +232,7 @@ describe('Account Resource', () => {
url:
'/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand Down Expand Up @@ -307,7 +307,7 @@ describe('Account Resource', () => {
url:
'/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -323,7 +323,7 @@ describe('Account Resource', () => {
url:
'/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand All @@ -337,7 +337,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/accountIdFoo321/external_accounts',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -348,7 +348,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/accountIdFoo321/external_accounts',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand Down Expand Up @@ -379,7 +379,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/persons/person_123',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -390,7 +390,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/persons/person_123',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand Down Expand Up @@ -471,7 +471,7 @@ describe('Account Resource', () => {
method: 'DELETE',
url: '/v1/accounts/acct_123/persons/person_123',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -482,7 +482,7 @@ describe('Account Resource', () => {
method: 'DELETE',
url: '/v1/accounts/acct_123/persons/person_123',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand All @@ -496,7 +496,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/persons',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -507,7 +507,7 @@ describe('Account Resource', () => {
method: 'GET',
url: '/v1/accounts/acct_123/persons',
headers: {},
data: {},
data: null,
auth: TEST_AUTH_KEY,
settings: {},
});
Expand Down
6 changes: 3 additions & 3 deletions test/resources/ApplePayDomains.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('ApplePayDomains Resource', () => {
method: 'GET',
url: '/v1/apple_pay/domains/apwc_retrieve',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -24,7 +24,7 @@ describe('ApplePayDomains Resource', () => {
method: 'DELETE',
url: '/v1/apple_pay/domains/apwc_delete',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('ApplePayDomains Resource', () => {
method: 'GET',
url: '/v1/apple_pay/domains',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/resources/ApplicationFees.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('ApplicationFee Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/application_fees',
data: {},
data: null,
headers: {},
settings: {},
});
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('ApplicationFee Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/application_fees/appFeeIdExample3242/refunds',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -65,7 +65,7 @@ describe('ApplicationFee Resource', () => {
method: 'GET',
url:
'/v1/application_fees/appFeeIdExample3242/refunds/refundIdExample2312',
data: {},
data: null,
headers: {},
settings: {},
});
Expand Down
4 changes: 2 additions & 2 deletions test/resources/Balance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Balance Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/balance',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -21,7 +21,7 @@ describe('Balance Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/balance',
data: {},
data: null,
auth: 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11',
headers: {},
settings: {},
Expand Down
4 changes: 2 additions & 2 deletions test/resources/BalanceTransactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('BalanceTransactions Resource', function() {
method: 'GET',
url: '/v1/balance_transactions/txn_123',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -24,7 +24,7 @@ describe('BalanceTransactions Resource', function() {
method: 'GET',
url: '/v1/balance_transactions',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/resources/BillingPortal/Configurations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('BillingPortal', () => {
method: 'GET',
url: '/v1/billing_portal/configurations/bpc_123',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand All @@ -64,7 +64,7 @@ describe('BillingPortal', () => {
method: 'GET',
url: '/v1/billing_portal/configurations',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/resources/Charges.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Charge Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/charges/chargeIdFoo123',
data: {},
data: null,
headers: {},
settings: {},
});
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('Charge Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/charges',
data: {},
data: null,
headers: {},
settings: {},
});
Expand Down
4 changes: 2 additions & 2 deletions test/resources/Checkout/Sessions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Checkout', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/checkout/sessions/cs_123',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -59,7 +59,7 @@ describe('Checkout', () => {
method: 'GET',
url: '/v1/checkout/sessions/cs_123/line_items',
headers: {},
data: {},
data: null,
settings: {},
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/resources/CountrySpecs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('CountrySpecs Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/country_specs',
data: {},
data: null,
headers: {},
settings: {},
});
Expand All @@ -24,7 +24,7 @@ describe('CountrySpecs Resource', () => {
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: `/v1/country_specs/${country}`,
data: {},
data: null,
headers: {},
settings: {},
});
Expand Down
Loading
Loading