Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe committed Nov 5, 2022
1 parent 9c9de9e commit 68ac772
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
24 changes: 10 additions & 14 deletions src/StripeMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import autoPagination = require('./autoPagination');
const makeAutoPaginationMethods = autoPagination.makeAutoPaginationMethods;

type StripeMethodSpec = {
method?: 'GET' | 'POST' | 'DELETE',
path: void, // removed in v11.0.0
fullPath: string,
urlParams?: Array<string>,
encode: any // TODO
host?: string,
methodType?: 'list' | 'search'
}
method?: 'GET' | 'POST' | 'DELETE';
path: void; // removed in v11.0.0
fullPath: string;
urlParams?: Array<string>;
encode: any;
host?: string;
methodType?: 'list' | 'search';
};
/**
* Create an API method from the declared spec.
*
Expand All @@ -33,16 +33,12 @@ function stripeMethod(spec: StripeMethodSpec) {
);
}
if (!spec.fullPath) {
throw new Error(
`'fullPath' must be provided when calling 'stripeMethod'`
);
throw new Error(`'fullPath' must be provided when calling 'stripeMethod'`);
}
return function(...args) {
const callback = typeof args[args.length - 1] == 'function' && args.pop();

spec.urlParams = utils.extractUrlParams(
spec.fullPath
);
spec.urlParams = utils.extractUrlParams(spec.fullPath);

const requestPromise = utils.callbackifyPromiseWithTimeout(
makeRequest(this, args, spec, {}),
Expand Down
16 changes: 11 additions & 5 deletions src/StripeResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function StripeResource(stripe, deprecatedUrlData) {
if (this.path) {
throw new Error(
'Support for StripeResource.path was dropped in stripe-node v11.0.0. Instead, you must fully specify "fullPath" on .stripeMethod({...})'
)
);
}

if (this.basePath) {
throw new Error(
'Support for StripeResource.basePath was dropped in stripe-node v11.0.0. Instead, you must fully specify "fullPath" on .stripeMethod({...})'
)
);
}

this.initialize(...arguments);
Expand All @@ -71,15 +71,21 @@ StripeResource.prototype = {
validateRequest: null,

createFullPath(_commandPath, _urlData) {
throw new Error('Support for `createFullPath` was removed in stripe-node v11.0.0. Please specify \'fullPath\' directly on .stripeMethod({})');
throw new Error(
"Support for `createFullPath` was removed in stripe-node v11.0.0. Please specify 'fullPath' directly on .stripeMethod({})"
);
},

createResourcePathWithSymbols(_pathWithSymbols) {
throw new Error('Support for `createResourcePathWithSymbols` was removed in stripe-node v11.0.0. Please specify \'fullPath\' directly on .stripeMethod({})')
throw new Error(
"Support for `createResourcePathWithSymbols` was removed in stripe-node v11.0.0. Please specify 'fullPath' directly on .stripeMethod({})"
);
},

_joinUrlParts(parts) {
throw new Error('Support for `_joinUrlParts` was removed in stripe-node v11.0.0. Please specify \'fullPath\' directly on .stripeMethod({})')
throw new Error(
"Support for `_joinUrlParts` was removed in stripe-node v11.0.0. Please specify 'fullPath' directly on .stripeMethod({})"
);
},

_timeoutHandler(timeout, req, callback) {
Expand Down
8 changes: 3 additions & 5 deletions src/makeRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ function getRequestOpts(self, requestArgs, spec, overrideData) {
const urlParams = spec.urlParams || [];
const encode = spec.encode || ((data) => data);

const commandPath = utils.makeURLInterpolator(
spec.fullPath || ''
);
const path = spec.fullPath
const commandPath = utils.makeURLInterpolator(spec.fullPath || '');
const path = spec.fullPath;

// Don't mutate args externally.
const args = [].slice.call(requestArgs);
Expand Down Expand Up @@ -40,7 +38,7 @@ function getRequestOpts(self, requestArgs, spec, overrideData) {
);
}

const requestPath = commandPath(urlData)
const requestPath = commandPath(urlData);

const headers = Object.assign(options.headers, spec.headers);

Expand Down
2 changes: 1 addition & 1 deletion src/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Stripe.prototype = {
case 'DEFAULT_PORT':
return DEFAULT_PORT;
case 'DEFAULT_BASE_PATH':
throw new Error("DEFAULT_BASE_BATH was removed in v11.0.0")
throw new Error('DEFAULT_BASE_BATH was removed in v11.0.0');
case 'DEFAULT_API_VERSION':
return DEFAULT_API_VERSION;
case 'DEFAULT_TIMEOUT':
Expand Down
3 changes: 1 addition & 2 deletions test/StripeResource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ describe('StripeResource', () => {
const makeResource = (stripe) => {
return new (StripeResource.extend({
testMethod: stripeMethod({
fullPath: "/v1/test",
fullPath: '/v1/test',
method: 'GET',
host: 'some.host.stripe.com',
}),
Expand Down Expand Up @@ -1109,7 +1109,6 @@ describe('StripeResource', () => {
*/
const makeResourceWithPDFMethod = (stripe) => {
return new (StripeResource.extend({

pdf: stripeMethod({
method: 'GET',
fullPath: '/v1/resourceWithPDF',
Expand Down

0 comments on commit 68ac772

Please sign in to comment.