diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..0f1786729b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.eslintrc.js b/.eslintrc.js index f9e49b1e55..6d8aa70f17 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,292 +1,251 @@ module.exports = { - "env": { - "node": true, - "es6": true - }, - "extends": "eslint:recommended", - "rules": { - "accessor-pairs": "error", - "array-bracket-spacing": [ - "error", - "never" - ], - "array-callback-return": "off", - "arrow-body-style": "error", - "arrow-parens": "error", - "arrow-spacing": "error", - "block-scoped-var": "off", - "block-spacing": "off", - "brace-style": [ - "error", - "1tbs", - { - "allowSingleLine": true - } - ], - "camelcase": [ - "error", - { - "properties": "never" - } - ], - "capitalized-comments": "off", - "class-methods-use-this": "error", - "comma-dangle": "off", - "comma-spacing": "off", - "comma-style": [ - "error", - "last" - ], - "complexity": "error", - "computed-property-spacing": [ - "error", - "never" - ], - "consistent-return": "off", - "consistent-this": "off", - "curly": "error", - "default-case": "off", - "dot-location": [ - "error", - "property" - ], - "dot-notation": "error", - "eol-last": "error", - "eqeqeq": "off", - "func-call-spacing": "error", - "func-name-matching": "error", - "func-names": "off", - "func-style": [ - "error", - "declaration" - ], - "generator-star-spacing": "error", - "global-require": "off", - "guard-for-in": "off", - "handle-callback-err": "off", - "id-blacklist": "error", - "id-length": "off", - "id-match": "error", - "indent": ["error", 2], - "init-declarations": "off", - "jsx-quotes": "error", - "key-spacing": "error", - "keyword-spacing": [ - "error", - { - "after": true, - "before": true - } - ], - "line-comment-position": "off", - "linebreak-style": [ - "error", - "unix" - ], - "lines-around-comment": "error", - "lines-around-directive": "error", - "max-depth": "error", - "max-len": "off", - "max-lines": "off", - "max-nested-callbacks": "error", - "max-params": "off", - "max-statements": "off", - "max-statements-per-line": "off", - "multiline-ternary": "off", - "new-cap": "error", - "new-parens": "error", - "newline-after-var": "off", - "newline-before-return": "off", - "newline-per-chained-call": "off", - "no-alert": "error", - "no-array-constructor": "error", - "no-await-in-loop": "error", - "no-bitwise": "off", - "no-caller": "error", - "no-catch-shadow": "off", - "no-compare-neg-zero": "error", - "no-confusing-arrow": "error", - "no-continue": "off", - "no-div-regex": "error", - "no-duplicate-imports": "error", - "no-else-return": "off", - "no-empty-function": "off", - "no-eq-null": "off", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-extra-parens": "off", - "no-floating-decimal": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-inline-comments": "off", - "no-inner-declarations": [ - "error", - "functions" - ], - "no-invalid-this": "off", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-lonely-if": "error", - "no-loop-func": "error", - "no-magic-numbers": "off", - "no-mixed-operators": "error", - "no-mixed-requires": "error", - "no-multi-assign": "off", - "no-multi-spaces": "error", - "no-multi-str": "error", - "no-multiple-empty-lines": "error", - "no-native-reassign": "error", - "no-negated-condition": "off", - "no-negated-in-lhs": "error", - "no-nested-ternary": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-object": "error", - "no-new-require": "error", - "no-new-wrappers": "error", - "no-octal-escape": "error", - "no-param-reassign": "off", - "no-path-concat": "error", - "no-plusplus": [ - "error", - { - "allowForLoopAfterthoughts": true - } - ], - "no-process-env": "off", - "no-process-exit": "error", - "no-proto": "error", - "no-prototype-builtins": "off", - "no-restricted-globals": "error", - "no-restricted-imports": "error", - "no-restricted-modules": "error", - "no-restricted-properties": "error", - "no-restricted-syntax": "error", - "no-return-assign": "error", - "no-return-await": "error", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-shadow": "off", - "no-shadow-restricted-names": "error", - "no-spaced-func": "error", - "no-sync": "error", - "no-tabs": "error", - "no-template-curly-in-string": "error", - "no-ternary": "off", - "no-throw-literal": "error", - "no-trailing-spaces": "error", - "no-undef-init": "error", - "no-undefined": "off", - "no-underscore-dangle": "off", - "no-unmodified-loop-condition": "error", - "no-unneeded-ternary": "error", - "no-unused-expressions": "error", - "no-unused-vars": [ - "error", - { - "args": "none" - } - ], - "no-use-before-define": "off", - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-constructor": "error", - "no-useless-escape": "off", - "no-useless-rename": "error", - "no-useless-return": "error", - "no-var": "off", - "no-void": "error", - "no-warning-comments": "error", - "no-whitespace-before-property": "error", - "no-with": "error", - "nonblock-statement-body-position": "error", - "object-curly-newline": "off", - "object-curly-spacing": [ - "error", - "never" - ], - "object-property-newline": "off", - "object-shorthand": "off", - "one-var": "off", - "one-var-declaration-per-line": "error", - "operator-assignment": [ - "error", - "always" - ], - "operator-linebreak": "off", - "padded-blocks": "off", - "prefer-arrow-callback": "off", - "prefer-const": "error", - "prefer-destructuring": [ - "error", - { - "array": false, - "object": false - } - ], - "prefer-numeric-literals": "error", - "prefer-promise-reject-errors": "error", - "prefer-reflect": "off", - "prefer-rest-params": "off", - "prefer-spread": "off", - "prefer-template": "off", - "quote-props": "off", - "quotes": [ - "error", - "single", - { - "avoidEscape": true - } - ], - "radix": "error", - "require-await": "error", - "require-jsdoc": "off", - "rest-spread-spacing": "error", - "semi": "off", - "semi-spacing": [ - "error", - { - "after": true, - "before": false - } - ], - "sort-imports": "error", - "sort-keys": "off", - "sort-vars": "error", - "space-before-blocks": "error", - "space-before-function-paren": "off", - "space-in-parens": [ - "error", - "never" - ], - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": [ - "error", - "always" - ], - "strict": "off", - "symbol-description": "error", - "template-curly-spacing": "error", - "template-tag-spacing": "error", - "unicode-bom": [ - "error", - "never" - ], - "valid-jsdoc": "off", - "vars-on-top": "off", - "wrap-iife": "error", - "wrap-regex": "off", - "yield-star-spacing": "error", - "yoda": [ - "error", - "never" - ] - } + env: { + node: true, + es6: true, + }, + rules: { + 'accessor-pairs': 'error', + 'array-bracket-spacing': ['error', 'never'], + 'array-callback-return': 'off', + 'arrow-parens': 'error', + 'arrow-spacing': 'error', + 'block-scoped-var': 'off', + 'block-spacing': 'off', + 'brace-style': [ + 'error', + '1tbs', + { + allowSingleLine: true, + }, + ], + camelcase: [ + 'error', + { + properties: 'never', + }, + ], + 'capitalized-comments': 'off', + 'class-methods-use-this': 'error', + 'comma-dangle': 'off', + 'comma-spacing': 'off', + 'comma-style': ['error', 'last'], + complexity: 'error', + 'computed-property-spacing': ['error', 'never'], + 'consistent-return': 'off', + 'consistent-this': 'off', + curly: 'error', + 'default-case': 'off', + 'dot-location': ['error', 'property'], + 'dot-notation': 'error', + 'eol-last': 'error', + eqeqeq: 'off', + 'func-call-spacing': 'error', + 'func-name-matching': 'error', + 'func-names': 'off', + 'func-style': ['error', 'declaration', {allowArrowFunctions: true}], + 'generator-star-spacing': 'error', + 'global-require': 'off', + 'guard-for-in': 'off', + 'handle-callback-err': 'off', + 'id-blacklist': 'error', + 'id-length': 'off', + 'id-match': 'error', + 'init-declarations': 'off', + 'jsx-quotes': 'error', + 'key-spacing': 'error', + 'keyword-spacing': [ + 'error', + { + after: true, + before: true, + }, + ], + 'line-comment-position': 'off', + 'linebreak-style': ['error', 'unix'], + 'lines-around-comment': 'error', + 'lines-around-directive': 'error', + 'max-depth': 'error', + 'max-len': 'off', + 'max-lines': 'off', + 'max-nested-callbacks': 'error', + 'max-params': 'off', + 'max-statements': 'off', + 'max-statements-per-line': 'off', + 'multiline-ternary': 'off', + 'new-cap': 'error', + 'new-parens': 'error', + 'newline-after-var': 'off', + 'newline-before-return': 'off', + 'newline-per-chained-call': 'off', + 'no-alert': 'error', + 'no-array-constructor': 'error', + 'no-await-in-loop': 'error', + 'no-bitwise': 'off', + 'no-caller': 'error', + 'no-catch-shadow': 'off', + 'no-compare-neg-zero': 'error', + 'no-confusing-arrow': 'error', + 'no-continue': 'off', + 'no-div-regex': 'error', + 'no-duplicate-imports': 'error', + 'no-else-return': 'off', + 'no-empty-function': 'off', + 'no-eq-null': 'off', + 'no-eval': 'error', + 'no-extend-native': 'error', + 'no-extra-bind': 'error', + 'no-extra-label': 'error', + 'no-extra-parens': 'off', + 'no-floating-decimal': 'error', + 'no-implicit-globals': 'error', + 'no-implied-eval': 'error', + 'no-inline-comments': 'off', + 'no-inner-declarations': ['error', 'functions'], + 'no-invalid-this': 'off', + 'no-iterator': 'error', + 'no-label-var': 'error', + 'no-labels': 'error', + 'no-lone-blocks': 'error', + 'no-lonely-if': 'error', + 'no-loop-func': 'error', + 'no-magic-numbers': 'off', + 'no-mixed-requires': 'error', + 'no-multi-assign': 'off', + 'no-multi-spaces': 'error', + 'no-multi-str': 'error', + 'no-multiple-empty-lines': 'error', + 'no-native-reassign': 'error', + 'no-negated-condition': 'off', + 'no-negated-in-lhs': 'error', + 'no-nested-ternary': 'error', + 'no-new': 'error', + 'no-new-func': 'error', + 'no-new-object': 'error', + 'no-new-require': 'error', + 'no-new-wrappers': 'error', + 'no-octal-escape': 'error', + 'no-param-reassign': 'off', + 'no-path-concat': 'error', + 'no-plusplus': [ + 'error', + { + allowForLoopAfterthoughts: true, + }, + ], + 'no-process-env': 'off', + 'no-process-exit': 'error', + 'no-proto': 'error', + 'no-prototype-builtins': 'off', + 'no-restricted-globals': 'error', + 'no-restricted-imports': 'error', + 'no-restricted-modules': 'error', + 'no-restricted-properties': 'error', + 'no-restricted-syntax': 'error', + 'no-return-assign': 'error', + 'no-return-await': 'error', + 'no-script-url': 'error', + 'no-self-compare': 'error', + 'no-sequences': 'error', + 'no-shadow': 'off', + 'no-shadow-restricted-names': 'error', + 'no-spaced-func': 'error', + 'no-sync': 'error', + 'no-tabs': 'error', + 'no-template-curly-in-string': 'error', + 'no-ternary': 'off', + 'no-throw-literal': 'error', + 'no-trailing-spaces': 'error', + 'no-undef-init': 'error', + 'no-undefined': 'off', + 'no-underscore-dangle': 'off', + 'no-unmodified-loop-condition': 'error', + 'no-unneeded-ternary': 'error', + 'no-unused-expressions': 'error', + 'no-unused-vars': [ + 'error', + { + args: 'none', + }, + ], + 'no-use-before-define': 'off', + 'no-useless-call': 'error', + 'no-useless-computed-key': 'error', + 'no-useless-concat': 'error', + 'no-useless-constructor': 'error', + 'no-useless-escape': 'off', + 'no-useless-rename': 'error', + 'no-useless-return': 'error', + 'no-var': 'off', + 'no-void': 'error', + 'no-warning-comments': 'error', + 'no-whitespace-before-property': 'error', + 'no-with': 'error', + 'nonblock-statement-body-position': 'error', + 'object-curly-newline': 'off', + 'object-curly-spacing': ['error', 'never'], + 'object-property-newline': 'off', + 'object-shorthand': 'off', + 'one-var': 'off', + 'one-var-declaration-per-line': 'error', + 'operator-assignment': ['error', 'always'], + 'operator-linebreak': 'off', + 'padded-blocks': 'off', + 'prefer-arrow-callback': 'off', + 'prefer-const': 'error', + 'prefer-destructuring': [ + 'error', + { + array: false, + object: false, + }, + ], + 'prefer-numeric-literals': 'error', + 'prefer-promise-reject-errors': 'error', + 'prefer-reflect': 'off', + 'prefer-rest-params': 'off', + 'prefer-spread': 'off', + 'prefer-template': 'off', + 'quote-props': 'off', + quotes: [ + 'error', + 'single', + { + avoidEscape: true, + }, + ], + radix: 'error', + 'require-await': 'error', + 'require-jsdoc': 'off', + 'rest-spread-spacing': 'error', + semi: 'off', + 'semi-spacing': [ + 'error', + { + after: true, + before: false, + }, + ], + 'sort-imports': 'error', + 'sort-keys': 'off', + 'sort-vars': 'error', + 'space-before-blocks': 'error', + 'space-before-function-paren': 'off', + 'space-in-parens': ['error', 'never'], + 'space-infix-ops': 'error', + 'space-unary-ops': 'error', + 'spaced-comment': ['error', 'always'], + strict: 'off', + 'symbol-description': 'error', + 'template-curly-spacing': 'error', + 'template-tag-spacing': 'error', + 'unicode-bom': ['error', 'never'], + 'valid-jsdoc': 'off', + 'vars-on-top': 'off', + 'wrap-regex': 'off', + 'yield-star-spacing': 'error', + yoda: ['error', 'never'], + }, + parser: 'babel-eslint', + plugins: ['prettier'], + extends: ['plugin:prettier/recommended'], }; diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..c1d1f967c6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "arrowParens": "always", + "trailingComma": "es5", + "bracketSpacing": false, + "singleQuote": true +} diff --git a/.travis.yml b/.travis.yml index e27e0be1c2..8688147ac6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,11 @@ language: node_js +cache: + yarn: true + directories: + - node_modules node_js: - - "4.0.0" - - "4" - - "5" - - "6" - - "7" - - "8" - - "9" - - "10" + - '6' + - '8' + - '10' sudo: false -after_success: npm run report && npm run coveralls +after_success: yarn report && yarn coveralls diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..4ae3c5fb06 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + "recommendations": [ + // JS Language plugins (~required) + "dbaeumer.vscode-eslint", + "joshpeng.sublime-babel-vscode", + "esbenp.prettier-vscode", + + // Highly recommended + "EditorConfig.editorconfig" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..03123de2c1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + // Show the path in the top window bar. + "window.title": "${rootName}${separator}${activeEditorMedium}", + + // Formatting + "editor.formatOnSave": true, + "beautify.ignore": ["**/*.js", "**/*.md"], + + // Extension settings + "eslint.autoFixOnSave": true, + "eslint.packageManager": "yarn", + "npm.packageManager": "yarn" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index b7502c6d34..0f7824541e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,486 +1,651 @@ # CHANGELOG +## 7.0.0 - 2019-05-14 + +Major version release. [The migration guide](https://github.com/stripe/stripe-node/wiki/Migration-guide-for-v7) contains a detailed list of backwards-incompatible changes with upgrade instructions. + +Pull requests included in this release (cf. [#606](https://github.com/stripe/stripe-node/pull/606)) (⚠️ = breaking changes): + +- ⚠️ Drop support for Node 4, 5 and 7 ([#606](https://github.com/stripe/stripe-node/pull/606)) +- Prettier formatting ([#604](https://github.com/stripe/stripe-node/pull/604)) +- Alphabetize “basic” methods ([#610](https://github.com/stripe/stripe-node/pull/610)) +- Use `id` for single positional arguments ([#611](https://github.com/stripe/stripe-node/pull/611)) +- Modernize ES5 to ES6 with lebab ([#607](https://github.com/stripe/stripe-node/pull/607)) +- ⚠️ Remove deprecated methods ([#613](https://github.com/stripe/stripe-node/pull/613)) +- Add VSCode and EditorConfig files ([#620](https://github.com/stripe/stripe-node/pull/620)) +- ⚠️ Drop support for Node 9 and bump dependencies to latest versions ([#614](https://github.com/stripe/stripe-node/pull/614)) +- Misc. manual formatting ([#623](https://github.com/stripe/stripe-node/pull/623)) +- ⚠️ Remove legacy parameter support in `invoices.retrieveUpcoming()` ([#621](https://github.com/stripe/stripe-node/pull/621)) +- ⚠️ Remove curried urlData and manually specified urlParams ([#625](https://github.com/stripe/stripe-node/pull/625)) +- Extract resources file ([#626](https://github.com/stripe/stripe-node/pull/626)) + ## 6.36.0 - 2019-05-14 -* [#622](https://github.com/stripe/stripe-node/pull/622) Add support for the `Capability` resource and APIs + +- [#622](https://github.com/stripe/stripe-node/pull/622) Add support for the `Capability` resource and APIs ## 6.35.0 - 2019-05-14 -* [#627](https://github.com/stripe/stripe-node/pull/627) Add `listLineItems` and `listUpcomingLineItems` methods to `Invoice` + +- [#627](https://github.com/stripe/stripe-node/pull/627) Add `listLineItems` and `listUpcomingLineItems` methods to `Invoice` ## 6.34.0 - 2019-05-08 -* [#619](https://github.com/stripe/stripe-node/pull/619) Move `generateTestHeaderString` to stripe.webhooks (fixes a bug in 6.33.0) + +- [#619](https://github.com/stripe/stripe-node/pull/619) Move `generateTestHeaderString` to stripe.webhooks (fixes a bug in 6.33.0) ## 6.33.0 - 2019-05-08 - UNRELEASED **Important**: This version is non-functional and has been yanked in favor of 6.32.0. -* [#609](https://github.com/stripe/stripe-node/pull/609) Add `generateWebhookHeaderString` to make it easier to mock webhook events +- [#609](https://github.com/stripe/stripe-node/pull/609) Add `generateWebhookHeaderString` to make it easier to mock webhook events ## 6.32.0 - 2019-05-07 -* [#612](https://github.com/stripe/stripe-node/pull/612) Add `balanceTransactions` resource + +- [#612](https://github.com/stripe/stripe-node/pull/612) Add `balanceTransactions` resource ## 6.31.2 - 2019-05-03 -* [#602](https://github.com/stripe/stripe-node/pull/602) Handle errors from the oauth/token endpoint + +- [#602](https://github.com/stripe/stripe-node/pull/602) Handle errors from the oauth/token endpoint ## 6.31.1 - 2019-04-26 -* [#600](https://github.com/stripe/stripe-node/pull/600) Fix encoding of nested parameters in multipart requests + +- [#600](https://github.com/stripe/stripe-node/pull/600) Fix encoding of nested parameters in multipart requests ## 6.31.0 - 2019-04-24 -* [#588](https://github.com/stripe/stripe-node/pull/588) Add support for the `TaxRate` resource and APIs + +- [#588](https://github.com/stripe/stripe-node/pull/588) Add support for the `TaxRate` resource and APIs ## 6.30.0 - 2019-04-22 -* [#589](https://github.com/stripe/stripe-node/pull/589) Add support for the `TaxId` resource and APIs -* [#593](https://github.com/stripe/stripe-node/pull/593) `retrieveUpcoming` on `Invoice` can now take one hash as parameter instead of requiring a customer id. + +- [#589](https://github.com/stripe/stripe-node/pull/589) Add support for the `TaxId` resource and APIs +- [#593](https://github.com/stripe/stripe-node/pull/593) `retrieveUpcoming` on `Invoice` can now take one hash as parameter instead of requiring a customer id. ## 6.29.0 - 2019-04-18 -* [#585](https://github.com/stripe/stripe-node/pull/585) Add support for the `CreditNote` resource and APIs + +- [#585](https://github.com/stripe/stripe-node/pull/585) Add support for the `CreditNote` resource and APIs ## 6.28.0 - 2019-03-18 -* [#570](https://github.com/stripe/stripe-node/pull/570) Add support for the `PaymentMethod` resource and APIs -* [#578](https://github.com/stripe/stripe-node/pull/578) Add support for retrieving a Checkout `Session` + +- [#570](https://github.com/stripe/stripe-node/pull/570) Add support for the `PaymentMethod` resource and APIs +- [#578](https://github.com/stripe/stripe-node/pull/578) Add support for retrieving a Checkout `Session` ## 6.27.0 - 2019-03-15 -* [#581](https://github.com/stripe/stripe-node/pull/581) Add support for deleting Terminal `Location` and `Reader` + +- [#581](https://github.com/stripe/stripe-node/pull/581) Add support for deleting Terminal `Location` and `Reader` ## 6.26.1 - 2019-03-14 -* [#580](https://github.com/stripe/stripe-node/pull/580) Fix support for HTTPS proxies + +- [#580](https://github.com/stripe/stripe-node/pull/580) Fix support for HTTPS proxies ## 6.26.0 - 2019-03-11 -* [#574](https://github.com/stripe/stripe-node/pull/574) Encode `Date`s as Unix timestamps + +- [#574](https://github.com/stripe/stripe-node/pull/574) Encode `Date`s as Unix timestamps ## 6.25.1 - 2019-02-14 -* [#565](https://github.com/stripe/stripe-node/pull/565) Always encode arrays as integer-indexed hashes + +- [#565](https://github.com/stripe/stripe-node/pull/565) Always encode arrays as integer-indexed hashes ## 6.25.0 - 2019-02-13 -* [#559](https://github.com/stripe/stripe-node/pull/559) Add `stripe.setMaxNetworkRetries(n)` for automatic network retries + +- [#559](https://github.com/stripe/stripe-node/pull/559) Add `stripe.setMaxNetworkRetries(n)` for automatic network retries ## 6.24.0 - 2019-02-12 -* [#562](https://github.com/stripe/stripe-node/pull/562) Add support for `SubscriptionSchedule` and `SubscriptionScheduleRevision` + +- [#562](https://github.com/stripe/stripe-node/pull/562) Add support for `SubscriptionSchedule` and `SubscriptionScheduleRevision` ## 6.23.1 - 2019-02-04 -* [#560](https://github.com/stripe/stripe-node/pull/560) Enable persistent connections by default + +- [#560](https://github.com/stripe/stripe-node/pull/560) Enable persistent connections by default ## 6.23.0 - 2019-01-30 -* [#557](https://github.com/stripe/stripe-node/pull/557) Add configurable telemetry to gather information on client-side request latency + +- [#557](https://github.com/stripe/stripe-node/pull/557) Add configurable telemetry to gather information on client-side request latency ## 6.22.0 - 2019-01-25 -* [#555](https://github.com/stripe/stripe-node/pull/555) Add support for OAuth methods + +- [#555](https://github.com/stripe/stripe-node/pull/555) Add support for OAuth methods ## 6.21.0 - 2019-01-23 -* [#551](https://github.com/stripe/stripe-node/pull/551) Rename `CheckoutSession` to `Session` and move it under the `checkout` namespace. This is a breaking change, but we've reached out to affected merchants and all new merchants would use the new approach. + +- [#551](https://github.com/stripe/stripe-node/pull/551) Rename `CheckoutSession` to `Session` and move it under the `checkout` namespace. This is a breaking change, but we've reached out to affected merchants and all new merchants would use the new approach. ## 6.20.1 - 2019-01-17 -* [#552](https://github.com/stripe/stripe-node/pull/552) Fix `Buffer` deprecation warnings + +- [#552](https://github.com/stripe/stripe-node/pull/552) Fix `Buffer` deprecation warnings ## 6.20.0 - 2018-12-21 -* [#539](https://github.com/stripe/stripe-node/pull/539) Add support for the `CheckoutSession` resource + +- [#539](https://github.com/stripe/stripe-node/pull/539) Add support for the `CheckoutSession` resource ## 6.19.0 - 2018-12-10 -* [#535](https://github.com/stripe/stripe-node/pull/535) Add support for account links + +- [#535](https://github.com/stripe/stripe-node/pull/535) Add support for account links ## 6.18.1 - 2018-12-07 -* [#534](https://github.com/stripe/stripe-node/pull/534) Fix iterating on `files.list` method + +- [#534](https://github.com/stripe/stripe-node/pull/534) Fix iterating on `files.list` method ## 6.18.0 - 2018-12-06 -* [#530](https://github.com/stripe/stripe-node/pull/530) Export errors on root Stripe object + +- [#530](https://github.com/stripe/stripe-node/pull/530) Export errors on root Stripe object ## 6.17.0 - 2018-11-28 -* [#527](https://github.com/stripe/stripe-node/pull/527) Add support for the `Review` APIs + +- [#527](https://github.com/stripe/stripe-node/pull/527) Add support for the `Review` APIs ## 6.16.0 - 2018-11-27 -* [#515](https://github.com/stripe/stripe-node/pull/515) Add support for `ValueLists` and `ValueListItems` for Radar + +- [#515](https://github.com/stripe/stripe-node/pull/515) Add support for `ValueLists` and `ValueListItems` for Radar ## 6.15.2 - 2018-11-26 -* [#526](https://github.com/stripe/stripe-node/pull/526) Fixes an accidental mutation of input in rare cases + +- [#526](https://github.com/stripe/stripe-node/pull/526) Fixes an accidental mutation of input in rare cases ## 6.15.1 - 2018-11-23 -* [#523](https://github.com/stripe/stripe-node/pull/523) Handle `Buffer` instances in `Webhook.constructEvent` + +- [#523](https://github.com/stripe/stripe-node/pull/523) Handle `Buffer` instances in `Webhook.constructEvent` ## 6.15.0 - 2018-11-12 -* [#474](https://github.com/stripe/stripe-node/pull/474) Add support for `partner_id` in `setAppInfo` + +- [#474](https://github.com/stripe/stripe-node/pull/474) Add support for `partner_id` in `setAppInfo` ## 6.14.0 - 2018-11-09 -* [#509](https://github.com/stripe/stripe-node/pull/509) Add support for new `Invoice` methods + +- [#509](https://github.com/stripe/stripe-node/pull/509) Add support for new `Invoice` methods ## 6.13.0 - 2018-10-30 -* [#507](https://github.com/stripe/stripe-node/pull/507) Add support for persons -* [#510](https://github.com/stripe/stripe-node/pull/510) Add support for webhook endpoints + +- [#507](https://github.com/stripe/stripe-node/pull/507) Add support for persons +- [#510](https://github.com/stripe/stripe-node/pull/510) Add support for webhook endpoints ## 6.12.1 - 2018-09-24 -* [#502](https://github.com/stripe/stripe-node/pull/502) Fix test suite + +- [#502](https://github.com/stripe/stripe-node/pull/502) Fix test suite ## 6.12.0 - 2018-09-24 -* [#498](https://github.com/stripe/stripe-node/pull/498) Add support for Stripe Terminal -* [#500](https://github.com/stripe/stripe-node/pull/500) Rename `FileUploads` to `Files`. For backwards compatibility, `Files` is aliased to `FileUploads`. `FileUploads` is deprecated and will be removed from the next major version. + +- [#498](https://github.com/stripe/stripe-node/pull/498) Add support for Stripe Terminal +- [#500](https://github.com/stripe/stripe-node/pull/500) Rename `FileUploads` to `Files`. For backwards compatibility, `Files` is aliased to `FileUploads`. `FileUploads` is deprecated and will be removed from the next major version. ## 6.11.0 - 2018-09-18 -* [#496](https://github.com/stripe/stripe-node/pull/496) Add auto-pagination + +- [#496](https://github.com/stripe/stripe-node/pull/496) Add auto-pagination ## 6.10.0 - 2018-09-05 -* [#491](https://github.com/stripe/stripe-node/pull/491) Add support for usage record summaries + +- [#491](https://github.com/stripe/stripe-node/pull/491) Add support for usage record summaries ## 6.9.0 - 2018-09-05 -* [#493](https://github.com/stripe/stripe-node/pull/493) Add support for reporting resources + +- [#493](https://github.com/stripe/stripe-node/pull/493) Add support for reporting resources ## 6.8.0 - 2018-08-27 -* [#488](https://github.com/stripe/stripe-node/pull/488) Remove support for `BitcoinReceivers` write-actions + +- [#488](https://github.com/stripe/stripe-node/pull/488) Remove support for `BitcoinReceivers` write-actions ## 6.7.0 - 2018-08-03 -* [#485](https://github.com/stripe/stripe-node/pull/485) Add support for `cancel` on topups + +- [#485](https://github.com/stripe/stripe-node/pull/485) Add support for `cancel` on topups ## 6.6.0 - 2018-08-02 -* [#483](https://github.com/stripe/stripe-node/pull/483) Add support for file links + +- [#483](https://github.com/stripe/stripe-node/pull/483) Add support for file links ## 6.5.0 - 2018-07-28 -* [#482](https://github.com/stripe/stripe-node/pull/482) Add support for Sigma scheduled query runs + +- [#482](https://github.com/stripe/stripe-node/pull/482) Add support for Sigma scheduled query runs ## 6.4.0 - 2018-07-26 -* [#481](https://github.com/stripe/stripe-node/pull/481) Add support for Stripe Issuing + +- [#481](https://github.com/stripe/stripe-node/pull/481) Add support for Stripe Issuing ## 6.3.0 - 2018-07-18 -* [#471](https://github.com/stripe/stripe-node/pull/471) Add support for streams in file uploads + +- [#471](https://github.com/stripe/stripe-node/pull/471) Add support for streams in file uploads ## 6.2.1 - 2018-07-03 -* [#475](https://github.com/stripe/stripe-node/pull/475) Fixes array encoding of subscription items for the upcoming invoices endpoint. + +- [#475](https://github.com/stripe/stripe-node/pull/475) Fixes array encoding of subscription items for the upcoming invoices endpoint. ## 6.2.0 - 2018-06-28 -* [#473](https://github.com/stripe/stripe-node/pull/473) Add support for payment intents + +- [#473](https://github.com/stripe/stripe-node/pull/473) Add support for payment intents ## 6.1.1 - 2018-06-07 -* [#469](https://github.com/stripe/stripe-node/pull/469) Add `.npmignore` to create a lighter package (minus examples and tests) + +- [#469](https://github.com/stripe/stripe-node/pull/469) Add `.npmignore` to create a lighter package (minus examples and tests) ## 6.1.0 - 2018-06-01 -* [#465](https://github.com/stripe/stripe-node/pull/465) Warn when unknown options are passed to functions + +- [#465](https://github.com/stripe/stripe-node/pull/465) Warn when unknown options are passed to functions ## 6.0.0 - 2018-05-14 -* [#453](https://github.com/stripe/stripe-node/pull/453) Re-implement usage record's `create` so that it correctly passes all arguments (this is a very minor breaking change) + +- [#453](https://github.com/stripe/stripe-node/pull/453) Re-implement usage record's `create` so that it correctly passes all arguments (this is a very minor breaking change) ## 5.10.0 - 2018-05-14 -* [#459](https://github.com/stripe/stripe-node/pull/459) Export error types on `stripe.errors` so that errors can be matched with `instanceof` instead of comparing the strings generated by `type` + +- [#459](https://github.com/stripe/stripe-node/pull/459) Export error types on `stripe.errors` so that errors can be matched with `instanceof` instead of comparing the strings generated by `type` ## 5.9.0 - 2018-05-09 -* [#456](https://github.com/stripe/stripe-node/pull/456) Add support for issuer fraud records + +- [#456](https://github.com/stripe/stripe-node/pull/456) Add support for issuer fraud records ## 5.8.0 - 2018-04-04 -* [#444](https://github.com/stripe/stripe-node/pull/444) Introduce flexible billing primitives for subscriptions + +- [#444](https://github.com/stripe/stripe-node/pull/444) Introduce flexible billing primitives for subscriptions ## 5.7.0 - 2018-04-02 -* [#441](https://github.com/stripe/stripe-node/pull/441) Write directly to a connection that's known to be still open + +- [#441](https://github.com/stripe/stripe-node/pull/441) Write directly to a connection that's known to be still open ## 5.6.1 - 2018-03-25 -* [#437](https://github.com/stripe/stripe-node/pull/437) Fix error message when passing invalid parameters to some API methods + +- [#437](https://github.com/stripe/stripe-node/pull/437) Fix error message when passing invalid parameters to some API methods ## 5.6.0 - 2018-03-24 -* [#439](https://github.com/stripe/stripe-node/pull/439) Drop Bluebird dependency and use native ES6 promises + +- [#439](https://github.com/stripe/stripe-node/pull/439) Drop Bluebird dependency and use native ES6 promises ## 5.5.0 - 2018-02-21 -* [#425](https://github.com/stripe/stripe-node/pull/425) Add support for topups + +- [#425](https://github.com/stripe/stripe-node/pull/425) Add support for topups ## 5.4.0 - 2017-12-05 -* [#412](https://github.com/stripe/stripe-node/pull/412) Add `StripeIdempotencyError` type for new kind of stripe error + +- [#412](https://github.com/stripe/stripe-node/pull/412) Add `StripeIdempotencyError` type for new kind of stripe error ## 5.3.0 - 2017-10-31 -* [#405](https://github.com/stripe/stripe-node/pull/405) Support for exchange rates APIs + +- [#405](https://github.com/stripe/stripe-node/pull/405) Support for exchange rates APIs ## 5.2.0 - 2017-10-26 -* [#404](https://github.com/stripe/stripe-node/pull/404) Support for listing source transactions + +- [#404](https://github.com/stripe/stripe-node/pull/404) Support for listing source transactions ## 5.1.1 - 2017-10-04 -* [#394](https://github.com/stripe/stripe-node/pull/394) Fix improper warning for requests that have options but no parameters + +- [#394](https://github.com/stripe/stripe-node/pull/394) Fix improper warning for requests that have options but no parameters ## 5.1.0 - 2017-09-25 -* Add check for when options are accidentally included in an arguments object -* Use safe-buffer package instead of building our own code -* Remove dependency on object-assign package -* Bump required versions of bluebird and qs + +- Add check for when options are accidentally included in an arguments object +- Use safe-buffer package instead of building our own code +- Remove dependency on object-assign package +- Bump required versions of bluebird and qs ## 5.0.0 - 2017-09-12 -* Drop support for Node 0.x (minimum required version is now >= 4) + +- Drop support for Node 0.x (minimum required version is now >= 4) ## 4.25.0 - 2017-09-05 -* Switch to Bearer token authentication on API requests + +- Switch to Bearer token authentication on API requests ## 4.24.1 - 2017-08-25 -* Specify UTF-8 encoding when verifying HMAC-SHA256 payloads + +- Specify UTF-8 encoding when verifying HMAC-SHA256 payloads ## 4.24.0 - 2017-08-10 -* Support informational events with `Stripe.on` (see README for details) + +- Support informational events with `Stripe.on` (see README for details) ## 4.23.2 - 2017-08-03 -* Handle `Buffer.from` incompatibility for Node versions prior to 4.5.x + +- Handle `Buffer.from` incompatibility for Node versions prior to 4.5.x ## 4.23.1 - 2017-06-24 -* Properly encode subscription items when retrieving upcoming invoice + +- Properly encode subscription items when retrieving upcoming invoice ## 4.23.0 - 2017-06-20 -* Add support for ephemeral keys + +- Add support for ephemeral keys ## 4.22.1 - 2017-06-20 -* Fix usage of hasOwnProperty in utils + +- Fix usage of hasOwnProperty in utils ## 4.22.0 - 2017-05-25 -* Make response headers accessible on error objects + +- Make response headers accessible on error objects ## 4.21.0 - 2017-05-25 -* Add support for account login links + +- Add support for account login links ## 4.20.0 - 2017-05-24 -* Add `stripe.setAppInfo` for plugin authors to register app information + +- Add `stripe.setAppInfo` for plugin authors to register app information ## 4.19.1 - 2017-05-18 -* Tweak class initialization for compatibility with divergent JS engines + +- Tweak class initialization for compatibility with divergent JS engines ## 4.19.0 - 2017-05-11 -* Support for checking webhook signatures + +- Support for checking webhook signatures ## 4.18.0 - 2017-04-12 -* Reject ID parameters that don't look like strings + +- Reject ID parameters that don't look like strings ## 4.17.1 - 2017-04-05 -* Fix paths in error messages on bad arguments + +- Fix paths in error messages on bad arguments ## 4.17.0 - 2017-03-31 -* Add support for payouts + +- Add support for payouts ## 4.16.1 - 2017-03-30 -* Fix bad reference to `requestId` when initializing errors + +- Fix bad reference to `requestId` when initializing errors ## 4.16.0 - 2017-03-22 -* Make `requestId` available on resource `lastResponse` objects + +- Make `requestId` available on resource `lastResponse` objects ## 4.15.1 - 2017-03-08 -* Update required version of "qs" dependency to 6.0.4+ + +- Update required version of "qs" dependency to 6.0.4+ ## 4.15.0 - 2017-01-18 -* Add support for updating sources + +- Add support for updating sources ## 4.14.0 - 2016-12-01 -* Add support for verifying sources + +- Add support for verifying sources ## 4.13.0 - 2016-11-21 -* Add retrieve method for 3-D Secure resources + +- Add retrieve method for 3-D Secure resources ## 4.12.0 - 2016-10-18 -* Support for 403 status codes (permission denied) + +- Support for 403 status codes (permission denied) ## 4.11.0 - 2016-09-16 -* Add support for Apple Pay domains + +- Add support for Apple Pay domains ## 4.10.0 - 2016-08-29 -* Refactor deprecated uses of Bluebird's `Promise.defer` + +- Refactor deprecated uses of Bluebird's `Promise.defer` ## 4.9.1 - 2016-08-22 -* URI-encode unames for Stripe user agents so we don't fail on special characters + +- URI-encode unames for Stripe user agents so we don't fail on special characters ## 4.9.0 - 2016-07-19 -* Add `Source` model for generic payment sources support (experimental) + +- Add `Source` model for generic payment sources support (experimental) ## 4.8.0 - 2016-07-14 -* Add `ThreeDSecure` model for 3-D secure payments + +- Add `ThreeDSecure` model for 3-D secure payments ## 4.7.0 - 2016-05-25 -* Add support for returning Relay orders + +- Add support for returning Relay orders ## 4.6.0 - 2016-05-04 -* Add `update`, `create`, `retrieve`, `list` and `del` methods to `stripe.subscriptions` + +- Add `update`, `create`, `retrieve`, `list` and `del` methods to `stripe.subscriptions` ## 4.5.0 - 2016-03-15 -* Add `reject` on `Account` to support the new API feature + +- Add `reject` on `Account` to support the new API feature ## 4.4.0 - 2016-02-08 -* Add `CountrySpec` model for looking up country payment information + +- Add `CountrySpec` model for looking up country payment information ## 4.3.0 - 2016-01-26 -* Add support for deleting Relay SKUs and products + +- Add support for deleting Relay SKUs and products ## 4.2.0 - 2016-01-13 -* Add `lastResponse` property on `StripeResource` objects -* Return usage errors of `stripeMethod` through callback instead of raising -* Use latest year for expiry years in tests to avoid new year problems + +- Add `lastResponse` property on `StripeResource` objects +- Return usage errors of `stripeMethod` through callback instead of raising +- Use latest year for expiry years in tests to avoid new year problems ## 4.1.0 - 2015-12-02 -* Add a verification routine for external accounts + +- Add a verification routine for external accounts ## 4.0.0 - 2015-09-17 -* Remove ability for API keys to be passed as 1st param to acct.retrieve -* Rename StripeInvalidRequest to StripeInvalidRequestError + +- Remove ability for API keys to be passed as 1st param to acct.retrieve +- Rename StripeInvalidRequest to StripeInvalidRequestError ## 3.9.0 - 2015-09-14 -* Add Relay resources: Products, SKUs, and Orders + +- Add Relay resources: Products, SKUs, and Orders ## 3.8.0 - 2015-09-11 -* Added rate limiting responses + +- Added rate limiting responses ## 3.7.1 - 2015-08-17 -* Added refund object with listing, retrieval, updating, and creation. + +- Added refund object with listing, retrieval, updating, and creation. ## 3.7.0 - 2015-08-03 -* Added managed account deletion -* Added dispute listing and retrieval + +- Added managed account deletion +- Added dispute listing and retrieval ## 3.6.0 - 2015-07-07 -* Added request IDs to all Stripe errors + +- Added request IDs to all Stripe errors ## 3.5.2 - 2015-06-30 -* [BUGFIX] Fixed issue with uploading binary files (Gabriel Chagas Marques) + +- [BUGFIX] Fixed issue with uploading binary files (Gabriel Chagas Marques) ## 3.5.1 - 2015-06-30 -* [BUGFIX] Fixed issue with passing arrays of objects + +- [BUGFIX] Fixed issue with passing arrays of objects ## 3.5.0 - 2015-06-11 -* Added support for optional parameters when retrieving an upcoming invoice -(Matthew Arkin) + +- Added support for optional parameters when retrieving an upcoming invoice + (Matthew Arkin) ## 3.4.0 - 2015-06-10 -* Added support for bank accounts and debit cards in managed accounts + +- Added support for bank accounts and debit cards in managed accounts ## 3.3.4 - 2015-04-02 -* Remove SSL revocation tests and check + +- Remove SSL revocation tests and check ## 3.3.3 - 2015-03-31 -* [BUGFIX] Fix support for both stripe.account and stripe.accounts + +- [BUGFIX] Fix support for both stripe.account and stripe.accounts ## 3.3.2 - 2015-02-24 -* Support transfer reversals. + +- Support transfer reversals. ## 3.3.1 - 2015-02-21 -* [BUGFIX] Fix passing in only a callback to the Account resource. (Matthew Arkin) + +- [BUGFIX] Fix passing in only a callback to the Account resource. (Matthew Arkin) ## 3.3.0 - 2015-02-19 -* Support BitcoinReceiver update & delete actions -* Add methods for manipulating customer sources as per 2015-02-18 API version -* The Account resource will now take an account ID. However, legacy use of the resource (without an account ID) will still work. + +- Support BitcoinReceiver update & delete actions +- Add methods for manipulating customer sources as per 2015-02-18 API version +- The Account resource will now take an account ID. However, legacy use of the resource (without an account ID) will still work. ## 3.2.0 - 2015-02-05 -* [BUGFIX] Fix incorrect failing tests for headers support -* Update all dependencies (remove mocha-as-promised) -* Switch to bluebird for promises + +- [BUGFIX] Fix incorrect failing tests for headers support +- Update all dependencies (remove mocha-as-promised) +- Switch to bluebird for promises ## 3.1.0 - 2015-01-21 -* Support making bitcoin charges through BitcoinReceiver source object + +- Support making bitcoin charges through BitcoinReceiver source object ## 3.0.3 - 2014-12-23 -* Adding file uploads as a resource. + +- Adding file uploads as a resource. ## 3.0.2 - 2014-11-26 -* [BUGFIX] Fix issue where multiple expand params were not getting passed through (#130) + +- [BUGFIX] Fix issue where multiple expand params were not getting passed through (#130) ## 3.0.1 - 2014-11-26 -* (Version skipped due to npm mishap) + +- (Version skipped due to npm mishap) ## 3.0.0 - 2014-11-18 -* [BUGFIX] Fix `stringifyRequestData` to deal with nested objs correctly -* Bump MAJOR as we're no longer supporting Node 0.8 + +- [BUGFIX] Fix `stringifyRequestData` to deal with nested objs correctly +- Bump MAJOR as we're no longer supporting Node 0.8 ## 2.9.0 - 2014-11-12 -* Allow setting of HTTP agent (proxy) (issue #124) -* Add stack traces to all Stripe Errors + +- Allow setting of HTTP agent (proxy) (issue #124) +- Add stack traces to all Stripe Errors ## 2.8.0 - 2014-07-26 -* Make application fee refunds a list instead of array + +- Make application fee refunds a list instead of array ## 2.7.4 - 2014-07-17 -* [BUGFIX] Fix lack of subscription param in `invoices#retrieveUpcoming` method -* Add support for an `optional!` annotation on `urlParams` + +- [BUGFIX] Fix lack of subscription param in `invoices#retrieveUpcoming` method +- Add support for an `optional!` annotation on `urlParams` ## 2.7.3 - 2014-06-17 -* Add metadata to disputes and refunds + +- Add metadata to disputes and refunds ## 2.6.3 - 2014-05-21 -* Support cards for recipients. + +- Support cards for recipients. ## 2.5.3 - 2014-05-16 -* Allow the `update` method on coupons for metadata changes + +- Allow the `update` method on coupons for metadata changes ## 2.5.2 - 2014-04-28 -* [BUGFIX] Fix when.js version string in package.json to support older npm versions + +- [BUGFIX] Fix when.js version string in package.json to support older npm versions ## 2.5.1 - 2014-04-25 -* [BUGFIX] Fix revoked-ssl check -* Upgrade when.js to 3.1.0 + +- [BUGFIX] Fix revoked-ssl check +- Upgrade when.js to 3.1.0 ## 2.5.0 - 2014-04-09 -* Ensure we prevent requests using revoked SSL certs + +- Ensure we prevent requests using revoked SSL certs ## 2.4.5 - 2014-04-08 -* Add better checks for incorrect arguments (throw exceptions accordingly). -* Validate the Connect Auth key, if passed + +- Add better checks for incorrect arguments (throw exceptions accordingly). +- Validate the Connect Auth key, if passed ## 2.4.4 - 2014-03-27 -* [BUGFIX] Fix URL encoding issue (not encoding interpolated URL params, see issue #93) + +- [BUGFIX] Fix URL encoding issue (not encoding interpolated URL params, see issue #93) ## 2.4.3 - 2014-03-27 -* Add more debug information to the case of a failed `JSON.parse()` + +- Add more debug information to the case of a failed `JSON.parse()` ## 2.4.2 - 2014-02-20 -* Add binding for `transfers/{tr_id}/transactions` endpoint + +- Add binding for `transfers/{tr_id}/transactions` endpoint ## 2.4.1 - 2014-02-07 -* Ensure raw error object is accessible on the generated StripeError + +- Ensure raw error object is accessible on the generated StripeError ## 2.4.0 - 2014-01-29 -* Support multiple subscriptions per customer + +- Support multiple subscriptions per customer ## 2.3.4 - 2014-01-11 -* [BUGFIX] Fix #76, pass latest as version to api & fix constructor arg signature + +- [BUGFIX] Fix #76, pass latest as version to api & fix constructor arg signature ## 2.3.3 - 2014-01-10 -* Document cancelSubscription method params and add specs for `at_period_end` + +- Document cancelSubscription method params and add specs for `at_period_end` ## 2.3.2 - 2013-12-02 -* Add application fees API + +- Add application fees API ## 2.2.2 - 2013-11-20 -* [BUGFIX] Fix incorrect deleteDiscount method & related spec(s) + +- [BUGFIX] Fix incorrect deleteDiscount method & related spec(s) ### 2.2.1 -* [BUGFIX] Fix user-agent header issue (see issue #75) + +- [BUGFIX] Fix user-agent header issue (see issue #75) ## 2.2.0 - 2013-11-09 -* Add support for setTimeout -* Add specs for invoice-item listing/querying via timestamp + +- Add support for setTimeout +- Add specs for invoice-item listing/querying via timestamp ## 2.1.0 - 2013-11-07 -* Support single key/value setting on setMetadata method -* [BUGFIX] Fix Windows url-path issue -* Add missing stripe.charges.update method -* Support setting auth_token per request (useful in Connect) -* Remove global 'resources' variable + +- Support single key/value setting on setMetadata method +- [BUGFIX] Fix Windows url-path issue +- Add missing stripe.charges.update method +- Support setting auth_token per request (useful in Connect) +- Remove global 'resources' variable ## 2.0.0 - 2013-10-18 -* API overhaul and refactor, including addition of promises. -* Release of version 2.0.0 + +- API overhaul and refactor, including addition of promises. +- Release of version 2.0.0 ## 1.3.0 - 2013-01-30 -* Requests return Javascript Errors (Guillaume Flandre) + +- Requests return Javascript Errors (Guillaume Flandre) ## 1.2.0 - 2012-08-03 -* Added events API (Jonathan Hollinger) -* Added plans update API (Pavan Kumar Sunkara) -* Various test fixes, node 0.8.x tweaks (Jan Lehnardt) + +- Added events API (Jonathan Hollinger) +- Added plans update API (Pavan Kumar Sunkara) +- Various test fixes, node 0.8.x tweaks (Jan Lehnardt) ## 1.1.0 - 2012-02-01 -* Add Coupons API (Ryan) -* Pass a more robust error object to the callback (Ryan) -* Fix duplicate callbacks from some functions when called incorrectly (bug #24, reported by Kishore Nallan) + +- Add Coupons API (Ryan) +- Pass a more robust error object to the callback (Ryan) +- Fix duplicate callbacks from some functions when called incorrectly (bug #24, reported by Kishore Nallan) ## 1.0.0 - 2011-12-06 -* Add APIs and tests for Plans and "Invoice Items" -(both changes by Ryan Ettipio) + +- Add APIs and tests for Plans and "Invoice Items" + (both changes by Ryan Ettipio) ## 0.0.5 - 2011-11-26 -* Add Subscription API (John Ku, #3) -* Add Invoices API (Chris Winn, #6) -* [BUGFIX] Fix a bug where callback could be called twice, if the callback() threw an error itself (Peteris Krumins) -* [BUGFIX] Fix bug in tokens.retrieve API (Xavi) -* Change documentation links (Stripe changed their URL structure) -* Make tests pass again (error in callback is null instead of 0 if all is well) -* Amount in stripe.charges.refund is optional (Branko Vukelic) -* Various documentation fixes (Xavi) -* Only require node 0.4.0 + +- Add Subscription API (John Ku, #3) +- Add Invoices API (Chris Winn, #6) +- [BUGFIX] Fix a bug where callback could be called twice, if the callback() threw an error itself (Peteris Krumins) +- [BUGFIX] Fix bug in tokens.retrieve API (Xavi) +- Change documentation links (Stripe changed their URL structure) +- Make tests pass again (error in callback is null instead of 0 if all is well) +- Amount in stripe.charges.refund is optional (Branko Vukelic) +- Various documentation fixes (Xavi) +- Only require node 0.4.0 ## 0.0.3 - 2011-10-05 -* Add Charges API (issue #1, brackishlake) -* Add customers.list API + +- Add Charges API (issue #1, brackishlake) +- Add customers.list API ## 0.0.2 - 2011-09-28 -* Initial release with customers and tokens APIs + +- Initial release with customers and tokens APIs diff --git a/README.md b/README.md index 8365287d90..0a14efdf6c 100644 --- a/README.md +++ b/README.md @@ -30,28 +30,14 @@ The package needs to be configured with your account's secret key which is available in your [Stripe Dashboard][api-keys]. Require it with the key's value: -``` js +```js const stripe = require('stripe')('sk_test_...'); const customer = await stripe.customers.create({ - email: 'customer@example.com' + email: 'customer@example.com', }); ``` -Or with versions of Node.js prior to v7.9: - -``` js -var stripe = require('stripe')('sk_test_...'); - -stripe.customers.create( - { email: 'customer@example.com' }, - function(err, customer) { - err; // null if no error occurred - customer; // the created customer object - } -); -``` - Or using ES modules, this looks more like: ```js @@ -60,6 +46,9 @@ const stripe = Stripe('sk_test_...'); //… ``` +On older versions of Node, you can use [promises](#using-promises) +or [callbacks](#using-callbacks) instead of `async`/`await`. + ### Usage with TypeScript Stripe does not currently maintain typings for this package, but there are @@ -78,7 +67,9 @@ To use: import * as Stripe from 'stripe'; const stripe = new Stripe('sk_test_...'); -const customer: Promise = stripe.customers.create(/* ... */); +const customer: Promise< + Stripe.customers.ICustomer +> = stripe.customers.create(/* ... */); ``` ### Using Promises @@ -88,30 +79,57 @@ callback: ```js // Create a new customer and then a new charge for that customer: -stripe.customers.create({ - email: 'foo-customer@example.com' -}).then((customer) => { - return stripe.customers.createSource(customer.id, { - source: 'tok_visa' - }); -}).then((source) => { - return stripe.charges.create({ - amount: 1600, - currency: 'usd', - customer: source.customer +stripe.customers + .create({ + email: 'foo-customer@example.com', + }) + .then((customer) => { + return stripe.customers.createSource(customer.id, { + source: 'tok_visa', + }); + }) + .then((source) => { + return stripe.charges.create({ + amount: 1600, + currency: 'usd', + customer: source.customer, + }); + }) + .then((charge) => { + // New charge created on a new customer + }) + .catch((err) => { + // Deal with an error }); -}).then((charge) => { - // New charge created on a new customer -}).catch((err) => { - // Deal with an error -}); +``` + +### Using callbacks + +On versions of Node.js prior to v7.9: + +```js +var stripe = require('stripe')('sk_test_...'); + +stripe.customers.create( + { + email: 'customer@example.com', + }, + function(err, customer) { + if (err) { + // Deal with an error (will be `null` if no error occurred). + } + + // Do something with created customer object + console.log(customer.id); + } +); ``` ### Configuring Timeout Request timeout is configurable (the default is Node's default of 120 seconds): -``` js +```js stripe.setTimeout(20000); // in ms (this is 20 seconds) ``` @@ -120,15 +138,18 @@ stripe.setTimeout(20000); // in ms (this is 20 seconds) A per-request `Stripe-Account` header for use with [Stripe Connect][connect] can be added to any method: -``` js +```js // Retrieve the balance for a connected account: -stripe.balance.retrieve({ - stripe_account: 'acct_foo' -}).then((balance) => { - // The balance object for the connected account -}).catch((err) => { - // Error -}); +stripe.balance + .retrieve({ + stripe_account: 'acct_foo', + }) + .then((balance) => { + // The balance object for the connected account + }) + .catch((err) => { + // Error + }); ``` ### Configuring a Proxy @@ -136,7 +157,7 @@ stripe.balance.retrieve({ An [https-proxy-agent][https-proxy-agent] can be configured with `setHttpAgent`. -To use stripe behind a proxy you can pass to sdk: +To use stripe behind a proxy you can pass to sdk: ```js if (process.env.http_proxy) { @@ -147,7 +168,9 @@ if (process.env.http_proxy) { ### Network retries -Automatic network retries can be enabled with `setMaxNetworkRetries`. This will retry requests `n` times with exponential backoff if they fail due to an intermittent network problem. [Idempotency keys](https://stripe.com/docs/api/idempotent_requests) are added where appropriate to prevent duplication. +Automatic network retries can be enabled with `setMaxNetworkRetries`. +This will retry requests `n` times with exponential backoff if they fail due to an intermittent network problem. +[Idempotency keys](https://stripe.com/docs/api/idempotent_requests) are added where appropriate to prevent duplication. ```js // Retry a request once before giving up @@ -160,20 +183,20 @@ Some information about the response which generated a resource is available with the `lastResponse` property: ```js -charge.lastResponse.requestId // see: https://stripe.com/docs/api/node#request_ids -charge.lastResponse.statusCode +charge.lastResponse.requestId; // see: https://stripe.com/docs/api/node#request_ids +charge.lastResponse.statusCode; ``` ### `request` and `response` events -The Stripe object emits `request` and `response` events. You can use them like this: +The Stripe object emits `request` and `response` events. You can use them like this: ```js const stripe = require('stripe')('sk_test_...'); const onRequest = (request) => { // Do something. -} +}; // Add the event handler function: stripe.on('request', onRequest); @@ -183,6 +206,7 @@ stripe.off('request', onRequest); ``` #### `request` object + ```js { api_version: 'latest', @@ -194,6 +218,7 @@ stripe.off('request', onRequest); ``` #### `response` object + ```js { api_version: 'latest', @@ -209,7 +234,7 @@ stripe.off('request', onRequest); ### Webhook signing -Stripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it [here](https://stripe.com/docs/webhooks#signatures). +Stripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it [here](https://stripe.com/docs/webhooks#signatures). Please note that you must pass the _raw_ request body, exactly as received from Stripe, to the `constructEvent()` function; this will not work with a parsed (i.e., JSON) request body. @@ -266,7 +291,6 @@ This information is passed along when the library makes calls to the Stripe API. As of stripe-node 6.11.0, you may auto-paginate list methods. We provide a few different APIs for this to aid with a variety of node versions and styles. - #### Async iterators (`for-await-of`) If you are in a Node environment that has support for [async iteration](https://github.com/tc39/proposal-async-iteration#the-async-iteration-statement-for-await-of), @@ -293,22 +317,26 @@ await stripe.customers.list().autoPagingEach(async (customer) => { if (shouldBreak()) { return false; } -}) +}); console.log('Done iterating.'); ``` Equivalently, without `await`, you may return a Promise, which can resolve to `false` to break: ```js -stripe.customers.list().autoPagingEach((customer) => { - return doSomething(customer).then(() => { - if (shouldBreak()) { - return false; - } - }); -}).then(() => { - console.log('Done iterating.'); -}).catch(handleError); +stripe.customers + .list() + .autoPagingEach((customer) => { + return doSomething(customer).then(() => { + if (shouldBreak()) { + return false; + } + }); + }) + .then(() => { + console.log('Done iterating.'); + }) + .catch(handleError); ``` If you prefer callbacks to promises, you may also use a `next` callback and a second `onDone` callback: @@ -331,7 +359,7 @@ stripe.customers.list().autoPagingEach( console.log('Done iterating.'); } } -) +); ``` If your `onItem` function does not accept a `next` callback parameter _or_ return a Promise, @@ -346,44 +374,55 @@ to prevent runaway list growth from consuming too much memory. Returns a promise of an array of all items across pages for a list request. ```js -const allNewCustomers = await stripe.customers.list({created: {gt: lastMonth}}) +const allNewCustomers = await stripe.customers + .list({created: {gt: lastMonth}}) .autoPagingToArray({limit: 10000}); ``` ## More Information - * [REST API Version](https://github.com/stripe/stripe-node/wiki/REST-API-Version) - * [Error Handling](https://github.com/stripe/stripe-node/wiki/Error-Handling) - * [Passing Options](https://github.com/stripe/stripe-node/wiki/Passing-Options) - * [Using Stripe Connect](https://github.com/stripe/stripe-node/wiki/Using-Stripe-Connect-with-node.js) +- [REST API Version](https://github.com/stripe/stripe-node/wiki/REST-API-Version) +- [Error Handling](https://github.com/stripe/stripe-node/wiki/Error-Handling) +- [Passing Options](https://github.com/stripe/stripe-node/wiki/Passing-Options) +- [Using Stripe Connect](https://github.com/stripe/stripe-node/wiki/Using-Stripe-Connect-with-node.js) ## Development Run all tests: ```bash -$ npm install -$ npm test +$ yarn install +$ yarn test ``` +If you do not have `yarn` installed, you can get it with `npm install --global yarn`. + Run a single test suite: ```bash -$ npm run mocha -- test/Error.spec.js +$ yarn mocha test/Error.spec.js ``` Run a single test (case sensitive): ```bash -$ npm run mocha -- test/Error.spec.js --grep 'Populates with type' +$ yarn mocha test/Error.spec.js --grep 'Populates with type' ``` -If you wish, you may run tests using your Stripe *Test* API key by setting the +If you wish, you may run tests using your Stripe _Test_ API key by setting the environment variable `STRIPE_TEST_API_KEY` before running the tests: ```bash $ export STRIPE_TEST_API_KEY='sk_test....' -$ npm test +$ yarn test +``` + +Run prettier: + +Add an [editor integration](https://prettier.io/docs/en/editors.html) or: + +```bash +$ yarn fix ``` [api-keys]: https://dashboard.stripe.com/account/apikeys diff --git a/examples/webhook-signing/express.js b/examples/webhook-signing/express.js index 2c64e12012..9317c86f7d 100644 --- a/examples/webhook-signing/express.js +++ b/examples/webhook-signing/express.js @@ -14,25 +14,29 @@ const webhookSecret = process.env.WEBHOOK_SECRET; const app = express(); // Stripe requires the raw body to construct the event -app.post('/webhooks', bodyParser.raw({type: 'application/json'}), (req, res) => { - const sig = req.headers['stripe-signature']; - - let event; - - try { - event = stripe.webhooks.constructEvent(req.body, sig, webhookSecret); - } catch (err) { - // On error, return the error message - return res.status(400).send(`Webhook Error: ${err.message}`); +app.post( + '/webhooks', + bodyParser.raw({type: 'application/json'}), + (req, res) => { + const sig = req.headers['stripe-signature']; + + let event; + + try { + event = stripe.webhooks.constructEvent(req.body, sig, webhookSecret); + } catch (err) { + // On error, return the error message + return res.status(400).send(`Webhook Error: ${err.message}`); + } + + // Do something with event + console.log('Success:', event.id); + + // Return a response to acknowledge receipt of the event + res.json({received: true}); } +); - // Do something with event - console.log('Success:', event.id); - - // Return a response to acknowledge receipt of the event - res.json({received: true}); -}); - -app.listen(3000, function() { - console.log('Example app listening on port 3000!') +app.listen(3000, () => { + console.log('Example app listening on port 3000!'); }); diff --git a/lib/Error.js b/lib/Error.js index 831aaa6eca..6e5bd43e67 100644 --- a/lib/Error.js +++ b/lib/Error.js @@ -1,6 +1,6 @@ 'use strict'; -var utils = require('./utils'); +const utils = require('./utils'); module.exports = _Error; @@ -8,8 +8,8 @@ module.exports = _Error; * Generic Error klass to wrap any errors returned by stripe-node */ function _Error(raw) { - this.populate.apply(this, arguments); - this.stack = (new Error(this.message)).stack; + this.populate(...arguments); + this.stack = new Error(this.message).stack; } // Extend Native Error @@ -27,13 +27,13 @@ _Error.extend = utils.protoExtend; * Create subclass of internal Error klass * (Specifically for errors returned from Stripe's REST API) */ -var StripeError = _Error.StripeError = _Error.extend({ +const StripeError = (_Error.StripeError = _Error.extend({ type: 'StripeError', - populate: function(raw) { + populate(raw) { // Move from prototype def (so it appears in stringified obj) this.type = this.type; - this.stack = (new Error(raw.message)).stack; + this.stack = new Error(raw.message).stack; this.rawType = raw.type; this.code = raw.code; this.param = raw.param; @@ -44,35 +44,51 @@ var StripeError = _Error.StripeError = _Error.extend({ this.requestId = raw.requestId; this.statusCode = raw.statusCode; }, -}); +})); /** * Helper factory which takes raw stripe errors and outputs wrapping instances */ -StripeError.generate = function(rawStripeError) { +StripeError.generate = (rawStripeError) => { switch (rawStripeError.type) { - case 'card_error': - return new _Error.StripeCardError(rawStripeError); - case 'invalid_request_error': - return new _Error.StripeInvalidRequestError(rawStripeError); - case 'api_error': - return new _Error.StripeAPIError(rawStripeError); - case 'idempotency_error': - return new _Error.StripeIdempotencyError(rawStripeError); - case 'invalid_grant': - return new _Error.StripeInvalidGrantError(rawStripeError); + case 'card_error': + return new _Error.StripeCardError(rawStripeError); + case 'invalid_request_error': + return new _Error.StripeInvalidRequestError(rawStripeError); + case 'api_error': + return new _Error.StripeAPIError(rawStripeError); + case 'idempotency_error': + return new _Error.StripeIdempotencyError(rawStripeError); + case 'invalid_grant': + return new _Error.StripeInvalidGrantError(rawStripeError); } return new _Error('Generic', 'Unknown Error'); }; // Specific Stripe Error types: _Error.StripeCardError = StripeError.extend({type: 'StripeCardError'}); -_Error.StripeInvalidRequestError = StripeError.extend({type: 'StripeInvalidRequestError'}); +_Error.StripeInvalidRequestError = StripeError.extend({ + type: 'StripeInvalidRequestError', +}); _Error.StripeAPIError = StripeError.extend({type: 'StripeAPIError'}); -_Error.StripeAuthenticationError = StripeError.extend({type: 'StripeAuthenticationError'}); -_Error.StripePermissionError = StripeError.extend({type: 'StripePermissionError'}); -_Error.StripeRateLimitError = StripeError.extend({type: 'StripeRateLimitError'}); -_Error.StripeConnectionError = StripeError.extend({type: 'StripeConnectionError'}); -_Error.StripeSignatureVerificationError = StripeError.extend({type: 'StripeSignatureVerificationError'}); -_Error.StripeIdempotencyError = StripeError.extend({type: 'StripeIdempotencyError'}); -_Error.StripeInvalidGrantError = StripeError.extend({type: 'StripeInvalidGrantError'}); +_Error.StripeAuthenticationError = StripeError.extend({ + type: 'StripeAuthenticationError', +}); +_Error.StripePermissionError = StripeError.extend({ + type: 'StripePermissionError', +}); +_Error.StripeRateLimitError = StripeError.extend({ + type: 'StripeRateLimitError', +}); +_Error.StripeConnectionError = StripeError.extend({ + type: 'StripeConnectionError', +}); +_Error.StripeSignatureVerificationError = StripeError.extend({ + type: 'StripeSignatureVerificationError', +}); +_Error.StripeIdempotencyError = StripeError.extend({ + type: 'StripeIdempotencyError', +}); +_Error.StripeInvalidGrantError = StripeError.extend({ + type: 'StripeInvalidGrantError', +}); diff --git a/lib/MultipartDataGenerator.js b/lib/MultipartDataGenerator.js index 4225375c40..76b8cb2962 100644 --- a/lib/MultipartDataGenerator.js +++ b/lib/MultipartDataGenerator.js @@ -1,19 +1,21 @@ 'use strict'; -var Buffer = require('safe-buffer').Buffer; -var utils = require('./utils'); +const Buffer = require('safe-buffer').Buffer; +const utils = require('./utils'); // Method for formatting HTTP body for the multipart/form-data specification // Mostly taken from Fermata.js // https://github.com/natevw/fermata/blob/5d9732a33d776ce925013a265935facd1626cc88/fermata.js#L315-L343 function multipartDataGenerator(method, data, headers) { - var segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString(); - headers['Content-Type'] = ('multipart/form-data; boundary=' + segno); - var buffer = Buffer.alloc(0); + const segno = ( + Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16) + ).toString(); + headers['Content-Type'] = `multipart/form-data; boundary=${segno}`; + let buffer = Buffer.alloc(0); function push(l) { - var prevBuffer = buffer; - var newBuffer = (l instanceof Buffer) ? l : Buffer.from(l); + const prevBuffer = buffer; + const newBuffer = l instanceof Buffer ? l : Buffer.from(l); buffer = Buffer.alloc(prevBuffer.length + newBuffer.length + 2); prevBuffer.copy(buffer); newBuffer.copy(buffer, prevBuffer.length); @@ -21,24 +23,28 @@ function multipartDataGenerator(method, data, headers) { } function q(s) { - return '"' + s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ') + '"'; + return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`; } - for (var k in utils.flattenAndStringify(data)) { - var v = data[k]; - push('--' + segno); + for (const k in utils.flattenAndStringify(data)) { + const v = data[k]; + push(`--${segno}`); if (v.hasOwnProperty('data')) { - push('Content-Disposition: form-data; name=' + q(k) + '; filename=' + q(v.name || 'blob')); - push('Content-Type: ' + (v.type || 'application/octet-stream')); + push( + `Content-Disposition: form-data; name=${q(k)}; filename=${q( + v.name || 'blob' + )}` + ); + push(`Content-Type: ${v.type || 'application/octet-stream'}`); push(''); push(v.data); } else { - push('Content-Disposition: form-data; name=' + q(k)); + push(`Content-Disposition: form-data; name=${q(k)}`); push(''); push(v); } } - push('--' + segno + '--'); + push(`--${segno}--`); return buffer; } diff --git a/lib/ResourceNamespace.js b/lib/ResourceNamespace.js index 872b9c4664..0d76787d81 100644 --- a/lib/ResourceNamespace.js +++ b/lib/ResourceNamespace.js @@ -4,17 +4,17 @@ // It also works recursively, so you could do i.e. `stripe.billing.invoicing.pay`. function ResourceNamespace(stripe, resources) { - for (var name in resources) { - var camelCaseName = name[0].toLowerCase() + name.substring(1); + for (const name in resources) { + const camelCaseName = name[0].toLowerCase() + name.substring(1); - var resource = new resources[name](stripe); + const resource = new resources[name](stripe); this[camelCaseName] = resource; } } module.exports = function(namespace, resources) { - return function (stripe) { + return function(stripe) { return new ResourceNamespace(stripe, resources); }; }; diff --git a/lib/StripeMethod.basic.js b/lib/StripeMethod.basic.js index cef6d8d597..c807ea1849 100644 --- a/lib/StripeMethod.basic.js +++ b/lib/StripeMethod.basic.js @@ -1,11 +1,8 @@ 'use strict'; -var isPlainObject = require('lodash.isplainobject'); -var stripeMethod = require('./StripeMethod'); -var utils = require('./utils'); +const stripeMethod = require('./StripeMethod'); module.exports = { - create: stripeMethod({ method: 'POST', }), @@ -18,95 +15,16 @@ module.exports = { retrieve: stripeMethod({ method: 'GET', path: '/{id}', - urlParams: ['id'], }), update: stripeMethod({ method: 'POST', path: '{id}', - urlParams: ['id'], }), // Avoid 'delete' keyword in JS del: stripeMethod({ method: 'DELETE', path: '{id}', - urlParams: ['id'], }), - - setMetadata: function(id, key, value, auth, cb) { - var self = this; - var data = key; - var isObject = isPlainObject(key); - // We assume null for an empty object - var isNull = data === null || (isObject && !Object.keys(data).length); - - // Allow optional passing of auth & cb: - if ((isNull || isObject) && typeof value == 'string') { - auth = value; - } else if (typeof auth != 'string') { - if (!cb && typeof auth == 'function') { - cb = auth; - } - auth = null; - } - - var urlData = this.createUrlData(); - var path = this.createFullPath('/' + id, urlData); - - return utils.callbackifyPromiseWithTimeout(new Promise((function(resolve, reject) { - if (isNull) { - // Reset metadata: - sendMetadata(null, auth); - } else if (!isObject) { - // Set individual metadata property: - var metadata = {}; - metadata[key] = value; - sendMetadata(metadata, auth); - } else { - // Set entire metadata object after resetting it: - this._request('POST', null, path, { - metadata: null, - }, auth, {}, function(err, response) { - if (err) { - return reject(err); - } - sendMetadata(data, auth); - }); - } - - function sendMetadata(metadata, auth) { - self._request('POST', null, path, { - metadata: metadata, - }, auth, {}, function(err, response) { - if (err) { - reject(err); - } else { - resolve(response.metadata); - } - }); - } - }).bind(this)), cb); - }, - - getMetadata: function(id, auth, cb) { - if (!cb && typeof auth == 'function') { - cb = auth; - auth = null; - } - - var urlData = this.createUrlData(); - var path = this.createFullPath('/' + id, urlData); - - return utils.callbackifyPromiseWithTimeout(new Promise((function(resolve, reject) { - this._request('GET', null, path, {}, auth, {}, function(err, response) { - if (err) { - reject(err); - } else { - resolve(response.metadata); - } - }); - }).bind(this)), cb); - }, - }; diff --git a/lib/StripeMethod.js b/lib/StripeMethod.js index 74bdfae7d5..dd8c6b846e 100644 --- a/lib/StripeMethod.js +++ b/lib/StripeMethod.js @@ -1,8 +1,9 @@ 'use strict'; -var utils = require('./utils'); -var makeRequest = require('./makeRequest'); -var makeAutoPaginationMethods = require('./autoPagination').makeAutoPaginationMethods; +const utils = require('./utils'); +const makeRequest = require('./makeRequest'); +const makeAutoPaginationMethods = require('./autoPagination') + .makeAutoPaginationMethods; /** * Create an API method from the declared spec. @@ -20,15 +21,27 @@ var makeAutoPaginationMethods = require('./autoPagination').makeAutoPaginationMe */ function stripeMethod(spec) { return function() { - var self = this; - var args = [].slice.call(arguments); + const self = this; + const args = [].slice.call(arguments); - var callback = typeof args[args.length - 1] == 'function' && args.pop(); + const callback = typeof args[args.length - 1] == 'function' && args.pop(); - var requestPromise = utils.callbackifyPromiseWithTimeout(makeRequest(self, args, spec, {}), callback) + spec.urlParams = utils.extractUrlParams( + self.createResourcePathWithSymbols(spec.path || '') + ); + + const requestPromise = utils.callbackifyPromiseWithTimeout( + makeRequest(self, args, spec, {}), + callback + ); if (spec.methodType === 'list') { - var autoPaginationMethods = makeAutoPaginationMethods(self, args, spec, requestPromise); + const autoPaginationMethods = makeAutoPaginationMethods( + self, + args, + spec, + requestPromise + ); Object.assign(requestPromise, autoPaginationMethods); } diff --git a/lib/StripeResource.js b/lib/StripeResource.js index bea29419ea..cfe509156a 100644 --- a/lib/StripeResource.js +++ b/lib/StripeResource.js @@ -1,17 +1,15 @@ 'use strict'; -var http = require('http'); -var https = require('https'); -var path = require('path'); -var uuid = require('uuid/v4'); +const http = require('http'); +const https = require('https'); +const path = require('path'); +const uuid = require('uuid/v4'); -var utils = require('./utils'); -var Error = require('./Error'); +const utils = require('./utils'); +const Error = require('./Error'); -var hasOwn = {}.hasOwnProperty; - -var defaultHttpAgent = new http.Agent({keepAlive: true}); -var defaultHttpsAgent = new https.Agent({keepAlive: true}); +const defaultHttpAgent = new http.Agent({keepAlive: true}); +const defaultHttpsAgent = new https.Agent({keepAlive: true}); // Provide extension mechanism for Stripe Resource Sub-Classes StripeResource.extend = utils.protoExtend; @@ -25,11 +23,17 @@ StripeResource.MAX_BUFFERED_REQUEST_METRICS = 100; /** * Encapsulates request logic for a Stripe Resource */ -function StripeResource(stripe, urlData) { +function StripeResource(stripe, deprecatedUrlData) { this._stripe = stripe; - this._urlData = urlData || {}; + if (deprecatedUrlData) { + throw new Error( + 'Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.' + ); + } - this.basePath = utils.makeURLInterpolator(this.basePath || stripe.getApiField('basePath')); + this.basePath = utils.makeURLInterpolator( + this.basePath || stripe.getApiField('basePath') + ); this.resourcePath = this.path; this.path = utils.makeURLInterpolator(this.path); @@ -39,17 +43,16 @@ function StripeResource(stripe, urlData) { }, this); } - this.initialize.apply(this, arguments); + this.initialize(...arguments); } StripeResource.prototype = { - path: '', // Methods that don't use the API's default '/v1' path can override it with this setting. basePath: null, - initialize: function() {}, + initialize() {}, // Function to override the default data processor. This allows full control // over how a StripeResource's request data will get converted into an HTTP @@ -61,43 +64,32 @@ StripeResource.prototype = { // be thrown, and they will be passed to the callback/promise. validateRequest: null, - createFullPath: function(commandPath, urlData) { - return path.join( - this.basePath(urlData), - this.path(urlData), - typeof commandPath == 'function' ? - commandPath(urlData) : commandPath - ).replace(/\\/g, '/'); // ugly workaround for Windows + createFullPath(commandPath, urlData) { + return path + .join( + this.basePath(urlData), + this.path(urlData), + typeof commandPath == 'function' ? commandPath(urlData) : commandPath + ) + .replace(/\\/g, '/'); // ugly workaround for Windows }, // Creates a relative resource path with symbols left in (unlike // createFullPath which takes some data to replace them with). For example it // might produce: /invoices/{id} - createResourcePathWithSymbols: function(pathWithSymbols) { - return '/' + path.join( - this.resourcePath, - pathWithSymbols || '' - ).replace(/\\/g, '/'); // ugly workaround for Windows - }, - - createUrlData: function() { - var urlData = {}; - // Merge in baseData - for (var i in this._urlData) { - if (hasOwn.call(this._urlData, i)) { - urlData[i] = this._urlData[i]; - } - } - return urlData; + createResourcePathWithSymbols(pathWithSymbols) { + return `/${path + .join(this.resourcePath, pathWithSymbols || '') + .replace(/\\/g, '/')}`; // ugly workaround for Windows }, // DEPRECATED: Here for backcompat in case users relied on this. wrapTimeout: utils.callbackifyPromiseWithTimeout, - _timeoutHandler: function(timeout, req, callback) { - var self = this; - return function() { - var timeoutErr = new Error('ETIMEDOUT'); + _timeoutHandler(timeout, req, callback) { + const self = this; + return () => { + const timeoutErr = new Error('ETIMEDOUT'); timeoutErr.code = 'ETIMEDOUT'; req._isAborted = true; @@ -106,34 +98,34 @@ StripeResource.prototype = { callback.call( self, new Error.StripeConnectionError({ - message: 'Request aborted due to timeout being reached (' + timeout + 'ms)', + message: `Request aborted due to timeout being reached (${timeout}ms)`, detail: timeoutErr, }), null ); - } + }; }, - _responseHandler: function(req, callback) { - var self = this; - return function(res) { - var response = ''; + _responseHandler(req, callback) { + const self = this; + return (res) => { + let response = ''; res.setEncoding('utf8'); - res.on('data', function(chunk) { + res.on('data', (chunk) => { response += chunk; }); - res.on('end', function() { - var headers = res.headers || {}; + res.on('end', () => { + const headers = res.headers || {}; // NOTE: Stripe responds with lowercase header names/keys. // For convenience, make Request-Id easily accessible on // lastResponse. res.requestId = headers['request-id']; - var requestDurationMs = Date.now() - req._requestStart; + const requestDurationMs = Date.now() - req._requestStart; - var responseEvent = utils.removeEmpty({ + const responseEvent = utils.removeEmpty({ api_version: headers['stripe-version'], account: headers['stripe-account'], idempotency_key: headers['idempotency-key'], @@ -150,15 +142,15 @@ StripeResource.prototype = { response = JSON.parse(response); if (response.error) { - var err; + let err; // Convert OAuth error responses into a standard format // so that the rest of the error logic can be shared if (typeof response.error === 'string') { response.error = { type: response.error, - message: response.error_description - } + message: response.error_description, + }; } response.error.headers = headers; @@ -181,7 +173,7 @@ StripeResource.prototype = { self, new Error.StripeAPIError({ message: 'Invalid JSON received from the Stripe API', - response: response, + response, exception: e, requestId: headers['request-id'], }), @@ -202,13 +194,15 @@ StripeResource.prototype = { }; }, - _generateConnectionErrorMessage: function(requestRetries) { - return 'An error occurred with our connection to Stripe.' + (requestRetries > 0 ? ' Request was retried ' + requestRetries + ' times.' : ''); + _generateConnectionErrorMessage(requestRetries) { + return `An error occurred with our connection to Stripe.${ + requestRetries > 0 ? ` Request was retried ${requestRetries} times.` : '' + }`; }, - _errorHandler: function(req, requestRetries, callback) { - var self = this; - return function(error) { + _errorHandler(req, requestRetries, callback) { + const self = this; + return (error) => { if (req._isAborted) { // already handled return; @@ -221,10 +215,10 @@ StripeResource.prototype = { }), null ); - } + }; }, - _shouldRetry: function(res, numRetries) { + _shouldRetry(res, numRetries) { // Do not retry if we are out of retries. if (numRetries >= this._stripe.getMaxNetworkRetries()) { return false; @@ -249,14 +243,14 @@ StripeResource.prototype = { return false; }, - _getSleepTimeInMS: function(numRetries) { - var initialNetworkRetryDelay = this._stripe.getInitialNetworkRetryDelay(); - var maxNetworkRetryDelay = this._stripe.getMaxNetworkRetryDelay(); + _getSleepTimeInMS(numRetries) { + const initialNetworkRetryDelay = this._stripe.getInitialNetworkRetryDelay(); + const maxNetworkRetryDelay = this._stripe.getMaxNetworkRetryDelay(); // Apply exponential backoff with initialNetworkRetryDelay on the // number of numRetries so far as inputs. Do not allow the number to exceed // maxNetworkRetryDelay. - var sleepSeconds = Math.min( + let sleepSeconds = Math.min( initialNetworkRetryDelay * Math.pow(numRetries - 1, 2), maxNetworkRetryDelay ); @@ -271,19 +265,19 @@ StripeResource.prototype = { return sleepSeconds * 1000; }, - _defaultHeaders: function(auth, contentLength, apiVersion) { - var userAgentString = 'Stripe/v1 NodeBindings/' + this._stripe.getConstant('PACKAGE_VERSION'); + _defaultHeaders(auth, contentLength, apiVersion) { + let userAgentString = `Stripe/v1 NodeBindings/${this._stripe.getConstant( + 'PACKAGE_VERSION' + )}`; if (this._stripe._appInfo) { - userAgentString += ' ' + this._stripe.getAppInfoAsString(); + userAgentString += ` ${this._stripe.getAppInfoAsString()}`; } - var headers = { + const headers = { // Use specified auth token or use default from this stripe instance: - 'Authorization': auth ? - 'Bearer ' + auth : - this._stripe.getApiField('auth'), - 'Accept': 'application/json', + Authorization: auth ? `Bearer ${auth}` : this._stripe.getApiField('auth'), + Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': contentLength, 'User-Agent': userAgentString, @@ -296,45 +290,54 @@ StripeResource.prototype = { return headers; }, - _addTelemetryHeader: function(headers) { - if (this._stripe.getTelemetryEnabled() && this._stripe._prevRequestMetrics.length > 0) { - var metrics = this._stripe._prevRequestMetrics.shift(); + _addTelemetryHeader(headers) { + if ( + this._stripe.getTelemetryEnabled() && + this._stripe._prevRequestMetrics.length > 0 + ) { + const metrics = this._stripe._prevRequestMetrics.shift(); headers['X-Stripe-Client-Telemetry'] = JSON.stringify({ - 'last_request_metrics': metrics + last_request_metrics: metrics, }); } }, - _recordRequestMetrics: function(requestId, requestDurationMs) { + _recordRequestMetrics(requestId, requestDurationMs) { if (this._stripe.getTelemetryEnabled() && requestId) { - if (this._stripe._prevRequestMetrics.length > StripeResource.MAX_BUFFERED_REQUEST_METRICS) { - utils.emitWarning('Request metrics buffer is full, dropping telemetry message.'); + if ( + this._stripe._prevRequestMetrics.length > + StripeResource.MAX_BUFFERED_REQUEST_METRICS + ) { + utils.emitWarning( + 'Request metrics buffer is full, dropping telemetry message.' + ); } else { this._stripe._prevRequestMetrics.push({ - 'request_id': requestId, - 'request_duration_ms': requestDurationMs, + request_id: requestId, + request_duration_ms: requestDurationMs, }); } } }, - _request: function(method, host, path, data, auth, options, callback) { - var self = this; - var requestData; + _request(method, host, path, data, auth, options, callback) { + const self = this; + let requestData; function makeRequestWithData(error, data) { - var apiVersion; - var headers; - if (error) { return callback(error); } - apiVersion = self._stripe.getApiField('version'); + const apiVersion = self._stripe.getApiField('version'); requestData = data; - headers = self._defaultHeaders(auth, requestData.length, apiVersion); + const headers = self._defaultHeaders( + auth, + requestData.length, + apiVersion + ); - self._stripe.getClientUserAgent(function(cua) { + self._stripe.getClientUserAgent((cua) => { headers['X-Stripe-Client-User-Agent'] = cua; if (options.headers) { @@ -348,7 +351,12 @@ StripeResource.prototype = { } if (self.requestDataProcessor) { - self.requestDataProcessor(method, data, options.headers, makeRequestWithData); + self.requestDataProcessor( + method, + data, + options.headers, + makeRequestWithData + ); } else { makeRequestWithData(null, utils.stringifyRequestData(data || {})); } @@ -366,22 +374,21 @@ StripeResource.prototype = { } function makeRequest(apiVersion, headers, numRetries) { - var timeout = self._stripe.getApiField('timeout'); - var isInsecureConnection = self._stripe.getApiField('protocol') == 'http'; - var agent = self._stripe.getApiField('agent'); + const timeout = self._stripe.getApiField('timeout'); + const isInsecureConnection = + self._stripe.getApiField('protocol') == 'http'; + let agent = self._stripe.getApiField('agent'); if (agent == null) { agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent; } - var req = ( - isInsecureConnection ? http : https - ).request({ + const req = (isInsecureConnection ? http : https).request({ host: host || self._stripe.getApiField('host'), port: self._stripe.getApiField('port'), - path: path, - method: method, - agent: agent, - headers: headers, + path, + method, + agent, + headers, ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5', }); @@ -393,15 +400,15 @@ StripeResource.prototype = { } } - var requestEvent = utils.removeEmpty({ + const requestEvent = utils.removeEmpty({ api_version: apiVersion, account: headers['Stripe-Account'], idempotency_key: headers['Idempotency-Key'], - method: method, - path: path, + method, + path, }); - var requestRetries = numRetries || 0; + const requestRetries = numRetries || 0; req._requestEvent = requestEvent; @@ -411,7 +418,7 @@ StripeResource.prototype = { req.setTimeout(timeout, self._timeoutHandler(timeout, req, callback)); - req.on('response', function(res) { + req.on('response', (res) => { if (self._shouldRetry(res, requestRetries)) { return retryRequest(makeRequest, apiVersion, headers, requestRetries); } else { @@ -419,7 +426,7 @@ StripeResource.prototype = { } }); - req.on('error', function(error) { + req.on('error', (error) => { if (self._shouldRetry(null, requestRetries)) { return retryRequest(makeRequest, apiVersion, headers, requestRetries); } else { @@ -427,9 +434,9 @@ StripeResource.prototype = { } }); - req.on('socket', function(socket) { + req.on('socket', (socket) => { if (socket.connecting) { - socket.on((isInsecureConnection ? 'connect' : 'secureConnect'), function() { + socket.on(isInsecureConnection ? 'connect' : 'secureConnect', () => { // Send payload; we're safe: req.write(requestData); req.end(); diff --git a/lib/Webhooks.js b/lib/Webhooks.js index d27c58d6a4..cb5a45a4d0 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -1,18 +1,23 @@ 'use strict'; -var Buffer = require('safe-buffer').Buffer; -var crypto = require('crypto'); +const Buffer = require('safe-buffer').Buffer; +const crypto = require('crypto'); -var utils = require('./utils'); -var Error = require('./Error'); +const utils = require('./utils'); +const Error = require('./Error'); -var Webhook = { +const Webhook = { DEFAULT_TOLERANCE: 300, // 5 minutes - constructEvent: function(payload, header, secret, tolerance) { - this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE); + constructEvent(payload, header, secret, tolerance) { + this.signature.verifyHeader( + payload, + header, + secret, + tolerance || Webhook.DEFAULT_TOLERANCE + ); - var jsonPayload = JSON.parse(payload); + const jsonPayload = JSON.parse(payload); return jsonPayload; }, @@ -33,11 +38,16 @@ var Webhook = { }); } - opts.timestamp = Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); + opts.timestamp = + Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); opts.scheme = opts.scheme || signature.EXPECTED_SCHEME; - opts.signature = opts.signature || - signature._computeSignature(opts.timestamp + '.' + opts.payload, opts.secret); + opts.signature = + opts.signature || + signature._computeSignature( + opts.timestamp + '.' + opts.payload, + opts.secret + ); var generatedHeader = [ 't=' + opts.timestamp, @@ -48,27 +58,28 @@ var Webhook = { }, }; -var signature = { +const signature = { EXPECTED_SCHEME: 'v1', - _computeSignature: function(payload, secret) { - return crypto.createHmac('sha256', secret) + _computeSignature: (payload, secret) => { + return crypto + .createHmac('sha256', secret) .update(payload, 'utf8') .digest('hex'); }, - verifyHeader: function(payload, header, secret, tolerance) { + verifyHeader(payload, header, secret, tolerance) { payload = Buffer.isBuffer(payload) ? payload.toString('utf8') : payload; header = Buffer.isBuffer(header) ? header.toString('utf8') : header; - var details = parseHeader(header, this.EXPECTED_SCHEME); + const details = parseHeader(header, this.EXPECTED_SCHEME); if (!details || details.timestamp === -1) { throw new Error.StripeSignatureVerificationError({ message: 'Unable to extract timestamp and signatures from header', detail: { - header: header, - payload: payload, + header, + payload, }, }); } @@ -77,38 +88,42 @@ var signature = { throw new Error.StripeSignatureVerificationError({ message: 'No signatures found with expected scheme', detail: { - header: header, - payload: payload, + header, + payload, }, }); } - var expectedSignature = this._computeSignature(details.timestamp + '.' + payload, secret); + const expectedSignature = this._computeSignature( + `${details.timestamp}.${payload}`, + secret + ); - var signatureFound = !!details.signatures - .filter(utils.secureCompare.bind(utils, expectedSignature)) - .length; + const signatureFound = !!details.signatures.filter( + utils.secureCompare.bind(utils, expectedSignature) + ).length; if (!signatureFound) { throw new Error.StripeSignatureVerificationError({ - message: 'No signatures found matching the expected signature for payload.' + + message: + 'No signatures found matching the expected signature for payload.' + ' Are you passing the raw request body you received from Stripe?' + ' https://github.com/stripe/stripe-node#webhook-signing', detail: { - header: header, - payload: payload, + header, + payload, }, }); } - var timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; + const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; if (tolerance > 0 && timestampAge > tolerance) { throw new Error.StripeSignatureVerificationError({ message: 'Timestamp outside the tolerance zone', detail: { - header: header, - payload: payload, + header, + payload, }, }); } @@ -122,22 +137,25 @@ function parseHeader(header, scheme) { return null; } - return header.split(',').reduce(function(accum, item) { - var kv = item.split('='); + return header.split(',').reduce( + (accum, item) => { + const kv = item.split('='); - if (kv[0] === 't') { - accum.timestamp = kv[1]; - } + if (kv[0] === 't') { + accum.timestamp = kv[1]; + } - if (kv[0] === scheme) { - accum.signatures.push(kv[1]); - } + if (kv[0] === scheme) { + accum.signatures.push(kv[1]); + } - return accum; - }, { - timestamp: -1, - signatures: [], - }); + return accum; + }, + { + timestamp: -1, + signatures: [], + } + ); } Webhook.signature = signature; diff --git a/lib/autoPagination.js b/lib/autoPagination.js index 2a21c416c2..c3f052169b 100644 --- a/lib/autoPagination.js +++ b/lib/autoPagination.js @@ -1,34 +1,44 @@ 'use strict'; -var makeRequest = require('./makeRequest'); -var utils = require('./utils'); +const makeRequest = require('./makeRequest'); +const utils = require('./utils'); function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { - var promiseCache = {currentPromise: null}; - var listPromise = firstPagePromise; - var i = 0; + const promiseCache = {currentPromise: null}; + let listPromise = firstPagePromise; + let i = 0; function iterate(listResult) { - if (!(listResult && listResult.data && typeof listResult.data.length === 'number')) { - throw Error('Unexpected: Stripe API response does not have a well-formed `data` array.'); + if ( + !( + listResult && + listResult.data && + typeof listResult.data.length === 'number' + ) + ) { + throw Error( + 'Unexpected: Stripe API response does not have a well-formed `data` array.' + ); } if (i < listResult.data.length) { - var value = listResult.data[i]; + const value = listResult.data[i]; i += 1; - return {value: value, done: false}; + return {value, done: false}; } else if (listResult.has_more) { // Reset counter, request next page, and recurse. i = 0; - var lastId = getLastId(listResult); - listPromise = makeRequest(self, requestArgs, spec, {starting_after: lastId}); + const lastId = getLastId(listResult); + listPromise = makeRequest(self, requestArgs, spec, { + starting_after: lastId, + }); return listPromise.then(iterate); } return {value: undefined, done: true}; } function asyncIteratorNext() { - return memoizedPromise(promiseCache, function(resolve, reject) { + return memoizedPromise(promiseCache, (resolve, reject) => { return listPromise .then(iterate) .then(resolve) @@ -36,22 +46,22 @@ function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { }); } - var autoPagingEach = makeAutoPagingEach(asyncIteratorNext); - var autoPagingToArray = makeAutoPagingToArray(autoPagingEach); + const autoPagingEach = makeAutoPagingEach(asyncIteratorNext); + const autoPagingToArray = makeAutoPagingToArray(autoPagingEach); - var autoPaginationMethods = { - autoPagingEach: autoPagingEach, - autoPagingToArray: autoPagingToArray, + const autoPaginationMethods = { + autoPagingEach, + autoPagingToArray, // Async iterator functions: next: asyncIteratorNext, - return: function() { + return: () => { // This is required for `break`. return {}; }, - [getAsyncIteratorSymbol()]: function() { + [getAsyncIteratorSymbol()]: () => { return autoPaginationMethods; - } + }, }; return autoPaginationMethods; } @@ -76,9 +86,11 @@ function getDoneCallback(args) { if (args.length < 2) { return undefined; } - var onDone = args[1]; + const onDone = args[1]; if (typeof onDone !== 'function') { - throw Error('The second argument to autoPagingEach, if present, must be a callback function; receieved ' + typeof onDone); + throw Error( + `The second argument to autoPagingEach, if present, must be a callback function; receieved ${typeof onDone}` + ); } return onDone; } @@ -98,9 +110,11 @@ function getItemCallback(args) { if (args.length === 0) { return undefined; } - var onItem = args[0]; + const onItem = args[0]; if (typeof onItem !== 'function') { - throw Error('The first argument to autoPagingEach, if present, must be a callback function; receieved ' + typeof onItem); + throw Error( + `The first argument to autoPagingEach, if present, must be a callback function; receieved ${typeof onItem}` + ); } // 4. `.autoPagingEach((item, next) => { doSomething(item); next(false); });` @@ -109,7 +123,9 @@ function getItemCallback(args) { } if (onItem.length > 2) { - throw Error('The `onItem` callback function passed to autoPagingEach must accept at most two arguments; got ' + onItem); + throw Error( + `The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${onItem}` + ); } // This magically handles all three of these usecases (the latter two being functionally identical): @@ -117,17 +133,19 @@ function getItemCallback(args) { // 2. `.autoPagingEach(async (item) => { await doSomething(item); return false; });` // 3. `.autoPagingEach((item) => doSomething(item).then(() => false));` return function _onItem(item, next) { - var shouldContinue = onItem(item); + const shouldContinue = onItem(item); next(shouldContinue); }; } function getLastId(listResult) { - var lastIdx = listResult.data.length - 1; - var lastItem = listResult.data[lastIdx]; - var lastId = lastItem && lastItem.id; + const lastIdx = listResult.data.length - 1; + const lastItem = listResult.data[lastIdx]; + const lastId = lastItem && lastItem.id; if (!lastId) { - throw Error('Unexpected: No `id` found on the last item while auto-paging a list.'); + throw Error( + 'Unexpected: No `id` found on the last item while auto-paging a list.' + ); } return lastId; } @@ -141,7 +159,7 @@ function memoizedPromise(promiseCache, cb) { if (promiseCache.currentPromise) { return promiseCache.currentPromise; } - promiseCache.currentPromise = new Promise(cb).then(function(ret) { + promiseCache.currentPromise = new Promise(cb).then((ret) => { promiseCache.currentPromise = undefined; return ret; }); @@ -150,57 +168,66 @@ function memoizedPromise(promiseCache, cb) { function makeAutoPagingEach(asyncIteratorNext) { return function autoPagingEach(/* onItem?, onDone? */) { - var args = [].slice.call(arguments); - var onItem = getItemCallback(args); - var onDone = getDoneCallback(args); + const args = [].slice.call(arguments); + const onItem = getItemCallback(args); + const onDone = getDoneCallback(args); if (args.length > 2) { throw Error('autoPagingEach takes up to two arguments; received:', args); } - var autoPagePromise = wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem); + const autoPagePromise = wrapAsyncIteratorWithCallback( + asyncIteratorNext, + onItem + ); return utils.callbackifyPromiseWithTimeout(autoPagePromise, onDone); - } + }; } function makeAutoPagingToArray(autoPagingEach) { return function autoPagingToArray(opts, onDone) { - var limit = opts && opts.limit; + const limit = opts && opts.limit; if (!limit) { - throw Error('You must pass a `limit` option to autoPagingToArray, eg; `autoPagingToArray({limit: 1000});`.'); + throw Error( + 'You must pass a `limit` option to autoPagingToArray, eg; `autoPagingToArray({limit: 1000});`.' + ); } if (limit > 10000) { - throw Error('You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.'); + throw Error( + 'You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.' + ); } - var promise = new Promise(function(resolve, reject) { - var items = []; - autoPagingEach(function(item) { + const promise = new Promise((resolve, reject) => { + const items = []; + autoPagingEach((item) => { items.push(item); if (items.length >= limit) { return false; } - }).then(function() { - resolve(items); - }).catch(reject); + }) + .then(() => { + resolve(items); + }) + .catch(reject); }); return utils.callbackifyPromiseWithTimeout(promise, onDone); - } + }; } function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { function handleIteration(iterResult) { if (iterResult.done) { resolve(); return; } - var item = iterResult.value; - return new Promise(function(next) { + const item = iterResult.value; + return new Promise((next) => { // Bit confusing, perhaps; we pass a `resolve` fn // to the user, so they can decide when and if to continue. // They can return false, or a promise which resolves to false, to break. onItem(item, next); - }).then(function(shouldContinue) { + }).then((shouldContinue) => { if (shouldContinue === false) { return handleIteration({done: true}); } else { @@ -209,6 +236,8 @@ function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { }); } - asyncIteratorNext().then(handleIteration).catch(reject); + asyncIteratorNext() + .then(handleIteration) + .catch(reject); }); } diff --git a/lib/makeRequest.js b/lib/makeRequest.js index c55ac3aaa3..c6b105b980 100644 --- a/lib/makeRequest.js +++ b/lib/makeRequest.js @@ -1,92 +1,63 @@ 'use strict'; -var utils = require('./utils'); -var OPTIONAL_REGEX = /^optional!/; +const utils = require('./utils'); function getRequestOpts(self, requestArgs, spec, overrideData) { // Extract spec values with defaults. - var commandPath = typeof spec.path == 'function' ? spec.path - : utils.makeURLInterpolator(spec.path || ''); - var requestMethod = (spec.method || 'GET').toUpperCase(); - var urlParams = spec.urlParams || []; - var encode = spec.encode || function(data) {return data;}; - var host = spec.host; + const commandPath = utils.makeURLInterpolator(spec.path || ''); + const requestMethod = (spec.method || 'GET').toUpperCase(); + const urlParams = spec.urlParams || []; + const encode = spec.encode || ((data) => data); + const host = spec.host; + const path = self.createResourcePathWithSymbols(spec.path); // Don't mutate args externally. - var args = [].slice.call(requestArgs); + const args = [].slice.call(requestArgs); // Generate and validate url params. - var urlData = self.createUrlData(); - for (var i = 0, l = urlParams.length; i < l; ++i) { - var path; - - // Note that we shift the args array after every iteration so this just - // grabs the "next" argument for use as a URL parameter. - var arg = args[0]; - - var param = urlParams[i]; - - var isOptional = OPTIONAL_REGEX.test(param); - param = param.replace(OPTIONAL_REGEX, ''); - - if (param == 'id' && typeof arg !== 'string') { - path = self.createResourcePathWithSymbols(spec.path); - throw new Error( - 'Stripe: "id" must be a string, but got: ' + typeof arg + - ' (on API request to `' + requestMethod + ' ' + path + '`)' - ); - } - - if (!arg) { - if (isOptional) { - urlData[param] = ''; - continue; - } - - path = self.createResourcePathWithSymbols(spec.path); + const urlData = urlParams.reduce((urlData, param) => { + const arg = args.shift(); + if (typeof arg !== 'string') { throw new Error( - 'Stripe: Argument "' + urlParams[i] + '" required, but got: ' + arg + - ' (on API request to `' + requestMethod + ' ' + path + '`)' + `Stripe: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)` ); } - urlData[param] = args.shift(); - } + urlData[param] = arg; + return urlData; + }, {}); // Pull request data and options (headers, auth) from args. - var dataFromArgs = utils.getDataFromArgs(args); - var data = encode(Object.assign({}, dataFromArgs, overrideData)); - var options = utils.getOptionsFromArgs(args); + const dataFromArgs = utils.getDataFromArgs(args); + const data = encode(Object.assign({}, dataFromArgs, overrideData)); + const options = utils.getOptionsFromArgs(args); // Validate that there are no more args. if (args.length) { - path = self.createResourcePathWithSymbols(spec.path); throw new Error( - 'Stripe: Unknown arguments (' + args + '). Did you mean to pass an options ' + - 'object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' + - ' (on API request to ' + requestMethod + ' `' + path + '`)' + `Stripe: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)` ); } - var requestPath = self.createFullPath(commandPath, urlData); - var headers = Object.assign(options.headers, spec.headers); + const requestPath = self.createFullPath(commandPath, urlData); + const headers = Object.assign(options.headers, spec.headers); if (spec.validator) { - spec.validator(data, {headers: headers}); + spec.validator(data, {headers}); } return { - requestMethod: requestMethod, - requestPath: requestPath, - data: data, + requestMethod, + requestPath, + data, auth: options.auth, - headers: headers, - host: host, + headers, + host, }; } function makeRequest(self, requestArgs, spec, overrideData) { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { try { var opts = getRequestOpts(self, requestArgs, spec, overrideData); } catch (err) { @@ -99,14 +70,22 @@ function makeRequest(self, requestArgs, spec, overrideData) { reject(err); } else { resolve( - spec.transformResponseData ? - spec.transformResponseData(response) : - response + spec.transformResponseData + ? spec.transformResponseData(response) + : response ); } } - self._request(opts.requestMethod, opts.host, opts.requestPath, opts.data, opts.auth, {headers: opts.headers}, requestCallback); + self._request( + opts.requestMethod, + opts.host, + opts.requestPath, + opts.data, + opts.auth, + {headers: opts.headers}, + requestCallback + ); }); } diff --git a/lib/resources.js b/lib/resources.js new file mode 100644 index 0000000000..44dc03574c --- /dev/null +++ b/lib/resources.js @@ -0,0 +1,79 @@ +'use strict'; + +const resourceNamespace = require('./ResourceNamespace'); + +module.exports = { + // Support Accounts for consistency, Account for backwards compatibility + Account: require('./resources/Accounts'), + Accounts: require('./resources/Accounts'), + AccountLinks: require('./resources/AccountLinks'), + ApplePayDomains: require('./resources/ApplePayDomains'), + ApplicationFees: require('./resources/ApplicationFees'), + Balance: require('./resources/Balance'), + BalanceTransactions: require('./resources/BalanceTransactions'), + BitcoinReceivers: require('./resources/BitcoinReceivers'), + Charges: require('./resources/Charges'), + CountrySpecs: require('./resources/CountrySpecs'), + Coupons: require('./resources/Coupons'), + CreditNotes: require('./resources/CreditNotes'), + Customers: require('./resources/Customers'), + Disputes: require('./resources/Disputes'), + EphemeralKeys: require('./resources/EphemeralKeys'), + Events: require('./resources/Events'), + ExchangeRates: require('./resources/ExchangeRates'), + Files: require('./resources/Files'), + FileLinks: require('./resources/FileLinks'), + InvoiceItems: require('./resources/InvoiceItems'), + Invoices: require('./resources/Invoices'), + IssuerFraudRecords: require('./resources/IssuerFraudRecords'), + OAuth: require('./resources/OAuth'), + OrderReturns: require('./resources/OrderReturns'), + Orders: require('./resources/Orders'), + PaymentIntents: require('./resources/PaymentIntents'), + PaymentMethods: require('./resources/PaymentMethods'), + Payouts: require('./resources/Payouts'), + Plans: require('./resources/Plans'), + Products: require('./resources/Products'), + Recipients: require('./resources/Recipients'), + Refunds: require('./resources/Refunds'), + Reviews: require('./resources/Reviews'), + Skus: require('./resources/SKUs'), + Sources: require('./resources/Sources'), + SubscriptionItems: require('./resources/SubscriptionItems'), + SubscriptionSchedules: require('./resources/SubscriptionSchedules'), + Subscriptions: require('./resources/Subscriptions'), + TaxRates: require('./resources/TaxRates'), + ThreeDSecure: require('./resources/ThreeDSecure'), + Tokens: require('./resources/Tokens'), + Topups: require('./resources/Topups'), + Transfers: require('./resources/Transfers'), + UsageRecords: require('./resources/UsageRecords'), + UsageRecordSummaries: require('./resources/UsageRecordSummaries'), + WebhookEndpoints: require('./resources/WebhookEndpoints'), + Checkout: resourceNamespace('checkout', { + Sessions: require('./resources/Checkout/Sessions'), + }), + Issuing: resourceNamespace('issuing', { + Authorizations: require('./resources/Issuing/Authorizations'), + Cardholders: require('./resources/Issuing/Cardholders'), + Cards: require('./resources/Issuing/Cards'), + Disputes: require('./resources/Issuing/Disputes'), + Transactions: require('./resources/Issuing/Transactions'), + }), + Radar: resourceNamespace('radar', { + ValueLists: require('./resources/Radar/ValueLists'), + ValueListItems: require('./resources/Radar/ValueListItems'), + }), + Reporting: resourceNamespace('reporting', { + ReportRuns: require('./resources/Reporting/ReportRuns'), + ReportTypes: require('./resources/Reporting/ReportTypes'), + }), + Sigma: resourceNamespace('sigma', { + ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'), + }), + Terminal: resourceNamespace('terminal', { + ConnectionTokens: require('./resources/Terminal/ConnectionTokens'), + Locations: require('./resources/Terminal/Locations'), + Readers: require('./resources/Terminal/Readers'), + }), +}; diff --git a/lib/resources/AccountLinks.js b/lib/resources/AccountLinks.js index 33bd4a2940..e7e11a63bc 100644 --- a/lib/resources/AccountLinks.js +++ b/lib/resources/AccountLinks.js @@ -1,7 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'account_links', + includeBasic: ['create'], }); - diff --git a/lib/resources/Accounts.js b/lib/resources/Accounts.js index 1968c48b0e..2a009990f0 100644 --- a/lib/resources/Accounts.js +++ b/lib/resources/Accounts.js @@ -1,7 +1,7 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ // Since path can either be `account` or `accounts`, support both through stripeMethod path @@ -20,30 +20,26 @@ module.exports = StripeResource.extend({ update: stripeMethod({ method: 'POST', path: 'accounts/{id}', - urlParams: ['id'], }), // Avoid 'delete' keyword in JS del: stripeMethod({ method: 'DELETE', path: 'accounts/{id}', - urlParams: ['id'], }), reject: stripeMethod({ method: 'POST', path: 'accounts/{id}/reject', - urlParams: ['id'], }), - retrieve: function(id) { + retrieve(id) { // No longer allow an api key to be passed as the first string to this function due to ambiguity between // old account ids and api keys. To request the account for an api key, send null as the id if (typeof id === 'string') { return stripeMethod({ method: 'GET', path: 'accounts/{id}', - urlParams: ['id'], }).apply(this, arguments); } else { if (id === null || id === undefined) { @@ -64,20 +60,17 @@ module.exports = StripeResource.extend({ listCapabilities: stripeMethod({ method: 'GET', path: 'accounts/{accountId}/capabilities', - urlParams: ['accountId'], methodType: 'list', }), retrieveCapability: stripeMethod({ method: 'GET', path: 'accounts/{accountId}/capabilities/{capabilityId}', - urlParams: ['accountId', 'capabilityId'], }), updateCapability: stripeMethod({ method: 'POST', path: 'accounts/{accountId}/capabilities/{capabilityId}', - urlParams: ['accountId', 'capabilityId'], }), /** @@ -87,42 +80,36 @@ module.exports = StripeResource.extend({ createExternalAccount: stripeMethod({ method: 'POST', path: 'accounts/{accountId}/external_accounts', - urlParams: ['accountId'], }), listExternalAccounts: stripeMethod({ method: 'GET', path: 'accounts/{accountId}/external_accounts', - urlParams: ['accountId'], methodType: 'list', }), retrieveExternalAccount: stripeMethod({ method: 'GET', path: 'accounts/{accountId}/external_accounts/{externalAccountId}', - urlParams: ['accountId', 'externalAccountId'], }), updateExternalAccount: stripeMethod({ method: 'POST', path: 'accounts/{accountId}/external_accounts/{externalAccountId}', - urlParams: ['accountId', 'externalAccountId'], }), deleteExternalAccount: stripeMethod({ method: 'DELETE', path: 'accounts/{accountId}/external_accounts/{externalAccountId}', - urlParams: ['accountId', 'externalAccountId'], }), /** - * Accounts: LoginLink methods - */ + * Accounts: LoginLink methods + */ createLoginLink: stripeMethod({ method: 'POST', path: 'accounts/{accountId}/login_links', - urlParams: ['accountId'], }), /** @@ -132,31 +119,26 @@ module.exports = StripeResource.extend({ createPerson: stripeMethod({ method: 'POST', path: 'accounts/{accountId}/persons', - urlParams: ['accountId'], }), listPersons: stripeMethod({ method: 'GET', path: 'accounts/{accountId}/persons', - urlParams: ['accountId'], methodType: 'list', }), retrievePerson: stripeMethod({ method: 'GET', path: 'accounts/{accountId}/persons/{personId}', - urlParams: ['accountId', 'personId'], }), updatePerson: stripeMethod({ method: 'POST', path: 'accounts/{accountId}/persons/{personId}', - urlParams: ['accountId', 'personId'], }), deletePerson: stripeMethod({ method: 'DELETE', path: 'accounts/{accountId}/persons/{personId}', - urlParams: ['accountId', 'personId'], }), }); diff --git a/lib/resources/ApplePayDomains.js b/lib/resources/ApplePayDomains.js index 4d05c2523b..21c8cf82e8 100644 --- a/lib/resources/ApplePayDomains.js +++ b/lib/resources/ApplePayDomains.js @@ -1,6 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'apple_pay/domains', - includeBasic: ['create', 'list', 'retrieve', 'del'], + + includeBasic: ['create', 'del', 'list', 'retrieve'], }); diff --git a/lib/resources/ApplicationFeeRefunds.js b/lib/resources/ApplicationFeeRefunds.js deleted file mode 100644 index e73a018cd4..0000000000 --- a/lib/resources/ApplicationFeeRefunds.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * ApplicationFeeRefunds is a unique resource in that, upon instantiation, - * requires an application fee id , and therefore each of its methods only - * require the refundId argument. - * - * This streamlines the API specifically for the case of accessing refunds - * on a returned application fee object. - * - * E.g. applicationFeeObject.refunds.retrieve(refundId) - * (As opposed to the also-supported stripe.applicationFees.retrieveRefund(chargeId, - * refundId)) - */ -module.exports = StripeResource.extend({ - path: 'application_fees/{feeId}/refunds', - includeBasic: ['create', 'list', 'retrieve', 'update'], -}); diff --git a/lib/resources/ApplicationFees.js b/lib/resources/ApplicationFees.js index 0e96e4ed65..0a439cc1d0 100644 --- a/lib/resources/ApplicationFees.js +++ b/lib/resources/ApplicationFees.js @@ -1,44 +1,31 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'application_fees', - includeBasic: [ - 'list', 'retrieve', - ], - - refund: stripeMethod({ - method: 'POST', - path: '/{id}/refund', - urlParams: ['id'], - }), + includeBasic: ['list', 'retrieve'], createRefund: stripeMethod({ method: 'POST', path: '/{feeId}/refunds', - urlParams: ['feeId'], }), listRefunds: stripeMethod({ method: 'GET', path: '/{feeId}/refunds', - urlParams: ['feeId'], methodType: 'list', }), retrieveRefund: stripeMethod({ method: 'GET', path: '/{feeId}/refunds/{refundId}', - urlParams: ['feeId', 'refundId'], }), updateRefund: stripeMethod({ method: 'POST', path: '/{feeId}/refunds/{refundId}', - urlParams: ['feeId', 'refundId'], }), }); diff --git a/lib/resources/Balance.js b/lib/resources/Balance.js index a6c5f1655c..cdb30b26a5 100644 --- a/lib/resources/Balance.js +++ b/lib/resources/Balance.js @@ -1,26 +1,12 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'balance', retrieve: stripeMethod({ method: 'GET', }), - - listTransactions: stripeMethod({ - method: 'GET', - path: 'history', - methodType: 'list', - }), - - retrieveTransaction: stripeMethod({ - method: 'GET', - path: 'history/{transactionId}', - urlParams: ['transactionId'], - }), - }); diff --git a/lib/resources/BalanceTransactions.js b/lib/resources/BalanceTransactions.js index c8095d4bdf..3e3a6c7dcd 100644 --- a/lib/resources/BalanceTransactions.js +++ b/lib/resources/BalanceTransactions.js @@ -1,6 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'balance/history', + includeBasic: ['list', 'retrieve'], }); diff --git a/lib/resources/BitcoinReceivers.js b/lib/resources/BitcoinReceivers.js index 430db040ed..1ee13383e0 100644 --- a/lib/resources/BitcoinReceivers.js +++ b/lib/resources/BitcoinReceivers.js @@ -1,20 +1,16 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'bitcoin/receivers', - includeBasic: [ - 'list', 'retrieve', 'getMetadata', - ], + includeBasic: ['list', 'retrieve'], listTransactions: stripeMethod({ method: 'GET', - path: '/{receiverId}/transactions', - urlParams: ['receiverId'], + path: '/{id}/transactions', methodType: 'list', }), }); diff --git a/lib/resources/Capabilities.js b/lib/resources/Capabilities.js deleted file mode 100644 index 42186890f7..0000000000 --- a/lib/resources/Capabilities.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -module.exports = StripeResource.extend({ - path: 'accounts/{accountId}/capabilities', - includeBasic: ['list', 'retrieve', 'update'], -}); - diff --git a/lib/resources/ChargeRefunds.js b/lib/resources/ChargeRefunds.js deleted file mode 100644 index f6de00306d..0000000000 --- a/lib/resources/ChargeRefunds.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * ChargeRefunds is a unique resource in that, upon instantiation, - * requires a chargeId, and therefore each of its methods only - * require the refundId argument. - * - * This streamlines the API specifically for the case of accessing refunds - * on a returned charge object. - * - * E.g. chargeObject.refunds.retrieve(refundId) - * (As opposed to the also-supported stripe.charges.retrieveRefund(chargeId, - * refundId)) - */ -module.exports = StripeResource.extend({ - path: 'charges/{chargeId}/refunds', - includeBasic: ['create', 'list', 'retrieve', 'update'], -}); diff --git a/lib/resources/Charges.js b/lib/resources/Charges.js index 28a0798aeb..1c5dd469eb 100644 --- a/lib/resources/Charges.js +++ b/lib/resources/Charges.js @@ -1,75 +1,15 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'charges', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', - 'setMetadata', 'getMetadata', - ], + includeBasic: ['create', 'list', 'retrieve', 'update'], capture: stripeMethod({ method: 'POST', path: '/{id}/capture', - urlParams: ['id'], - }), - - refund: stripeMethod({ - method: 'POST', - path: '/{id}/refund', - urlParams: ['id'], - }), - - updateDispute: stripeMethod({ - method: 'POST', - path: '/{id}/dispute', - urlParams: ['id'], - }), - - closeDispute: stripeMethod({ - method: 'POST', - path: '/{id}/dispute/close', - urlParams: ['id'], - }), - - /** - * Charge: Refund methods - * (Deprecated) - */ - createRefund: stripeMethod({ - method: 'POST', - path: '/{chargeId}/refunds', - urlParams: ['chargeId'], - }), - - listRefunds: stripeMethod({ - method: 'GET', - path: '/{chargeId}/refunds', - urlParams: ['chargeId'], - methodType: 'list', - }), - - retrieveRefund: stripeMethod({ - method: 'GET', - path: '/{chargeId}/refunds/{refundId}', - urlParams: ['chargeId', 'refundId'], }), - - updateRefund: stripeMethod({ - method: 'POST', - path: '/{chargeId}/refunds/{refundId}', - urlParams: ['chargeId', 'refundId'], - }), - - markAsSafe: function(chargeId) { - return this.update(chargeId, {'fraud_details': {'user_report': 'safe'}}) - }, - - markAsFraudulent: function(chargeId) { - return this.update(chargeId, {'fraud_details': {'user_report': 'fraudulent'}}) - }, }); diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js index 3accef7cc0..8aa1fb56de 100644 --- a/lib/resources/Checkout/Sessions.js +++ b/lib/resources/Checkout/Sessions.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'checkout/sessions', + includeBasic: ['create', 'retrieve'], -}) +}); diff --git a/lib/resources/CountrySpecs.js b/lib/resources/CountrySpecs.js index 25210ac31a..b6d5477afe 100644 --- a/lib/resources/CountrySpecs.js +++ b/lib/resources/CountrySpecs.js @@ -1,12 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'country_specs', - includeBasic: [ - 'list', 'retrieve', - ], + includeBasic: ['list', 'retrieve'], }); diff --git a/lib/resources/Coupons.js b/lib/resources/Coupons.js index a9f519afa3..d7a50d88bb 100644 --- a/lib/resources/Coupons.js +++ b/lib/resources/Coupons.js @@ -1,7 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'coupons', - includeBasic: ['create', 'list', 'update', 'retrieve', 'del'], -}); + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/CreditNotes.js b/lib/resources/CreditNotes.js index 24df5aca90..e38dd295ca 100644 --- a/lib/resources/CreditNotes.js +++ b/lib/resources/CreditNotes.js @@ -1,16 +1,15 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'credit_notes', + includeBasic: ['create', 'list', 'retrieve', 'update'], voidCreditNote: stripeMethod({ method: 'POST', - path: '{creditNoteId}/void', - urlParams: ['creditNoteId'], + path: '/{id}/void', }), }); diff --git a/lib/resources/CustomerCards.js b/lib/resources/CustomerCards.js deleted file mode 100644 index 059c403de2..0000000000 --- a/lib/resources/CustomerCards.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * CustomerCard is a unique resource in that, upon instantiation, - * requires a customerId, and therefore each of its methods only - * require the cardId argument. - * - * This streamlines the API specifically for the case of accessing cards - * on a returned customer object. - * - * E.g. customerObject.cards.retrieve(cardId) - * (As opposed to the also-supported stripe.customers.retrieveCard(custId, cardId)) - */ -module.exports = StripeResource.extend({ - path: 'customers/{customerId}/cards', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], -}); diff --git a/lib/resources/CustomerSubscriptions.js b/lib/resources/CustomerSubscriptions.js deleted file mode 100644 index 3082d84049..0000000000 --- a/lib/resources/CustomerSubscriptions.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; - -/** - * CustomerSubscription is a unique resource in that, upon instantiation, - * requires a customerId, and therefore each of its methods only - * require the subscriptionId argument. - * - * This streamlines the API specifically for the case of accessing cards - * on a returned customer object. - * - * E.g. customerObject.cards.retrieve(cardId) - * (As opposed to the also-supported stripe.customers.retrieveCard(custId, cardId)) - */ -module.exports = StripeResource.extend({ - path: 'customers/{customerId}/subscriptions', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], - - /** - * Customer: Discount methods - */ - - deleteDiscount: stripeMethod({ - method: 'DELETE', - path: '/{subscriptionId}/discount', - urlParams: ['customerId', 'subscriptionId'], - }), -}); diff --git a/lib/resources/Customers.js b/lib/resources/Customers.js index 6a182612ad..1255184b93 100644 --- a/lib/resources/Customers.js +++ b/lib/resources/Customers.js @@ -1,115 +1,20 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var utils = require('../utils'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'customers', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', 'del', - 'setMetadata', 'getMetadata', - ], - - /** - * Customer: Subscription methods - */ - - _legacyUpdateSubscription: stripeMethod({ - method: 'POST', - path: '{customerId}/subscription', - urlParams: ['customerId'], - }), - _newstyleUpdateSubscription: stripeMethod({ - method: 'POST', - path: '/{customerId}/subscriptions/{subscriptionId}', - urlParams: ['customerId', 'subscriptionId'], - }), - - _legacyCancelSubscription: stripeMethod({ - method: 'DELETE', - path: '{customerId}/subscription', - urlParams: ['customerId'], - }), - - _newstyleCancelSubscription: stripeMethod({ - method: 'DELETE', - path: '/{customerId}/subscriptions/{subscriptionId}', - urlParams: ['customerId', 'subscriptionId'], - }), - - createSubscription: stripeMethod({ - method: 'POST', - path: '/{customerId}/subscriptions', - urlParams: ['customerId'], - }), - - listSubscriptions: stripeMethod({ - method: 'GET', - path: '/{customerId}/subscriptions', - urlParams: ['customerId'], - methodType: 'list', - }), - - retrieveSubscription: stripeMethod({ - method: 'GET', - path: '/{customerId}/subscriptions/{subscriptionId}', - urlParams: ['customerId', 'subscriptionId'], - }), - - updateSubscription: function(customerId, subscriptionId) { - if (typeof subscriptionId == 'string') { - return this._newstyleUpdateSubscription.apply(this, arguments); - } else { - return this._legacyUpdateSubscription.apply(this, arguments); - } - }, - - cancelSubscription: function(customerId, subscriptionId) { - // This is a hack, but it lets us maximize our overloading. - // Precarious assumption: If it's not an auth key it _could_ be a sub id: - if (typeof subscriptionId == 'string' && !utils.isAuthKey(subscriptionId)) { - return this._newstyleCancelSubscription.apply(this, arguments); - } else { - return this._legacyCancelSubscription.apply(this, arguments); - } - }, + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], /** - * Customer: Card methods + * Customer: Discount methods */ - createCard: stripeMethod({ - method: 'POST', - path: '/{customerId}/cards', - urlParams: ['customerId'], - }), - - listCards: stripeMethod({ - method: 'GET', - path: '/{customerId}/cards', - urlParams: ['customerId'], - methodType: 'list', - }), - - retrieveCard: stripeMethod({ - method: 'GET', - path: '/{customerId}/cards/{cardId}', - urlParams: ['customerId', 'cardId'], - }), - - updateCard: stripeMethod({ - method: 'POST', - path: '/{customerId}/cards/{cardId}', - urlParams: ['customerId', 'cardId'], - }), - - deleteCard: stripeMethod({ + deleteDiscount: stripeMethod({ method: 'DELETE', - path: '/{customerId}/cards/{cardId}', - urlParams: ['customerId', 'cardId'], + path: '/{customerId}/discount', }), /** @@ -119,54 +24,32 @@ module.exports = StripeResource.extend({ createSource: stripeMethod({ method: 'POST', path: '/{customerId}/sources', - urlParams: ['customerId'], }), listSources: stripeMethod({ method: 'GET', path: '/{customerId}/sources', - urlParams: ['customerId'], methodType: 'list', }), retrieveSource: stripeMethod({ method: 'GET', path: '/{customerId}/sources/{sourceId}', - urlParams: ['customerId', 'sourceId'], }), updateSource: stripeMethod({ method: 'POST', path: '/{customerId}/sources/{sourceId}', - urlParams: ['customerId', 'sourceId'], }), deleteSource: stripeMethod({ method: 'DELETE', path: '/{customerId}/sources/{sourceId}', - urlParams: ['customerId', 'sourceId'], }), verifySource: stripeMethod({ method: 'POST', path: '/{customerId}/sources/{sourceId}/verify', - urlParams: ['customerId', 'sourceId'], - }), - - /** - * Customer: Discount methods - */ - - deleteDiscount: stripeMethod({ - method: 'DELETE', - path: '/{customerId}/discount', - urlParams: ['customerId'], - }), - - deleteSubscriptionDiscount: stripeMethod({ - method: 'DELETE', - path: '/{customerId}/subscriptions/{subscriptionId}/discount', - urlParams: ['customerId', 'subscriptionId'], }), /** @@ -176,25 +59,21 @@ module.exports = StripeResource.extend({ createTaxId: stripeMethod({ method: 'POST', path: '/{customerId}/tax_ids', - urlParams: ['customerId'], }), deleteTaxId: stripeMethod({ method: 'DELETE', path: '/{customerId}/tax_ids/{taxIdId}', - urlParams: ['customerId', 'taxIdId'], }), listTaxIds: stripeMethod({ method: 'GET', path: '/{customerId}/tax_ids', - urlParams: ['customerId'], methodType: 'list', }), retrieveTaxId: stripeMethod({ method: 'GET', path: '/{customerId}/tax_ids/{taxIdId}', - urlParams: ['customerId', 'taxIdId'], }), }); diff --git a/lib/resources/Disputes.js b/lib/resources/Disputes.js index eff2aba687..1d476249a0 100644 --- a/lib/resources/Disputes.js +++ b/lib/resources/Disputes.js @@ -1,21 +1,15 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'disputes', - includeBasic: [ - 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata', - ], + includeBasic: ['list', 'retrieve', 'update'], close: stripeMethod({ method: 'POST', path: '/{id}/close', - urlParams: ['id'], }), - }); - diff --git a/lib/resources/EphemeralKeys.js b/lib/resources/EphemeralKeys.js index 2be6f9c9d5..fe9d7d5bb8 100644 --- a/lib/resources/EphemeralKeys.js +++ b/lib/resources/EphemeralKeys.js @@ -1,19 +1,21 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ + path: 'ephemeral_keys', + + includeBasic: ['del'], + create: stripeMethod({ method: 'POST', - validator: function(data, options) { + validator: (data, options) => { if (!options.headers || !options.headers['Stripe-Version']) { - throw new Error('stripe_version must be specified to create an ephemeral key'); + throw new Error( + 'stripe_version must be specified to create an ephemeral key' + ); } }, }), - - path: 'ephemeral_keys', - - includeBasic: ['del'], }); diff --git a/lib/resources/Events.js b/lib/resources/Events.js index ae4f092432..16745f149b 100644 --- a/lib/resources/Events.js +++ b/lib/resources/Events.js @@ -1,7 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'events', + includeBasic: ['list', 'retrieve'], }); - diff --git a/lib/resources/ExchangeRates.js b/lib/resources/ExchangeRates.js index a7d3b10853..7a314cadca 100644 --- a/lib/resources/ExchangeRates.js +++ b/lib/resources/ExchangeRates.js @@ -1,12 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'exchange_rates', - includeBasic: [ - 'list', 'retrieve', - ], + includeBasic: ['list', 'retrieve'], }); diff --git a/lib/resources/FileLinks.js b/lib/resources/FileLinks.js index 8052fc7f02..580b038562 100644 --- a/lib/resources/FileLinks.js +++ b/lib/resources/FileLinks.js @@ -1,11 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'file_links', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata', - ], + + includeBasic: ['create', 'list', 'retrieve', 'update'], }); diff --git a/lib/resources/Files.js b/lib/resources/Files.js index 0315d3092d..424475c0e2 100644 --- a/lib/resources/Files.js +++ b/lib/resources/Files.js @@ -1,15 +1,18 @@ 'use strict'; -var Buffer = require('safe-buffer').Buffer; -var utils = require('../utils'); -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; -var multipartDataGenerator = require('../MultipartDataGenerator'); -var Error = require('../Error'); +const Buffer = require('safe-buffer').Buffer; +const utils = require('../utils'); +const multipartDataGenerator = require('../MultipartDataGenerator'); +const Error = require('../Error'); +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ + path: 'files', + + includeBasic: ['list', 'retrieve'], - requestDataProcessor: function(method, data, headers, callback) { + requestDataProcessor(method, data, headers, callback) { data = data || {}; if (method === 'POST') { @@ -19,54 +22,55 @@ module.exports = StripeResource.extend({ } function getProcessorForSourceType(data) { - var isStream = utils.checkForStream(data); + const isStream = utils.checkForStream(data); if (isStream) { return streamProcessor(multipartDataGenerator); } else { - var buffer = multipartDataGenerator(method, data, headers); + const buffer = multipartDataGenerator(method, data, headers); return callback(null, buffer); } } - function streamProcessor (fn) { - var bufferArray = []; - data.file.data.on('data', function(line) { - bufferArray.push(line); - }).on('end', function() { - var bufferData = Object.assign({}, data); - bufferData.file.data = Buffer.concat(bufferArray); - var buffer = fn(method, bufferData, headers); - callback(null, buffer); - }).on('error', function(err) { - var errorHandler = streamError(callback); - errorHandler(err); - }); + function streamProcessor(fn) { + const bufferArray = []; + data.file.data + .on('data', (line) => { + bufferArray.push(line); + }) + .on('end', () => { + const bufferData = Object.assign({}, data); + bufferData.file.data = Buffer.concat(bufferArray); + const buffer = fn(method, bufferData, headers); + callback(null, buffer); + }) + .on('error', (err) => { + const errorHandler = streamError(callback); + errorHandler(err); + }); } function streamError(callback) { - var StreamProcessingError = Error.extend({ + const StreamProcessingError = Error.extend({ type: 'StreamProcessingError', - populate: function(raw) { + populate(raw) { this.type = this.type; this.message = raw.message; this.detail = raw.detail; - } + }, }); - return function(error) { + return (error) => { callback( new StreamProcessingError({ - message: 'An error occurred while attempting to process the file for upload.', + message: + 'An error occurred while attempting to process the file for upload.', detail: error, }), null ); - } + }; } }, - path: 'files', - includeBasic: ['list', 'retrieve'], - create: stripeMethod({ method: 'POST', headers: { diff --git a/lib/resources/InvoiceItems.js b/lib/resources/InvoiceItems.js index 00af738ed5..0a17e43ee1 100644 --- a/lib/resources/InvoiceItems.js +++ b/lib/resources/InvoiceItems.js @@ -1,10 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'invoiceitems', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', 'del', - 'setMetadata', 'getMetadata', - ], -}); + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/Invoices.js b/lib/resources/Invoices.js index bc3f483bb8..5faca3ff0c 100644 --- a/lib/resources/Invoices.js +++ b/lib/resources/Invoices.js @@ -1,36 +1,21 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; -var utils = require('../utils'); +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'invoices', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], - - finalizeInvoice: stripeMethod({ - method: 'POST', - path: '{invoiceId}/finalize', - urlParams: ['invoiceId'], - }), - markUncollectible: stripeMethod({ - method: 'POST', - path: '{invoiceId}/mark_uncollectible', - urlParams: ['invoiceId'], - }), + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], - pay: stripeMethod({ + finalizeInvoice: stripeMethod({ method: 'POST', - path: '{invoiceId}/pay', - urlParams: ['invoiceId'], + path: '{id}/finalize', }), listLineItems: stripeMethod({ method: 'GET', - path: '{invoiceId}/lines', - urlParams: ['invoiceId'], + path: '{id}/lines', }), listUpcomingLineItems: stripeMethod({ @@ -38,50 +23,28 @@ module.exports = StripeResource.extend({ path: 'upcoming/lines', }), - // deprecated in favor of `listLineItems` - retrieveLines: stripeMethod({ - method: 'GET', - path: '{invoiceId}/lines', - urlParams: ['invoiceId'], + markUncollectible: stripeMethod({ + method: 'POST', + path: '{id}/mark_uncollectible', + }), + + pay: stripeMethod({ + method: 'POST', + path: '{id}/pay', }), retrieveUpcoming: stripeMethod({ method: 'GET', - path: function(urlData) { - var url = 'upcoming?'; - var hasParam = false; - - // If you pass just a hash with the relevant parameters, including customer id inside. - if (urlData.invoiceOptionsOrCustomerId && typeof urlData.invoiceOptionsOrCustomerId === 'object') { - return url + utils.stringifyRequestData(urlData.invoiceOptionsOrCustomerId); - } - - // Legacy implementation where the first parameter is a customer id as a string - if (urlData.invoiceOptionsOrCustomerId && typeof urlData.invoiceOptionsOrCustomerId === 'string') { - url = url + 'customer=' + urlData.invoiceOptionsOrCustomerId; - hasParam = true; - } - - // Legacy support where second argument is the subscription id - if (urlData.invoiceOptionsOrSubscriptionId && typeof urlData.invoiceOptionsOrSubscriptionId === 'string') { - return url + (hasParam ? '&' : '') + 'subscription=' + urlData.invoiceOptionsOrSubscriptionId; - } else if (urlData.invoiceOptionsOrSubscriptionId && typeof urlData.invoiceOptionsOrSubscriptionId === 'object') { - return url + (hasParam ? '&' : '') + utils.stringifyRequestData(urlData.invoiceOptionsOrSubscriptionId); - } - return url; - }, - urlParams: ['optional!invoiceOptionsOrCustomerId', 'optional!invoiceOptionsOrSubscriptionId'], + path: 'upcoming', }), sendInvoice: stripeMethod({ method: 'POST', - path: '{invoiceId}/send', - urlParams: ['invoiceId'], + path: '{id}/send', }), voidInvoice: stripeMethod({ method: 'POST', - path: '{invoiceId}/void', - urlParams: ['invoiceId'], + path: '{id}/void', }), }); diff --git a/lib/resources/IssuerFraudRecords.js b/lib/resources/IssuerFraudRecords.js index 76c1e1e4d0..97d38fd133 100644 --- a/lib/resources/IssuerFraudRecords.js +++ b/lib/resources/IssuerFraudRecords.js @@ -1,6 +1,6 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ path: 'issuer_fraud_records', diff --git a/lib/resources/Issuing/Authorizations.js b/lib/resources/Issuing/Authorizations.js index a17deec892..1be1546969 100644 --- a/lib/resources/Issuing/Authorizations.js +++ b/lib/resources/Issuing/Authorizations.js @@ -1,22 +1,20 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'issuing/authorizations', - includeBasic: ['list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], + includeBasic: ['list', 'retrieve', 'update'], approve: stripeMethod({ method: 'POST', path: '/{id}/approve', - urlParams: ['id'], }), decline: stripeMethod({ method: 'POST', path: '/{id}/decline', - urlParams: ['id'], }), }); diff --git a/lib/resources/Issuing/Cardholders.js b/lib/resources/Issuing/Cardholders.js index e8a175e918..9bd9572f7e 100644 --- a/lib/resources/Issuing/Cardholders.js +++ b/lib/resources/Issuing/Cardholders.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'issuing/cardholders', - includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], + + includeBasic: ['create', 'list', 'retrieve', 'update'], }); diff --git a/lib/resources/Issuing/Cards.js b/lib/resources/Issuing/Cards.js index 99199642e8..81475c9524 100644 --- a/lib/resources/Issuing/Cards.js +++ b/lib/resources/Issuing/Cards.js @@ -1,16 +1,15 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'issuing/cards', - includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], + includeBasic: ['create', 'list', 'retrieve', 'update'], retrieveDetails: stripeMethod({ method: 'GET', path: '/{id}/details', - urlParams: ['id'], }), }); diff --git a/lib/resources/Issuing/Disputes.js b/lib/resources/Issuing/Disputes.js index 296fa779f7..90ebc0cc3d 100644 --- a/lib/resources/Issuing/Disputes.js +++ b/lib/resources/Issuing/Disputes.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'issuing/disputes', - includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], + + includeBasic: ['create', 'list', 'retrieve', 'update'], }); diff --git a/lib/resources/Issuing/Transactions.js b/lib/resources/Issuing/Transactions.js index f7f004bbd8..2f8399fa16 100644 --- a/lib/resources/Issuing/Transactions.js +++ b/lib/resources/Issuing/Transactions.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'issuing/transactions', - includeBasic: ['list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], + + includeBasic: ['list', 'retrieve', 'update'], }); diff --git a/lib/resources/LoginLinks.js b/lib/resources/LoginLinks.js deleted file mode 100644 index ac82bc71c9..0000000000 --- a/lib/resources/LoginLinks.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -module.exports = StripeResource.extend({ - path: 'accounts/{accountId}/login_links', - includeBasic: ['create'], -}); diff --git a/lib/resources/OAuth.js b/lib/resources/OAuth.js index 1649599119..70ce4a2358 100644 --- a/lib/resources/OAuth.js +++ b/lib/resources/OAuth.js @@ -1,23 +1,23 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; -var utils = require('../utils'); +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; +const utils = require('../utils'); -var oAuthHost = 'connect.stripe.com'; +const oAuthHost = 'connect.stripe.com'; module.exports = StripeResource.extend({ basePath: '/', - authorizeUrl: function(params, options) { + authorizeUrl(params, options) { params = params || {}; options = options || {}; - var path = 'oauth/authorize'; + let path = 'oauth/authorize'; // For Express accounts, the path changes if (options.express) { - path = 'express/' + path; + path = `express/${path}`; } if (!params.response_type) { @@ -32,7 +32,7 @@ module.exports = StripeResource.extend({ params.scope = 'read_write'; } - return 'https://' + oAuthHost + '/' + path + '?' + utils.stringifyRequestData(params); + return `https://${oAuthHost}/${path}?${utils.stringifyRequestData(params)}`; }, token: stripeMethod({ @@ -41,7 +41,7 @@ module.exports = StripeResource.extend({ host: oAuthHost, }), - deauthorize: function(spec) { + deauthorize(spec) { if (!spec.client_id) { spec.client_id = this._stripe.getClientId(); } diff --git a/lib/resources/OrderReturns.js b/lib/resources/OrderReturns.js index 777821a682..058c702c87 100644 --- a/lib/resources/OrderReturns.js +++ b/lib/resources/OrderReturns.js @@ -1,12 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'order_returns', - includeBasic: [ - 'list', 'retrieve', - ], + includeBasic: ['list', 'retrieve'], }); diff --git a/lib/resources/Orders.js b/lib/resources/Orders.js index 0e32b3fdca..b242e3cf30 100644 --- a/lib/resources/Orders.js +++ b/lib/resources/Orders.js @@ -1,26 +1,20 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'orders', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', - ], + includeBasic: ['create', 'list', 'retrieve', 'update'], pay: stripeMethod({ method: 'POST', - path: '/{orderId}/pay', - urlParams: ['orderId'], + path: '/{id}/pay', }), returnOrder: stripeMethod({ method: 'POST', - path: '/{orderId}/returns', - urlParams: ['orderId'], + path: '/{id}/returns', }), - }); diff --git a/lib/resources/PaymentIntents.js b/lib/resources/PaymentIntents.js index fae0950b27..54da65e251 100644 --- a/lib/resources/PaymentIntents.js +++ b/lib/resources/PaymentIntents.js @@ -1,28 +1,25 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'payment_intents', + includeBasic: ['create', 'list', 'retrieve', 'update'], cancel: stripeMethod({ method: 'POST', - path: '{paymentIntentId}/cancel', - urlParams: ['paymentIntentId'], + path: '/{id}/cancel', }), capture: stripeMethod({ method: 'POST', - path: '{paymentIntentId}/capture', - urlParams: ['paymentIntentId'], + path: '/{id}/capture', }), confirm: stripeMethod({ method: 'POST', - path: '{paymentIntentId}/confirm', - urlParams: ['paymentIntentId'], + path: '/{id}/confirm', }), }); - diff --git a/lib/resources/PaymentMethods.js b/lib/resources/PaymentMethods.js index 54f3c829c5..38e3bd893a 100644 --- a/lib/resources/PaymentMethods.js +++ b/lib/resources/PaymentMethods.js @@ -1,22 +1,20 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_methods', + includeBasic: ['create', 'list', 'retrieve', 'update'], attach: stripeMethod({ method: 'POST', - path: '{paymentMethodId}/attach', - urlParams: ['paymentMethodId'], + path: '/{id}/attach', }), detach: stripeMethod({ method: 'POST', - path: '{paymentMethodId}/detach', - urlParams: ['paymentMethodId'], + path: '/{id}/detach', }), }); diff --git a/lib/resources/Payouts.js b/lib/resources/Payouts.js index 433b5b04ae..31785ef458 100644 --- a/lib/resources/Payouts.js +++ b/lib/resources/Payouts.js @@ -1,28 +1,15 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payouts', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', - 'setMetadata', 'getMetadata', - ], + includeBasic: ['create', 'list', 'retrieve', 'update'], cancel: stripeMethod({ method: 'POST', - path: '{payoutId}/cancel', - urlParams: ['payoutId'], - }), - - listTransactions: stripeMethod({ - method: 'GET', - path: '{payoutId}/transactions', - urlParams: ['payoutId'], - methodType: 'list', + path: '/{id}/cancel', }), }); - diff --git a/lib/resources/Persons.js b/lib/resources/Persons.js deleted file mode 100644 index 605bd24b48..0000000000 --- a/lib/resources/Persons.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * Persons is a unique resource in that, upon instantiation, - * requires an accountId, and therefore each of its methods only - * require the personId argument. - * - * This streamlines the API specifically for the case of accessing person - * on a returned transfer object. - * - * E.g. accountObject.person.retrieve(personId) - * (As opposed to the also-supported stripe.accounts.retrievePerson(accountId, - * personId)) - */ -module.exports = StripeResource.extend({ - path: 'accounts/{accountId}/persons', - includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], -}); - diff --git a/lib/resources/Plans.js b/lib/resources/Plans.js index a7d01bae8a..8ab81fba9f 100644 --- a/lib/resources/Plans.js +++ b/lib/resources/Plans.js @@ -1,7 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'plans', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], -}); + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/Products.js b/lib/resources/Products.js index d8bcedef5c..02da55d5da 100644 --- a/lib/resources/Products.js +++ b/lib/resources/Products.js @@ -1,13 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'products', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', 'del', - ], - + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], }); diff --git a/lib/resources/Radar/ValueListItems.js b/lib/resources/Radar/ValueListItems.js index f15d4e69b2..d21d48d976 100644 --- a/lib/resources/Radar/ValueListItems.js +++ b/lib/resources/Radar/ValueListItems.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'radar/value_list_items', - includeBasic: ['create', 'list', 'retrieve', 'del'], + + includeBasic: ['create', 'del', 'list', 'retrieve'], }); diff --git a/lib/resources/Radar/ValueLists.js b/lib/resources/Radar/ValueLists.js index afda83a75c..c1071b3b9f 100644 --- a/lib/resources/Radar/ValueLists.js +++ b/lib/resources/Radar/ValueLists.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'radar/value_lists', - includeBasic: ['create', 'list', 'update', 'retrieve', 'del'], + + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], }); diff --git a/lib/resources/RecipientCards.js b/lib/resources/RecipientCards.js deleted file mode 100644 index 2986003798..0000000000 --- a/lib/resources/RecipientCards.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * RecipientCard is similar to CustomerCard in that, upon instantiation, it - * requires a recipientId, and therefore each of its methods only - * require the cardId argument. - * - * This streamlines the API specifically for the case of accessing cards - * on a returned recipient object. - * - * E.g. recipientObject.cards.retrieve(cardId) - * (As opposed to the also-supported stripe.recipients.retrieveCard(recipientId, cardId)) - */ -module.exports = StripeResource.extend({ - path: 'recipients/{recipientId}/cards', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], -}); diff --git a/lib/resources/Recipients.js b/lib/resources/Recipients.js index 536e98f730..84e594e701 100644 --- a/lib/resources/Recipients.js +++ b/lib/resources/Recipients.js @@ -1,46 +1,40 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'recipients', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', 'del', - 'setMetadata', 'getMetadata', - ], + + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], + + /** + * Recipient: Card methods + */ createCard: stripeMethod({ method: 'POST', - path: '/{recipientId}/cards', - urlParams: ['recipientId'], + path: '/{id}/cards', }), listCards: stripeMethod({ method: 'GET', - path: '/{recipientId}/cards', - urlParams: ['recipientId'], + path: '/{id}/cards', methodType: 'list', }), retrieveCard: stripeMethod({ method: 'GET', path: '/{recipientId}/cards/{cardId}', - urlParams: ['recipientId', 'cardId'], }), updateCard: stripeMethod({ method: 'POST', path: '/{recipientId}/cards/{cardId}', - urlParams: ['recipientId', 'cardId'], }), deleteCard: stripeMethod({ method: 'DELETE', path: '/{recipientId}/cards/{cardId}', - urlParams: ['recipientId', 'cardId'], }), - }); - diff --git a/lib/resources/Refunds.js b/lib/resources/Refunds.js index e4e70c1eb4..76373c92c0 100644 --- a/lib/resources/Refunds.js +++ b/lib/resources/Refunds.js @@ -1,13 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'refunds', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', - ], + includeBasic: ['create', 'list', 'retrieve', 'update'], }); - diff --git a/lib/resources/Reporting/ReportRuns.js b/lib/resources/Reporting/ReportRuns.js index 46d8a989d6..12c7c72598 100644 --- a/lib/resources/Reporting/ReportRuns.js +++ b/lib/resources/Reporting/ReportRuns.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'reporting/report_runs', + includeBasic: ['create', 'list', 'retrieve'], }); diff --git a/lib/resources/Reporting/ReportTypes.js b/lib/resources/Reporting/ReportTypes.js index 576c2aad4b..f516580244 100644 --- a/lib/resources/Reporting/ReportTypes.js +++ b/lib/resources/Reporting/ReportTypes.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'reporting/report_types', + includeBasic: ['list', 'retrieve'], }); diff --git a/lib/resources/Reviews.js b/lib/resources/Reviews.js index 9eeb7f413e..8bbd670cff 100644 --- a/lib/resources/Reviews.js +++ b/lib/resources/Reviews.js @@ -1,10 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reviews', includeBasic: ['list', 'retrieve'], @@ -12,7 +11,5 @@ module.exports = StripeResource.extend({ approve: stripeMethod({ method: 'POST', path: '/{id}/approve', - urlParams: ['id'], }), }); - diff --git a/lib/resources/SKUs.js b/lib/resources/SKUs.js index 0364ed4ed2..9fd01cf439 100644 --- a/lib/resources/SKUs.js +++ b/lib/resources/SKUs.js @@ -1,13 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: 'skus', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', 'del', - ], - + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], }); diff --git a/lib/resources/Sigma/ScheduledQueryRuns.js b/lib/resources/Sigma/ScheduledQueryRuns.js index bc80b40040..0714497062 100644 --- a/lib/resources/Sigma/ScheduledQueryRuns.js +++ b/lib/resources/Sigma/ScheduledQueryRuns.js @@ -1,6 +1,6 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'sigma/scheduled_query_runs', diff --git a/lib/resources/Sources.js b/lib/resources/Sources.js index 255896dd38..6afc7bbfe0 100644 --- a/lib/resources/Sources.js +++ b/lib/resources/Sources.js @@ -1,27 +1,21 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'sources', - includeBasic: [ - 'create', 'retrieve', 'update', 'setMetadata', 'getMetadata', - ], + includeBasic: ['create', 'retrieve', 'update'], listSourceTransactions: stripeMethod({ method: 'GET', path: '/{id}/source_transactions', - urlParams: ['id'], methodType: 'list', }), verify: stripeMethod({ method: 'POST', path: '/{id}/verify', - urlParams: ['id'], }), - }); diff --git a/lib/resources/SubscriptionItems.js b/lib/resources/SubscriptionItems.js index ea6e8e006e..13f2591634 100644 --- a/lib/resources/SubscriptionItems.js +++ b/lib/resources/SubscriptionItems.js @@ -1,9 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ path: 'subscription_items', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del',], -}); + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/SubscriptionScheduleRevisions.js b/lib/resources/SubscriptionScheduleRevisions.js deleted file mode 100644 index c230e37379..0000000000 --- a/lib/resources/SubscriptionScheduleRevisions.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * SubscriptionScheduleRevisions is a unique resource in that, upon instantiation, - * requires a subscription schedule id, and therefore each of its methods only - * require the scheduleId argument. - * - * This streamlines the API specifically for the case of accessing a revision - * on a returned subscription schedule object. - * - * E.g. scheduleObject.revisions.retrieve(revisionId) - * (As opposed to the also-supported stripe.subscriptionSchedules.retrieveRevision(scheduleId, - * revisionId)) - */ -module.exports = StripeResource.extend({ - path: 'subscription_schedules/{scheduleId}/revisions', - includeBasic: ['list', 'retrieve',], -}); diff --git a/lib/resources/SubscriptionSchedules.js b/lib/resources/SubscriptionSchedules.js index 0f838bdbb1..e803533c2c 100644 --- a/lib/resources/SubscriptionSchedules.js +++ b/lib/resources/SubscriptionSchedules.js @@ -1,43 +1,31 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscription_schedules', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', - 'setMetadata', 'getMetadata', - ], - - release: stripeMethod({ - method: 'POST', - path: '/{id}/release', - urlParams: ['id'], - }), + includeBasic: ['create', 'list', 'retrieve', 'update'], cancel: stripeMethod({ method: 'POST', path: '/{id}/cancel', - urlParams: ['id'], }), - /** - * SubscriptionSchedules: SubscriptionScheduleRevisions methods - */ + release: stripeMethod({ + method: 'POST', + path: '/{id}/release', + }), listRevisions: stripeMethod({ method: 'GET', path: '/{scheduleId}/revisions', - urlParams: ['scheduleId'], methodType: 'list', }), retrieveRevision: stripeMethod({ method: 'GET', path: '/{scheduleId}/revisions/{revisionId}', - urlParams: ['scheduleId', 'revisionId'], }), }); diff --git a/lib/resources/Subscriptions.js b/lib/resources/Subscriptions.js index a014c5d85a..3b404c2eb8 100644 --- a/lib/resources/Subscriptions.js +++ b/lib/resources/Subscriptions.js @@ -1,19 +1,15 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscriptions', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del',], - /** - * Subscription: Discount methods - */ + includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], + deleteDiscount: stripeMethod({ method: 'DELETE', - path: '/{subscriptionId}/discount', - urlParams: ['subscriptionId'], + path: '/{id}/discount', }), }); diff --git a/lib/resources/TaxIds.js b/lib/resources/TaxIds.js deleted file mode 100644 index bc8d860452..0000000000 --- a/lib/resources/TaxIds.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * TaxIds is a unique resource in that, upon instantiation, - * requires a customerId, and therefore each of its methods only - * require the taxId argument. - * - * This streamlines the API specifically for the case of accessing a tax id - * on a returned customer object. - * - * E.g. customerObject.tax_ids.retrieve(taxIdId) - * (As opposed to the also-supported stripe.customers.retrieveTaxId(customerId, taxIdId)) - */ -module.exports = StripeResource.extend({ - path: 'customers/{customerId}/tax_ids', - includeBasic: ['create', 'del', 'list', 'retrieve'], -}); diff --git a/lib/resources/TaxRates.js b/lib/resources/TaxRates.js index 7bea8e7f33..4c3ccf7055 100644 --- a/lib/resources/TaxRates.js +++ b/lib/resources/TaxRates.js @@ -1,7 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'tax_rates', - includeBasic: ['create', 'list', 'update', 'retrieve'], -}); + includeBasic: ['create', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/Terminal/ConnectionTokens.js b/lib/resources/Terminal/ConnectionTokens.js index a7c4d68f3b..e4587b9b76 100644 --- a/lib/resources/Terminal/ConnectionTokens.js +++ b/lib/resources/Terminal/ConnectionTokens.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'terminal/connection_tokens', + includeBasic: ['create'], -}) +}); diff --git a/lib/resources/Terminal/Locations.js b/lib/resources/Terminal/Locations.js index 0f2dccaf03..745774d9db 100644 --- a/lib/resources/Terminal/Locations.js +++ b/lib/resources/Terminal/Locations.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'terminal/locations', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], -}) + + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/Terminal/Readers.js b/lib/resources/Terminal/Readers.js index a4b2322a4e..7d213b7e5c 100644 --- a/lib/resources/Terminal/Readers.js +++ b/lib/resources/Terminal/Readers.js @@ -1,8 +1,9 @@ 'use strict'; -var StripeResource = require('../../StripeResource'); +const StripeResource = require('../../StripeResource'); module.exports = StripeResource.extend({ path: 'terminal/readers', - includeBasic: ['create', 'list', 'retrieve', 'update', 'del'], -}) + + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/resources/ThreeDSecure.js b/lib/resources/ThreeDSecure.js index 52a49e579b..96248d1ea9 100644 --- a/lib/resources/ThreeDSecure.js +++ b/lib/resources/ThreeDSecure.js @@ -1,13 +1,9 @@ 'use strict'; -var StripeResource = require('../StripeResource'); +const StripeResource = require('../StripeResource'); module.exports = StripeResource.extend({ - path: '3d_secure', - includeBasic: [ - 'create', - 'retrieve', - ], + includeBasic: ['create', 'retrieve'], }); diff --git a/lib/resources/Tokens.js b/lib/resources/Tokens.js index 120bf0e3c3..2d4f5ed983 100644 --- a/lib/resources/Tokens.js +++ b/lib/resources/Tokens.js @@ -1,6 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'tokens', + includeBasic: ['create', 'retrieve'], }); diff --git a/lib/resources/Topups.js b/lib/resources/Topups.js index 72875168ba..eecb88207d 100644 --- a/lib/resources/Topups.js +++ b/lib/resources/Topups.js @@ -1,15 +1,15 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'topups', - includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], + + includeBasic: ['create', 'list', 'retrieve', 'update'], cancel: stripeMethod({ method: 'POST', - path: '{topupId}/cancel', - urlParams: ['topupId'], + path: '/{id}/cancel', }), }); diff --git a/lib/resources/TransferReversals.js b/lib/resources/TransferReversals.js deleted file mode 100644 index a73081f12d..0000000000 --- a/lib/resources/TransferReversals.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var StripeResource = require('../StripeResource'); - -/** - * TransferReversals is a unique resource in that, upon instantiation, - * requires a transferId, and therefore each of its methods only - * require the reversalId argument. - * - * This streamlines the API specifically for the case of accessing reversals - * on a returned transfer object. - * - * E.g. transferObject.reversals.retrieve(reversalId) - * (As opposed to the also-supported stripe.transfers.retrieveReversal(transferId, - * reversalId)) - */ -module.exports = StripeResource.extend({ - path: 'transfers/{transferId}/reversals', - includeBasic: ['create', 'list', 'retrieve', 'update'], -}); - diff --git a/lib/resources/Transfers.js b/lib/resources/Transfers.js index f93a20f684..75f0007ac7 100644 --- a/lib/resources/Transfers.js +++ b/lib/resources/Transfers.js @@ -1,62 +1,34 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'transfers', - includeBasic: [ - 'create', 'list', 'retrieve', 'update', - 'setMetadata', 'getMetadata', - ], - - reverse: stripeMethod({ - method: 'POST', - path: '/{transferId}/reversals', - urlParams: ['transferId'], - }), - - cancel: stripeMethod({ - method: 'POST', - path: '{transferId}/cancel', - urlParams: ['transferId'], - }), - - listTransactions: stripeMethod({ - method: 'GET', - path: '{transferId}/transactions', - urlParams: ['transferId'], - methodType: 'list', - }), + includeBasic: ['create', 'list', 'retrieve', 'update'], /** * Transfer: Reversal methods */ createReversal: stripeMethod({ method: 'POST', - path: '/{transferId}/reversals', - urlParams: ['transferId'], + path: '/{id}/reversals', }), listReversals: stripeMethod({ method: 'GET', - path: '/{transferId}/reversals', - urlParams: ['transferId'], + path: '/{id}/reversals', methodType: 'list', }), retrieveReversal: stripeMethod({ method: 'GET', path: '/{transferId}/reversals/{reversalId}', - urlParams: ['transferId', 'reversalId'], }), updateReversal: stripeMethod({ method: 'POST', path: '/{transferId}/reversals/{reversalId}', - urlParams: ['transferId', 'reversalId'], }), }); - diff --git a/lib/resources/UsageRecordSummaries.js b/lib/resources/UsageRecordSummaries.js index f0f438f33e..db4722188a 100644 --- a/lib/resources/UsageRecordSummaries.js +++ b/lib/resources/UsageRecordSummaries.js @@ -1,7 +1,7 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'subscription_items', @@ -9,7 +9,6 @@ module.exports = StripeResource.extend({ list: stripeMethod({ method: 'GET', path: '{subscriptionItem}/usage_record_summaries', - urlParams: ['subscriptionItem'], methodType: 'list', }), }); diff --git a/lib/resources/UsageRecords.js b/lib/resources/UsageRecords.js index fb4eb1436a..ad8960b8b2 100644 --- a/lib/resources/UsageRecords.js +++ b/lib/resources/UsageRecords.js @@ -1,14 +1,13 @@ 'use strict'; -var StripeResource = require('../StripeResource'); -var stripeMethod = StripeResource.method; +const StripeResource = require('../StripeResource'); +const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ path: 'subscription_items', create: stripeMethod({ method: 'POST', - path: '{subscriptionItem}/usage_records', - urlParams: ['subscriptionItem'], + path: '/{id}/usage_records', }), }); diff --git a/lib/resources/WebhookEndpoints.js b/lib/resources/WebhookEndpoints.js index 149d4cd888..dab4a4b0b2 100644 --- a/lib/resources/WebhookEndpoints.js +++ b/lib/resources/WebhookEndpoints.js @@ -1,7 +1,9 @@ 'use strict'; -module.exports = require('../StripeResource').extend({ +const StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ path: 'webhook_endpoints', - includeBasic: ['create', 'list', 'update', 'retrieve', 'del'], -}); + includeBasic: ['create', 'del', 'list', 'retrieve', 'update'], +}); diff --git a/lib/stripe.js b/lib/stripe.js index 0e77ef520a..7a22138d8c 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -1,5 +1,7 @@ 'use strict'; +const resources = require('./resources'); + Stripe.DEFAULT_HOST = 'api.stripe.com'; Stripe.DEFAULT_PORT = '443'; Stripe.DEFAULT_BASE_PATH = '/v1/'; @@ -24,106 +26,10 @@ Stripe.USER_AGENT_SERIALIZED = null; Stripe.MAX_NETWORK_RETRY_DELAY_SEC = 2; Stripe.INITIAL_NETWORK_RETRY_DELAY_SEC = 0.5; -var APP_INFO_PROPERTIES = ['name', 'version', 'url', 'partner_id']; - -var EventEmitter = require('events').EventEmitter; -var utils = require('./utils'); - -var resourceNamespace = require('./ResourceNamespace'); - -var resources = { - // Support Accounts for consistency, Account for backwards compat - Account: require('./resources/Accounts'), - Accounts: require('./resources/Accounts'), - AccountLinks: require('./resources/AccountLinks'), - ApplePayDomains: require('./resources/ApplePayDomains'), - ApplicationFees: require('./resources/ApplicationFees'), - Balance: require('./resources/Balance'), - BalanceTransactions: require('./resources/BalanceTransactions'), - BitcoinReceivers: require('./resources/BitcoinReceivers'), - Charges: require('./resources/Charges'), - CountrySpecs: require('./resources/CountrySpecs'), - Coupons: require('./resources/Coupons'), - CreditNotes: require('./resources/CreditNotes'), - Customers: require('./resources/Customers'), - Disputes: require('./resources/Disputes'), - EphemeralKeys: require('./resources/EphemeralKeys'), - Events: require('./resources/Events'), - ExchangeRates: require('./resources/ExchangeRates'), - Files: require('./resources/Files'), - FileLinks: require('./resources/FileLinks'), - InvoiceItems: require('./resources/InvoiceItems'), - Invoices: require('./resources/Invoices'), - IssuerFraudRecords: require('./resources/IssuerFraudRecords'), - LoginLinks: require('./resources/LoginLinks'), - OAuth: require('./resources/OAuth'), - OrderReturns: require('./resources/OrderReturns'), - Orders: require('./resources/Orders'), - PaymentIntents: require('./resources/PaymentIntents'), - PaymentMethods: require('./resources/PaymentMethods'), - Payouts: require('./resources/Payouts'), - Plans: require('./resources/Plans'), - Products: require('./resources/Products'), - RecipientCards: require('./resources/RecipientCards'), - Recipients: require('./resources/Recipients'), - Refunds: require('./resources/Refunds'), - Reviews: require('./resources/Reviews'), - Skus: require('./resources/SKUs'), - Sources: require('./resources/Sources'), - SubscriptionItems: require('./resources/SubscriptionItems'), - SubscriptionSchedules: require('./resources/SubscriptionSchedules'), - Subscriptions: require('./resources/Subscriptions'), - TaxRates: require('./resources/TaxRates'), - ThreeDSecure: require('./resources/ThreeDSecure'), - Tokens: require('./resources/Tokens'), - Topups: require('./resources/Topups'), - Transfers: require('./resources/Transfers'), - UsageRecords: require('./resources/UsageRecords'), - UsageRecordSummaries: require('./resources/UsageRecordSummaries'), - WebhookEndpoints: require('./resources/WebhookEndpoints'), - - // The following rely on pre-filled IDs: - ApplicationFeeRefunds: require('./resources/ApplicationFeeRefunds'), - Capabilities: require('./resources/Capabilities'), - ChargeRefunds: require('./resources/ChargeRefunds'), - CustomerCards: require('./resources/CustomerCards'), - CustomerSubscriptions: require('./resources/CustomerSubscriptions'), - Persons: require('./resources/Persons'), - SubscriptionScheduleRevisions: require('./resources/SubscriptionScheduleRevisions'), - TaxIds: require('./resources/TaxIds'), - TransferReversals: require('./resources/TransferReversals'), - - // Namespaced resources - Checkout: resourceNamespace('checkout', { - Sessions: require('./resources/Checkout/Sessions'), - }), - Issuing: resourceNamespace('issuing', { - Authorizations: require('./resources/Issuing/Authorizations'), - Cardholders: require('./resources/Issuing/Cardholders'), - Cards: require('./resources/Issuing/Cards'), - Disputes: require('./resources/Issuing/Disputes'), - Transactions: require('./resources/Issuing/Transactions'), - }), - Radar: resourceNamespace('radar', { - ValueLists: require('./resources/Radar/ValueLists'), - ValueListItems: require('./resources/Radar/ValueListItems'), - }), - Reporting: resourceNamespace('reporting', { - ReportRuns: require('./resources/Reporting/ReportRuns'), - ReportTypes: require('./resources/Reporting/ReportTypes'), - }), - Sigma: resourceNamespace('sigma', { - ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'), - }), - Terminal: resourceNamespace('terminal', { - ConnectionTokens: require('./resources/Terminal/ConnectionTokens'), - Locations: require('./resources/Terminal/Locations'), - Readers: require('./resources/Terminal/Readers'), - }), -}; +const APP_INFO_PROPERTIES = ['name', 'version', 'url', 'partner_id']; -// For backwards compatibility, `Files` is aliased to `FileUploads` -resources.FileUploads = resources.Files; +const EventEmitter = require('events').EventEmitter; +const utils = require('./utils'); Stripe.StripeResource = require('./StripeResource'); Stripe.resources = resources; @@ -170,7 +76,7 @@ Stripe.errors = require('./Error'); Stripe.webhooks = require('./Webhooks'); Stripe.prototype = { - setHost: function(host, port, protocol) { + setHost(host, port, protocol) { this._setApiField('host', host); if (port) { this.setPort(port); @@ -180,37 +86,34 @@ Stripe.prototype = { } }, - setProtocol: function(protocol) { + setProtocol(protocol) { this._setApiField('protocol', protocol.toLowerCase()); }, - setPort: function(port) { + setPort(port) { this._setApiField('port', port); }, - setApiVersion: function(version) { + setApiVersion(version) { if (version) { this._setApiField('version', version); } }, - setApiKey: function(key) { + setApiKey(key) { if (key) { - this._setApiField( - 'auth', - 'Bearer ' + key - ); + this._setApiField('auth', `Bearer ${key}`); } }, - setTimeout: function(timeout) { + setTimeout(timeout) { this._setApiField( 'timeout', timeout == null ? Stripe.DEFAULT_TIMEOUT : timeout ); }, - setAppInfo: function(info) { + setAppInfo(info) { if (info && typeof info !== 'object') { throw new Error('AppInfo must be an object.'); } @@ -221,7 +124,7 @@ Stripe.prototype = { info = info || {}; - var appInfo = APP_INFO_PROPERTIES.reduce(function(accum, prop) { + const appInfo = APP_INFO_PROPERTIES.reduce((accum, prop) => { if (typeof info[prop] == 'string') { accum = accum || {}; @@ -237,70 +140,73 @@ Stripe.prototype = { this._appInfo = appInfo; }, - setHttpAgent: function(agent) { + setHttpAgent(agent) { this._setApiField('agent', agent); }, - _setApiField: function(key, value) { + _setApiField(key, value) { this._api[key] = value; }, - getApiField: function(key) { + getApiField(key) { return this._api[key]; }, - setClientId: function(clientId) { + setClientId(clientId) { this._clientId = clientId; }, - getClientId: function() { + getClientId() { return this._clientId; }, - getConstant: function(c) { + getConstant: (c) => { return Stripe[c]; }, - getMaxNetworkRetries: function() { + getMaxNetworkRetries() { return this.getApiField('maxNetworkRetries'); }, - setMaxNetworkRetries: function(maxNetworkRetries) { - if ((maxNetworkRetries && typeof maxNetworkRetries !== 'number') || arguments.length < 1) { + setMaxNetworkRetries(maxNetworkRetries) { + if ( + (maxNetworkRetries && typeof maxNetworkRetries !== 'number') || + arguments.length < 1 + ) { throw new Error('maxNetworkRetries must be a number.'); } this._setApiField('maxNetworkRetries', maxNetworkRetries); }, - getMaxNetworkRetryDelay: function() { + getMaxNetworkRetryDelay() { return this.getConstant('MAX_NETWORK_RETRY_DELAY_SEC'); }, - getInitialNetworkRetryDelay: function() { + getInitialNetworkRetryDelay() { return this.getConstant('INITIAL_NETWORK_RETRY_DELAY_SEC'); }, // Gets a JSON version of a User-Agent and uses a cached version for a slight // speed advantage. - getClientUserAgent: function(cb) { + getClientUserAgent(cb) { if (Stripe.USER_AGENT_SERIALIZED) { return cb(Stripe.USER_AGENT_SERIALIZED); } - this.getClientUserAgentSeeded(Stripe.USER_AGENT, function(cua) { + this.getClientUserAgentSeeded(Stripe.USER_AGENT, (cua) => { Stripe.USER_AGENT_SERIALIZED = cua; cb(Stripe.USER_AGENT_SERIALIZED); - }) + }); }, // Gets a JSON version of a User-Agent by encoding a seeded object and // fetching a uname from the system. - getClientUserAgentSeeded: function(seed, cb) { - var self = this; + getClientUserAgentSeeded(seed, cb) { + const self = this; - utils.safeExec('uname -a', function(err, uname) { - var userAgent = {}; - for (var field in seed) { + utils.safeExec('uname -a', (err, uname) => { + const userAgent = {}; + for (const field in seed) { userAgent[field] = encodeURIComponent(seed[field]); } @@ -311,38 +217,38 @@ Stripe.prototype = { userAgent.application = self._appInfo; } - cb(JSON.stringify(userAgent)) + cb(JSON.stringify(userAgent)); }); }, - getAppInfoAsString: function() { + getAppInfoAsString() { if (!this._appInfo) { return ''; } - var formatted = this._appInfo.name; + let formatted = this._appInfo.name; if (this._appInfo.version) { - formatted += '/' + this._appInfo.version; + formatted += `/${this._appInfo.version}`; } if (this._appInfo.url) { - formatted += ' (' + this._appInfo.url + ')'; + formatted += ` (${this._appInfo.url})`; } return formatted; }, - setTelemetryEnabled: function(enableTelemetry) { + setTelemetryEnabled(enableTelemetry) { this._enableTelemetry = enableTelemetry; }, - getTelemetryEnabled: function() { + getTelemetryEnabled() { return this._enableTelemetry; }, - _prepResources: function() { - for (var name in resources) { + _prepResources() { + for (const name in resources) { this[utils.pascalToCamelCase(name)] = new resources[name](this); } }, diff --git a/lib/utils.js b/lib/utils.js index d74ea0f432..d2aeb370e1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,38 +1,46 @@ 'use strict'; -var Buffer = require('safe-buffer').Buffer; -var EventEmitter = require('events').EventEmitter; -var exec = require('child_process').exec; -var qs = require('qs'); -var crypto = require('crypto'); - -var hasOwn = {}.hasOwnProperty; -var isPlainObject = require('lodash.isplainobject'); - -var OPTIONS_KEYS = ['api_key', 'idempotency_key', 'stripe_account', 'stripe_version']; - -var utils = module.exports = { - - isAuthKey: function(key) { +const Buffer = require('safe-buffer').Buffer; +const EventEmitter = require('events').EventEmitter; +const exec = require('child_process').exec; +const qs = require('qs'); +const crypto = require('crypto'); + +const hasOwn = {}.hasOwnProperty; +const isPlainObject = require('lodash.isplainobject'); + +const OPTIONS_KEYS = [ + 'api_key', + 'idempotency_key', + 'stripe_account', + 'stripe_version', +]; + +const utils = (module.exports = { + isAuthKey: (key) => { return typeof key == 'string' && /^(?:[a-z]{2}_)?[A-z0-9]{32}$/.test(key); }, - isOptionsHash: function(o) { - return isPlainObject(o) && OPTIONS_KEYS.some(function(key) { - return hasOwn.call(o, key); - }); + isOptionsHash: (o) => { + return isPlainObject(o) && OPTIONS_KEYS.some((key) => hasOwn.call(o, key)); }, /** * Stringifies an Object, accommodating nested objects * (forming the conventional key 'parent[child]=value') */ - stringifyRequestData: function(data) { - return qs.stringify(data, {serializeDate: function (d) { return Math.floor(d.getTime() / 1000); }}) - // Don't use strict form encoding by changing the square bracket control - // characters back to their literals. This is fine by the server, and - // makes these parameter strings easier to read. - .replace(/%5B/g, '[').replace(/%5D/g, ']'); + stringifyRequestData: (data) => { + return ( + qs + .stringify(data, { + serializeDate: (d) => Math.floor(d.getTime() / 1000), + }) + // Don't use strict form encoding by changing the square bracket control + // characters back to their literals. This is fine by the server, and + // makes these parameter strings easier to read. + .replace(/%5B/g, '[') + .replace(/%5D/g, ']') + ); }, /** @@ -41,27 +49,36 @@ var utils = module.exports = { * var fn = makeURLInterpolator('some/url/{param1}/{param2}'); * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' */ - makeURLInterpolator: (function() { - var rc = { - '\n': '\\n', '\"': '\\\"', - '\u2028': '\\u2028', '\u2029': '\\u2029', + makeURLInterpolator: (() => { + const rc = { + '\n': '\\n', + '"': '\\"', + '\u2028': '\\u2028', + '\u2029': '\\u2029', }; - return function makeURLInterpolator(str) { - var cleanString = str.replace(/["\n\r\u2028\u2029]/g, function($0) { - return rc[$0]; - }); - return function(outputs) { - return cleanString.replace(/\{([\s\S]+?)\}/g, function($0, $1) { - return encodeURIComponent(outputs[$1] || ''); - }); + return (str) => { + const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); + return (outputs) => { + return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => + encodeURIComponent(outputs[$1] || '') + ); }; }; - }()), + })(), + + extractUrlParams: (path) => { + const params = path.match(/\{\w+\}/g); + if (!params) { + return []; + } + + return params.map((param) => param.replace(/[{}]/g, '')); + }, /** * Return the data argument from a list of arguments */ - getDataFromArgs: function(args) { + getDataFromArgs: (args) => { if (args.length < 1 || !isPlainObject(args[0])) { return {}; } @@ -70,20 +87,24 @@ var utils = module.exports = { return args.shift(); } - var argKeys = Object.keys(args[0]); + const argKeys = Object.keys(args[0]); - var optionKeysInArgs = argKeys.filter(function(key) { - return OPTIONS_KEYS.indexOf(key) > -1; - }); + const optionKeysInArgs = argKeys.filter((key) => + OPTIONS_KEYS.includes(key) + ); // In some cases options may be the provided as the first argument. // Here we're detecting a case where there are two distinct arguments // (the first being args and the second options) and with known // option keys in the first so that we can warn the user about it. - if (optionKeysInArgs.length > 0 && optionKeysInArgs.length !== argKeys.length) { + if ( + optionKeysInArgs.length > 0 && + optionKeysInArgs.length !== argKeys.length + ) { emitWarning( - 'Options found in arguments (' + optionKeysInArgs.join(', ') + '). Did you mean to pass an options ' + - 'object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' + `Options found in arguments (${optionKeysInArgs.join( + ', ' + )}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.` ); } @@ -93,24 +114,26 @@ var utils = module.exports = { /** * Return the options hash from a list of arguments */ - getOptionsFromArgs: function(args) { - var opts = { + getOptionsFromArgs: (args) => { + const opts = { auth: null, headers: {}, }; if (args.length > 0) { - var arg = args[args.length - 1]; + const arg = args[args.length - 1]; if (utils.isAuthKey(arg)) { opts.auth = args.pop(); } else if (utils.isOptionsHash(arg)) { - var params = args.pop(); + const params = args.pop(); - var extraKeys = Object.keys(params).filter(function(key) { - return OPTIONS_KEYS.indexOf(key) == -1; - }); + const extraKeys = Object.keys(params).filter( + (key) => !OPTIONS_KEYS.includes(key) + ); if (extraKeys.length) { - emitWarning('Invalid options found (' + extraKeys.join(', ') + '); ignoring.'); + emitWarning( + `Invalid options found (${extraKeys.join(', ')}); ignoring.` + ); } if (params.api_key) { @@ -133,11 +156,13 @@ var utils = module.exports = { /** * Provide simple "Class" extension mechanism */ - protoExtend: function(sub) { - var Super = this; - var Constructor = hasOwn.call(sub, 'constructor') ? sub.constructor : function() { - Super.apply(this, arguments); - }; + protoExtend(sub) { + const Super = this; + const Constructor = hasOwn.call(sub, 'constructor') + ? sub.constructor + : function(...args) { + Super.apply(this, args); + }; // This initialization logic is somewhat sensitive to be compatible with // divergent JS implementations like the one found in Qt. See here for more @@ -152,9 +177,9 @@ var utils = module.exports = { }, /** - * Secure compare, from https://github.com/freewil/scmp - */ - secureCompare: function(a, b) { + * Secure compare, from https://github.com/freewil/scmp + */ + secureCompare: (a, b) => { a = Buffer.from(a); b = Buffer.from(b); @@ -170,24 +195,24 @@ var utils = module.exports = { return crypto.timingSafeEqual(a, b); } - var len = a.length; - var result = 0; + const len = a.length; + let result = 0; - for (var i = 0; i < len; ++i) { + for (let i = 0; i < len; ++i) { result |= a[i] ^ b[i]; } return result === 0; }, /** - * Remove empty values from an object - */ - removeEmpty: function(obj) { + * Remove empty values from an object + */ + removeEmpty: (obj) => { if (typeof obj !== 'object') { throw new Error('Argument must be an object'); } - Object.keys(obj).forEach(function(key) { + Object.keys(obj).forEach((key) => { if (obj[key] === null || obj[key] === undefined) { delete obj[key]; } @@ -197,24 +222,31 @@ var utils = module.exports = { }, /** - * Determine if file data is a derivative of EventEmitter class. - * https://nodejs.org/api/events.html#events_events - */ - checkForStream: function (obj) { + * Determine if file data is a derivative of EventEmitter class. + * https://nodejs.org/api/events.html#events_events + */ + checkForStream: (obj) => { if (obj.file && obj.file.data) { return obj.file.data instanceof EventEmitter; } return false; }, - callbackifyPromiseWithTimeout: function(promise, callback) { + callbackifyPromiseWithTimeout: (promise, callback) => { if (callback) { // Ensure callback is called outside of promise stack. - return promise.then(function(res) { - setTimeout(function() { callback(null, res) }, 0); - }, function(err) { - setTimeout(function() { callback(err, null); }, 0); - }); + return promise.then( + (res) => { + setTimeout(() => { + callback(null, res); + }, 0); + }, + (err) => { + setTimeout(() => { + callback(err, null); + }, 0); + } + ); } return promise; @@ -223,7 +255,7 @@ var utils = module.exports = { /** * Allow for special capitalization cases (such as OAuth) */ - pascalToCamelCase: function(name) { + pascalToCamelCase: (name) => { if (name === 'OAuth') { return 'oauth'; } else { @@ -231,7 +263,7 @@ var utils = module.exports = { } }, - emitWarning: emitWarning, + emitWarning, /** * Node's built in `exec` function sometimes throws outright, @@ -240,7 +272,7 @@ var utils = module.exports = { * * This unifies that interface. */ - safeExec: function safeExec(cmd, cb) { + safeExec: (cmd, cb) => { try { utils._exec(cmd, cb); } catch (e) { @@ -251,20 +283,20 @@ var utils = module.exports = { // For mocking in tests. _exec: exec, - isObject: function isObject(obj) { - var type = typeof obj; + isObject: (obj) => { + const type = typeof obj; return (type === 'function' || type === 'object') && !!obj; }, // For use in multipart requests - flattenAndStringify: function flattenAndStringify(data) { - var result = {}; + flattenAndStringify: (data) => { + const result = {}; - function step(obj, prevKey) { - Object.keys(obj).forEach(function (key) { - var value = obj[key]; + const step = (obj, prevKey) => { + Object.keys(obj).forEach((key) => { + const value = obj[key]; - var newKey = prevKey ? `${prevKey}[${key}]` : key; + const newKey = prevKey ? `${prevKey}[${key}]` : key; if (utils.isObject(value)) { if (!Buffer.isBuffer(value) && !value.hasOwnProperty('data')) { @@ -278,18 +310,20 @@ var utils = module.exports = { // Primitives are converted to strings result[newKey] = String(value); } - }) - } + }); + }; step(data); return result; }, -}; +}); function emitWarning(warning) { if (typeof process.emitWarning !== 'function') { - return console.warn('Stripe: ' + warning); /* eslint-disable-line no-console */ + return console.warn( + `Stripe: ${warning}` + ); /* eslint-disable-line no-console */ } return process.emitWarning(warning, 'Stripe'); diff --git a/package.json b/package.json index 50e1d8fd36..79285f5baa 100644 --- a/package.json +++ b/package.json @@ -22,18 +22,23 @@ }, "bugs:": "https://github.com/stripe/stripe-node/issues", "engines": { - "node": ">=4" + "node": "^6 || ^8.1 || >=10.*" }, "main": "lib/stripe.js", "devDependencies": { - "chai": "~4.1.2", + "babel-eslint": "^10.0.1", + "chai": "~4.2.0", "chai-as-promised": "~7.1.1", "coveralls": "^3.0.0", - "eslint": "^4.19.1", + "eslint": "^5.16.0", + "eslint-config-prettier": "^4.1.0", "eslint-plugin-chai-friendly": "^0.4.0", - "mocha": "~5.0.5", - "nock": "^9.0.0", - "nyc": "^11.3.0" + "eslint-plugin-flowtype": "^3.8.1", + "eslint-plugin-prettier": "^3.0.1", + "mocha": "~6.1.4", + "nock": "^10.0.6", + "nyc": "^14.1.0", + "prettier": "^1.16.4" }, "dependencies": { "lodash.isplainobject": "^4.0.6", @@ -45,8 +50,10 @@ "scripts": { "clean": "rm -rf ./.nyc_output ./node_modules/.cache ./coverage", "mocha": "nyc mocha", + "mocha-only": "mocha", "test": "npm run lint && npm run mocha", - "lint": "eslint .", + "lint": "eslint --ext .js,.jsx .", + "fix": "yarn lint --fix", "report": "nyc -r text -r lcov report", "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" } diff --git a/test/Error.spec.js b/test/Error.spec.js index ff8f649eff..91b7ad9bc6 100644 --- a/test/Error.spec.js +++ b/test/Error.spec.js @@ -2,40 +2,55 @@ require('../testUtils'); -var Error = require('../lib/Error'); -var expect = require('chai').expect; +const Error = require('../lib/Error'); +const expect = require('chai').expect; -describe('Error', function() { - it('Populates with type and message params', function() { - var e = new Error('FooError', 'Foo happened'); +describe('Error', () => { + it('Populates with type and message params', () => { + const e = new Error('FooError', 'Foo happened'); expect(e).to.have.property('type', 'FooError'); expect(e).to.have.property('message', 'Foo happened'); expect(e).to.have.property('stack'); }); - describe('StripeError', function() { - it('Generates specific instance depending on error-type', function() { - expect(Error.StripeError.generate({type: 'card_error'})).to.be.instanceOf(Error.StripeCardError); - expect(Error.StripeError.generate({type: 'invalid_request_error'})).to.be.instanceOf( - Error.StripeInvalidRequestError + describe('StripeError', () => { + it('Generates specific instance depending on error-type', () => { + expect(Error.StripeError.generate({type: 'card_error'})).to.be.instanceOf( + Error.StripeCardError ); - expect(Error.StripeError.generate({type: 'api_error'})).to.be.instanceOf(Error.StripeAPIError); - expect(Error.StripeError.generate({type: 'idempotency_error'})).to.be.instanceOf(Error.StripeIdempotencyError); + expect( + Error.StripeError.generate({type: 'invalid_request_error'}) + ).to.be.instanceOf(Error.StripeInvalidRequestError); + expect(Error.StripeError.generate({type: 'api_error'})).to.be.instanceOf( + Error.StripeAPIError + ); + expect( + Error.StripeError.generate({type: 'idempotency_error'}) + ).to.be.instanceOf(Error.StripeIdempotencyError); }); - it('Pulls in headers', function() { - var headers = {'Request-Id': '123'}; - var e = Error.StripeError.generate({type: 'card_error', headers: headers}); + it('Pulls in headers', () => { + const headers = {'Request-Id': '123'}; + const e = Error.StripeError.generate({ + type: 'card_error', + headers, + }); expect(e).to.have.property('headers', headers); }); - it('Pulls in request IDs', function() { - var e = Error.StripeError.generate({type: 'card_error', requestId: 'foo'}); + it('Pulls in request IDs', () => { + const e = Error.StripeError.generate({ + type: 'card_error', + requestId: 'foo', + }); expect(e).to.have.property('requestId', 'foo'); }); - it('Pulls in HTTP status code', function() { - var e = Error.StripeError.generate({type: 'card_error', statusCode: 400}); + it('Pulls in HTTP status code', () => { + const e = Error.StripeError.generate({ + type: 'card_error', + statusCode: 400, + }); expect(e).to.have.property('statusCode', 400); }); }); diff --git a/test/StripeResource.spec.js b/test/StripeResource.spec.js index 7b19d898a5..7fac0c5cb4 100644 --- a/test/StripeResource.spec.js +++ b/test/StripeResource.spec.js @@ -1,55 +1,60 @@ 'use strict'; -var utils = require('../testUtils'); -var uuid = require('uuid/v4'); +const utils = require('../testUtils'); +const uuid = require('uuid/v4'); -var nock = require('nock'); +const nock = require('nock'); -var stripe = require('../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('StripeResource', function() { - describe('createResourcePathWithSymbols', function() { - it('Generates a path', function() { +describe('StripeResource', () => { + describe('createResourcePathWithSymbols', () => { + it('Generates a path', () => { stripe.invoices.create({}); - var path = stripe.invoices.createResourcePathWithSymbols('{id}'); + const path = stripe.invoices.createResourcePathWithSymbols('{id}'); expect(path).to.equal('/invoices/{id}'); }); }); - describe('_defaultHeaders', function() { - it('sets the Authorization header with Bearer auth using the global API key', function() { - var headers = stripe.invoices._defaultHeaders(null, 0, null); + describe('_defaultHeaders', () => { + it('sets the Authorization header with Bearer auth using the global API key', () => { + const headers = stripe.invoices._defaultHeaders(null, 0, null); expect(headers.Authorization).to.equal('Bearer fakeAuthToken'); }); - it('sets the Authorization header with Bearer auth using the specified API key', function() { - var headers = stripe.invoices._defaultHeaders('anotherFakeAuthToken', 0, null); + it('sets the Authorization header with Bearer auth using the specified API key', () => { + const headers = stripe.invoices._defaultHeaders( + 'anotherFakeAuthToken', + 0, + null + ); expect(headers.Authorization).to.equal('Bearer anotherFakeAuthToken'); }); - it('sets the Stripe-Version header if an API version is provided', function() { - var headers = stripe.invoices._defaultHeaders(null, 0, '1970-01-01'); + it('sets the Stripe-Version header if an API version is provided', () => { + const headers = stripe.invoices._defaultHeaders(null, 0, '1970-01-01'); expect(headers['Stripe-Version']).to.equal('1970-01-01'); }); - it('does not the set the Stripe-Version header if no API version is provided', function() { - var headers = stripe.invoices._defaultHeaders(null, 0, null); + it('does not the set the Stripe-Version header if no API version is provided', () => { + const headers = stripe.invoices._defaultHeaders(null, 0, null); expect(headers).to.not.include.keys('Stripe-Version'); }); }); - describe('Parameter encoding', function() { + describe('Parameter encoding', () => { // Use a real instance of stripe as we're mocking the http.request responses. - var realStripe = require('../lib/stripe')(utils.getUserStripeKey()); + const realStripe = require('../lib/stripe')(utils.getUserStripeKey()); - after(function() { + after(() => { nock.cleanAll(); - }) + }); - describe('_request', function() { - it('encodes the query string in GET requests', function(done) { - var options = { + describe('_request', () => { + it('encodes the body in GET requests', (done) => { + const options = { host: stripe.getConstant('DEFAULT_HOST'), path: '/v1/invoices/upcoming', data: { + customer: 'cus_123', subscription_items: [ {plan: 'foo', quantity: 2}, {id: 'si_123', deleted: true}, @@ -57,88 +62,87 @@ describe('StripeResource', function() { }, }; - const scope = nock('https://' + options.host) - .get(options.path) - .query(Object.assign({customer: 'cus_123'}, options.data)) + const scope = nock(`https://${options.host}`) + .get(options.path, options.data) .reply(200, '{}'); - realStripe.invoices.retrieveUpcoming('cus_123', options.data, function(err, response) { + realStripe.invoices.retrieveUpcoming(options.data, (err, response) => { done(); scope.done(); }); }); - it('encodes the body in POST requests', function(done) { - var options = { + it('encodes the body in POST requests', (done) => { + const options = { host: stripe.getConstant('DEFAULT_HOST'), path: '/v1/subscriptions/sub_123', data: { customer: 'cus_123', - items: [ - {plan: 'foo', quantity: 2}, - {id: 'si_123', deleted: true}, - ], + items: [{plan: 'foo', quantity: 2}, {id: 'si_123', deleted: true}], }, - body: 'customer=cus_123&items[0][plan]=foo&items[0][quantity]=2&items[1][id]=si_123&items[1][deleted]=true', + body: + 'customer=cus_123&items[0][plan]=foo&items[0][quantity]=2&items[1][id]=si_123&items[1][deleted]=true', }; - const scope = nock('https://' + options.host) + const scope = nock(`https://${options.host}`) .post(options.path, options.body) .reply(200, '{}'); - realStripe.subscriptions.update('sub_123', options.data, function(err, response) { - done(); - scope.done(); - }); + realStripe.subscriptions.update( + 'sub_123', + options.data, + (err, response) => { + done(); + scope.done(); + } + ); }); }); }); - describe('Retry Network Requests', function() { + describe('Retry Network Requests', () => { // Use a real instance of stripe as we're mocking the http.request responses. - var realStripe = require('../lib/stripe')(utils.getUserStripeKey()); + const realStripe = require('../lib/stripe')(utils.getUserStripeKey()); // Override the sleep timer to speed up tests - realStripe.charges._getSleepTimeInMS = function() { - return 0; - }; + realStripe.charges._getSleepTimeInMS = () => 0; - var options = { + const options = { host: stripe.getConstant('DEFAULT_HOST'), path: '/v1/charges', data: { amount: 1000, currency: 'usd', source: 'tok_visa', - description: 'test' + description: 'test', }, - params: 'amount=1000¤cy=usd&source=tok_visa&description=test' + params: 'amount=1000¤cy=usd&source=tok_visa&description=test', }; - afterEach(function() { + afterEach(() => { realStripe.setMaxNetworkRetries(0); stripe.setMaxNetworkRetries(0); }); - after(function() { + after(() => { nock.cleanAll(); - }) + }); - describe('_request', function() { - it('throws an error on connection failure', function(done) { + describe('_request', () => { + it('throws an error on connection failure', (done) => { // Mock the connection error. - nock('https://' + options.host) + nock(`https://${options.host}`) .post(options.path, options.params) .replyWithError('bad stuff'); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { expect(err.detail.message).to.deep.equal('bad stuff'); done(); }); }); - it('should retry the request if max retries are set', function(done) { - nock('https://' + options.host) + it('should retry the request if max retries are set', (done) => { + nock(`https://${options.host}`) .post(options.path, options.params) .replyWithError('bad stuff') .post(options.path, options.params) @@ -146,16 +150,18 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err) { - var errorMessage = realStripe.invoices._generateConnectionErrorMessage(1); + realStripe.charges.create(options.data, (err) => { + const errorMessage = realStripe.invoices._generateConnectionErrorMessage( + 1 + ); expect(err.message).to.equal(errorMessage); expect(err.detail.message).to.deep.equal('worse stuff'); done(); }); }); - it('should stop retrying after a successful retry', function(done) { - nock('https://' + options.host) + it('should stop retrying after a successful retry', (done) => { + nock(`https://${options.host}`) .post(options.path, options.params) .replyWithError('bad stuff') .post(options.path, options.params) @@ -167,19 +173,19 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(2); - realStripe.charges.create(options.data, function(err, charge) { + realStripe.charges.create(options.data, (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should retry on a 409 error', function(done) { - nock('https://' + options.host) + it('should retry on a 409 error', (done) => { + nock(`https://${options.host}`) .post(options.path, options.params) .reply(409, { error: { - message: 'Conflict' - } + message: 'Conflict', + }, }) .post(options.path, options.params) .reply(200, { @@ -190,69 +196,70 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err, charge) { + realStripe.charges.create(options.data, (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should not retry on a 400 error', function(done) { - nock('https://' + options.host) + it('should not retry on a 400 error', (done) => { + nock(`https://${options.host}`) .post(options.path, options.params) .reply(400, { error: { - type: 'card_error' - } + type: 'card_error', + }, }); realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { expect(err.type).to.equal('StripeCardError'); done(); }); }); - it('should not retry on a 500 error when the method is POST', function(done) { - nock('https://' + options.host) + it('should not retry on a 500 error when the method is POST', (done) => { + nock(`https://${options.host}`) .post(options.path, options.params) .reply(500, { error: { - type: 'api_error' - } + type: 'api_error', + }, }); realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { expect(err.type).to.equal('StripeAPIError'); done(); }); }); - it('should handle OAuth errors gracefully', function (done) { + it('should handle OAuth errors gracefully', (done) => { nock('https://connect.stripe.com') .post('/oauth/token') .reply(400, { error: 'invalid_grant', - error_description: 'This authorization code has already been used. All tokens issued with this code have been revoked.' + error_description: + 'This authorization code has already been used. All tokens issued with this code have been revoked.', }); realStripe.setMaxNetworkRetries(1); - realStripe.oauth.token(options.data, function (err) { + realStripe.oauth.token(options.data, (err) => { expect(err.type).to.equal('StripeInvalidGrantError'); done(); }); }); - it('should retry on a 503 error when the method is POST', function(done) { - nock('https://' + options.host) + it('should retry on a 503 error when the method is POST', (done) => { + nock(`https://${options.host}`) .post(options.path, options.params) .reply(503, { error: { - message: 'Service unavailable' - } + message: 'Service unavailable', + }, }) .post(options.path, options.params) .reply(200, { @@ -263,21 +270,21 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err, charge) { + realStripe.charges.create(options.data, (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should retry on a 500 error when the method is GET', function(done) { - nock('https://' + options.host) - .get(options.path + '/ch_123') + it('should retry on a 500 error when the method is GET', (done) => { + nock(`https://${options.host}`) + .get(`${options.path}/ch_123`) .reply(500, { error: { - type: 'api_error' - } + type: 'api_error', + }, }) - .get(options.path + '/ch_123') + .get(`${options.path}/ch_123`) .reply(200, { id: 'ch_123', object: 'charge', @@ -286,144 +293,168 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.retrieve('ch_123', function(err, charge) { + realStripe.charges.retrieve('ch_123', (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should add an idempotency key for retries using the POST method', function(done) { - var headers; + it('should add an idempotency key for retries using the POST method', (done) => { + let headers; // Fail the first request but succeed on the 2nd. - nock('https://' + options.host) + nock(`https://${options.host}`) .post(options.path, options.params) .replyWithError('bad stuff') .post(options.path, options.params) .reply(function(uri, requestBody, cb) { headers = this.req.headers; - return cb(null, [200, { - id: 'ch_123"', - object: 'charge', - amount: 1000, - }]); + return cb(null, [ + 200, + { + id: 'ch_123"', + object: 'charge', + amount: 1000, + }, + ]); }); realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function() { + realStripe.charges.create(options.data, () => { expect(headers).to.have.property('idempotency-key'); done(); }); }); - it('should not add idempotency key for retries using the GET method', function(done) { - var headers; + it('should not add idempotency key for retries using the GET method', (done) => { + let headers; - nock('https://' + options.host) - .get(options.path + '/ch_123') + nock(`https://${options.host}`) + .get(`${options.path}/ch_123`) .replyWithError('bad stuff') - .get(options.path + '/ch_123') + .get(`${options.path}/ch_123`) .reply(function(uri, requestBody, cb) { headers = this.req.headers; - return cb(null, [200, { - id: 'ch_123"', - object: 'charge', - amount: 1000, - }]); + return cb(null, [ + 200, + { + id: 'ch_123"', + object: 'charge', + amount: 1000, + }, + ]); }); realStripe.setMaxNetworkRetries(1); - realStripe.charges.retrieve('ch_123', function() { + realStripe.charges.retrieve('ch_123', () => { expect(headers).to.not.have.property('idempotency-key'); done(); }); }); - it('should reuse the given idempotency key provided for retries', function(done) { - var key = uuid(); - var headers; + it('should reuse the given idempotency key provided for retries', (done) => { + const key = uuid(); + let headers; - nock('https://' + options.host) + nock(`https://${options.host}`) .post(options.path, options.params) .replyWithError('bad stuff') .post(options.path, options.params) .reply(function(uri, requestBody, cb) { headers = this.req.headers; - return cb(null, [200, { - id: 'ch_123"', - object: 'charge', - amount: 1000, - }]); + return cb(null, [ + 200, + { + id: 'ch_123"', + object: 'charge', + amount: 1000, + }, + ]); }); realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, {idempotency_key: key}, function() { + realStripe.charges.create(options.data, {idempotency_key: key}, () => { expect(headers['idempotency-key']).to.equal(key); done(); }); }); }); - describe('_shouldRetry', function() { - it('should return false if we\'ve reached maximum retries', function() { + describe('_shouldRetry', () => { + it("should return false if we've reached maximum retries", () => { stripe.setMaxNetworkRetries(1); - var res = stripe.invoices._shouldRetry({ - statusCode: 409 - }, 1); + const res = stripe.invoices._shouldRetry( + { + statusCode: 409, + }, + 1 + ); expect(res).to.equal(false); }); - it('should return true if we have more retries available', function() { + it('should return true if we have more retries available', () => { stripe.setMaxNetworkRetries(1); - var res = stripe.invoices._shouldRetry({ - statusCode: 409 - }, 0); + const res = stripe.invoices._shouldRetry( + { + statusCode: 409, + }, + 0 + ); expect(res).to.equal(true); }); - it('should return true if the error code is either 409 or 503', function() { + it('should return true if the error code is either 409 or 503', () => { stripe.setMaxNetworkRetries(1); - var res = stripe.invoices._shouldRetry({ - statusCode: 409 - }, 0); + let res = stripe.invoices._shouldRetry( + { + statusCode: 409, + }, + 0 + ); expect(res).to.equal(true); - res = stripe.invoices._shouldRetry({ - statusCode: 503 - }, 0); + res = stripe.invoices._shouldRetry( + { + statusCode: 503, + }, + 0 + ); expect(res).to.equal(true); }); - it('should return false if the status is 200', function() { + it('should return false if the status is 200', () => { stripe.setMaxNetworkRetries(2); // mocking that we're on our 2nd request - var res = stripe.invoices._shouldRetry({ - statusCode: 200, - req: {_requestEvent: {method: 'POST'}} - }, 1); + const res = stripe.invoices._shouldRetry( + { + statusCode: 200, + req: {_requestEvent: {method: 'POST'}}, + }, + 1 + ); expect(res).to.equal(false); }); }); - describe('_getSleepTimeInMS', function() { - it('should not exceed the maximum or minimum values', function() { - var sleepSeconds; - var max = stripe.getMaxNetworkRetryDelay(); - var min = stripe.getInitialNetworkRetryDelay(); + describe('_getSleepTimeInMS', () => { + it('should not exceed the maximum or minimum values', () => { + let sleepSeconds; + const max = stripe.getMaxNetworkRetryDelay(); + const min = stripe.getInitialNetworkRetryDelay(); - for (var i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { sleepSeconds = stripe.invoices._getSleepTimeInMS(i) / 1000; expect(sleepSeconds).to.be.at.most(max); diff --git a/test/Webhook.spec.js b/test/Webhook.spec.js index ab957f1489..f1f1c089c0 100644 --- a/test/Webhook.spec.js +++ b/test/Webhook.spec.js @@ -1,26 +1,26 @@ 'use strict'; -var stripe = require('../testUtils').getSpyableStripe(); -var expect = require('chai').expect; -var Buffer = require('safe-buffer').Buffer; +const stripe = require('../testUtils').getSpyableStripe(); +const expect = require('chai').expect; +const Buffer = require('safe-buffer').Buffer; -var EVENT_PAYLOAD = { +const EVENT_PAYLOAD = { id: 'evt_test_webhook', object: 'event', }; -var EVENT_PAYLOAD_STRING = JSON.stringify(EVENT_PAYLOAD, null, 2); -var SECRET = 'whsec_test_secret'; - -describe('Webhooks', function() { - describe('.generateTestHeaderString', function() { - it('should throw when no opts are passed', function() { - expect(function() { - stripe.webhooks.generateTestHeaderString() +const EVENT_PAYLOAD_STRING = JSON.stringify(EVENT_PAYLOAD, null, 2); +const SECRET = 'whsec_test_secret'; + +describe('Webhooks', () => { + describe('.generateTestHeaderString', () => { + it('should throw when no opts are passed', () => { + expect(() => { + stripe.webhooks.generateTestHeaderString(); }).to.throw(); }); - it('should correctly construct a webhook header', function() { - var header = stripe.webhooks.generateTestHeaderString({ + it('should correctly construct a webhook header', () => { + const header = stripe.webhooks.generateTestHeaderString({ payload: EVENT_PAYLOAD_STRING, secret: SECRET, }); @@ -30,142 +30,217 @@ describe('Webhooks', function() { }); }); - describe('.constructEvent', function() { - it('should return an Event instance from a valid JSON payload and valid signature header', function() { - var header = stripe.webhooks.generateTestHeaderString({ + describe('.constructEvent', () => { + it('should return an Event instance from a valid JSON payload and valid signature header', () => { + const header = stripe.webhooks.generateTestHeaderString({ payload: EVENT_PAYLOAD_STRING, secret: SECRET, }); - var event = stripe.webhooks.constructEvent(EVENT_PAYLOAD_STRING, header, SECRET); + const event = stripe.webhooks.constructEvent( + EVENT_PAYLOAD_STRING, + header, + SECRET + ); expect(event.id).to.equal(EVENT_PAYLOAD.id); }); - it('should raise a JSON error from invalid JSON payload', - function() { - var header = stripe.webhooks.generateTestHeaderString({ - payload: '} I am not valid JSON; 123][', - secret: SECRET, - }); - expect(function() { - stripe.webhooks.constructEvent('} I am not valid JSON; 123][', header, SECRET); - }).to.throw(/Unexpected token/); + it('should raise a JSON error from invalid JSON payload', () => { + const header = stripe.webhooks.generateTestHeaderString({ + payload: '} I am not valid JSON; 123][', + secret: SECRET, }); + expect(() => { + stripe.webhooks.constructEvent( + '} I am not valid JSON; 123][', + header, + SECRET + ); + }).to.throw(/Unexpected token/); + expect(() => { + stripe.webhooks.constructEvent( + '} I am not valid JSON; 123][', + header, + SECRET + ); + }).to.throw(/Unexpected token/); + }); - it('should raise a SignatureVerificationError from a valid JSON payload and an invalid signature header', - function() { - var header = 'bad_header'; + it('should raise a SignatureVerificationError from a valid JSON payload and an invalid signature header', () => { + const header = 'bad_header'; - expect(function() { - stripe.webhooks.constructEvent(EVENT_PAYLOAD_STRING, header, SECRET); - }).to.throw(/Unable to extract timestamp and signatures from header/); - }); + expect(() => { + stripe.webhooks.constructEvent(EVENT_PAYLOAD_STRING, header, SECRET); + }).to.throw(/Unable to extract timestamp and signatures from header/); + }); }); - describe('.verifySignatureHeader', function() { - it('should raise a SignatureVerificationError when the header does not have the expected format', function() { - var header = "I'm not even a real signature header"; + describe('.verifySignatureHeader', () => { + it('should raise a SignatureVerificationError when the header does not have the expected format', () => { + const header = "I'm not even a real signature header"; - var expectedMessage = /Unable to extract timestamp and signatures from header/; + const expectedMessage = /Unable to extract timestamp and signatures from header/; - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET + ); }).to.throw(expectedMessage); - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, null, SECRET); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + null, + SECRET + ); }).to.throw(expectedMessage); - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, undefined, SECRET); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + undefined, + SECRET + ); }).to.throw(expectedMessage); - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, '', SECRET); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + '', + SECRET + ); }).to.throw(expectedMessage); }); - it('should raise a SignatureVerificationError when there are no signatures with the expected scheme', function() { - var header = stripe.webhooks.generateTestHeaderString({ + it('should raise a SignatureVerificationError when there are no signatures with the expected scheme', () => { + const header = stripe.webhooks.generateTestHeaderString({ payload: EVENT_PAYLOAD_STRING, secret: SECRET, scheme: 'v0', }); - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET + ); }).to.throw(/No signatures found with expected scheme/); }); - it('should raise a SignatureVerificationError when there are no valid signatures for the payload', function() { - var header = stripe.webhooks.generateTestHeaderString({ + it('should raise a SignatureVerificationError when there are no valid signatures for the payload', () => { + const header = stripe.webhooks.generateTestHeaderString({ payload: EVENT_PAYLOAD_STRING, secret: SECRET, signature: 'bad_signature', }); - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET); - }).to.throw(/No signatures found matching the expected signature for payload/); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET + ); + }).to.throw( + /No signatures found matching the expected signature for payload/ + ); }); - it('should raise a SignatureVerificationError when the timestamp is not within the tolerance', function() { - var header = stripe.webhooks.generateTestHeaderString({ - timestamp: (Date.now() / 1000) - 15, + it('should raise a SignatureVerificationError when the timestamp is not within the tolerance', () => { + const header = stripe.webhooks.generateTestHeaderString({ + timestamp: Date.now() / 1000 - 15, payload: EVENT_PAYLOAD_STRING, secret: SECRET, }); - expect(function() { - stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET, 10); + expect(() => { + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET, + 10 + ); }).to.throw(/Timestamp outside the tolerance zone/); }); - it('should return true when the header contains a valid signature and ' + - 'the timestamp is within the tolerance', - function() { - var header = stripe.webhooks.generateTestHeaderString({ - timestamp: (Date.now() / 1000), - payload: EVENT_PAYLOAD_STRING, - secret: SECRET, - }); - - expect(stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET, 10)).to.equal(true); - }); + it( + 'should return true when the header contains a valid signature and ' + + 'the timestamp is within the tolerance', + () => { + const header = stripe.webhooks.generateTestHeaderString({ + timestamp: Date.now() / 1000, + payload: EVENT_PAYLOAD_STRING, + secret: SECRET, + }); - it('should return true when the header contains at least one valid signature', function() { - var header = stripe.webhooks.generateTestHeaderString({ - timestamp: (Date.now() / 1000), + expect( + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET, + 10 + ) + ).to.equal(true); + } + ); + + it('should return true when the header contains at least one valid signature', () => { + let header = stripe.webhooks.generateTestHeaderString({ + timestamp: Date.now() / 1000, payload: EVENT_PAYLOAD_STRING, secret: SECRET, }); header += ',v1=potato'; - expect(stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET, 10)).to.equal(true); + expect( + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET, + 10 + ) + ).to.equal(true); }); - it('should return true when the header contains a valid signature ' + - 'and the timestamp is off but no tolerance is provided', - function() { - var header = stripe.webhooks.generateTestHeaderString({ - timestamp: 12345, - payload: EVENT_PAYLOAD_STRING, - secret: SECRET, - }); - - expect(stripe.webhooks.signature.verifyHeader(EVENT_PAYLOAD_STRING, header, SECRET)).to.equal(true); - }); + it( + 'should return true when the header contains a valid signature ' + + 'and the timestamp is off but no tolerance is provided', + () => { + const header = stripe.webhooks.generateTestHeaderString({ + timestamp: 12345, + payload: EVENT_PAYLOAD_STRING, + secret: SECRET, + }); - it('should accept Buffer instances for the payload and header', function() { - var header = stripe.webhooks.generateTestHeaderString({ - timestamp: (Date.now() / 1000), + expect( + stripe.webhooks.signature.verifyHeader( + EVENT_PAYLOAD_STRING, + header, + SECRET + ) + ).to.equal(true); + } + ); + + it('should accept Buffer instances for the payload and header', () => { + const header = stripe.webhooks.generateTestHeaderString({ + timestamp: Date.now() / 1000, payload: EVENT_PAYLOAD_STRING, secret: SECRET, }); - expect(stripe.webhooks.signature.verifyHeader(Buffer.from(EVENT_PAYLOAD_STRING), Buffer.from(header), SECRET, 10)).to.equal(true); + expect( + stripe.webhooks.signature.verifyHeader( + Buffer.from(EVENT_PAYLOAD_STRING), + Buffer.from(header), + SECRET, + 10 + ) + ).to.equal(true); }); }); }); diff --git a/test/autoPagination.spec.js b/test/autoPagination.spec.js index 6674462d78..3cc3d9e35c 100644 --- a/test/autoPagination.spec.js +++ b/test/autoPagination.spec.js @@ -2,421 +2,485 @@ /* eslint-disable callback-return */ -var testUtils = require('../testUtils'); -var stripe = require('../lib/stripe')( - testUtils.getUserStripeKey(), - 'latest' -); +const testUtils = require('../testUtils'); +const stripe = require('../lib/stripe')(testUtils.getUserStripeKey(), 'latest'); -var expect = require('chai').expect; +const expect = require('chai').expect; -var LIMIT = 7; -var TOTAL_OBJECTS = 8; +const LIMIT = 7; +const TOTAL_OBJECTS = 8; describe('auto pagination', function() { this.timeout(20000); - var email = 'test.' + Date.now() + '@example.com'; - var realCustomerIds; - before(function() { - return new Promise(function(resolve) { - var createReqs = []; - for (var i = 0; i < TOTAL_OBJECTS; i++) { - createReqs.push(stripe.customers.create({email: email})); - } - return Promise.all(createReqs).then(function() { - // re-fetch to ensure correct order - return stripe.customers.list({email: email}).then(function(customers) { - realCustomerIds = customers.data.map(function(customer) {return customer.id}); - }) - }).then(resolve); - }); - }); - - after(function() { - return new Promise(function(resolve) { - Promise.all(realCustomerIds.map(function(customerId) { - return stripe.customers.del(customerId); - })).then(resolve); - }); - }); + const email = `test.${Date.now()}@example.com`; + let realCustomerIds; + before( + () => + new Promise((resolve) => { + const createReqs = []; + for (let i = 0; i < TOTAL_OBJECTS; i++) { + createReqs.push(stripe.customers.create({email})); + } + return Promise.all(createReqs) + .then(() => + // re-fetch to ensure correct order + stripe.customers.list({email}).then((customers) => { + realCustomerIds = customers.data.map((customer) => customer.id); + }) + ) + .then(resolve); + }) + ); + + after( + () => + new Promise((resolve) => { + Promise.all( + realCustomerIds.map((customerId) => stripe.customers.del(customerId)) + ).then(resolve); + }) + ); + + describe('callbacks', () => { + it('lets you call `next()` to iterate and `next(false)` to break', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + function onCustomer(customer, next) { + customerIds.push(customer.id); + if (customerIds.length === LIMIT) { + next(false); + } else { + expect(customerIds.length).to.be.lessThan(LIMIT); + next(); + } + } + function onDone(err) { + if (err) { + reject(err); + } else { + resolve(customerIds); + } + } - describe('callbacks', function() { - it('lets you call `next()` to iterate and `next(false)` to break', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - function onCustomer(customer, next) { - customerIds.push(customer.id); - if (customerIds.length === LIMIT) { - next(false); - } else { - expect(customerIds.length).to.be.lessThan(LIMIT); - next(); + stripe.customers + .list({limit: 3, email}) + .autoPagingEach(onCustomer, onDone); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + + it('lets you ignore the second arg and `return false` to break', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + function onCustomer(customer) { + customerIds.push(customer.id); + if (customerIds.length === LIMIT) { + return false; + } else { + expect(customerIds.length).to.be.lessThan(LIMIT); + } } - } - function onDone(err) { - if (err) { - reject(err); - } else { - resolve(customerIds); + function onDone(err) { + if (err) { + reject(err); + } else { + resolve(customerIds); + } } - } - stripe.customers.list({limit: 3, email: email}) - .autoPagingEach(onCustomer, onDone); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('lets you ignore the second arg and `return false` to break', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - function onCustomer(customer) { - customerIds.push(customer.id); - if (customerIds.length === LIMIT) { - return false; - } else { - expect(customerIds.length).to.be.lessThan(LIMIT); + stripe.customers + .list({limit: 3, email}) + .autoPagingEach(onCustomer, onDone); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + + it('lets you ignore the second arg and return a Promise which returns `false` to break', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + function onCustomer(customer) { + customerIds.push(customer.id); + if (customerIds.length === LIMIT) { + return Promise.resolve(false); + } else { + expect(customerIds.length).to.be.lessThan(LIMIT); + return Promise.resolve(); + } } - } - function onDone(err) { - if (err) { - reject(err); - } else { - resolve(customerIds); + function onDone(err) { + if (err) { + reject(err); + } else { + resolve(customerIds); + } } - } - stripe.customers.list({limit: 3, email: email}) - .autoPagingEach(onCustomer, onDone); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('lets you ignore the second arg and return a Promise which returns `false` to break', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - function onCustomer(customer) { - customerIds.push(customer.id); - if (customerIds.length === LIMIT) { - return Promise.resolve(false); - } else { - expect(customerIds.length).to.be.lessThan(LIMIT); - return Promise.resolve(); + stripe.customers + .list({limit: 3, email}) + .autoPagingEach(onCustomer, onDone); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + + it('can use a promise instead of a callback for onDone', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + function onCustomer(customer) { + customerIds.push(customer.id); } - } - function onDone(err) { - if (err) { - reject(err); - } else { + function onDone() { resolve(customerIds); } - } - - stripe.customers.list({limit: 3, email: email}) - .autoPagingEach(onCustomer, onDone); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('can use a promise instead of a callback for onDone', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - function onCustomer(customer) { - customerIds.push(customer.id); - } - function onDone() { - resolve(customerIds); - } - stripe.customers.list({limit: 3, email: email}) - .autoPagingEach(onCustomer) - .then(onDone) - .catch(reject); - })).to.eventually.deep.equal(realCustomerIds); - }); - - it('handles the end of a list properly when the last page is full', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - return stripe.customers.list({email: email, limit: TOTAL_OBJECTS / 2}) - .autoPagingEach(function(customer) { customerIds.push(customer.id); }) - .catch(reject) - .then(function() { - resolve(customerIds); - }); - })).to.eventually.deep.equal(realCustomerIds); - }); - - it('handles the end of a list properly when the last page is not full', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - return stripe.customers.list({email: email, limit: TOTAL_OBJECTS - 2}) - .autoPagingEach(function(customer) { customerIds.push(customer.id); }) - .catch(reject) - .then(function() { - resolve(customerIds); - }); - })).to.eventually.deep.equal(realCustomerIds); - }); - - it('handles a list which is shorter than the page size properly', function() { - return expect(new Promise(function(resolve, reject) { - var customerIds = []; - return stripe.customers.list({email: email, limit: TOTAL_OBJECTS + 2}) - .autoPagingEach(function(customer) { customerIds.push(customer.id); }) - .catch(reject) - .then(function() { - resolve(customerIds); - }); - })).to.eventually.deep.equal(realCustomerIds); - }); - - it('handles errors after the first page correctly (callback)', function() { - return expect(new Promise(function(resolve, reject) { - var i = 0; - function onCustomer() { - i += 1; - if (i > 4) { - throw Error('Simulated error'); + stripe.customers + .list({limit: 3, email}) + .autoPagingEach(onCustomer) + .then(onDone) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds)); + + it('handles the end of a list properly when the last page is full', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + return stripe.customers + .list({email, limit: TOTAL_OBJECTS / 2}) + .autoPagingEach((customer) => { + customerIds.push(customer.id); + }) + .catch(reject) + .then(() => { + resolve(customerIds); + }); + }) + ).to.eventually.deep.equal(realCustomerIds)); + + it('handles the end of a list properly when the last page is not full', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + return stripe.customers + .list({email, limit: TOTAL_OBJECTS - 2}) + .autoPagingEach((customer) => { + customerIds.push(customer.id); + }) + .catch(reject) + .then(() => { + resolve(customerIds); + }); + }) + ).to.eventually.deep.equal(realCustomerIds)); + + it('handles a list which is shorter than the page size properly', () => + expect( + new Promise((resolve, reject) => { + const customerIds = []; + return stripe.customers + .list({email, limit: TOTAL_OBJECTS + 2}) + .autoPagingEach((customer) => { + customerIds.push(customer.id); + }) + .catch(reject) + .then(() => { + resolve(customerIds); + }); + }) + ).to.eventually.deep.equal(realCustomerIds)); + + it('handles errors after the first page correctly (callback)', () => + expect( + new Promise((resolve, reject) => { + let i = 0; + function onCustomer() { + i += 1; + if (i > 4) { + throw Error('Simulated error'); + } } - } - return stripe.customers.list({email: email, limit: 3}) - .autoPagingEach(onCustomer, function(err) { - if (err) { - resolve(err.message); - } else { - reject(Error('Expected an error, did not get one.')); + return stripe.customers + .list({email, limit: 3}) + .autoPagingEach(onCustomer, (err) => { + if (err) { + resolve(err.message); + } else { + reject(Error('Expected an error, did not get one.')); + } + }); + }) + ).to.eventually.deep.equal('Simulated error')); + + it('handles errors after the first page correctly (promise)', () => + expect( + new Promise((resolve, reject) => { + let i = 0; + function onCustomer() { + i += 1; + if (i > 4) { + throw Error('Simulated error'); } - }); - })).to.eventually.deep.equal('Simulated error'); - }); - - it('handles errors after the first page correctly (promise)', function() { - return expect(new Promise(function(resolve, reject) { - var i = 0; - function onCustomer() { - i += 1; - if (i > 4) { - throw Error('Simulated error'); } - } - return stripe.customers.list({email: email, limit: 3}) - .autoPagingEach(onCustomer) - .then(function() { - reject(Error('Expected an error, did not get one.')); - }) - .catch(function(err) { - resolve(err.message); - }); - })).to.eventually.deep.equal('Simulated error'); - }); + return stripe.customers + .list({email, limit: 3}) + .autoPagingEach(onCustomer) + .then(() => { + reject(Error('Expected an error, did not get one.')); + }) + .catch((err) => { + resolve(err.message); + }); + }) + ).to.eventually.deep.equal('Simulated error')); }); - describe('async iterators', function() { - + describe('async iterators', () => { if (testUtils.envSupportsForAwait()) { // `for await` throws a syntax error everywhere but node 10, // so we must conditionally require it. - var forAwaitUntil = require('../testUtils/forAwait.node10').forAwaitUntil; - - it('works with `for await` when that feature exists (user break)', function() { - return expect(new Promise(function(resolve, reject) { - forAwaitUntil(stripe.customers.list({limit: 3, email: email}), LIMIT) - .then(function(customers) { - resolve(customers.map(function(customer) { return customer.id; })); - }) - .catch(reject) - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('works with `for await` when that feature exists (end of list)', function() { - return expect(new Promise(function(resolve, reject) { - forAwaitUntil(stripe.customers.list({limit: 3, email: email}), TOTAL_OBJECTS + 1) - .then(function(customers) { - resolve(customers.map(function(customer) { return customer.id; })); - }) - .catch(reject); - })).to.eventually.deep.equal(realCustomerIds); - }); + const forAwaitUntil = require('../testUtils/forAwait.node10') + .forAwaitUntil; + + it('works with `for await` when that feature exists (user break)', () => + expect( + new Promise((resolve, reject) => { + forAwaitUntil(stripe.customers.list({limit: 3, email}), LIMIT) + .then((customers) => { + resolve(customers.map((customer) => customer.id)); + }) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + + it('works with `for await` when that feature exists (end of list)', () => + expect( + new Promise((resolve, reject) => { + forAwaitUntil( + stripe.customers.list({limit: 3, email}), + TOTAL_OBJECTS + 1 + ) + .then((customers) => { + resolve(customers.map((customer) => customer.id)); + }) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds)); } if (testUtils.envSupportsAwait()) { // Similarly, `await` throws a syntax error below Node 7.6. - var awaitUntil = require('../testUtils/await.node7').awaitUntil; + const awaitUntil = require('../testUtils/await.node7').awaitUntil; + + it('works with `await` and a while loop when await exists', () => + expect( + new Promise((resolve, reject) => { + awaitUntil(stripe.customers.list({limit: 3, email}), LIMIT) + .then((customers) => { + resolve(customers.map((customer) => customer.id)); + }) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + } + + it('returns an empty object from .return() so that `break;` works in for-await', () => + expect( + new Promise((resolve, reject) => { + const iter = stripe.customers.list({limit: 3, email}); + + const customerIds = []; + function handleIter(result) { + customerIds.push(result.value.id); + expect(iter.return()).to.deep.equal({}); + } - it('works with `await` and a while loop when await exists', function() { - return expect(new Promise(function(resolve, reject) { - awaitUntil(stripe.customers.list({limit: 3, email: email}), LIMIT) - .then(function(customers) { - resolve(customers.map(function(customer) { return customer.id; })); + iter + .next() + .then(handleIter) + .then(() => { + resolve(customerIds); }) .catch(reject); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - } - - it('returns an empty object from .return() so that `break;` works in for-await', function() { - return expect(new Promise(function(resolve, reject) { - var iter = stripe.customers.list({limit: 3, email: email}); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, 1))); + + it('works when you call it sequentially', () => + expect( + new Promise((resolve, reject) => { + const iter = stripe.customers.list({limit: 3, email}); + + const customerIds = []; + function handleIter(result) { + customerIds.push(result.value.id); + if (customerIds.length < 7) { + return iter.next().then(handleIter); + } + } + iter + .next() + .then(handleIter) + .then(() => { + resolve(customerIds); + }) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - var customerIds = []; - function handleIter(result) { - customerIds.push(result.value.id); - expect(iter.return()).to.deep.equal({}); - } + it('gives you the same result each time when you call it multiple times in parallel', () => + expect( + new Promise((resolve, reject) => { + const iter = stripe.customers.list({limit: 3, email}); - iter.next().then(handleIter).then(function() { - resolve(customerIds); - }).catch(reject); - })).to.eventually.deep.equal(realCustomerIds.slice(0, 1)); - }); - - it('works when you call it sequentially', function() { - return expect(new Promise(function(resolve, reject) { - var iter = stripe.customers.list({limit: 3, email: email}); - - var customerIds = []; - function handleIter(result) { - customerIds.push(result.value.id); - if (customerIds.length < 7) { - return iter.next().then(handleIter); + const customerIds = []; + function handleIter(result) { + customerIds.push(result.value.id); } - } - iter.next().then(handleIter).then(function() { - resolve(customerIds); - }).catch(reject); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('gives you the same result each time when you call it multiple times in parallel', function() { - return expect(new Promise(function(resolve, reject) { - var iter = stripe.customers.list({limit: 3, email: email}); - - var customerIds = [] - function handleIter(result) { - customerIds.push(result.value.id); - } - Promise.all([ - iter.next().then(handleIter), - iter.next().then(handleIter).then(function() { - return Promise.all([ - iter.next().then(handleIter), - iter.next().then(handleIter), - ]) - }).then(function() { - return Promise.all([ - iter.next().then(handleIter), - iter.next().then(handleIter), - ]) - }).then(function() { - return Promise.all([ - iter.next().then(handleIter), - iter.next().then(handleIter), - ]) - }) - ]).then(function() { - resolve(customerIds); - }).catch(reject); - })).to.eventually.deep.equal(realCustomerIds.slice(0, 4).reduce(function(acc, x) { - acc.push(x); - acc.push(x); - return acc; - }, [])); - }); + Promise.all([ + iter.next().then(handleIter), + iter + .next() + .then(handleIter) + .then(() => + Promise.all([ + iter.next().then(handleIter), + iter.next().then(handleIter), + ]) + ) + .then(() => + Promise.all([ + iter.next().then(handleIter), + iter.next().then(handleIter), + ]) + ) + .then(() => + Promise.all([ + iter.next().then(handleIter), + iter.next().then(handleIter), + ]) + ), + ]) + .then(() => { + resolve(customerIds); + }) + .catch(reject); + }) + ).to.eventually.deep.equal( + realCustomerIds.slice(0, 4).reduce((acc, x) => { + acc.push(x); + acc.push(x); + return acc; + }, []) + )); }); - describe('autoPagingToArray', function() { - it('can go to the end', function() { - return expect(new Promise(function(resolve, reject) { - stripe.customers.list({limit: 3, email: email}) - .autoPagingToArray({limit: TOTAL_OBJECTS + 1}) - .then(function(customers) { - return customers.map(function(customer) { return customer.id; }); - }) - .then(resolve) - .catch(reject); - })).to.eventually.deep.equal(realCustomerIds); - }); - - it('returns a promise of an array', function() { - return expect(new Promise(function(resolve, reject) { - stripe.customers.list({limit: 3, email: email}) - .autoPagingToArray({limit: LIMIT}) - .then(function(customers) { - return customers.map(function(customer) { return customer.id; }); - }) - .then(resolve) - .catch(reject); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('accepts an onDone callback, passing an array', function() { - return expect(new Promise(function(resolve, reject) { - function onDone(err, customers) { - if (err) { - reject(err); - } else { - resolve(customers.map(function(customer) { return customer.id; })); + describe('autoPagingToArray', () => { + it('can go to the end', () => + expect( + new Promise((resolve, reject) => { + stripe.customers + .list({limit: 3, email}) + .autoPagingToArray({limit: TOTAL_OBJECTS + 1}) + .then((customers) => customers.map((customer) => customer.id)) + .then(resolve) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds)); + + it('returns a promise of an array', () => + expect( + new Promise((resolve, reject) => { + stripe.customers + .list({limit: 3, email}) + .autoPagingToArray({limit: LIMIT}) + .then((customers) => customers.map((customer) => customer.id)) + .then(resolve) + .catch(reject); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + + it('accepts an onDone callback, passing an array', () => + expect( + new Promise((resolve, reject) => { + function onDone(err, customers) { + if (err) { + reject(err); + } else { + resolve(customers.map((customer) => customer.id)); + } } - } - stripe.customers.list({limit: 3, email: email}) - .autoPagingToArray({limit: LIMIT}, onDone); - })).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); - - it('enforces a `limit` arg', function() { - return expect(new Promise(function(resolve, reject) { - try { - stripe.customers.list({limit: 3, email: email}) - .autoPagingToArray(); - reject(Error('Should have thrown.')); - } catch (err) { - resolve(err.message); - } - })).to.eventually.equal('You must pass a `limit` option to autoPagingToArray, eg; `autoPagingToArray({limit: 1000});`.'); - }); - - it('caps the `limit` arg to a reasonable ceiling', function() { - return expect(new Promise(function(resolve, reject) { - try { - stripe.customers.list({limit: 3, email: email}) - .autoPagingToArray({limit: 1000000}); - reject(Error('Should have thrown.')); - } catch (err) { - resolve(err.message); - } - })).to.eventually.equal('You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.'); - }); + stripe.customers + .list({limit: 3, email}) + .autoPagingToArray({limit: LIMIT}, onDone); + }) + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); + + it('enforces a `limit` arg', () => + expect( + new Promise((resolve, reject) => { + try { + stripe.customers.list({limit: 3, email}).autoPagingToArray(); + reject(Error('Should have thrown.')); + } catch (err) { + resolve(err.message); + } + }) + ).to.eventually.equal( + 'You must pass a `limit` option to autoPagingToArray, eg; `autoPagingToArray({limit: 1000});`.' + )); + + it('caps the `limit` arg to a reasonable ceiling', () => + expect( + new Promise((resolve, reject) => { + try { + stripe.customers + .list({limit: 3, email}) + .autoPagingToArray({limit: 1000000}); + reject(Error('Should have thrown.')); + } catch (err) { + resolve(err.message); + } + }) + ).to.eventually.equal( + 'You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.' + )); }); - describe('api compat edge cases', function() { - it('lets you listen to the first request as its own promise, and separately each item, but only sends one request for the first page.', function() { - return expect(new Promise(function(resolve, reject) { - // Count requests: we want one for the first page (not two), and then one for the second page. - var reqCount = 0; - function onRequest() { - reqCount += 1; - } - stripe.on('request', onRequest); - - var customerIds = []; - var p = stripe.customers.list({email: email, limit: 4}) - Promise.all([ - p, - p.autoPagingEach(function(customer) { customerIds.push(customer.id); }), - ]).then(function(results) { - stripe.off('request', onRequest); - expect(reqCount).to.equal(2); // not 3. - - resolve({ - firstReq: results[0].data.map(function(customer) { return customer.id; }), - paginated: customerIds, - }); - }).catch(reject); - })).to.eventually.deep.equal({ + describe('api compat edge cases', () => { + it('lets you listen to the first request as its own promise, and separately each item, but only sends one request for the first page.', () => + expect( + new Promise((resolve, reject) => { + // Count requests: we want one for the first page (not two), and then one for the second page. + let reqCount = 0; + function onRequest() { + reqCount += 1; + } + stripe.on('request', onRequest); + + const customerIds = []; + const p = stripe.customers.list({email, limit: 4}); + Promise.all([ + p, + p.autoPagingEach((customer) => { + customerIds.push(customer.id); + }), + ]) + .then((results) => { + stripe.off('request', onRequest); + expect(reqCount).to.equal(2); // not 3. + + resolve({ + firstReq: results[0].data.map((customer) => customer.id), + paginated: customerIds, + }); + }) + .catch(reject); + }) + ).to.eventually.deep.equal({ firstReq: realCustomerIds.slice(0, 4), paginated: realCustomerIds, - }); - }); + })); }); }); diff --git a/test/flows.spec.js b/test/flows.spec.js index 879918c07a..28a98be4a6 100644 --- a/test/flows.spec.js +++ b/test/flows.spec.js @@ -1,433 +1,329 @@ 'use strict'; -var testUtils = require('../testUtils'); -var chai = require('chai'); -var stripe = require('../lib/stripe')( - testUtils.getUserStripeKey(), - 'latest' -); -var fs = require('fs'); -var path = require('path'); -var stream = require('stream'); -var expect = chai.expect; - -var CUSTOMER_DETAILS = { +const testUtils = require('../testUtils'); +const chai = require('chai'); +const stripe = require('../lib/stripe')(testUtils.getUserStripeKey(), 'latest'); +const fs = require('fs'); +const path = require('path'); +const stream = require('stream'); +const expect = chai.expect; + +const CUSTOMER_DETAILS = { description: 'Some customer', card: 'tok_visa', }; -var CURRENCY = '_DEFAULT_CURRENCY_NOT_YET_GOTTEN_'; +let CURRENCY = '_DEFAULT_CURRENCY_NOT_YET_GOTTEN_'; describe('Flows', function() { // Note: These tests must be run as one so we can retrieve the // default_currency (required in subsequent tests); - var cleanup = new testUtils.CleanupUtility(); + const cleanup = new testUtils.CleanupUtility(); this.timeout(30000); - it('Allows me to retrieve default_currency', function() { - return expect( - stripe.account.retrieve() - .then(function(acct) { - CURRENCY = acct.default_currency; - return acct; - }) - ).to.eventually.have.property('default_currency'); - }); - - describe('Plan+Subscription flow', function() { - it('Allows me to: Create a plan and subscribe a customer to it', function() { - return expect( + it('Allows me to retrieve default_currency', () => + expect( + stripe.account.retrieve().then((acct) => { + CURRENCY = acct.default_currency; + return acct; + }) + ).to.eventually.have.property('default_currency')); + + describe('Plan+Subscription flow', () => { + it('Allows me to: Create a plan and subscribe a customer to it', () => + expect( Promise.all([ stripe.plans.create({ - id: 'plan' + testUtils.getRandomString(), + id: `plan${testUtils.getRandomString()}`, amount: 1700, currency: CURRENCY, interval: 'month', nickname: 'Gold Super Amazing Tier', product: { - name: 'product' + testUtils.getRandomString(), + name: `product${testUtils.getRandomString()}`, }, }), - stripe.customers.create(CUSTOMER_DETAILS) - ]).then(function(j) { - var plan = j[0]; - var customer = j[1]; + stripe.customers.create(CUSTOMER_DETAILS), + ]).then((j) => { + const plan = j[0]; + const customer = j[1]; cleanup.deleteCustomer(customer.id); cleanup.deletePlan(plan.id); - return stripe.customers.updateSubscription(customer.id, { + return stripe.subscriptions.create({ + customer: customer.id, plan: plan.id, }); }) - ).to.eventually.have.property('status', 'active'); - }); + ).to.eventually.have.property('status', 'active')); - it( - 'Allows me to: Create a plan and subscribe a customer to it, and update subscription (multi-subs API)', - function() { - var plan; - return expect( - Promise.all([ - stripe.plans.create({ - id: 'plan' + testUtils.getRandomString(), - amount: 1700, - currency: CURRENCY, - interval: 'month', - nickname: 'Gold Super Amazing Tier', - product: { - name: 'product' + testUtils.getRandomString(), - }, - }), - stripe.customers.create(CUSTOMER_DETAILS) - ]).then(function(j) { + it('Allows me to: Create a plan and subscribe a customer to it, and update subscription', () => { + let plan; + return expect( + Promise.all([ + stripe.plans.create({ + id: `plan${testUtils.getRandomString()}`, + amount: 1700, + currency: CURRENCY, + interval: 'month', + nickname: 'Gold Super Amazing Tier', + product: { + name: `product${testUtils.getRandomString()}`, + }, + }), + stripe.customers.create(CUSTOMER_DETAILS), + ]) + .then((j) => { plan = j[0]; - var customer = j[1]; + const customer = j[1]; cleanup.deleteCustomer(customer.id); cleanup.deletePlan(plan.id); - return stripe.customers.createSubscription(customer.id, { + return stripe.subscriptions.create({ + customer: customer.id, plan: plan.id, }); - }).then(function(subscription) { - return stripe.customers.updateSubscription(subscription.customer, subscription.id, { - plan: plan.id, quantity: '3', - }); - }).then(function(subscription) { - return [subscription.status, subscription.quantity]; }) - ).to.eventually.deep.equal(['active', 3]); - } - ); - - it('Errors when I attempt to subscribe a customer to a non-existent plan', function() { - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(customer) { - cleanup.deleteCustomer(customer.id); - - return stripe.customers.updateSubscription(customer.id, { - plan: 'someNonExistentPlan' + testUtils.getRandomString(), - }).then(null, function(err) { - // Resolve with the error so we can inspect it below - return err; - }); - }) - ).to.eventually.satisfy(function(err) { - return err.type === 'StripeInvalidRequestError' && - err.rawType === 'invalid_request_error'; - }); + .then((subscription) => + stripe.subscriptions.update(subscription.id, { + plan: plan.id, + quantity: 3, + }) + ) + .then((subscription) => [subscription.status, subscription.quantity]) + ).to.eventually.deep.equal(['active', 3]); }); - it('Allows me to: subscribe then update with `cancel_at_period_end` defined', function() { - return expect( + it('Errors when I attempt to subscribe a customer to a non-existent plan', () => + expect( + stripe.customers.create(CUSTOMER_DETAILS).then((customer) => { + cleanup.deleteCustomer(customer.id); + + return stripe.subscriptions + .create({ + customer: customer.id, + plan: `someNonExistentPlan${testUtils.getRandomString()}`, + }) + .then( + null, + (err) => + // Resolve with the error so we can inspect it below + err + ); + }) + ).to.eventually.satisfy( + (err) => + err.type === 'StripeInvalidRequestError' && + err.rawType === 'invalid_request_error' + )); + + it('Allows me to: subscribe then update with `cancel_at_period_end` defined', () => + expect( Promise.all([ stripe.plans.create({ - id: 'plan' + testUtils.getRandomString(), + id: `plan${testUtils.getRandomString()}`, amount: 1700, currency: CURRENCY, interval: 'month', nickname: 'Silver Super Amazing Tier', product: { - name: 'product' + testUtils.getRandomString(), + name: `product${testUtils.getRandomString()}`, }, }), - stripe.customers.create(CUSTOMER_DETAILS) - ]).then(function(j) { - var plan = j[0]; - var customer = j[1]; + stripe.customers.create(CUSTOMER_DETAILS), + ]) + .then((j) => { + const plan = j[0]; + const customer = j[1]; - cleanup.deleteCustomer(customer.id); - cleanup.deletePlan(plan.id); + cleanup.deleteCustomer(customer.id); + cleanup.deletePlan(plan.id); - return stripe.customers.updateSubscription(customer.id, { - plan: plan.id, - cancel_at_period_end: true, - }); - }) - ).to.eventually.have.property('cancel_at_period_end', true); - }); + return stripe.subscriptions.create({ + customer: customer.id, + plan: plan.id, + }); + }) + .then((subscription) => + stripe.subscriptions.update(subscription.id, { + cancel_at_period_end: true, + }) + ) + ).to.eventually.have.property('cancel_at_period_end', true)); - describe('Plan name variations', function() { + describe('Plan name variations', () => { [ - '34535_355453' + testUtils.getRandomString(), - 'TEST_239291' + testUtils.getRandomString(), - 'TEST_a-i' + testUtils.getRandomString(), - 'foobarbazteston___etwothree' + testUtils.getRandomString(), - ].forEach(function(planID) { - it('Allows me to create and retrieve plan with ID: ' + planID, function() { - return expect( - stripe.plans.create({ - id: planID, - amount: 1700, - currency: CURRENCY, - interval: 'month', - nickname: 'generic', - product: { - name: 'product' + testUtils.getRandomString(), - }, - }).then(function() { - cleanup.deletePlan(planID); - return stripe.plans.retrieve(planID); - }) - ).to.eventually.have.property('id', planID); - }); + `34535_355453${testUtils.getRandomString()}`, + `TEST_239291${testUtils.getRandomString()}`, + `TEST_a-i${testUtils.getRandomString()}`, + `foobarbazteston___etwothree${testUtils.getRandomString()}`, + ].forEach((planID) => { + it(`Allows me to create and retrieve plan with ID: ${planID}`, () => + expect( + stripe.plans + .create({ + id: planID, + amount: 1700, + currency: CURRENCY, + interval: 'month', + nickname: 'generic', + product: { + name: `product${testUtils.getRandomString()}`, + }, + }) + .then(() => { + cleanup.deletePlan(planID); + return stripe.plans.retrieve(planID); + }) + ).to.eventually.have.property('id', planID)); }); }); }); - describe('Coupon flow', function() { - var customer; - var coupon; + describe('Coupon flow', () => { + let customer; + let coupon; - describe('When I create a coupon & customer', function() { - it('Does so', function() { - return expect( + describe('When I create a coupon & customer', () => { + it('Does so', () => + expect( Promise.all([ stripe.coupons.create({ percent_off: 20, duration: 'once', }), - stripe.customers.create(CUSTOMER_DETAILS) - ]).then(function(joined) { + stripe.customers.create(CUSTOMER_DETAILS), + ]).then((joined) => { coupon = joined[0]; customer = joined[1]; }) - ).to.not.be.eventually.rejected; - }); - describe('And I apply the coupon to the customer', function() { - it('Does so', function() { - return expect( + ).to.not.be.eventually.rejected); + describe('And I apply the coupon to the customer', () => { + it('Does so', () => + expect( stripe.customers.update(customer.id, { coupon: coupon.id, }) - ).to.not.be.eventually.rejected; - }); - it('Can be retrieved from that customer', function() { - return expect( + ).to.not.be.eventually.rejected); + it('Can be retrieved from that customer', () => + expect( stripe.customers.retrieve(customer.id) - ).to.eventually.have.nested.property('discount.coupon.id', coupon.id); - }); - describe('The resulting discount', function() { - it('Can be removed', function() { - return expect( + ).to.eventually.have.nested.property( + 'discount.coupon.id', + coupon.id + )); + describe('The resulting discount', () => { + it('Can be removed', () => + expect( stripe.customers.deleteDiscount(customer.id) - ).to.eventually.have.property('deleted', true); - }); - describe('Re-querying it', function() { - it('Does indeed indicate that it is deleted', function() { - return expect( + ).to.eventually.have.property('deleted', true)); + describe('Re-querying it', () => { + it('Does indeed indicate that it is deleted', () => + expect( stripe.customers.retrieve(customer.id) - ).to.eventually.have.property('discount', null); - }); + ).to.eventually.have.property('discount', null)); }); }); }); }); }); - describe('Metadata flow', function() { - it('Can save and retrieve metadata', function() { - var customer; - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(cust) { - customer = cust; - cleanup.deleteCustomer(cust.id); - return stripe.customers.setMetadata(cust.id, {foo: '123'}); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id); - }) - ).to.eventually.deep.equal({foo: '123'}); - }); - it('Can reset metadata', function() { - var customer; - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(cust) { - customer = cust; - cleanup.deleteCustomer(cust.id); - return stripe.customers.setMetadata(cust.id, {baz: '123'}); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, null); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id); - }) - ).to.eventually.deep.equal({}); - }); - it('Resets metadata when setting new metadata', function() { - var customer; - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(cust) { - customer = cust; - cleanup.deleteCustomer(cust.id); - return stripe.customers.setMetadata(cust.id, {foo: '123'}); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, {baz: '456'}); - }) - ).to.eventually.deep.equal({baz: '456'}); - }); - it('Can set individual key/value pairs', function() { - var customer; - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(cust) { - customer = cust; - cleanup.deleteCustomer(cust.id); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, 'baz', 456); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, '_other_', 999); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, 'foo', 123); - }) - .then(function() { - // Change foo - return stripe.customers.setMetadata(customer.id, 'foo', 222); - }) - .then(function() { - // Delete baz - return stripe.customers.setMetadata(customer.id, 'baz', null); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id); - }) - ).to.eventually.deep.equal({_other_: '999', foo: '222'}); - }); - it('Can set individual key/value pairs [with per request token]', function() { - var customer; - var authToken = testUtils.getUserStripeKey(); - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(cust) { - customer = cust; + describe('Expanding', () => { + describe('A customer within a charge', () => { + it('Allows you to expand a customer object', () => + expect( + stripe.customers.create(CUSTOMER_DETAILS).then((cust) => { cleanup.deleteCustomer(cust.id); + return stripe.charges.create({ + customer: cust.id, + amount: 1700, + currency: CURRENCY, + expand: ['customer'], + }); }) - .then(function() { - return stripe.customers.setMetadata(customer.id, {'baz': 456}, authToken); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, '_other_', 999, authToken); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, 'foo', 123, authToken); - }) - .then(function() { - // Change foo - return stripe.customers.setMetadata(customer.id, 'foo', 222, authToken); - }) - .then(function() { - // Delete baz - return stripe.customers.setMetadata(customer.id, 'baz', null, authToken); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id, authToken); - }) - ).to.eventually.deep.equal({_other_: '999', foo: '222'}); + ).to.eventually.have.nested.property('customer.created')); }); - }); - - describe('Expanding', function() { - describe('A customer within a charge', function() { - it('Allows you to expand a customer object', function() { - return expect( - stripe.customers.create(CUSTOMER_DETAILS) - .then(function(cust) { - cleanup.deleteCustomer(cust.id); - return stripe.charges.create({ - customer: cust.id, - amount: 1700, - currency: CURRENCY, - expand: ['customer'], - }); + describe("A customer's default source", () => { + it('Allows you to expand a default_source', () => + expect( + stripe.customers + .create({ + description: 'Some customer', + source: 'tok_visa', + expand: ['default_source'], }) - ).to.eventually.have.nested.property('customer.created'); - }); - }); - describe('A customer\'s default source', function() { - it('Allows you to expand a default_source', function() { - return expect( - stripe.customers.create({ - description: 'Some customer', - source: 'tok_visa', - expand: ['default_source'], - }) - .then(function(cust) { + .then((cust) => { cleanup.deleteCustomer(cust.id); return cust; }) // Confirm it's expanded by checking that some prop (e.g. exp_year) exists: - ).to.eventually.have.nested.property('default_source.exp_year'); - }); + ).to.eventually.have.nested.property('default_source.exp_year')); }); }); - describe('Charge', function() { - it('Allows you to create a charge', function() { - return expect( - stripe.charges.create({ - amount: 1234, - currency: CURRENCY, - card: 'tok_chargeDeclined', - shipping: { - name: 'Bobby Tables', - address: { - line1: '1 Foo St.', + describe('Charge', () => { + it('Allows you to create a charge', () => + expect( + stripe.charges + .create({ + amount: 1234, + currency: CURRENCY, + card: 'tok_chargeDeclined', + shipping: { + name: 'Bobby Tables', + address: { + line1: '1 Foo St.', + }, }, - }, - }).then(null, function(error) { - return error; - }) - ).to.eventually.have.nested.property('raw.charge'); - }); + }) + .then(null, (error) => error) + ).to.eventually.have.nested.property('raw.charge')); }); - describe('Getting balance', function() { - it('Allows me to do so', function() { - return expect( - stripe.balance.retrieve() - ).to.eventually.have.property('object', 'balance'); - }); - it('Allows me to do so with specified auth key', function() { - return expect( + describe('Getting balance', () => { + it('Allows me to do so', () => + expect(stripe.balance.retrieve()).to.eventually.have.property( + 'object', + 'balance' + )); + it('Allows me to do so with specified auth key', () => + expect( stripe.balance.retrieve(testUtils.getUserStripeKey()) - ).to.eventually.have.property('object', 'balance'); - }); + ).to.eventually.have.property('object', 'balance')); }); - describe('Request/Response Events', function() { - var connectedAccountId; + describe('Request/Response Events', () => { + let connectedAccountId; - before(function(done) { + before((done) => { // Pick a random connected account to use in the `Stripe-Account` header - stripe.accounts.list({ - limit: 1, - }).then(function(accounts) { - if (accounts.data.length < 1) { - return done( - new Error('Test requires at least one Connected Account in the Test Account') - ); - } - - connectedAccountId = accounts.data[0].id; - - done(); - }); + stripe.accounts + .list({ + limit: 1, + }) + .then((accounts) => { + if (accounts.data.length < 1) { + return done( + new Error( + 'Test requires at least one Connected Account in the Test Account' + ) + ); + } + + connectedAccountId = accounts.data[0].id; + + done(); + }); }); - it('should emit a `request` event to listeners on request', function(done) { - var apiVersion = '2017-06-05'; - var idempotencyKey = Math.random().toString(36).slice(2); + it('should emit a `request` event to listeners on request', (done) => { + const apiVersion = '2017-06-05'; + const idempotencyKey = Math.random() + .toString(36) + .slice(2); function onRequest(request) { stripe.off('request', onRequest); @@ -445,22 +341,29 @@ describe('Flows', function() { stripe.on('request', onRequest); - stripe.charges.create({ - amount: 1234, - currency: 'usd', - card: 'tok_chargeDeclined', - }, { - stripe_version: apiVersion, - idempotency_key: idempotencyKey, - stripe_account: connectedAccountId, - }).then(null, function() { - // I expect there to be an error here. - }); + stripe.charges + .create( + { + amount: 1234, + currency: 'usd', + card: 'tok_chargeDeclined', + }, + { + stripe_version: apiVersion, + idempotency_key: idempotencyKey, + stripe_account: connectedAccountId, + } + ) + .then(null, () => { + // I expect there to be an error here. + }); }); - it('should emit a `response` event to listeners on response', function(done) { - var apiVersion = '2017-06-05'; - var idempotencyKey = Math.random().toString(36).slice(2); + it('should emit a `response` event to listeners on response', (done) => { + const apiVersion = '2017-06-05'; + const idempotencyKey = Math.random() + .toString(36) + .slice(2); function onResponse(response) { // On the off chance we're picking up a response from a differentrequest @@ -485,20 +388,25 @@ describe('Flows', function() { stripe.on('response', onResponse); - stripe.charges.create({ - amount: 1234, - currency: 'usd', - card: 'tok_chargeDeclined', - }, { - stripe_version: apiVersion, - idempotency_key: idempotencyKey, - stripe_account: connectedAccountId, - }).then(null, function() { - // I expect there to be an error here. - }); + stripe.charges + .create( + { + amount: 1234, + currency: 'usd', + card: 'tok_chargeDeclined', + }, + { + stripe_version: apiVersion, + idempotency_key: idempotencyKey, + stripe_account: connectedAccountId, + } + ) + .then(null, () => { + // I expect there to be an error here. + }); }); - it('should not emit a `response` event to removed listeners on response', function(done) { + it('should not emit a `response` event to removed listeners on response', (done) => { function onResponse(response) { done(new Error('How did you get here?')); } @@ -506,76 +414,82 @@ describe('Flows', function() { stripe.on('response', onResponse); stripe.off('response', onResponse); - stripe.charges.create({ - amount: 1234, - currency: 'usd', - card: 'tok_visa', - }).then(function() { - done(); - }); + stripe.charges + .create({ + amount: 1234, + currency: 'usd', + card: 'tok_visa', + }) + .then(() => { + done(); + }); }); }); - describe('FileUpload', function() { - it('Allows you to upload a file as a stream', function() { - var testFilename = path.join(__dirname, 'resources/data/minimal.pdf'); - var f = fs.createReadStream(testFilename); + describe('File', () => { + it('Allows you to upload a file as a stream', () => { + const testFilename = path.join(__dirname, 'resources/data/minimal.pdf'); + const f = fs.createReadStream(testFilename); return expect( - stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - }).then(null, function(error) { - return error; - }) + stripe.files + .create({ + purpose: 'dispute_evidence', + file: { + data: f, + name: 'minimal.pdf', + type: 'application/octet-stream', + }, + }) + .then(null, (error) => error) ).to.eventually.have.nested.property('size', 739); }); - it('Allows you to upload a file synchronously', function() { - var testFilename = path.join(__dirname, 'resources/data/minimal.pdf'); - var f = fs.readFileSync(testFilename); + it('Allows you to upload a file synchronously', () => { + const testFilename = path.join(__dirname, 'resources/data/minimal.pdf'); + const f = fs.readFileSync(testFilename); return expect( - stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - }).then(null, function(error) { - return error; - }) + stripe.files + .create({ + purpose: 'dispute_evidence', + file: { + data: f, + name: 'minimal.pdf', + type: 'application/octet-stream', + }, + }) + .then(null, (error) => error) ).to.eventually.have.nested.property('size', 739); }); - it('Surfaces stream errors correctly', function(done) { - var mockedStream = new stream.Readable(); - mockedStream._read = function() {}; + it('Surfaces stream errors correctly', (done) => { + const mockedStream = new stream.Readable(); + mockedStream._read = () => {}; - var fakeError = new Error('I am a fake error'); + const fakeError = new Error('I am a fake error'); - process.nextTick(function() { + process.nextTick(() => { mockedStream.emit('error', fakeError); }); - stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: mockedStream, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - }).catch(function(error) { - expect(error.message).to.equal('An error occurred while attempting to process the file for upload.'); - expect(error.detail).to.equal(fakeError); + stripe.files + .create({ + purpose: 'dispute_evidence', + file: { + data: mockedStream, + name: 'minimal.pdf', + type: 'application/octet-stream', + }, + }) + .catch((error) => { + expect(error.message).to.equal( + 'An error occurred while attempting to process the file for upload.' + ); + expect(error.detail).to.equal(fakeError); - done(); - }); + done(); + }); }); }); }); diff --git a/test/resources/Account.spec.js b/test/resources/Account.spec.js index 5ec0f9ab6c..5a4a2b1552 100644 --- a/test/resources/Account.spec.js +++ b/test/resources/Account.spec.js @@ -1,17 +1,17 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; +const TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Account Resource', function() { +describe('Account Resource', () => { function uniqueEmail() { - return Math.random() + 'bob@example.com'; + return `${Math.random()}bob@example.com`; } - describe('create', function() { - it('Sends the correct request', function() { - var data = { + describe('create', () => { + it('Sends the correct request', () => { + const data = { managed: false, country: 'US', email: uniqueEmail(), @@ -20,14 +20,14 @@ describe('Account Resource', function() { expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/accounts', - data: data, + data, headers: {}, }); }); }); - describe('delete', function() { - it('deletes an account successfully', function() { + describe('delete', () => { + it('deletes an account successfully', () => { stripe.account.del('acct_16Tzq6DBahdM4C8s'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -38,8 +38,8 @@ describe('Account Resource', function() { }); }); - describe('reject', function() { - it('rejects an account successfully', function() { + describe('reject', () => { + it('rejects an account successfully', () => { stripe.account.reject('acct_16Tzq6DBahdM4C8s', {reason: 'fraud'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -50,8 +50,8 @@ describe('Account Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request with no params', function() { + describe('retrieve', () => { + it('Sends the correct request with no params', () => { stripe.account.retrieve(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -61,7 +61,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with ID param', function() { + it('Sends the correct request with ID param', () => { stripe.account.retrieve('foo'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -71,8 +71,8 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with secret key', function() { - var key = 'sk_12345678901234567890123456789012'; + it('Sends the correct request with secret key', () => { + const key = 'sk_12345678901234567890123456789012'; stripe.account.retrieve(null, key); expect(stripe.LAST_REQUEST).to.deep.equal({ auth: key, @@ -83,8 +83,8 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with secret key as first object', function() { - var params = {api_key: 'sk_12345678901234567890123456789012'}; + it('Sends the correct request with secret key as first object', () => { + const params = {api_key: 'sk_12345678901234567890123456789012'}; stripe.account.retrieve(params); expect(stripe.LAST_REQUEST).to.deep.equal({ auth: params.api_key, @@ -95,8 +95,8 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with a callback', function() { - stripe.account.retrieve(function(err, account) {}); + it('Sends the correct request with a callback', () => { + stripe.account.retrieve((err, account) => {}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/account', @@ -106,9 +106,9 @@ describe('Account Resource', function() { }); }); - describe('Capability methods', function() { - describe('listCapabilities', function() { - it('Sends the correct request', function() { + describe('Capability methods', () => { + describe('listCapabilities', () => { + it('Sends the correct request', () => { stripe.account.listCapabilities('acct_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -118,7 +118,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.listCapabilities('acct_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -130,8 +130,8 @@ describe('Account Resource', function() { }); }); - describe('retrieveCapability', function() { - it('Sends the correct request', function() { + describe('retrieveCapability', () => { + it('Sends the correct request', () => { stripe.account.retrieveCapability('acct_123', 'acap_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -141,8 +141,12 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.retrieveCapability('acct_123', 'acap_123', TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.retrieveCapability( + 'acct_123', + 'acap_123', + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/accounts/acct_123/capabilities/acap_123', @@ -153,8 +157,8 @@ describe('Account Resource', function() { }); }); - describe('updateCapability', function() { - it('Sends the correct request', function() { + describe('updateCapability', () => { + it('Sends the correct request', () => { stripe.account.updateCapability('acct_123', 'acap_123', { first_name: 'John', }); @@ -166,10 +170,15 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.updateCapability('acct_123', 'acap_123', { - first_name: 'John', - }, TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.updateCapability( + 'acct_123', + 'acap_123', + { + first_name: 'John', + }, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/accounts/acct_123/capabilities/acap_123', @@ -181,23 +190,32 @@ describe('Account Resource', function() { }); }); - describe('External account methods', function() { - describe('retrieveExternalAccount', function() { - it('Sends the correct request', function() { - stripe.account.retrieveExternalAccount('accountIdFoo321', 'externalAccountIdFoo456'); + describe('External account methods', () => { + describe('retrieveExternalAccount', () => { + it('Sends the correct request', () => { + stripe.account.retrieveExternalAccount( + 'accountIdFoo321', + 'externalAccountIdFoo456' + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', + url: + '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', headers: {}, data: {}, }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.retrieveExternalAccount('accountIdFoo321', 'externalAccountIdFoo456', TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.retrieveExternalAccount( + 'accountIdFoo321', + 'externalAccountIdFoo456', + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', + url: + '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', headers: {}, data: {}, auth: TEST_AUTH_KEY, @@ -205,10 +223,12 @@ describe('Account Resource', function() { }); }); - describe('createExternalAccount', function() { - it('Sends the correct request', function() { + describe('createExternalAccount', () => { + it('Sends the correct request', () => { stripe.account.createExternalAccount('accountIdFoo321', { - number: '123456', currency: 'usd', country: 'US', + number: '123456', + currency: 'usd', + country: 'US', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -218,10 +238,16 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.createExternalAccount('accountIdFoo321', { - number: '123456', currency: 'usd', country: 'US', - }, TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.createExternalAccount( + 'accountIdFoo321', + { + number: '123456', + currency: 'usd', + country: 'US', + }, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/accounts/accountIdFoo321/external_accounts', @@ -232,36 +258,50 @@ describe('Account Resource', function() { }); }); - describe('updateExternalAccount', function() { - it('Sends the correct request', function() { - stripe.account.updateExternalAccount('accountIdFoo321', 'externalAccountIdFoo456', { - default_for_currency: true, - }); + describe('updateExternalAccount', () => { + it('Sends the correct request', () => { + stripe.account.updateExternalAccount( + 'accountIdFoo321', + 'externalAccountIdFoo456', + { + default_for_currency: true, + } + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', + url: + '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', headers: {}, data: {default_for_currency: true}, }); }); }); - describe('deleteExternalAccount', function() { - it('Sends the correct request', function() { - stripe.account.deleteExternalAccount('accountIdFoo321', 'externalAccountIdFoo456'); + describe('deleteExternalAccount', () => { + it('Sends the correct request', () => { + stripe.account.deleteExternalAccount( + 'accountIdFoo321', + 'externalAccountIdFoo456' + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', - url: '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', + url: + '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', headers: {}, data: {}, }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.deleteExternalAccount('accountIdFoo321', 'externalAccountIdFoo456', TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.deleteExternalAccount( + 'accountIdFoo321', + 'externalAccountIdFoo456', + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', - url: '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', + url: + '/v1/accounts/accountIdFoo321/external_accounts/externalAccountIdFoo456', headers: {}, data: {}, auth: TEST_AUTH_KEY, @@ -269,8 +309,8 @@ describe('Account Resource', function() { }); }); - describe('listExternalAccounts', function() { - it('Sends the correct request', function() { + describe('listExternalAccounts', () => { + it('Sends the correct request', () => { stripe.account.listExternalAccounts('accountIdFoo321'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -280,7 +320,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.listExternalAccounts('accountIdFoo321', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -293,9 +333,9 @@ describe('Account Resource', function() { }); }); - describe('LoginLink methods', function() { - describe('createLoginLink', function() { - it('Sends the correct request', function() { + describe('LoginLink methods', () => { + describe('createLoginLink', () => { + it('Sends the correct request', () => { stripe.account.createLoginLink('acct_EXPRESS'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -307,9 +347,9 @@ describe('Account Resource', function() { }); }); - describe('Person methods', function() { - describe('retrievePerson', function() { - it('Sends the correct request', function() { + describe('Person methods', () => { + describe('retrievePerson', () => { + it('Sends the correct request', () => { stripe.account.retrievePerson('acct_123', 'person_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -319,7 +359,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.retrievePerson('acct_123', 'person_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -331,8 +371,8 @@ describe('Account Resource', function() { }); }); - describe('createPerson', function() { - it('Sends the correct request', function() { + describe('createPerson', () => { + it('Sends the correct request', () => { stripe.account.createPerson('acct_123', { first_name: 'John', }); @@ -344,10 +384,14 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.createPerson('acct_123', { - first_name: 'John', - }, TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.createPerson( + 'acct_123', + { + first_name: 'John', + }, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/accounts/acct_123/persons', @@ -358,8 +402,8 @@ describe('Account Resource', function() { }); }); - describe('updatePerson', function() { - it('Sends the correct request', function() { + describe('updatePerson', () => { + it('Sends the correct request', () => { stripe.account.updatePerson('acct_123', 'person_123', { first_name: 'John', }); @@ -371,10 +415,15 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.account.updatePerson('acct_123', 'person_123', { - first_name: 'John', - }, TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.account.updatePerson( + 'acct_123', + 'person_123', + { + first_name: 'John', + }, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/accounts/acct_123/persons/person_123', @@ -385,8 +434,8 @@ describe('Account Resource', function() { }); }); - describe('deletePerson', function() { - it('Sends the correct request', function() { + describe('deletePerson', () => { + it('Sends the correct request', () => { stripe.account.deletePerson('acct_123', 'person_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -396,7 +445,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.deletePerson('acct_123', 'person_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -408,8 +457,8 @@ describe('Account Resource', function() { }); }); - describe('listPersons', function() { - it('Sends the correct request', function() { + describe('listPersons', () => { + it('Sends the correct request', () => { stripe.account.listPersons('acct_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -419,7 +468,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.listPersons('acct_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/AccountLinks.spec.js b/test/resources/AccountLinks.spec.js index 74dfe1caef..bd42414fcd 100644 --- a/test/resources/AccountLinks.spec.js +++ b/test/resources/AccountLinks.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('AccountLinks Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('AccountLinks Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.accountLinks.create({ account: 'acct_123', failure_url: 'https://stripe.com/failure', diff --git a/test/resources/ApplePayDomains.spec.js b/test/resources/ApplePayDomains.spec.js index 106e3fd9fd..38fd741849 100644 --- a/test/resources/ApplePayDomains.spec.js +++ b/test/resources/ApplePayDomains.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('ApplePayDomains Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('ApplePayDomains Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.applePayDomains.retrieve('apwc_retrieve'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('ApplePayDomains Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.applePayDomains.del('apwc_delete'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('ApplePayDomains Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.applePayDomains.create({ domain_name: 'example.com', }); @@ -45,8 +45,8 @@ describe('ApplePayDomains Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.applePayDomains.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ApplicationFeeRefunds.spec.js b/test/resources/ApplicationFeeRefunds.spec.js deleted file mode 100644 index f4f2a72a80..0000000000 --- a/test/resources/ApplicationFeeRefunds.spec.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var APPFEE_TEST_ID = 'appFeeIdTest999'; -var REFUND_TEST_ID = 'refundIdTest999'; - -// Create new CustomerCard instance with pre-filled customerId: -var appFeeRefund = new resources.ApplicationFeeRefunds( - stripe, - {feeId: APPFEE_TEST_ID} -); - -// Use spy from existing resource: -appFeeRefund._request = stripe.customers._request; - -describe('ApplicationFeeRefund Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - appFeeRefund.retrieve(REFUND_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/application_fees/' + APPFEE_TEST_ID + '/refunds/' + REFUND_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - appFeeRefund.update(REFUND_TEST_ID, { - metadata: {key: 'value'}, - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/application_fees/' + APPFEE_TEST_ID + '/refunds/' + REFUND_TEST_ID, - data: {metadata: {key: 'value'}}, - headers: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - appFeeRefund.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/application_fees/' + APPFEE_TEST_ID + '/refunds', - data: {}, - headers: {}, - }); - }); - }); -}); diff --git a/test/resources/ApplicationFees.spec.js b/test/resources/ApplicationFees.spec.js index 2cec4f95ff..4264714106 100644 --- a/test/resources/ApplicationFees.spec.js +++ b/test/resources/ApplicationFees.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('ApplicationFee Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('ApplicationFee Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.applicationFees.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,20 +16,8 @@ describe('ApplicationFee Resource', function() { }); }); - describe('refund', function() { - it('Sends the correct request', function() { - stripe.applicationFees.refund('applicationFeeIdExample3242', {amount: 23}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/application_fees/applicationFeeIdExample3242/refund', - data: {amount: 23}, - headers: {}, - }); - }); - }); - - describe('refunds', function() { - it('Sends the correct update request', function() { + describe('refunds', () => { + it('Sends the correct update request', () => { stripe.applicationFees.updateRefund( 'appFeeIdExample3242', 'refundIdExample2312', @@ -37,17 +25,15 @@ describe('ApplicationFee Resource', function() { ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/application_fees/appFeeIdExample3242/refunds/refundIdExample2312', + url: + '/v1/application_fees/appFeeIdExample3242/refunds/refundIdExample2312', data: {metadata: {key: 'value'}}, headers: {}, }); }); - it('Sends the correct create request', function() { - stripe.applicationFees.createRefund( - 'appFeeIdExample3242', - {amount: 100} - ); + it('Sends the correct create request', () => { + stripe.applicationFees.createRefund('appFeeIdExample3242', {amount: 100}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/application_fees/appFeeIdExample3242/refunds', @@ -56,10 +42,8 @@ describe('ApplicationFee Resource', function() { }); }); - it('Sends the correct list request', function() { - stripe.applicationFees.listRefunds( - 'appFeeIdExample3242' - ); + it('Sends the correct list request', () => { + stripe.applicationFees.listRefunds('appFeeIdExample3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/application_fees/appFeeIdExample3242/refunds', @@ -68,14 +52,15 @@ describe('ApplicationFee Resource', function() { }); }); - it('Sends the correct retrieve request', function() { + it('Sends the correct retrieve request', () => { stripe.applicationFees.retrieveRefund( 'appFeeIdExample3242', 'refundIdExample2312' ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/application_fees/appFeeIdExample3242/refunds/refundIdExample2312', + url: + '/v1/application_fees/appFeeIdExample3242/refunds/refundIdExample2312', data: {}, headers: {}, }); diff --git a/test/resources/Balance.spec.js b/test/resources/Balance.spec.js index 0845e36106..83acd76cbb 100644 --- a/test/resources/Balance.spec.js +++ b/test/resources/Balance.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Balance Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Balance Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.balance.retrieve(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -15,7 +15,7 @@ describe('Balance Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.balance.retrieve('aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -26,50 +26,4 @@ describe('Balance Resource', function() { }); }); }); - - describe('listTransactions', function() { - it('Sends the correct request', function() { - stripe.balance.listTransactions(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/balance/history', - data: {}, - headers: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.balance.listTransactions('aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/balance/history', - data: {}, - headers: {}, - auth: 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11', - }); - }); - }); - - describe('retrieveTransaction', function() { - it('Sends the correct request', function() { - stripe.balance.retrieveTransaction('transactionIdFoo'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/balance/history/transactionIdFoo', - data: {}, - headers: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.balance.retrieveTransaction('transactionIdFoo', 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/balance/history/transactionIdFoo', - data: {}, - headers: {}, - auth: 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11', - }); - }); - }); }); diff --git a/test/resources/BitcoinReceivers.spec.js b/test/resources/BitcoinReceivers.spec.js index 2ca675e6bc..494840c17a 100644 --- a/test/resources/BitcoinReceivers.spec.js +++ b/test/resources/BitcoinReceivers.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('BitcoinReceivers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('BitcoinReceivers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.bitcoinReceivers.retrieve('receiverId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('BitcoinReceivers Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.bitcoinReceivers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('BitcoinReceivers Resource', function() { }); }); - describe('listTransactions', function() { - it('Sends the correct request', function() { + describe('listTransactions', () => { + it('Sends the correct request', () => { stripe.bitcoinReceivers.listTransactions('receiverId', { limit: 1, }); @@ -40,7 +40,7 @@ describe('BitcoinReceivers Resource', function() { data: { limit: 1, }, - }) + }); }); }); }); diff --git a/test/resources/Capabilities.spec.js b/test/resources/Capabilities.spec.js deleted file mode 100644 index d586715096..0000000000 --- a/test/resources/Capabilities.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var ACCOUNT_TEST_ID = 'acct_123'; -var CAPABILITY_TEST_ID = 'acap_123'; - -// Create new Capability instance with pre-filled accountId: -var capability = new resources.Capabilities( - stripe, - {accountId: ACCOUNT_TEST_ID} -); - -// Use spy from existing resource: -capability._request = stripe.customers._request; - -describe('Capability Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { - capability.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/capabilities', - data: {}, - headers: {}, - }); - }); - }); - - describe('retrieve', function() { - it('Sends the correct request', function() { - capability.retrieve(CAPABILITY_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/capabilities/' + CAPABILITY_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - capability.update(CAPABILITY_TEST_ID, { - first_name: 'John', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/capabilities/' + CAPABILITY_TEST_ID, - data: {first_name: 'John'}, - headers: {}, - }); - }); - }); -}); - diff --git a/test/resources/ChargeRefunds.spec.js b/test/resources/ChargeRefunds.spec.js deleted file mode 100644 index adc1790f49..0000000000 --- a/test/resources/ChargeRefunds.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var CHARGE_TEST_ID = 'chargeIdTest999'; -var REFUND_TEST_ID = 'refundIdTest999'; - -// Create new CustomerCard instance with pre-filled customerId: -var chargeRefund = new resources.ChargeRefunds( - stripe, - {chargeId: CHARGE_TEST_ID} -); - -// Use spy from existing resource: -chargeRefund._request = stripe.customers._request; - -describe('ChargeRefund Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - chargeRefund.retrieve(REFUND_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/charges/' + CHARGE_TEST_ID + '/refunds/' + REFUND_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('create', function() { - it('Sends the correct request', function() { - chargeRefund.create({ - amount: 100, - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/' + CHARGE_TEST_ID + '/refunds', - data: {amount: 100}, - headers: {}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - chargeRefund.update(REFUND_TEST_ID, { - metadata: {key: 'value'}, - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/' + CHARGE_TEST_ID + '/refunds/' + REFUND_TEST_ID, - data: {metadata: {key: 'value'}}, - headers: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - chargeRefund.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/charges/' + CHARGE_TEST_ID + '/refunds', - data: {}, - headers: {}, - }); - }); - }); -}); diff --git a/test/resources/Charges.spec.js b/test/resources/Charges.spec.js index 6308e82cd0..3c4aa224e7 100644 --- a/test/resources/Charges.spec.js +++ b/test/resources/Charges.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Charge Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Charge Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.charges.retrieve('chargeIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Charge Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.charges.create({ amount: '1500', currency: 'usd', @@ -44,8 +44,8 @@ describe('Charge Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.charges.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -56,8 +56,8 @@ describe('Charge Resource', function() { }); }); - describe('capture', function() { - it('Sends the correct request', function() { + describe('capture', () => { + it('Sends the correct request', () => { stripe.charges.capture('chargeIdExample3242', {amount: 23}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -68,8 +68,8 @@ describe('Charge Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.charges.update('chargeIdExample3242', {description: 'foo321'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -79,132 +79,4 @@ describe('Charge Resource', function() { }); }); }); - - describe('refund', function() { - it('Sends the correct request', function() { - stripe.charges.refund('chargeIdExample3242', {amount: 23}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242/refund', - headers: {}, - data: {amount: 23}, - }); - }); - - it('Incorrect arguments result in an error', function() { - expect( - stripe.charges.refund('chargeIdExample123', 39392) - ).to.be.eventually.rejectedWith(/unknown arguments/i); - - expect( - stripe.charges.refund({potato: 'chargeIdExample123'}) - ).to.be.eventually.rejectedWith(/must be a string, but got: object/i); - - expect( - stripe.charges.refund(442) - ).to.be.eventually.rejectedWith(/must be a string, but got: number/i); - }); - }); - - describe('refunds', function() { - it('Sends the correct update request', function() { - stripe.charges.updateRefund( - 'chargeIdExample3242', - 'refundIdExample2312', - {metadata: {key: 'value'}} - ); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242/refunds/refundIdExample2312', - headers: {}, - data: {metadata: {key: 'value'}}, - }); - }); - - it('Sends the correct create request', function() { - stripe.charges.createRefund( - 'chargeIdExample3242', - {amount: 100} - ); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242/refunds', - headers: {}, - data: {amount: 100}, - }); - }); - - it('Sends the correct list request', function() { - stripe.charges.listRefunds( - 'chargeIdExample3242' - ); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/charges/chargeIdExample3242/refunds', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct retrieve request', function() { - stripe.charges.retrieveRefund( - 'chargeIdExample3242', - 'refundIdExample2312' - ); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/charges/chargeIdExample3242/refunds/refundIdExample2312', - headers: {}, - data: {}, - }); - }); - }); - - describe('updateDispute', function() { - it('Sends the correct request', function() { - stripe.charges.updateDispute('chargeIdExample3242', {evidence: 'foo'}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242/dispute', - headers: {}, - data: {evidence: 'foo'}, - }); - }); - }); - - describe('closeDispute', function() { - it('Sends the correct request', function() { - stripe.charges.closeDispute('chargeIdExample3242', {}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242/dispute/close', - headers: {}, - data: {}, - }); - }); - }); - - describe('markAsFraudulent', function() { - it('Sends the correct request', function() { - stripe.charges.markAsFraudulent('chargeIdExample3242'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242', - data: {'fraud_details': {'user_report': 'fraudulent'}}, - headers: {}, - }); - }); - }); - - describe('markAsSafe', function() { - it('Sends the correct request', function() { - stripe.charges.markAsSafe('chargeIdExample3242'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/charges/chargeIdExample3242', - data: {'fraud_details': {'user_report': 'safe'}}, - headers: {}, - }); - }); - }); }); diff --git a/test/resources/Checkout/Sessions.spec.js b/test/resources/Checkout/Sessions.spec.js index b0268ab786..2ab499b94f 100644 --- a/test/resources/Checkout/Sessions.spec.js +++ b/test/resources/Checkout/Sessions.spec.js @@ -1,14 +1,14 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Checkout', function () { - describe('Sessions Resource', function () { - describe('create', function() { - it('Sends the correct request', function() { - var params = { +describe('Checkout', () => { + describe('Sessions Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { + const params = { cancel_url: 'https://stripe.com/cancel', client_reference_id: '1234', line_items: [ @@ -16,9 +16,7 @@ describe('Checkout', function () { amount: 123, currency: 'usd', description: 'item 1', - images: [ - 'https://stripe.com/img1', - ], + images: ['https://stripe.com/img1'], name: 'name', quantity: 2, }, @@ -40,8 +38,8 @@ describe('Checkout', function () { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.checkout.sessions.retrieve('cs_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/CountrySpecs.spec.js b/test/resources/CountrySpecs.spec.js index b896cdb91d..d5f6252aa4 100644 --- a/test/resources/CountrySpecs.spec.js +++ b/test/resources/CountrySpecs.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('CountrySpecs Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('CountrySpecs Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.countrySpecs.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,13 +16,13 @@ describe('CountrySpecs Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { - var country = 'US'; + describe('retrieve', () => { + it('Sends the correct request', () => { + const country = 'US'; stripe.countrySpecs.retrieve(country); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/country_specs/' + country, + url: `/v1/country_specs/${country}`, data: {}, headers: {}, }); diff --git a/test/resources/Coupons.spec.js b/test/resources/Coupons.spec.js index 199845993e..f906a02d79 100644 --- a/test/resources/Coupons.spec.js +++ b/test/resources/Coupons.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Coupons Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Coupons Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.coupons.retrieve('couponId123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Coupons Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.coupons.del('couponId123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('Coupons Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.coupons.update('couponId123', { metadata: {a: '1234'}, }); @@ -44,8 +44,8 @@ describe('Coupons Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.coupons.create({ percent_off: 25, duration: 'repeating', @@ -65,8 +65,8 @@ describe('Coupons Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.coupons.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/CreditNotes.spec.js b/test/resources/CreditNotes.spec.js index eb76a7aa16..025e01a176 100644 --- a/test/resources/CreditNotes.spec.js +++ b/test/resources/CreditNotes.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('CreditNotes Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('CreditNotes Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.creditNotes.retrieve('cn_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,9 +16,9 @@ describe('CreditNotes Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { - var data = { + describe('create', () => { + it('Sends the correct request', () => { + const data = { amount: 100, invoice: 'in_123', reason: 'duplicate', @@ -28,13 +28,13 @@ describe('CreditNotes Resource', function() { method: 'POST', url: '/v1/credit_notes', headers: {}, - data: data, + data, }); }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.creditNotes.list({count: 25}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -45,8 +45,8 @@ describe('CreditNotes Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.creditNotes.update('cn_123', {application_fee: 200}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -57,14 +57,14 @@ describe('CreditNotes Resource', function() { }); }); - describe('voidCreditNote', function() { - it('Sends the correct request', function() { + describe('voidCreditNote', () => { + it('Sends the correct request', () => { stripe.creditNotes.voidCreditNote('cn_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/credit_notes/cn_123/void', headers: {}, - data: {} + data: {}, }); }); }); diff --git a/test/resources/CustomerCards.spec.js b/test/resources/CustomerCards.spec.js deleted file mode 100644 index 4c9708c472..0000000000 --- a/test/resources/CustomerCards.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var CUSTOMER_TEST_ID = 'customerIdTest999'; - -// Create new CustomerCard instance with pre-filled customerId: -var customerCard = new resources.CustomerCards( - stripe, - {customerId: CUSTOMER_TEST_ID} -); - -// Use spy from existing resource: -customerCard._request = stripe.customers._request; - -describe('CustomerCard Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - customerCard.retrieve('cardIdFoo456'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/cards/cardIdFoo456', - headers: {}, - data: {}, - }); - }); - }); - - describe('create', function() { - it('Sends the correct request', function() { - customerCard.create({ - number: '123456', exp_month: '12', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/cards', - headers: {}, - data: {number: '123456', exp_month: '12'}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - customerCard.update('cardIdFoo456', { - name: 'Bob M. Baz', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/cards/cardIdFoo456', - headers: {}, - data: {name: 'Bob M. Baz'}, - }); - }); - }); - - describe('del', function() { - it('Sends the correct request', function() { - customerCard.del('cardIdFoo456'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/cards/cardIdFoo456', - headers: {}, - data: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - customerCard.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/cards', - headers: {}, - data: {}, - }); - }); - }); -}); diff --git a/test/resources/CustomerSubscriptions.spec.js b/test/resources/CustomerSubscriptions.spec.js deleted file mode 100644 index 461e19e137..0000000000 --- a/test/resources/CustomerSubscriptions.spec.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var CUSTOMER_TEST_ID = 'customerIdTest999'; - -// Create new CustomerSubscription instance with pre-filled customerId: -var customerSubscription = new resources.CustomerSubscriptions( - stripe, - {customerId: CUSTOMER_TEST_ID} -); - -// Use spy from existing resource: -customerSubscription._request = stripe.customers._request; - -describe('CustomerSubscription Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - customerSubscription.retrieve('subscriptionIdFoo456'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/subscriptions/subscriptionIdFoo456', - headers: {}, - data: {}, - }); - }); - }); - - describe('create', function() { - it('Sends the correct request', function() { - customerSubscription.create({ - plan: 'gold', quantity: '12', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/subscriptions', - headers: {}, - data: {plan: 'gold', quantity: '12'}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - customerSubscription.update('subscriptionIdFoo456', { - name: 'Bob M. Baz', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/subscriptions/subscriptionIdFoo456', - headers: {}, - data: {name: 'Bob M. Baz'}, - }); - }); - }); - - describe('del', function() { - it('Sends the correct request', function() { - customerSubscription.del('subscriptionIdFoo456'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/subscriptions/subscriptionIdFoo456', - headers: {}, - data: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - customerSubscription.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/subscriptions', - headers: {}, - data: {}, - }); - }); - }); - - describe('Discount methods', function() { - describe('deleteDiscount', function() { - it('Sends the correct request', function() { - customerSubscription.deleteDiscount('customerIdFoo321', 'subscriptionIdBar654'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/customerIdFoo321/subscriptions/subscriptionIdBar654/discount', - headers: {}, - data: {}, - }); - }); - }); - }); -}); diff --git a/test/resources/Customers.spec.js b/test/resources/Customers.spec.js index c895f740a1..57881bb790 100644 --- a/test/resources/Customers.spec.js +++ b/test/resources/Customers.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; +const TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Customers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Customers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.customers.retrieve('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -17,7 +17,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.retrieve('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -29,8 +29,8 @@ describe('Customers Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.customers.create({description: 'Some customer'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -40,7 +40,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.create({description: 'Some customer'}, TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -51,7 +51,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth and no body]', function() { + it('Sends the correct request [with specified auth and no body]', () => { stripe.customers.create(TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -62,8 +62,11 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified idempotency_key in options]', function() { - stripe.customers.create({description: 'Some customer'}, {idempotency_key: 'foo'}); + it('Sends the correct request [with specified idempotency_key in options]', () => { + stripe.customers.create( + {description: 'Some customer'}, + {idempotency_key: 'foo'} + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/customers', @@ -72,8 +75,11 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth in options]', function() { - stripe.customers.create({description: 'Some customer'}, {api_key: TEST_AUTH_KEY}); + it('Sends the correct request [with specified auth in options]', () => { + stripe.customers.create( + {description: 'Some customer'}, + {api_key: TEST_AUTH_KEY} + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/customers', @@ -83,8 +89,11 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth and idempotent key in options]', function() { - stripe.customers.create({description: 'Some customer'}, {api_key: TEST_AUTH_KEY, idempotency_key: 'foo'}); + it('Sends the correct request [with specified auth and idempotent key in options]', () => { + stripe.customers.create( + {description: 'Some customer'}, + {api_key: TEST_AUTH_KEY, idempotency_key: 'foo'} + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/customers', @@ -94,7 +103,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth in options and no body]', function() { + it('Sends the correct request [with specified auth in options and no body]', () => { stripe.customers.create({api_key: TEST_AUTH_KEY}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -106,8 +115,8 @@ describe('Customers Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.customers.update('cus_123', { description: 'Foo "baz"', }); @@ -120,8 +129,8 @@ describe('Customers Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.customers.del('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -132,8 +141,8 @@ describe('Customers Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.customers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -143,7 +152,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.list(TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -155,86 +164,9 @@ describe('Customers Resource', function() { }); }); - describe('Subscription methods', function() { - describe('updateSubscription', function() { - it('Sends the correct request', function() { - stripe.customers.updateSubscription('cus_123', { - plan: 'fooPlan', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/subscription', - headers: {}, - data: {plan: 'fooPlan'}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.updateSubscription('cus_123', { - plan: 'fooPlan', - }, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/subscription', - headers: {}, - data: {plan: 'fooPlan'}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('cancelSubscription', function() { - it('Sends the correct request', function() { - stripe.customers.cancelSubscription('cus_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscription', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.cancelSubscription('cus_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscription', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - - describe('With at_period_end defined', function() { - it('Sends the correct request', function() { - stripe.customers.cancelSubscription('cus_123', {at_period_end: true}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscription', - headers: {}, - data: {at_period_end: true}, - }); - }); - }); - - describe('With at_period_end defined [with specified auth]', function() { - it('Sends the correct request', function() { - stripe.customers.cancelSubscription('cus_123', {at_period_end: true}, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscription', - headers: {}, - data: {at_period_end: true}, - auth: TEST_AUTH_KEY, - }); - }); - }); - }); - }); - - describe('Discount methods', function() { - describe('deleteDiscount', function() { - it('Sends the correct request', function() { + describe('Discount methods', () => { + describe('deleteDiscount', () => { + it('Sends the correct request', () => { stripe.customers.deleteDiscount('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -244,223 +176,11 @@ describe('Customers Resource', function() { }); }); }); - - describe('deleteSubscriptionDiscount', function() { - it('Sends the correct request', function() { - stripe.customers.deleteSubscriptionDiscount('cus_123', 'sub_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscriptions/sub_123/discount', - headers: {}, - data: {}, - }); - }); - }); - }); - - describe('Metadata methods', function() { - describe('setMetadata', function() { - describe('When deleting metadata', function() { - it('Sends the correct request', function() { - stripe.customers.setMetadata('cus_123', null); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123', - headers: {}, - data: { - metadata: null, - }, - }); - }); - }); - - describe('When setting new metadata', function() { - it('Sends one request to get current, and another to set new data', function() { - return expect(new Promise(function(resolve, reject) { - stripe.customers.setMetadata('cus_123', { - foo: 123, - baz: 456, - }).then(function() { - var reqs = stripe.REQUESTS; - resolve([ - // Last two requests - reqs[reqs.length - 2], - reqs[reqs.length - 1], - ]); - }); - })).to.eventually.deep.equal([ - { - // First reset metadata: - method: 'POST', - url: '/v1/customers/cus_123', - headers: {}, - data: {metadata: null}, - }, - { - // Then set new metadata: - method: 'POST', - url: '/v1/customers/cus_123', - headers: {}, - data: { - metadata: {foo: 123, baz: 456}, - }, - }, - ]); - }); - }); - - describe('When setting with an auth key', function() { - it('Sends the correct request, including the specified auth key', function() { - stripe.customers.setMetadata('cus_123', null, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123', - headers: {}, - data: { - metadata: null, - }, - auth: TEST_AUTH_KEY, - }); - stripe.customers.setMetadata('cus_123', 'a', '1234', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123', - headers: {}, - data: { - metadata: {a: '1234'}, - }, - auth: TEST_AUTH_KEY, - }); - stripe.customers.setMetadata('cus_123', 'a', null, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123', - headers: {}, - data: { - metadata: {a: null}, - }, - auth: TEST_AUTH_KEY, - }); - }); - }); - }); - }); - - describe('Card methods', function() { - describe('retrieveCard', function() { - it('Sends the correct request', function() { - stripe.customers.retrieveCard('cus_123', 'card_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/cards/card_123', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.retrieveCard('cus_123', 'card_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/cards/card_123', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('createCard', function() { - it('Sends the correct request', function() { - stripe.customers.createCard('cus_123', { - number: '123456', exp_month: '12', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/cards', - headers: {}, - data: {number: '123456', exp_month: '12'}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.createCard('cus_123', { - number: '123456', exp_month: '12', - }, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/cards', - headers: {}, - data: {number: '123456', exp_month: '12'}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('updateCard', function() { - it('Sends the correct request', function() { - stripe.customers.updateCard('cus_123', 'card_123', { - name: 'Bob M. Baz', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/cards/card_123', - headers: {}, - data: {name: 'Bob M. Baz'}, - }); - }); - }); - - describe('deleteCard', function() { - it('Sends the correct request', function() { - stripe.customers.deleteCard('cus_123', 'card_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/cards/card_123', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.deleteCard('cus_123', 'card_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/cards/card_123', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('listCards', function() { - it('Sends the correct request', function() { - stripe.customers.listCards('cus_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/cards', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.listCards('cus_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/cards', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - }); }); - describe('Source methods', function() { - describe('retrieveSource', function() { - it('Sends the correct request', function() { + describe('Source methods', () => { + describe('retrieveSource', () => { + it('Sends the correct request', () => { stripe.customers.retrieveSource('cus_123', 'card_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -470,7 +190,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.retrieveSource('cus_123', 'card_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -482,10 +202,12 @@ describe('Customers Resource', function() { }); }); - describe('createSource', function() { - it('Sends the correct request', function() { + describe('createSource', () => { + it('Sends the correct request', () => { stripe.customers.createSource('cus_123', { - object: 'card', number: '123456', exp_month: '12', + object: 'card', + number: '123456', + exp_month: '12', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -495,10 +217,16 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.customers.createSource('cus_123', { - object: 'card', number: '123456', exp_month: '12', - }, TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.customers.createSource( + 'cus_123', + { + object: 'card', + number: '123456', + exp_month: '12', + }, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/customers/cus_123/sources', @@ -509,8 +237,8 @@ describe('Customers Resource', function() { }); }); - describe('updateSource', function() { - it('Sends the correct request', function() { + describe('updateSource', () => { + it('Sends the correct request', () => { stripe.customers.updateSource('cus_123', 'card_123', { name: 'Bob M. Baz', }); @@ -523,8 +251,8 @@ describe('Customers Resource', function() { }); }); - describe('deleteSource', function() { - it('Sends the correct request', function() { + describe('deleteSource', () => { + it('Sends the correct request', () => { stripe.customers.deleteSource('cus_123', 'card_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -534,7 +262,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.deleteSource('cus_123', 'card_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -546,8 +274,8 @@ describe('Customers Resource', function() { }); }); - describe('listSources', function() { - it('Sends the correct request', function() { + describe('listSources', () => { + it('Sends the correct request', () => { stripe.customers.listSources('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -557,7 +285,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.listSources('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -569,180 +297,30 @@ describe('Customers Resource', function() { }); }); - describe('verifySource', function() { - it('Sends the correct request', function() { - var data = {amounts: [32,45]} + describe('verifySource', () => { + it('Sends the correct request', () => { + const data = {amounts: [32, 45]}; - stripe.customers.verifySource('cus_123', 'card_123', data, TEST_AUTH_KEY); + stripe.customers.verifySource( + 'cus_123', + 'card_123', + data, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/customers/cus_123/sources/card_123/verify', headers: {}, - data: data, - auth: TEST_AUTH_KEY, - }) - }); - }); - }); - - describe('Subscription methods', function() { - describe('retrieveSubscription', function() { - it('Sends the correct request', function() { - stripe.customers.retrieveSubscription('cus_123', 'sub_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.retrieveSubscription('cus_123', 'sub_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('createSubscription', function() { - it('Sends the correct request', function() { - stripe.customers.createSubscription('cus_123', { - plan: 'gold', quantity: '12', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/subscriptions', - headers: {}, - data: {plan: 'gold', quantity: '12'}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.createSubscription('cus_123', { - plan: 'gold', quantity: '12', - }, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/subscriptions', - headers: {}, - data: {plan: 'gold', quantity: '12'}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('updateSubscription (new-style api)', function() { - it('Sends the correct request', function() { - stripe.customers.updateSubscription('cus_123', 'sub_123', { - quantity: '2', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {quantity: '2'}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.updateSubscription('cus_123', 'sub_123', { - quantity: '2', - }, TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {quantity: '2'}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('cancelSubscription (new-style api)', function() { - it('Sends the correct request', function() { - stripe.customers.cancelSubscription('cus_123', 'sub_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.cancelSubscription('cus_123', 'sub_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - - describe('With at_period_end defined', function() { - it('Sends the correct request', function() { - stripe.customers.cancelSubscription('cus_123', 'sub_123', {at_period_end: true}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {at_period_end: true}, - }); - }); - }); - - describe('With at_period_end defined [with specified auth]', function() { - it('Sends the correct request', function() { - stripe.customers.cancelSubscription( - 'cus_123', - 'sub_123', - {at_period_end: true}, - TEST_AUTH_KEY - ); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/cus_123/subscriptions/sub_123', - headers: {}, - data: {at_period_end: true}, - auth: TEST_AUTH_KEY, - }); - }); - }); - }); - - describe('listSubscriptions', function() { - it('Sends the correct request', function() { - stripe.customers.listSubscriptions('cus_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/subscriptions', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.customers.listSubscriptions('cus_123', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/cus_123/subscriptions', - headers: {}, - data: {}, + data, auth: TEST_AUTH_KEY, }); }); }); }); - describe('TaxId methods', function() { - describe('retrieveTaxId', function() { - it('Sends the correct request', function() { + describe('TaxId methods', () => { + describe('retrieveTaxId', () => { + it('Sends the correct request', () => { stripe.customers.retrieveTaxId('cus_123', 'txi_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -753,9 +331,9 @@ describe('Customers Resource', function() { }); }); - describe('createTaxId', function() { - it('Sends the correct request', function() { - var data = { + describe('createTaxId', () => { + it('Sends the correct request', () => { + const data = { type: 'eu_vat', value: '11111', }; @@ -764,13 +342,13 @@ describe('Customers Resource', function() { method: 'POST', url: '/v1/customers/cus_123/tax_ids', headers: {}, - data: data, + data, }); }); }); - describe('deleteTaxId', function() { - it('Sends the correct request', function() { + describe('deleteTaxId', () => { + it('Sends the correct request', () => { stripe.customers.deleteTaxId('cus_123', 'txi_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -781,8 +359,8 @@ describe('Customers Resource', function() { }); }); - describe('listTaxIds', function() { - it('Sends the correct request', function() { + describe('listTaxIds', () => { + it('Sends the correct request', () => { stripe.customers.listTaxIds('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Disputes.spec.js b/test/resources/Disputes.spec.js index d227adfe3d..6bee3ed7f8 100644 --- a/test/resources/Disputes.spec.js +++ b/test/resources/Disputes.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Dispute Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Dispute Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.disputes.retrieve('dp_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Dispute Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.disputes.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('Dispute Resource', function() { }); }); - describe('close', function() { - it('Sends the correct request', function() { + describe('close', () => { + it('Sends the correct request', () => { stripe.disputes.close('dp_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -40,8 +40,8 @@ describe('Dispute Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.disputes.update('dp_123', {evidence: {customer_name: 'Bob'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/EphemeralKeys.spec.js b/test/resources/EphemeralKeys.spec.js index 565a066186..1a5a2ca171 100644 --- a/test/resources/EphemeralKeys.spec.js +++ b/test/resources/EphemeralKeys.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; function errorsOnNoStripeVersion() { return expect( @@ -27,9 +27,9 @@ function sendsCorrectStripeVersion() { }); } -describe('EphemeralKey Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('EphemeralKey Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.ephemeralKeys.create( {customer: 'cus_123'}, {stripe_version: '2017-05-25'} @@ -46,7 +46,7 @@ describe('EphemeralKey Resource', function() { }); }); - describe('when an api version is set', function() { + describe('when an api version is set', () => { beforeEach(function() { this.oldVersion = stripe.getApiField('version'); stripe.setApiVersion('2017-05-25'); @@ -56,16 +56,15 @@ describe('EphemeralKey Resource', function() { stripe.setApiVersion(this.oldVersion); }); - it('Errors if no stripe-version is specified', function() { - return errorsOnNoStripeVersion(); - }); + it('Errors if no stripe-version is specified', () => + errorsOnNoStripeVersion()); - it('Sends the correct stripe-version', function() { + it('Sends the correct stripe-version', () => { sendsCorrectStripeVersion(); }); }); - describe('when no api version is set', function() { + describe('when no api version is set', () => { beforeEach(function() { this.oldVersion = stripe.getApiField('version'); stripe.setApiVersion(null); @@ -75,18 +74,17 @@ describe('EphemeralKey Resource', function() { stripe.setApiVersion(this.oldVersion); }); - it('Errors if no stripe-version is specified', function() { - return errorsOnNoStripeVersion(); - }); + it('Errors if no stripe-version is specified', () => + errorsOnNoStripeVersion()); - it('Sends the correct stripe-version', function() { + it('Sends the correct stripe-version', () => { sendsCorrectStripeVersion(); }); }); }); - describe('delete', function() { - it('Sends the correct request', function() { + describe('delete', () => { + it('Sends the correct request', () => { stripe.ephemeralKeys.del('ephkey_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Events.spec.js b/test/resources/Events.spec.js index c5e77fdfdb..28fbe98ed4 100644 --- a/test/resources/Events.spec.js +++ b/test/resources/Events.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Events Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Events Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.events.retrieve('eventIdBaz'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Events Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.events.list({count: 25}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ExchangeRates.spec.js b/test/resources/ExchangeRates.spec.js index 9f7108b77f..233119cd57 100644 --- a/test/resources/ExchangeRates.spec.js +++ b/test/resources/ExchangeRates.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('ExchangeRates Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('ExchangeRates Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.exchangeRates.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,13 +16,13 @@ describe('ExchangeRates Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { - var currency = 'USD'; + describe('retrieve', () => { + it('Sends the correct request', () => { + const currency = 'USD'; stripe.exchangeRates.retrieve(currency); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/exchange_rates/' + currency, + url: `/v1/exchange_rates/${currency}`, data: {}, headers: {}, }); diff --git a/test/resources/FileLinks.spec.js b/test/resources/FileLinks.spec.js index 8bf6677b21..1071d22ec0 100644 --- a/test/resources/FileLinks.spec.js +++ b/test/resources/FileLinks.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('FileLinks Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('FileLinks Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.fileLinks.retrieve('link_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('FileLinks Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.fileLinks.create({file: 'file_123'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -28,8 +28,8 @@ describe('FileLinks Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.fileLinks.update('link_123', {metadata: {key: 'value'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -40,8 +40,8 @@ describe('FileLinks Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.fileLinks.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/FileUploads.spec.js b/test/resources/FileUploads.spec.js deleted file mode 100644 index c8ea6bb6dd..0000000000 --- a/test/resources/FileUploads.spec.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; -var fs = require('fs'); -var path = require('path'); - -var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; - -describe('File Uploads Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - stripe.fileUploads.retrieve('fil_12345'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/files/fil_12345', - headers: {}, - data: {}, - }); - }); - - it('Sends the correct request [with specified auth]', function() { - stripe.fileUploads.retrieve('fil_12345', TEST_AUTH_KEY); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/files/fil_12345', - headers: {}, - data: {}, - auth: TEST_AUTH_KEY, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - stripe.fileUploads.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/files', - headers: {}, - data: {}, - }); - }); - }); - - describe('create', function() { - it('Sends the correct file upload request', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.readFileSync(testFilename); - - stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - file_link_data: {create: true}, - }); - - expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); - expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); - expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); - }); - - it('Sends the correct file upload request [with specified auth]', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.readFileSync(testFilename); - - stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - file_link_data: {create: true}, - }, TEST_AUTH_KEY); - - expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); - expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); - expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); - expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); - }); - - it('Streams a file and sends the correct file upload request', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.createReadStream(testFilename); - - return stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - file_link_data: {create: true}, - }).then(function() { - expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); - expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); - expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); - }); - }); - - it('Streams a file and sends the correct file upload request [with specified auth]', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.createReadStream(testFilename); - - return stripe.fileUploads.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - file_link_data: {create: true}, - }, TEST_AUTH_KEY).then(function() { - expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); - expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); - expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); - expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); - }); - }); - }); -}); diff --git a/test/resources/Files.spec.js b/test/resources/Files.spec.js index 215652cec1..52487ffe07 100644 --- a/test/resources/Files.spec.js +++ b/test/resources/Files.spec.js @@ -1,15 +1,15 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; -var fs = require('fs'); -var path = require('path'); +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; +const fs = require('fs'); +const path = require('path'); -var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; +const TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Files Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Files Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.files.retrieve('fil_12345'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -19,7 +19,7 @@ describe('Files Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.files.retrieve('fil_12345', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -31,8 +31,8 @@ describe('Files Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.files.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -43,10 +43,10 @@ describe('Files Resource', function() { }); }); - describe('create', function() { - it('Sends the correct file upload request', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.readFileSync(testFilename); + describe('create', () => { + it('Sends the correct file upload request', () => { + const testFilename = path.join(__dirname, 'data/minimal.pdf'); + const f = fs.readFileSync(testFilename); stripe.files.create({ purpose: 'dispute_evidence', @@ -63,19 +63,22 @@ describe('Files Resource', function() { expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); }); - it('Sends the correct file upload request [with specified auth]', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.readFileSync(testFilename); + it('Sends the correct file upload request [with specified auth]', () => { + const testFilename = path.join(__dirname, 'data/minimal.pdf'); + const f = fs.readFileSync(testFilename); - stripe.files.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', + stripe.files.create( + { + purpose: 'dispute_evidence', + file: { + data: f, + name: 'minimal.pdf', + type: 'application/octet-stream', + }, + file_link_data: {create: true}, }, - file_link_data: {create: true}, - }, TEST_AUTH_KEY); + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); @@ -83,43 +86,56 @@ describe('Files Resource', function() { expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); }); - it('Streams a file and sends the correct file upload request', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.createReadStream(testFilename); + it('Streams a file and sends the correct file upload request', () => { + const testFilename = path.join(__dirname, 'data/minimal.pdf'); + const f = fs.createReadStream(testFilename); - return stripe.files.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - file_link_data: {create: true}, - }).then(function() { - expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); - expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); - expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); - }); + return stripe.files + .create({ + purpose: 'dispute_evidence', + file: { + data: f, + name: 'minimal.pdf', + type: 'application/octet-stream', + }, + file_link_data: {create: true}, + }) + .then(() => { + expect(stripe.LAST_REQUEST).to.deep.property( + 'host', + 'files.stripe.com' + ); + expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); + expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); + }); }); - it('Streams a file and sends the correct file upload request [with specified auth]', function() { - var testFilename = path.join(__dirname, 'data/minimal.pdf'); - var f = fs.createReadStream(testFilename); + it('Streams a file and sends the correct file upload request [with specified auth]', () => { + const testFilename = path.join(__dirname, 'data/minimal.pdf'); + const f = fs.createReadStream(testFilename); - return stripe.files.create({ - purpose: 'dispute_evidence', - file: { - data: f, - name: 'minimal.pdf', - type: 'application/octet-stream', - }, - file_link_data: {create: true}, - }, TEST_AUTH_KEY).then(function() { - expect(stripe.LAST_REQUEST).to.deep.property('host', 'files.stripe.com'); - expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); - expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); - expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); - }); + return stripe.files + .create( + { + purpose: 'dispute_evidence', + file: { + data: f, + name: 'minimal.pdf', + type: 'application/octet-stream', + }, + file_link_data: {create: true}, + }, + TEST_AUTH_KEY + ) + .then(() => { + expect(stripe.LAST_REQUEST).to.deep.property( + 'host', + 'files.stripe.com' + ); + expect(stripe.LAST_REQUEST).to.deep.property('method', 'POST'); + expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); + expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); + }); }); }); }); diff --git a/test/resources/InvoiceItems.spec.js b/test/resources/InvoiceItems.spec.js index 6a6352968a..61de4fd338 100644 --- a/test/resources/InvoiceItems.spec.js +++ b/test/resources/InvoiceItems.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('InvoiceItems Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('InvoiceItems Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.invoiceItems.retrieve('invoiceItemIdTesting123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.invoiceItems.create({ customer: 'cust_id_888', }); @@ -30,8 +30,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.invoiceItems.update('invoiceItemId1', { amount: 1900, }); @@ -44,8 +44,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.invoiceItems.del('invoiceItemId2'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -56,8 +56,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.invoiceItems.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Invoices.spec.js b/test/resources/Invoices.spec.js index 16b9dd9b68..4a714c40fd 100644 --- a/test/resources/Invoices.spec.js +++ b/test/resources/Invoices.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Invoices Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Invoices Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.invoices.retrieve('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Invoices Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.invoices.create({application_fee: 111}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -28,8 +28,8 @@ describe('Invoices Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.invoices.list({count: 25}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -40,8 +40,8 @@ describe('Invoices Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.invoices.update('in_123', {application_fee: 200}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -52,8 +52,8 @@ describe('Invoices Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.invoices.del('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -64,8 +64,8 @@ describe('Invoices Resource', function() { }); }); - describe('listLineItems', function() { - it('Sends the correct request', function() { + describe('listLineItems', () => { + it('Sends the correct request', () => { stripe.invoices.listLineItems('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -76,8 +76,8 @@ describe('Invoices Resource', function() { }); }); - describe('listUpcomingLineItems', function() { - it('Sends the correct request', function() { + describe('listUpcomingLineItems', () => { + it('Sends the correct request', () => { stripe.invoices.listUpcomingLineItems(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -88,150 +88,72 @@ describe('Invoices Resource', function() { }); }); - describe('retrieveLines', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveLines('in_123'); + describe('retrieveUpcoming', () => { + it('Sends the correct request', () => { + stripe.invoices.retrieveUpcoming({ + customer: 'cus_abc', + subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], + }); + expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/invoices/in_123/lines', + url: '/v1/invoices/upcoming', headers: {}, - data: {}, + data: { + customer: 'cus_abc', + subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], + }, }); }); }); - describe('retrieveUpcoming', function() { - describe('With just a customer ID', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveUpcoming('cus_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/invoices/upcoming?customer=cus_123', - headers: {}, - data: {}, - }); + describe('listUpcomingLineItems', () => { + it('Sends the correct request', () => { + stripe.invoices.listUpcomingLineItems({ + customer: 'cus_abc', + subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], + limit: 5, }); - }); - describe('With a subscription ID in addition to a customer ID', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveUpcoming('cus_123', 'sub_123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/invoices/upcoming?customer=cus_123&subscription=sub_123', - headers: {}, - data: {}, - }); - }); - }); - - describe('With an options object that includes `subscription_items`', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveUpcoming('cus_123', { - subscription_items: [ - {plan: 'potato'}, - {plan: 'rutabaga'}, - ], - }); - - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/invoices/upcoming?customer=cus_123&' + - 'subscription_items[0][plan]=potato&subscription_items[1][plan]=rutabaga', - headers: {}, - data: {}, - }); - }); - }); - - describe('Without a customer id but options', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveUpcoming({ + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/invoices/upcoming/lines', + headers: {}, + data: { customer: 'cus_abc', - subscription_items: [ - {plan: 'potato'}, - {plan: 'rutabaga'}, - ], - }); - - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/invoices/upcoming?customer=cus_abc&' + - 'subscription_items[0][plan]=potato&subscription_items[1][plan]=rutabaga', - headers: {}, - data: {}, - }); - }); - }); - - describe('With an options object that includes `subscription_items` in addition to a subscription ID', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveUpcoming('cus_123', 'sub_123', - { - subscription_items: [ - {plan: 'potato'}, - {plan: 'rutabaga'}, - {id: 'SOME_ID', deleted: true}, - ], - subscription_prorate: true, - }); - - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/invoices/upcoming?customer=cus_123&subscription=sub_123', - headers: {}, - data: { - subscription_items: [ - {plan: 'potato'}, - {plan: 'rutabaga'}, - {id: 'SOME_ID', deleted: true}, - ], - subscription_prorate: true, - }, - }); - }); - }); - - describe('With a options object in addition to a customer ID', function() { - it('Sends the correct request', function() { - stripe.invoices.retrieveUpcoming('cus_123', {plan: 'planId123'}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/invoices/upcoming?customer=cus_123&plan=planId123', - headers: {}, - data: {}, - }); + subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], + limit: 5, + }, }); }); }); - describe('finalizeInvoice', function() { - it('Sends the correct request', function() { + describe('finalizeInvoice', () => { + it('Sends the correct request', () => { stripe.invoices.finalizeInvoice('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/invoices/in_123/finalize', headers: {}, - data: {} + data: {}, }); }); }); - describe('mark uncollectible', function() { - it('Sends the correct request', function() { + describe('mark uncollectible', () => { + it('Sends the correct request', () => { stripe.invoices.markUncollectible('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/invoices/in_123/mark_uncollectible', headers: {}, - data: {} + data: {}, }); }); }); - - describe('pay', function() { - it('Sends the correct request', function() { + describe('pay', () => { + it('Sends the correct request', () => { stripe.invoices.pay('in_123', { source: 'tok_FooBar', }); @@ -244,26 +166,26 @@ describe('Invoices Resource', function() { }); }); - describe('sendInvoice', function() { - it('Sends the correct request', function() { + describe('sendInvoice', () => { + it('Sends the correct request', () => { stripe.invoices.sendInvoice('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/invoices/in_123/send', headers: {}, - data: {} + data: {}, }); }); }); - describe('voidInvoice', function() { - it('Sends the correct request', function() { + describe('voidInvoice', () => { + it('Sends the correct request', () => { stripe.invoices.voidInvoice('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/invoices/in_123/void', headers: {}, - data: {} + data: {}, }); }); }); diff --git a/test/resources/IssuerFraudRecords.spec.js b/test/resources/IssuerFraudRecords.spec.js index 46842348c7..6a4bd87265 100644 --- a/test/resources/IssuerFraudRecords.spec.js +++ b/test/resources/IssuerFraudRecords.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('IssuerFraudRecord Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('IssuerFraudRecord Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuerFraudRecords.retrieve('issfr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('IssuerFraudRecord Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuerFraudRecords.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Issuing/Authorization.spec.js b/test/resources/Issuing/Authorization.spec.js index b4eb56de4c..e58774d59f 100644 --- a/test/resources/Issuing/Authorization.spec.js +++ b/test/resources/Issuing/Authorization.spec.js @@ -1,12 +1,12 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Issuing', function () { - describe('Authorization Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Issuing', () => { + describe('Authorization Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.retrieve('iauth_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -17,8 +17,8 @@ describe('Issuing', function () { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -29,12 +29,12 @@ describe('Issuing', function () { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.update('iauth_123', { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -44,15 +44,15 @@ describe('Issuing', function () { data: { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }, }); }); }); - describe('approve', function() { - it('Sends the correct request', function() { + describe('approve', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.approve('iauth_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -63,8 +63,8 @@ describe('Issuing', function () { }); }); - describe('decline', function() { - it('Sends the correct request', function() { + describe('decline', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.decline('iauth_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Issuing/Cardholders.spec.js b/test/resources/Issuing/Cardholders.spec.js index b854cd592c..16bf3b531b 100644 --- a/test/resources/Issuing/Cardholders.spec.js +++ b/test/resources/Issuing/Cardholders.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Issuing', function () { - describe('Cardholders Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Issuing', () => { + describe('Cardholders Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.retrieve('ich_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.create({ billing: {}, name: 'Tim Testperson', @@ -39,12 +39,12 @@ describe('Issuing', function () { }); }); - describe('update', function () { - it('Sends the correct request', function () { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.update('ich_123', { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -54,15 +54,15 @@ describe('Issuing', function () { data: { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }, }); }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Issuing/Cards.spec.js b/test/resources/Issuing/Cards.spec.js index 8cf312a16c..551667064b 100644 --- a/test/resources/Issuing/Cards.spec.js +++ b/test/resources/Issuing/Cards.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Issuing', function () { - describe('Cards Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Issuing', () => { + describe('Cards Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.cards.retrieve('ic_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.issuing.cards.create({ currency: 'usd', type: 'physical', @@ -37,12 +37,12 @@ describe('Issuing', function () { }); }); - describe('update', function () { - it('Sends the correct request', function () { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.cards.update('ic_123', { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -52,15 +52,15 @@ describe('Issuing', function () { data: { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }, }); }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.cards.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -72,9 +72,9 @@ describe('Issuing', function () { }); }); - describe('Virtual Cards Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { + describe('Virtual Cards Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.cards.retrieveDetails('ic_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ diff --git a/test/resources/Issuing/Disputes.spec.js b/test/resources/Issuing/Disputes.spec.js index dcb5ac6eb2..4ae2d3ac5a 100644 --- a/test/resources/Issuing/Disputes.spec.js +++ b/test/resources/Issuing/Disputes.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Issuing', function () { - describe('Disputes Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Issuing', () => { + describe('Disputes Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.retrieve('idp_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.create({ transaction: 'ipi_123', }); @@ -35,12 +35,12 @@ describe('Issuing', function () { }); }); - describe('update', function () { - it('Sends the correct request', function () { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.update('idp_123', { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -50,15 +50,15 @@ describe('Issuing', function () { data: { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }, }); }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Issuing/Transactions.spec.js b/test/resources/Issuing/Transactions.spec.js index ca44877232..2fa9854d56 100644 --- a/test/resources/Issuing/Transactions.spec.js +++ b/test/resources/Issuing/Transactions.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Issuing', function () { - describe('Transactions Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Issuing', () => { + describe('Transactions Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.transactions.retrieve('ipi_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,12 +19,12 @@ describe('Issuing', function () { }); }); - describe('update', function () { - it('Sends the correct request', function () { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.transactions.update('ipi_123', { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -34,15 +34,15 @@ describe('Issuing', function () { data: { metadata: { thing1: true, - thing2: 'yes' + thing2: 'yes', }, }, }); }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.transactions.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/LoginLinks.spec.js b/test/resources/LoginLinks.spec.js deleted file mode 100644 index b796a4356e..0000000000 --- a/test/resources/LoginLinks.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var ACCOUNT_ID = 'acct_EXPRESS'; - -// Create new LoginLink instance with pre-filled accountId: -var loginLink = new resources.LoginLinks( - stripe, - {accountId: ACCOUNT_ID} -); - -// Use spy from existing resource: -loginLink._request = stripe.customers._request; - -describe('LoginLink Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { - loginLink.create(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/accounts/' + ACCOUNT_ID + '/login_links', - headers: {}, - data: {}, - }); - }); - }); -}); diff --git a/test/resources/OAuth.spec.js b/test/resources/OAuth.spec.js index 5f21e48eea..c04af14f3c 100644 --- a/test/resources/OAuth.spec.js +++ b/test/resources/OAuth.spec.js @@ -1,38 +1,38 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); +const stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; -var URL = require('url'); -var qs = require('qs'); +const expect = require('chai').expect; +const URL = require('url'); +const qs = require('qs'); -describe('OAuth', function() { - describe('authorize', function() { - describe('when a default client_id is set', function() { - beforeEach(function() { +describe('OAuth', () => { + describe('authorize', () => { + describe('when a default client_id is set', () => { + beforeEach(() => { stripe.setClientId('default_client_id'); }); - it('Uses the correct host', function() { - var url = stripe.oauth.authorizeUrl(); + it('Uses the correct host', () => { + const url = stripe.oauth.authorizeUrl(); - var host = URL.parse(url).hostname; + const host = URL.parse(url).hostname; expect(host).to.equal('connect.stripe.com'); }); - it('Uses the correct path', function() { - var url = stripe.oauth.authorizeUrl({state: 'some_state'}); + it('Uses the correct path', () => { + const url = stripe.oauth.authorizeUrl({state: 'some_state'}); - var pathname = URL.parse(url).pathname; + const pathname = URL.parse(url).pathname; expect(pathname).to.equal('/oauth/authorize'); }); - it('Uses the correct query', function() { - var url = stripe.oauth.authorizeUrl({state: 'some_state'}); + it('Uses the correct query', () => { + const url = stripe.oauth.authorizeUrl({state: 'some_state'}); - var query = qs.parse(URL.parse(url).query) + const query = qs.parse(URL.parse(url).query); expect(query.client_id).to.equal('default_client_id'); expect(query.response_type).to.equal('code'); @@ -40,19 +40,19 @@ describe('OAuth', function() { expect(query.state).to.equal('some_state'); }); - it('Uses a provided client_id instead of the default', function() { - var url = stripe.oauth.authorizeUrl({client_id: '123abc'}); + it('Uses a provided client_id instead of the default', () => { + const url = stripe.oauth.authorizeUrl({client_id: '123abc'}); - var query = qs.parse(URL.parse(url).query) + const query = qs.parse(URL.parse(url).query); expect(query.client_id).to.equal('123abc'); }); - describe('for Express account', function() { - it('Uses the correct path', function() { - var url = stripe.oauth.authorizeUrl({}, {express: true}); + describe('for Express account', () => { + it('Uses the correct path', () => { + const url = stripe.oauth.authorizeUrl({}, {express: true}); - var pathname = URL.parse(url).pathname; + const pathname = URL.parse(url).pathname; expect(pathname).to.equal('/express/oauth/authorize'); }); @@ -60,11 +60,11 @@ describe('OAuth', function() { }); }); - describe('token', function() { - it('Sends the correct request', function() { + describe('token', () => { + it('Sends the correct request', () => { stripe.oauth.token({ code: '123abc', - grant_type: 'authorization_code' + grant_type: 'authorization_code', }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -74,18 +74,18 @@ describe('OAuth', function() { headers: {}, data: { code: '123abc', - grant_type: 'authorization_code' + grant_type: 'authorization_code', }, }); }); }); - describe('deauthorize', function() { - beforeEach(function() { + describe('deauthorize', () => { + beforeEach(() => { stripe.setClientId('default_client_id'); }); - it('Sends the correct request without explicit client_id', function() { + it('Sends the correct request without explicit client_id', () => { stripe.oauth.deauthorize({ stripe_user_id: 'some_user_id', }); @@ -97,12 +97,12 @@ describe('OAuth', function() { headers: {}, data: { client_id: stripe.getClientId(), - stripe_user_id: 'some_user_id' + stripe_user_id: 'some_user_id', }, }); }); - it('Sends the correct request with explicit client_id', function() { + it('Sends the correct request with explicit client_id', () => { stripe.oauth.deauthorize({ stripe_user_id: 'some_user_id', client_id: '123abc', @@ -115,7 +115,7 @@ describe('OAuth', function() { headers: {}, data: { client_id: '123abc', - stripe_user_id: 'some_user_id' + stripe_user_id: 'some_user_id', }, }); }); diff --git a/test/resources/OrderReturns.spec.js b/test/resources/OrderReturns.spec.js index 2dff709fe9..f39052edb2 100644 --- a/test/resources/OrderReturns.spec.js +++ b/test/resources/OrderReturns.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('OrderReturn Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('OrderReturn Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.orderReturns.retrieve('orderReturnIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('OrderReturn Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.orderReturns.list({ limit: 3, }); @@ -31,7 +31,7 @@ describe('OrderReturn Resource', function() { }); }); - it('Supports filtering by order', function() { + it('Supports filtering by order', () => { stripe.orderReturns.list({ order: 'orderIdFoo123', }); diff --git a/test/resources/Orders.spec.js b/test/resources/Orders.spec.js index 092d6de8d2..c367271577 100644 --- a/test/resources/Orders.spec.js +++ b/test/resources/Orders.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Order Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Order Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.orders.retrieve('orderIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Order Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.orders.create({ currency: 'usd', items: [ @@ -56,10 +56,10 @@ describe('Order Resource', function() { headers: {}, }); }); - }) + }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.orders.list({ limit: 3, }); @@ -73,7 +73,7 @@ describe('Order Resource', function() { }); }); - it('Supports filtering by status', function() { + it('Supports filtering by status', () => { stripe.orders.list({ status: 'active', }); @@ -88,8 +88,8 @@ describe('Order Resource', function() { }); }); - describe('pay', function() { - it('Sends the correct request', function() { + describe('pay', () => { + it('Sends the correct request', () => { stripe.orders.pay('orderIdFoo3242', { source: 'tok_FooBar', }); @@ -102,12 +102,10 @@ describe('Order Resource', function() { }); }); - describe('returnOrder', function() { - it('Sends the correct request', function() { + describe('returnOrder', () => { + it('Sends the correct request', () => { stripe.orders.returnOrder('orderIdFoo3242', { - items: [ - {parent: 'sku_123'}, - ], + items: [{parent: 'sku_123'}], }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -118,8 +116,8 @@ describe('Order Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.orders.update('orderIdFoo3242', {status: 'fulfilled'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/PaymentIntents.spec.js b/test/resources/PaymentIntents.spec.js index 81f8f2c639..757b900ff5 100644 --- a/test/resources/PaymentIntents.spec.js +++ b/test/resources/PaymentIntents.spec.js @@ -1,14 +1,14 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -var PAYMENT_INTENT_TEST_ID = 'pi_123'; +const PAYMENT_INTENT_TEST_ID = 'pi_123'; -describe('Payment Intents Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { - var params = { +describe('Payment Intents Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { + const params = { amount: 200, currency: 'usd', payment_method_types: ['card'], @@ -23,8 +23,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.paymentIntents.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -35,62 +35,62 @@ describe('Payment Intents Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.paymentIntents.retrieve(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/payment_intents/' + PAYMENT_INTENT_TEST_ID, + url: `/v1/payment_intents/${PAYMENT_INTENT_TEST_ID}`, headers: {}, data: {}, }); }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.paymentIntents.update(PAYMENT_INTENT_TEST_ID, { metadata: {key: 'value'}, }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/payment_intents/' + PAYMENT_INTENT_TEST_ID, + url: `/v1/payment_intents/${PAYMENT_INTENT_TEST_ID}`, headers: {}, data: {metadata: {key: 'value'}}, }); }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.paymentIntents.cancel(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/payment_intents/' + PAYMENT_INTENT_TEST_ID + '/cancel', + url: `/v1/payment_intents/${PAYMENT_INTENT_TEST_ID}/cancel`, headers: {}, data: {}, }); }); }); - describe('capture', function() { - it('Sends the correct request', function() { + describe('capture', () => { + it('Sends the correct request', () => { stripe.paymentIntents.capture(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/payment_intents/' + PAYMENT_INTENT_TEST_ID + '/capture', + url: `/v1/payment_intents/${PAYMENT_INTENT_TEST_ID}/capture`, headers: {}, data: {}, }); }); }); - describe('confirm', function() { - it('Sends the correct request', function() { + describe('confirm', () => { + it('Sends the correct request', () => { stripe.paymentIntents.confirm(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/payment_intents/' + PAYMENT_INTENT_TEST_ID + '/confirm', + url: `/v1/payment_intents/${PAYMENT_INTENT_TEST_ID}/confirm`, headers: {}, data: {}, }); diff --git a/test/resources/PaymentMethods.spec.js b/test/resources/PaymentMethods.spec.js index 8106dce73b..0860c1cb45 100644 --- a/test/resources/PaymentMethods.spec.js +++ b/test/resources/PaymentMethods.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('PaymentMethods Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('PaymentMethods Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.paymentMethods.retrieve('pm_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,9 +16,9 @@ describe('PaymentMethods Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { - var data = { + describe('create', () => { + it('Sends the correct request', () => { + const data = { type: 'card', }; stripe.paymentMethods.create(data); @@ -26,14 +26,14 @@ describe('PaymentMethods Resource', function() { method: 'POST', url: '/v1/payment_methods', headers: {}, - data: data, + data, }); }); }); - describe('list', function() { - it('Sends the correct request', function() { - var data = { + describe('list', () => { + it('Sends the correct request', () => { + const data = { customer: 'cus_123', type: 'card', }; @@ -42,14 +42,14 @@ describe('PaymentMethods Resource', function() { method: 'GET', url: '/v1/payment_methods', headers: {}, - data: data, + data, }); }); }); - describe('update', function() { - it('Sends the correct request', function() { - var data = { + describe('update', () => { + it('Sends the correct request', () => { + const data = { metadata: {key: 'value'}, }; stripe.paymentMethods.update('pm_123', data); @@ -57,31 +57,31 @@ describe('PaymentMethods Resource', function() { method: 'POST', url: '/v1/payment_methods/pm_123', headers: {}, - data: data, + data, }); }); }); - describe('attach', function() { - it('Sends the correct request', function() { + describe('attach', () => { + it('Sends the correct request', () => { stripe.paymentMethods.attach('pm_123', {customer: 'cus_123'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/payment_methods/pm_123/attach', headers: {}, - data: {customer: 'cus_123'} + data: {customer: 'cus_123'}, }); }); }); - describe('detach', function() { - it('Sends the correct request', function() { + describe('detach', () => { + it('Sends the correct request', () => { stripe.paymentMethods.detach('pm_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/payment_methods/pm_123/detach', headers: {}, - data: {} + data: {}, }); }); }); diff --git a/test/resources/Payouts.spec.js b/test/resources/Payouts.spec.js index 9d4f92b648..6db0f5a387 100644 --- a/test/resources/Payouts.spec.js +++ b/test/resources/Payouts.spec.js @@ -1,27 +1,28 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -var PAYOUT_TEST_ID = 'po_testid1'; +const PAYOUT_TEST_ID = 'po_testid1'; -describe('Payouts Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Payouts Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.payouts.retrieve(PAYOUT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/payouts/' + PAYOUT_TEST_ID, + url: `/v1/payouts/${PAYOUT_TEST_ID}`, headers: {}, data: {}, }); }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.payouts.create({ - amount: 200, currency: 'usd', + amount: 200, + currency: 'usd', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -32,34 +33,34 @@ describe('Payouts Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.payouts.update(PAYOUT_TEST_ID, { metadata: {key: 'value'}, }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/payouts/' + PAYOUT_TEST_ID, + url: `/v1/payouts/${PAYOUT_TEST_ID}`, headers: {}, data: {metadata: {key: 'value'}}, }); }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.payouts.cancel(PAYOUT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/payouts/' + PAYOUT_TEST_ID + '/cancel', + url: `/v1/payouts/${PAYOUT_TEST_ID}/cancel`, headers: {}, data: {}, }); }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.payouts.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -69,16 +70,4 @@ describe('Payouts Resource', function() { }); }); }); - - describe('listTransactions', function() { - it('Sends the correct request', function() { - stripe.payouts.listTransactions(PAYOUT_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/payouts/' + PAYOUT_TEST_ID + '/transactions', - headers: {}, - data: {}, - }); - }); - }); }); diff --git a/test/resources/Persons.spec.js b/test/resources/Persons.spec.js deleted file mode 100644 index 0a355d0ad8..0000000000 --- a/test/resources/Persons.spec.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var ACCOUNT_TEST_ID = 'acct_123'; -var PERSON_TEST_ID = 'person_123'; - -// Create new Person instance with pre-filled accountId: -var person = new resources.Persons( - stripe, - {accountId: ACCOUNT_TEST_ID} -); - -// Use spy from existing resource: -person._request = stripe.customers._request; - -describe('Person Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { - person.create({ - first_name: 'John', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/persons', - data: {first_name: 'John'}, - headers: {}, - }); - }); - }); - - describe('delete', function() { - it('Sends the correct request', function() { - person.del(PERSON_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/persons/' + PERSON_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - person.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/persons', - data: {}, - headers: {}, - }); - }); - }); - - describe('retrieve', function() { - it('Sends the correct request', function() { - person.retrieve(PERSON_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/persons/' + PERSON_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - person.update(PERSON_TEST_ID, { - first_name: 'John', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/persons/' + PERSON_TEST_ID, - data: {first_name: 'John'}, - headers: {}, - }); - }); - }); -}); - diff --git a/test/resources/Plans.spec.js b/test/resources/Plans.spec.js index d231ddb6b6..85f9226fdc 100644 --- a/test/resources/Plans.spec.js +++ b/test/resources/Plans.spec.js @@ -1,55 +1,55 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Plans Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Plans Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.plans.retrieve('planId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/plans/planId1', headers: {}, - data: {} + data: {}, }); }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.plans.create({ amount: 200, - currency: 'usd' + currency: 'usd', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/plans', headers: {}, - data: {amount: 200, currency: 'usd'} + data: {amount: 200, currency: 'usd'}, }); }); - it('Sends the correct request for metered', function() { + it('Sends the correct request for metered', () => { stripe.plans.create({ amount: 200, currency: 'usd', - usage_type: 'metered' + usage_type: 'metered', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/plans', headers: {}, - data: {amount: 200, currency: 'usd', usage_type: 'metered'} + data: {amount: 200, currency: 'usd', usage_type: 'metered'}, }); }); - it('Sends the correct request for tiered plans', function() { + it('Sends the correct request for tiered plans', () => { stripe.plans.create({ currency: 'usd', billing_scheme: 'tiered', tiers: [{up_to: 123, amount: 100}, {up_to: 'inf', amount: 200}], - tiers_mode: 'volume' + tiers_mode: 'volume', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -59,16 +59,16 @@ describe('Plans Resource', function() { currency: 'usd', billing_scheme: 'tiered', tiers: [{up_to: 123, amount: 100}, {up_to: 'inf', amount: 200}], - tiers_mode: 'volume' - } + tiers_mode: 'volume', + }, }); }); - it('Sends the correct request for transform usage plans', function() { + it('Sends the correct request for transform usage plans', () => { stripe.plans.create({ amount: 200, currency: 'usd', - transform_usage: {divide_by: 123, round: 'up'} + transform_usage: {divide_by: 123, round: 'up'}, }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -77,47 +77,47 @@ describe('Plans Resource', function() { data: { amount: 200, currency: 'usd', - transform_usage: {divide_by: 123, round: 'up'} - } + transform_usage: {divide_by: 123, round: 'up'}, + }, }); }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.plans.update('planId3', { amount: 1900, - currency: 'usd' + currency: 'usd', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/plans/planId3', headers: {}, - data: {amount: 1900, currency: 'usd'} + data: {amount: 1900, currency: 'usd'}, }); }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.plans.del('planId4'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', url: '/v1/plans/planId4', headers: {}, - data: {} + data: {}, }); }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.plans.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/plans', headers: {}, - data: {} + data: {}, }); }); }); diff --git a/test/resources/Products.spec.js b/test/resources/Products.spec.js index 274f82ecac..21c6193521 100644 --- a/test/resources/Products.spec.js +++ b/test/resources/Products.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Product Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Product Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.products.retrieve('productIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Product Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.products.create({ name: 'Llamas', active: true, @@ -34,10 +34,10 @@ describe('Product Resource', function() { headers: {}, }); }); - }) + }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.products.list({ limit: 3, }); @@ -51,7 +51,7 @@ describe('Product Resource', function() { }); }); - it('Supports filtering by shippable', function() { + it('Supports filtering by shippable', () => { stripe.products.list({ shippable: true, }); @@ -66,8 +66,8 @@ describe('Product Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.products.update('productIdFoo3242', {caption: 'test'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -78,8 +78,8 @@ describe('Product Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.products.del('productIdFoo3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Radar/ValueListItems.spec.js b/test/resources/Radar/ValueListItems.spec.js index 3ce40f3e17..286ef956ba 100644 --- a/test/resources/Radar/ValueListItems.spec.js +++ b/test/resources/Radar/ValueListItems.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Radar', function () { - describe('ValueLists Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Radar', () => { + describe('ValueLists Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.retrieve('rsli_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Radar', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.create({ value_list: 'rsl_123', value: 'value', @@ -37,8 +37,8 @@ describe('Radar', function () { }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.list({ value_list: 'rsl_123', }); @@ -53,8 +53,8 @@ describe('Radar', function () { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.del('rsli_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Radar/ValueLists.spec.js b/test/resources/Radar/ValueLists.spec.js index 8c3743af5e..57c778257e 100644 --- a/test/resources/Radar/ValueLists.spec.js +++ b/test/resources/Radar/ValueLists.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Radar', function () { - describe('ValueLists Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Radar', () => { + describe('ValueLists Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.retrieve('rsl_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Radar', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.create({ alias: 'alias', name: 'name', @@ -37,8 +37,8 @@ describe('Radar', function () { }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -49,8 +49,8 @@ describe('Radar', function () { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.del('rsl_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -61,8 +61,8 @@ describe('Radar', function () { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.update('rsl_123', { metadata: {a: '1234'}, }); diff --git a/test/resources/RecipientCards.spec.js b/test/resources/RecipientCards.spec.js deleted file mode 100644 index 85475fd93a..0000000000 --- a/test/resources/RecipientCards.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var RECIPIENT_TEST_ID = 'recipientIdTest999'; - -// Create new recipientCard instance with pre-filled recipientId: -var recipientCard = new resources.RecipientCards( - stripe, - {recipientId: RECIPIENT_TEST_ID} -); - -// Use spy from existing resource: -recipientCard._request = stripe.recipients._request; - -describe('RecipientCard Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - recipientCard.retrieve('cardIdFoo456'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/recipients/' + RECIPIENT_TEST_ID + '/cards/cardIdFoo456', - headers: {}, - data: {}, - }); - }); - }); - - describe('create', function() { - it('Sends the correct request', function() { - recipientCard.create({ - number: '123456', exp_month: '12', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/recipients/' + RECIPIENT_TEST_ID + '/cards', - headers: {}, - data: {number: '123456', exp_month: '12'}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - recipientCard.update('cardIdFoo456', { - name: 'Bob M. Baz', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/recipients/' + RECIPIENT_TEST_ID + '/cards/cardIdFoo456', - headers: {}, - data: {name: 'Bob M. Baz'}, - }); - }); - }); - - describe('del', function() { - it('Sends the correct request', function() { - recipientCard.del('cardIdFoo456'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/recipients/' + RECIPIENT_TEST_ID + '/cards/cardIdFoo456', - headers: {}, - data: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - recipientCard.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/recipients/' + RECIPIENT_TEST_ID + '/cards', - headers: {}, - data: {}, - }); - }); - }); -}); diff --git a/test/resources/Recipients.spec.js b/test/resources/Recipients.spec.js index 51350d079b..8ee3f33fe1 100644 --- a/test/resources/Recipients.spec.js +++ b/test/resources/Recipients.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; +const TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Recipients Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Recipients Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.recipients.retrieve('recipientId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -18,10 +18,11 @@ describe('Recipients Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.recipients.create({ - name: 'Bob', type: 'individual', + name: 'Bob', + type: 'individual', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -32,8 +33,8 @@ describe('Recipients Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.recipients.update('recipientId3', { name: 'Bob Smith', }); @@ -46,8 +47,8 @@ describe('Recipients Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.recipients.del('recipientId4'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -58,8 +59,8 @@ describe('Recipients Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.recipients.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -70,9 +71,9 @@ describe('Recipients Resource', function() { }); }); - describe('Card methods', function() { - describe('retrieveCard', function() { - it('Sends the correct request', function() { + describe('Card methods', () => { + describe('retrieveCard', () => { + it('Sends the correct request', () => { stripe.recipients.retrieveCard('recipientIdFoo321', 'cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -82,8 +83,12 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.recipients.retrieveCard('recipientIdFoo321', 'cardIdFoo456', TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.recipients.retrieveCard( + 'recipientIdFoo321', + 'cardIdFoo456', + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/recipients/recipientIdFoo321/cards/cardIdFoo456', @@ -94,10 +99,11 @@ describe('Recipients Resource', function() { }); }); - describe('createCard', function() { - it('Sends the correct request', function() { + describe('createCard', () => { + it('Sends the correct request', () => { stripe.recipients.createCard('recipientIdFoo321', { - number: '123456', exp_month: '12', + number: '123456', + exp_month: '12', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -107,10 +113,15 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.recipients.createCard('recipientIdFoo321', { - number: '123456', exp_month: '12', - }, TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.recipients.createCard( + 'recipientIdFoo321', + { + number: '123456', + exp_month: '12', + }, + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/recipients/recipientIdFoo321/cards', @@ -121,8 +132,8 @@ describe('Recipients Resource', function() { }); }); - describe('updateCard', function() { - it('Sends the correct request', function() { + describe('updateCard', () => { + it('Sends the correct request', () => { stripe.recipients.updateCard('recipientIdFoo321', 'cardIdFoo456', { name: 'Bob M. Baz', }); @@ -135,8 +146,8 @@ describe('Recipients Resource', function() { }); }); - describe('deleteCard', function() { - it('Sends the correct request', function() { + describe('deleteCard', () => { + it('Sends the correct request', () => { stripe.recipients.deleteCard('recipientIdFoo321', 'cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -146,8 +157,12 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { - stripe.recipients.deleteCard('recipientIdFoo321', 'cardIdFoo456', TEST_AUTH_KEY); + it('Sends the correct request [with specified auth]', () => { + stripe.recipients.deleteCard( + 'recipientIdFoo321', + 'cardIdFoo456', + TEST_AUTH_KEY + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', url: '/v1/recipients/recipientIdFoo321/cards/cardIdFoo456', @@ -158,8 +173,8 @@ describe('Recipients Resource', function() { }); }); - describe('listCards', function() { - it('Sends the correct request', function() { + describe('listCards', () => { + it('Sends the correct request', () => { stripe.recipients.listCards('recipientIdFoo321'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -169,7 +184,7 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.recipients.listCards('recipientIdFoo321', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Refunds.spec.js b/test/resources/Refunds.spec.js index f47550f01b..843477d149 100644 --- a/test/resources/Refunds.spec.js +++ b/test/resources/Refunds.spec.js @@ -1,15 +1,15 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Refund Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Refund Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.refunds.create({ amount: '300', charge: 'ch_123', - }) + }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -23,8 +23,8 @@ describe('Refund Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.refunds.retrieve('re_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -35,8 +35,8 @@ describe('Refund Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.refunds.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -47,8 +47,8 @@ describe('Refund Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.refunds.update('re_123', {metadata: {key: 'abcd'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Reporting/ReportRuns.spec.js b/test/resources/Reporting/ReportRuns.spec.js index fa6cb522cc..dd83a00854 100644 --- a/test/resources/Reporting/ReportRuns.spec.js +++ b/test/resources/Reporting/ReportRuns.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Reporting', function () { - describe('ReportRuns Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Reporting', () => { + describe('ReportRuns Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.reporting.reportRuns.retrieve('frr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Reporting', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.reporting.reportRuns.create({ parameters: { connected_account: 'acct_123', @@ -41,8 +41,8 @@ describe('Reporting', function () { }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.reporting.reportRuns.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Reporting/ReportTypes.spec.js b/test/resources/Reporting/ReportTypes.spec.js index 75b99d4d60..37e7bd3134 100644 --- a/test/resources/Reporting/ReportTypes.spec.js +++ b/test/resources/Reporting/ReportTypes.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Reporting', function () { - describe('ReportTypes Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Reporting', () => { + describe('ReportTypes Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.reporting.reportTypes.retrieve('activity.summary.1'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Reporting', function () { }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.reporting.reportTypes.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Reviews.spec.js b/test/resources/Reviews.spec.js index 850473afec..03296088aa 100644 --- a/test/resources/Reviews.spec.js +++ b/test/resources/Reviews.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Review Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Review Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.reviews.retrieve('prv_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Review Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.reviews.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('Review Resource', function() { }); }); - describe('approve', function() { - it('Sends the correct request', function() { + describe('approve', () => { + it('Sends the correct request', () => { stripe.reviews.approve('prv_123', {amount: 23}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/SKUs.spec.js b/test/resources/SKUs.spec.js index 24ce99437d..5155d8fec8 100644 --- a/test/resources/SKUs.spec.js +++ b/test/resources/SKUs.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('SKU Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('SKU Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.skus.retrieve('skuIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('SKU Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.skus.create({ currency: 'usd', inventory: {type: 'finite', quantity: 500}, @@ -38,10 +38,10 @@ describe('SKU Resource', function() { headers: {}, }); }); - }) + }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.skus.list({ limit: 3, }); @@ -55,7 +55,7 @@ describe('SKU Resource', function() { }); }); - it('Supports filtering by product', function() { + it('Supports filtering by product', () => { stripe.skus.list({ product: 'prodId123', }); @@ -70,8 +70,8 @@ describe('SKU Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.skus.update('skuIdFoo3242', {caption: 'test'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -82,8 +82,8 @@ describe('SKU Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.skus.del('skuIdFoo3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Sigma/ScheduledQueryRuns.spec.js b/test/resources/Sigma/ScheduledQueryRuns.spec.js index 88e81ce2b1..710762d8e0 100644 --- a/test/resources/Sigma/ScheduledQueryRuns.spec.js +++ b/test/resources/Sigma/ScheduledQueryRuns.spec.js @@ -1,12 +1,12 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Sigma', function () { - describe('ScheduledQueryRun Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Sigma', () => { + describe('ScheduledQueryRun Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.sigma.scheduledQueryRuns.retrieve('sqr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -17,8 +17,8 @@ describe('Sigma', function () { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.sigma.scheduledQueryRuns.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Sources.spec.js b/test/resources/Sources.spec.js index 51d7111539..89da485560 100644 --- a/test/resources/Sources.spec.js +++ b/test/resources/Sources.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Sources Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Sources Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.sources.retrieve('sourceId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Sources Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.sources.create({ amount: 200, currency: 'usd', @@ -46,8 +46,8 @@ describe('Sources Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.sources.update('src_foo', { metadata: {foo: 'bar'}, }); @@ -60,8 +60,8 @@ describe('Sources Resource', function() { }); }); - describe('listSourceTransactions', function() { - it('Sends the correct request', function() { + describe('listSourceTransactions', () => { + it('Sends the correct request', () => { stripe.sources.listSourceTransactions('src_foo'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -72,8 +72,8 @@ describe('Sources Resource', function() { }); }); - describe('verify', function() { - it('Sends the correct request', function() { + describe('verify', () => { + it('Sends the correct request', () => { stripe.sources.verify('src_foo', {values: [32, 45]}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/SubscriptionItems.spec.js b/test/resources/SubscriptionItems.spec.js index 76b1c598b3..73e59d58c2 100644 --- a/test/resources/SubscriptionItems.spec.js +++ b/test/resources/SubscriptionItems.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('SubscriptionItems Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('SubscriptionItems Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.retrieve('test_sub_item'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.del('test_sub_item'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.update('test_sub_item', { plan: 'gold', }); @@ -44,8 +44,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.create({ subscription: 'test_sub', plan: 'gold', @@ -63,8 +63,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.list({ limit: 3, subscription: 'test_sub', diff --git a/test/resources/SubscriptionSchedule.spec.js b/test/resources/SubscriptionSchedule.spec.js index b38246c129..68107b3382 100644 --- a/test/resources/SubscriptionSchedule.spec.js +++ b/test/resources/SubscriptionSchedule.spec.js @@ -1,44 +1,44 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -var SCHEDULE_TEST_ID = 'sub_sched_123'; -var REVISION_TEST_ID = 'sub_sched_rev_123'; +const SCHEDULE_TEST_ID = 'sub_sched_123'; +const REVISION_TEST_ID = 'sub_sched_rev_123'; -describe('Subscription Schedule Resource', function() { - describe('cancel', function() { - it('Sends the correct request', function() { - var data = { +describe('Subscription Schedule Resource', () => { + describe('cancel', () => { + it('Sends the correct request', () => { + const data = { invoice_now: true, - } + }; stripe.subscriptionSchedules.cancel(SCHEDULE_TEST_ID, data); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID + '/cancel', - data: data, + url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}/cancel`, + data, headers: {}, }); }); }); - describe('create', function() { - it('Sends the correct request', function() { - var data = { + describe('create', () => { + it('Sends the correct request', () => { + const data = { customer: 'cus_123', }; stripe.subscriptionSchedules.create(data); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/subscription_schedules', - data: data, + data, headers: {}, }); }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -49,23 +49,23 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('release', function() { - it('Sends the correct request', function() { - var data = { + describe('release', () => { + it('Sends the correct request', () => { + const data = { preserve_cancel_date: true, - } + }; stripe.subscriptionSchedules.release(SCHEDULE_TEST_ID, data); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID + '/release', - data: data, + url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}/release`, + data, headers: {}, }); }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.retrieve(SCHEDULE_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -76,38 +76,41 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { - var data = {metadata: {key: 'value'}}; + describe('update', () => { + it('Sends the correct request', () => { + const data = {metadata: {key: 'value'}}; stripe.subscriptionSchedules.update(SCHEDULE_TEST_ID, data); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID, - data: data, + url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}`, + data, headers: {}, }); }); }); - describe('Revision methods', function() { - describe('retrieveRevision', function() { - it('Sends the correct request', function() { - stripe.subscriptionSchedules.retrieveRevision(SCHEDULE_TEST_ID, REVISION_TEST_ID); + describe('Revision methods', () => { + describe('retrieveRevision', () => { + it('Sends the correct request', () => { + stripe.subscriptionSchedules.retrieveRevision( + SCHEDULE_TEST_ID, + REVISION_TEST_ID + ); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID + '/revisions/' + REVISION_TEST_ID, + url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}/revisions/${REVISION_TEST_ID}`, headers: {}, data: {}, }); }); }); - describe('listRevisions', function() { - it('Sends the correct request', function() { + describe('listRevisions', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.listRevisions(SCHEDULE_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID + '/revisions', + url: `/v1/subscription_schedules/${SCHEDULE_TEST_ID}/revisions`, headers: {}, data: {}, }); diff --git a/test/resources/SubscriptionScheduleRevision.spec.js b/test/resources/SubscriptionScheduleRevision.spec.js deleted file mode 100644 index bbc76a5e1b..0000000000 --- a/test/resources/SubscriptionScheduleRevision.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var SCHEDULE_TEST_ID = 'sub_sched_123'; -var REVISION_TEST_ID = 'sub_sched_rev_123'; - -// Create new SubscriptionScheduleRevision instance with pre-filled scheduleId: -var revision = new resources.SubscriptionScheduleRevisions( - stripe, - {scheduleId: SCHEDULE_TEST_ID} -); - -// Use spy from existing resource: -revision._request = stripe.customers._request; - -describe('SubscriptionScheduleRevision Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { - revision.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID + '/revisions', - data: {}, - headers: {}, - }); - }); - }); - - describe('retrieve', function() { - it('Sends the correct request', function() { - revision.retrieve(REVISION_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/subscription_schedules/' + SCHEDULE_TEST_ID + '/revisions/' + REVISION_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); -}); - diff --git a/test/resources/Subscriptions.spec.js b/test/resources/Subscriptions.spec.js index 8e732dab61..d1f7631295 100644 --- a/test/resources/Subscriptions.spec.js +++ b/test/resources/Subscriptions.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('subscriptions Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('subscriptions Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.subscriptions.retrieve('test_sub'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('subscriptions Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.subscriptions.del('test_sub'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('subscriptions Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.subscriptions.update('test_sub', { metadata: {a: '1234'}, }); @@ -44,8 +44,8 @@ describe('subscriptions Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.subscriptions.create({ customer: 'test_cus', plan: 'gold', @@ -63,8 +63,8 @@ describe('subscriptions Resource', function() { }); }); - describe('update with items array', function() { - it('Sends the correct request', function() { + describe('update with items array', () => { + it('Sends the correct request', () => { stripe.subscriptions.update('test_sub', { items: [ { @@ -89,8 +89,8 @@ describe('subscriptions Resource', function() { }); }); - describe('create with items array', function() { - it('Sends the correct request', function() { + describe('create with items array', () => { + it('Sends the correct request', () => { stripe.subscriptions.create({ items: [ { @@ -116,8 +116,8 @@ describe('subscriptions Resource', function() { }); }); - describe('update with items object', function() { - it('Sends the correct request', function() { + describe('update with items object', () => { + it('Sends the correct request', () => { stripe.subscriptions.update('test_sub', { items: { '0': { @@ -133,8 +133,8 @@ describe('subscriptions Resource', function() { data: { items: { '0': { - 'plan': 'foo', - 'quantity': 2, + plan: 'foo', + quantity: 2, }, }, }, @@ -142,8 +142,8 @@ describe('subscriptions Resource', function() { }); }); - describe('create with items object', function() { - it('Sends the correct request', function() { + describe('create with items object', () => { + it('Sends the correct request', () => { stripe.subscriptions.create({ items: { '0': { @@ -160,8 +160,8 @@ describe('subscriptions Resource', function() { data: { items: { '0': { - 'plan': 'foo', - 'quantity': 2, + plan: 'foo', + quantity: 2, }, }, }, @@ -169,8 +169,8 @@ describe('subscriptions Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.subscriptions.list({ limit: 3, customer: 'test_cus', @@ -189,9 +189,9 @@ describe('subscriptions Resource', function() { }); }); - describe('Discount methods', function() { - describe('deleteDiscount', function() { - it('Sends the correct request', function() { + describe('Discount methods', () => { + describe('deleteDiscount', () => { + it('Sends the correct request', () => { stripe.subscriptions.deleteDiscount('test_sub'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/TaxIds.spec.js b/test/resources/TaxIds.spec.js deleted file mode 100644 index 4de4cf2804..0000000000 --- a/test/resources/TaxIds.spec.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var CUSTOMER_TEST_ID = 'cus_123'; -var TAX_ID_TEST_ID = 'txi_123'; - -var taxId = new resources.TaxIds( - stripe, - {customerId: CUSTOMER_TEST_ID} -); - -// Use spy from existing resource: -taxId._request = stripe.customers._request; - -describe('TaxId Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { - var data = { - type: 'eu_vat', - value: '11111', - }; - taxId.create(data); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/tax_ids', - data: data, - headers: {}, - }); - }); - }); - - describe('delete', function() { - it('Sends the correct request', function() { - taxId.del(TAX_ID_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/tax_ids/' + TAX_ID_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - taxId.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/tax_ids', - data: {}, - headers: {}, - }); - }); - }); - - describe('retrieve', function() { - it('Sends the correct request', function() { - taxId.retrieve(TAX_ID_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/customers/' + CUSTOMER_TEST_ID + '/tax_ids/' + TAX_ID_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); -}); diff --git a/test/resources/TaxRates.spec.js b/test/resources/TaxRates.spec.js index 74e931b29b..65afc211b3 100644 --- a/test/resources/TaxRates.spec.js +++ b/test/resources/TaxRates.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('TaxRates Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('TaxRates Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.taxRates.retrieve('txr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,9 +16,9 @@ describe('TaxRates Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { - var data = { + describe('update', () => { + it('Sends the correct request', () => { + const data = { metadata: {a: '1234'}, }; stripe.taxRates.update('txr_123', data); @@ -26,14 +26,14 @@ describe('TaxRates Resource', function() { method: 'POST', url: '/v1/tax_rates/txr_123', headers: {}, - data: data, + data, }); }); }); - describe('create', function() { - it('Sends the correct request', function() { - var data = { + describe('create', () => { + it('Sends the correct request', () => { + const data = { display_name: 'name', inclusive: false, percentage: 10.15, @@ -44,13 +44,13 @@ describe('TaxRates Resource', function() { method: 'POST', url: '/v1/tax_rates', headers: {}, - data: data, + data, }); }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.taxRates.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Terminal/ConnectionTokens.spec.js b/test/resources/Terminal/ConnectionTokens.spec.js index b0a58510ba..2fa3a23845 100644 --- a/test/resources/Terminal/ConnectionTokens.spec.js +++ b/test/resources/Terminal/ConnectionTokens.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Terminal', function() { - describe('ConnectionToken Resource', function () { - describe('create', function() { - it('Sends the correct request', function () { +describe('Terminal', () => { + describe('ConnectionToken Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.terminal.connectionTokens.create({}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Terminal/Locations.spec.js b/test/resources/Terminal/Locations.spec.js index bc6f7b41ae..9ed65d5f8b 100644 --- a/test/resources/Terminal/Locations.spec.js +++ b/test/resources/Terminal/Locations.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Terminal', function () { - describe('Locations Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Terminal', () => { + describe('Locations Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.terminal.locations.retrieve('loc_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Terminal', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.terminal.locations.create({ display_name: 'name', address: { @@ -49,8 +49,8 @@ describe('Terminal', function () { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.terminal.locations.del('loc_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -61,10 +61,10 @@ describe('Terminal', function () { }); }); - describe('update', function () { - it('Sends the correct request', function () { + describe('update', () => { + it('Sends the correct request', () => { stripe.terminal.locations.update('loc_123', { - display_name: 'name' + display_name: 'name', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -77,8 +77,8 @@ describe('Terminal', function () { }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.terminal.locations.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Terminal/Readers.spec.js b/test/resources/Terminal/Readers.spec.js index c3739c2b39..f4bd88fb90 100644 --- a/test/resources/Terminal/Readers.spec.js +++ b/test/resources/Terminal/Readers.spec.js @@ -1,13 +1,13 @@ 'use strict'; -var stripe = require('../../../testUtils').getSpyableStripe(); +const stripe = require('../../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const expect = require('chai').expect; -describe('Terminal', function () { - describe('Readers Resource', function () { - describe('retrieve', function () { - it('Sends the correct request', function () { +describe('Terminal', () => { + describe('Readers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.terminal.readers.retrieve('rdr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Terminal', function () { }); }); - describe('create', function () { - it('Sends the correct request', function () { + describe('create', () => { + it('Sends the correct request', () => { stripe.terminal.readers.create({ registration_code: 'a-b-c', label: 'name', @@ -37,8 +37,8 @@ describe('Terminal', function () { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.terminal.readers.del('rdr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -49,10 +49,10 @@ describe('Terminal', function () { }); }); - describe('update', function () { - it('Sends the correct request', function () { + describe('update', () => { + it('Sends the correct request', () => { stripe.terminal.readers.update('rdr_123', { - label: 'name' + label: 'name', }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -65,8 +65,8 @@ describe('Terminal', function () { }); }); - describe('list', function () { - it('Sends the correct request', function () { + describe('list', () => { + it('Sends the correct request', () => { stripe.terminal.readers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ThreeDSecure.spec.js b/test/resources/ThreeDSecure.spec.js index 9efc67b1e6..7ff3aad648 100644 --- a/test/resources/ThreeDSecure.spec.js +++ b/test/resources/ThreeDSecure.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('ThreeDSecure Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('ThreeDSecure Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.threeDSecure.retrieve('tdsrc_id'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('ThreeDSecure Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.threeDSecure.create({ card: 'tok_test', amount: 1500, diff --git a/test/resources/Tokens.spec.js b/test/resources/Tokens.spec.js index 397168f002..a5dd59708a 100644 --- a/test/resources/Tokens.spec.js +++ b/test/resources/Tokens.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Tokens Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Tokens Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.tokens.create({ card: {number: 123}, }); @@ -18,8 +18,8 @@ describe('Tokens Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.tokens.retrieve('tokenId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Topups.spec.js b/test/resources/Topups.spec.js index 88db95651a..dc77c0d2d0 100644 --- a/test/resources/Topups.spec.js +++ b/test/resources/Topups.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Topup Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Topup Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.topups.retrieve('tu_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Topup Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.topups.create({ source: 'src_123', amount: '1500', @@ -40,8 +40,8 @@ describe('Topup Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.topups.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -52,8 +52,8 @@ describe('Topup Resource', function() { }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.topups.cancel('tu_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -64,14 +64,14 @@ describe('Topup Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { - stripe.topups.update('tu_123', {metadata: {'key': 'value'}}); + describe('update', () => { + it('Sends the correct request', () => { + stripe.topups.update('tu_123', {metadata: {key: 'value'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/topups/tu_123', headers: {}, - data: {metadata: {'key': 'value'}}, + data: {metadata: {key: 'value'}}, }); }); }); diff --git a/test/resources/TransferReversals.spec.js b/test/resources/TransferReversals.spec.js deleted file mode 100644 index 19cb36f8a1..0000000000 --- a/test/resources/TransferReversals.spec.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -var resources = require('../../lib/stripe').resources; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; - -var TRANSFER_TEST_ID = 'transferIdTest999'; -var REVERSAL_TEST_ID = 'reversalIdTest999'; - -// Create new CustomerCard instance with pre-filled customerId: -var transferReversal = new resources.TransferReversals( - stripe, - {transferId: TRANSFER_TEST_ID} -); - -// Use spy from existing resource: -transferReversal._request = stripe.customers._request; - -describe('TransferReversal Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { - transferReversal.retrieve(REVERSAL_TEST_ID); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/transfers/' + TRANSFER_TEST_ID + '/reversals/' + REVERSAL_TEST_ID, - data: {}, - headers: {}, - }); - }); - }); - - describe('create', function() { - it('Sends the correct request', function() { - transferReversal.create({ - amount: 100, - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/transfers/' + TRANSFER_TEST_ID + '/reversals', - data: {amount: 100}, - headers: {}, - }); - }); - }); - - describe('update', function() { - it('Sends the correct request', function() { - transferReversal.update(REVERSAL_TEST_ID, { - metadata: {key: 'value'}, - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/transfers/' + TRANSFER_TEST_ID + '/reversals/' + REVERSAL_TEST_ID, - data: {metadata: {key: 'value'}}, - headers: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { - transferReversal.list(); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/transfers/' + TRANSFER_TEST_ID + '/reversals', - data: {}, - headers: {}, - }); - }); - }); -}); - diff --git a/test/resources/Transfers.spec.js b/test/resources/Transfers.spec.js index 8fc6cdce71..03c8d2e0e1 100644 --- a/test/resources/Transfers.spec.js +++ b/test/resources/Transfers.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('Transfers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Transfers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.transfers.retrieve('transferId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,10 +16,12 @@ describe('Transfers Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.transfers.create({ - amount: 200, currency: 'usd', recipient: {}, + amount: 200, + currency: 'usd', + recipient: {}, }); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -30,8 +32,8 @@ describe('Transfers Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.transfers.update('transferId6654', { amount: 300, }); @@ -44,32 +46,8 @@ describe('Transfers Resource', function() { }); }); - describe('cancel', function() { - it('Sends the correct request', function() { - stripe.transfers.cancel('transferId4'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/transfers/transferId4/cancel', - headers: {}, - data: {}, - }); - }); - }); - - describe('reverse', function() { - it('Sends the correct request', function() { - stripe.transfers.reverse('transferId4'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/transfers/transferId4/reversals', - headers: {}, - data: {}, - }); - }); - }); - - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.transfers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -79,16 +57,4 @@ describe('Transfers Resource', function() { }); }); }); - - describe('listTransactions', function() { - it('Sends the correct request', function() { - stripe.transfers.listTransactions('tr_14222'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/transfers/tr_14222/transactions', - headers: {}, - data: {}, - }); - }); - }); }); diff --git a/test/resources/UsageRecordSummaries.spec.js b/test/resources/UsageRecordSummaries.spec.js index 7f9a1285a3..0661ca727d 100644 --- a/test/resources/UsageRecordSummaries.spec.js +++ b/test/resources/UsageRecordSummaries.spec.js @@ -1,40 +1,46 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('UsageRecordSummaries Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('UsageRecordSummaries Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.usageRecordSummaries.list('si_123', {}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/subscription_items/si_123/usage_record_summaries', headers: {}, - data: {} + data: {}, }); }); - it('Includes any options that were provided', function(done) { - stripe.usageRecordSummaries.list('si_123', {}, { - stripe_account: 'acct_456', - }).then(function(record) { - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/subscription_items/si_123/usage_record_summaries', - headers: { - 'Stripe-Account': 'acct_456' - }, - data: {} - }); + it('Includes any options that were provided', (done) => { + stripe.usageRecordSummaries + .list( + 'si_123', + {}, + { + stripe_account: 'acct_456', + } + ) + .then((record) => { + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/subscription_items/si_123/usage_record_summaries', + headers: { + 'Stripe-Account': 'acct_456', + }, + data: {}, + }); - done(); - }); + done(); + }); }); - it('Calls a given callback', function(done) { - stripe.usageRecordSummaries.list('si_123', {}, function(error, record) { + it('Calls a given callback', (done) => { + stripe.usageRecordSummaries.list('si_123', {}, (error, record) => { done(error); }); }); diff --git a/test/resources/UsageRecords.spec.js b/test/resources/UsageRecords.spec.js index 3dc29e4f71..fd9e3c7afc 100644 --- a/test/resources/UsageRecords.spec.js +++ b/test/resources/UsageRecords.spec.js @@ -1,15 +1,15 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('UsageRecords Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('UsageRecords Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.usageRecords.create('si_123', { quantity: 123, timestamp: 123321, - action: 'increment' + action: 'increment', }); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,44 +19,54 @@ describe('UsageRecords Resource', function() { data: { quantity: 123, timestamp: 123321, - action: 'increment' - } + action: 'increment', + }, }); }); - it('Includes any options that were provided', function(done) { - stripe.usageRecords.create('si_123', { - quantity: 123, - timestamp: 123321, - action: 'increment' - }, { - stripe_account: 'acct_456', - }).then(function(record) { - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/subscription_items/si_123/usage_records', - headers: { - 'Stripe-Account': 'acct_456' - }, - data: { + it('Includes any options that were provided', (done) => { + stripe.usageRecords + .create( + 'si_123', + { quantity: 123, timestamp: 123321, - action: 'increment' + action: 'increment', + }, + { + stripe_account: 'acct_456', } - }); + ) + .then((record) => { + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'POST', + url: '/v1/subscription_items/si_123/usage_records', + headers: { + 'Stripe-Account': 'acct_456', + }, + data: { + quantity: 123, + timestamp: 123321, + action: 'increment', + }, + }); - done(); - }); + done(); + }); }); - it('Calls a given callback', function(done) { - stripe.usageRecords.create('si_123', { - quantity: 123, - timestamp: 123321, - action: 'increment' - }, function(error, record) { - done(error); - }); + it('Calls a given callback', (done) => { + stripe.usageRecords.create( + 'si_123', + { + quantity: 123, + timestamp: 123321, + action: 'increment', + }, + (error, record) => { + done(error); + } + ); }); }); }); diff --git a/test/resources/WebhookEndpoints.spec.js b/test/resources/WebhookEndpoints.spec.js index a2ac60b390..4c76854402 100644 --- a/test/resources/WebhookEndpoints.spec.js +++ b/test/resources/WebhookEndpoints.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var stripe = require('../../testUtils').getSpyableStripe(); -var expect = require('chai').expect; +const stripe = require('../../testUtils').getSpyableStripe(); +const expect = require('chai').expect; -describe('WebhookEndpoints Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('WebhookEndpoints Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.retrieve('we_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.del('we_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.update('we_123', { enabled_events: ['charge.succeeded'], }); @@ -44,8 +44,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.create({ enabled_events: ['charge.succeeded'], url: 'https://stripe.com', @@ -63,8 +63,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/stripe.spec.js b/test/stripe.spec.js index 566cc93ba0..37fb4b62b8 100644 --- a/test/stripe.spec.js +++ b/test/stripe.spec.js @@ -1,128 +1,140 @@ 'use strict'; -var testUtils = require('../testUtils'); -var utils = require('../lib/utils'); -var stripe = require('../lib/stripe')( - testUtils.getUserStripeKey(), - 'latest' -); +const testUtils = require('../testUtils'); +const utils = require('../lib/utils'); +const stripe = require('../lib/stripe')(testUtils.getUserStripeKey(), 'latest'); -var http = require('http'); +const http = require('http'); -var expect = require('chai').expect; +const expect = require('chai').expect; -var CUSTOMER_DETAILS = { +const CUSTOMER_DETAILS = { description: 'Some customer', card: 'tok_visa', }; describe('Stripe Module', function() { - var cleanup = new testUtils.CleanupUtility(); + const cleanup = new testUtils.CleanupUtility(); this.timeout(20000); - describe('setApiKey', function() { - it('uses Bearer auth', function() { - expect(stripe.getApiField('auth')).to.equal('Bearer ' + testUtils.getUserStripeKey()); + describe('setApiKey', () => { + it('uses Bearer auth', () => { + expect(stripe.getApiField('auth')).to.equal( + `Bearer ${testUtils.getUserStripeKey()}` + ); }); }); - describe('GetClientUserAgent', function() { - it('Should return a user-agent serialized JSON object', function() { - return expect(new Promise(function(resolve, reject) { - stripe.getClientUserAgent(function(c) { - resolve(JSON.parse(c)); - }); - })).to.eventually.have.property('lang', 'node'); - }); + describe('GetClientUserAgent', () => { + it('Should return a user-agent serialized JSON object', () => + expect( + new Promise((resolve, reject) => { + stripe.getClientUserAgent((c) => { + resolve(JSON.parse(c)); + }); + }) + ).to.eventually.have.property('lang', 'node')); }); - describe('GetClientUserAgentSeeded', function() { - it('Should return a user-agent serialized JSON object', function() { - var userAgent = {lang: 'node'}; - return expect(new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded(userAgent, function(c) { - resolve(JSON.parse(c)); - }); - })).to.eventually.have.property('lang', 'node'); + describe('GetClientUserAgentSeeded', () => { + it('Should return a user-agent serialized JSON object', () => { + const userAgent = {lang: 'node'}; + return expect( + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded(userAgent, (c) => { + resolve(JSON.parse(c)); + }); + }) + ).to.eventually.have.property('lang', 'node'); }); - it('Should URI-encode user-agent fields', function() { - var userAgent = {lang: 'ï'}; - return expect(new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded(userAgent, function(c) { - resolve(JSON.parse(c)); - }); - })).to.eventually.have.property('lang', '%C3%AF'); + it('Should URI-encode user-agent fields', () => { + const userAgent = {lang: 'ï'}; + return expect( + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded(userAgent, (c) => { + resolve(JSON.parse(c)); + }); + }) + ).to.eventually.have.property('lang', '%C3%AF'); }); - describe('uname', function() { - var origExec; - beforeEach(function() { + describe('uname', () => { + let origExec; + beforeEach(() => { origExec = utils.safeExec; }); - afterEach(function() { + afterEach(() => { utils.safeExec = origExec; }); - it('gets added to the user-agent', function() { - utils.safeExec = function(cmd, cb) { - cb(null, 'foøname') + it('gets added to the user-agent', () => { + utils.safeExec = (cmd, cb) => { + cb(null, 'foøname'); }; - return expect(new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded({lang: 'node'}, function(c) { - resolve(JSON.parse(c)); - }); - })).to.eventually.have.property('uname', 'fo%C3%B8name'); + return expect( + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded({lang: 'node'}, (c) => { + resolve(JSON.parse(c)); + }); + }) + ).to.eventually.have.property('uname', 'fo%C3%B8name'); }); - it('sets uname to UNKOWN in case of an error', function() { - utils.safeExec = function(cmd, cb) { - cb(new Error('security'), null) + it('sets uname to UNKOWN in case of an error', () => { + utils.safeExec = (cmd, cb) => { + cb(new Error('security'), null); }; - return expect(new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded({lang: 'node'}, function(c) { - resolve(JSON.parse(c)); - }); - })).to.eventually.have.property('uname', 'UNKNOWN'); + return expect( + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded({lang: 'node'}, (c) => { + resolve(JSON.parse(c)); + }); + }) + ).to.eventually.have.property('uname', 'UNKNOWN'); }); }); }); - describe('setTimeout', function() { - it('Should define a default equal to the node default', function() { - expect(stripe.getApiField('timeout')).to.equal(http.createServer().timeout); + describe('setTimeout', () => { + it('Should define a default equal to the node default', () => { + expect(stripe.getApiField('timeout')).to.equal( + http.createServer().timeout + ); }); - it('Should allow me to set a custom timeout', function() { + it('Should allow me to set a custom timeout', () => { stripe.setTimeout(900); expect(stripe.getApiField('timeout')).to.equal(900); }); - it('Should allow me to set null, to reset to the default', function() { + it('Should allow me to set null, to reset to the default', () => { stripe.setTimeout(null); - expect(stripe.getApiField('timeout')).to.equal(http.createServer().timeout); + expect(stripe.getApiField('timeout')).to.equal( + http.createServer().timeout + ); }); }); - describe('setAppInfo', function() { - describe('when given nothing or an empty object', function() { - it('should unset stripe._appInfo', function() { + describe('setAppInfo', () => { + describe('when given nothing or an empty object', () => { + it('should unset stripe._appInfo', () => { stripe.setAppInfo(); expect(stripe._appInfo).to.be.undefined; }); }); - describe('when given an object with no `name`', function() { - it('should throw an error', function() { - expect(function() { + describe('when given an object with no `name`', () => { + it('should throw an error', () => { + expect(() => { stripe.setAppInfo({}); }).to.throw(/AppInfo.name is required/); - expect(function() { + expect(() => { stripe.setAppInfo({ version: '1.2.3', }); }).to.throw(/AppInfo.name is required/); - expect(function() { + expect(() => { stripe.setAppInfo({ cats: '42', }); @@ -130,8 +142,8 @@ describe('Stripe Module', function() { }); }); - describe('when given at least a `name`', function() { - it('should set name, partner ID, url, and version of stripe._appInfo', function() { + describe('when given at least a `name`', () => { + it('should set name, partner ID, url, and version of stripe._appInfo', () => { stripe.setAppInfo({ name: 'MyAwesomeApp', }); @@ -165,10 +177,9 @@ describe('Stripe Module', function() { name: 'MyAwesomeApp', partner_id: 'partner_1234', }); - }); - it('should ignore any invalid properties', function() { + it('should ignore any invalid properties', () => { stripe.setAppInfo({ name: 'MyAwesomeApp', partner_id: 'partner_1234', @@ -185,8 +196,8 @@ describe('Stripe Module', function() { }); }); - it('should be included in the ClientUserAgent and be added to the UserAgent String', function(done) { - var appInfo = { + it('should be included in the ClientUserAgent and be added to the UserAgent String', (done) => { + const appInfo = { name: testUtils.getRandomString(), version: '1.2.345', url: 'https://myawesomeapp.info', @@ -194,74 +205,85 @@ describe('Stripe Module', function() { stripe.setAppInfo(appInfo); - stripe.getClientUserAgent(function(uaString) { + stripe.getClientUserAgent((uaString) => { expect(JSON.parse(uaString).application).to.eql(appInfo); - expect(stripe.getAppInfoAsString()).to.eql(appInfo.name + '/' + appInfo.version + ' (' + appInfo.url + ')'); + expect(stripe.getAppInfoAsString()).to.eql( + `${appInfo.name}/${appInfo.version} (${appInfo.url})` + ); done(); }); }); }); - describe('Callback support', function() { - describe('Any given endpoint', function() { - it('Will call a callback if successful', function() { - return expect(new Promise(function(resolve, reject) { - stripe.customers.create(CUSTOMER_DETAILS, function(err, customer) { - cleanup.deleteCustomer(customer.id); - resolve('Called!'); - }); - })).to.eventually.equal('Called!'); - }); - - it('Will expose HTTP response object', function() { - return expect(new Promise(function(resolve, reject) { - stripe.customers.create(CUSTOMER_DETAILS, function(err, customer) { - cleanup.deleteCustomer(customer.id); - - var headers = customer.lastResponse.headers; - expect(headers).to.contain.keys('request-id'); - - expect(customer.lastResponse.requestId).to.match(/^req_/); - expect(customer.lastResponse.statusCode).to.equal(200); - - resolve('Called!'); - }); - })).to.eventually.equal('Called!'); - }); - - it('Given an error the callback will receive it', function() { - return expect(new Promise(function(resolve, reject) { - stripe.customers.createCard('nonExistentCustId', {card: {}}, function(err, customer) { - if (err) { - resolve('ErrorWasPassed'); - } else { - reject(new Error('NoErrorPassed')); - } - }); - })).to.eventually.become('ErrorWasPassed'); - }); + describe('Callback support', () => { + describe('Any given endpoint', () => { + it('Will call a callback if successful', () => + expect( + new Promise((resolve, reject) => { + stripe.customers.create(CUSTOMER_DETAILS, (err, customer) => { + cleanup.deleteCustomer(customer.id); + resolve('Called!'); + }); + }) + ).to.eventually.equal('Called!')); + + it('Will expose HTTP response object', () => + expect( + new Promise((resolve, reject) => { + stripe.customers.create(CUSTOMER_DETAILS, (err, customer) => { + cleanup.deleteCustomer(customer.id); + + const headers = customer.lastResponse.headers; + expect(headers).to.contain.keys('request-id'); + + expect(customer.lastResponse.requestId).to.match(/^req_/); + expect(customer.lastResponse.statusCode).to.equal(200); + + resolve('Called!'); + }); + }) + ).to.eventually.equal('Called!')); + + it('Given an error the callback will receive it', () => + expect( + new Promise((resolve, reject) => { + stripe.customers.createSource( + 'nonExistentCustId', + {card: {}}, + (err, customer) => { + if (err) { + resolve('ErrorWasPassed'); + } else { + reject(new Error('NoErrorPassed')); + } + } + ); + }) + ).to.eventually.become('ErrorWasPassed')); }); }); - describe('errors', function() { - it('Exports errors as types', function() { - var Stripe = require('../lib/stripe'); - expect(new Stripe.errors.StripeInvalidRequestError({ - message: 'error' - }).type).to.equal('StripeInvalidRequestError'); + describe('errors', () => { + it('Exports errors as types', () => { + const Stripe = require('../lib/stripe'); + expect( + new Stripe.errors.StripeInvalidRequestError({ + message: 'error', + }).type + ).to.equal('StripeInvalidRequestError'); }); }); - describe('setMaxNetworkRetries', function() { - describe('when given an empty or non-number variable', function() { - it('should error', function() { - expect(function() { + describe('setMaxNetworkRetries', () => { + describe('when given an empty or non-number variable', () => { + it('should error', () => { + expect(() => { stripe.setMaxNetworkRetries('foo'); }).to.throw(/maxNetworkRetries must be a number/); - expect(function() { + expect(() => { stripe.setMaxNetworkRetries(); }).to.throw(/maxNetworkRetries must be a number/); }); diff --git a/test/telemetry.spec.js b/test/telemetry.spec.js index 845d51770a..355ec61de5 100644 --- a/test/telemetry.spec.js +++ b/test/telemetry.spec.js @@ -1,151 +1,171 @@ 'use strict'; require('../testUtils'); -var http = require('http'); +const http = require('http'); -var expect = require('chai').expect; -var testServer = null; +const expect = require('chai').expect; +let testServer = null; function createTestServer(handlerFunc, cb) { - var host = '127.0.0.1'; - testServer = http.createServer(function(req, res) { + const host = '127.0.0.1'; + testServer = http.createServer((req, res) => { try { handlerFunc(req, res); } catch (e) { res.writeHead(400, {'Content-Type': 'application/json'}); - res.end(JSON.stringify({ - error: {type: 'invalid_request_error', message: e.message} - })); + res.end( + JSON.stringify({ + error: {type: 'invalid_request_error', message: e.message}, + }) + ); } }); - testServer.listen(0, host, function() { - var port = testServer.address().port; + testServer.listen(0, host, () => { + const port = testServer.address().port; cb(host, port); }); } -describe('Client Telemetry', function() { - afterEach(function() { +describe('Client Telemetry', () => { + afterEach(() => { if (testServer) { testServer.close(); testServer = null; } }); - it('Does not send telemetry when disabled', function(done) { - var numRequests = 0; - - createTestServer(function (req, res) { - numRequests += 1; - - var telemetry = req.headers['x-stripe-client-telemetry']; - - switch (numRequests) { - case 1: - case 2: - expect(telemetry).to.not.exist; - break; - default: - expect.fail(`Should not have reached request ${numRequests}`); + it('Does not send telemetry when disabled', (done) => { + let numRequests = 0; + + createTestServer( + (req, res) => { + numRequests += 1; + + const telemetry = req.headers['x-stripe-client-telemetry']; + + switch (numRequests) { + case 1: + case 2: + expect(telemetry).to.not.exist; + break; + default: + expect.fail(`Should not have reached request ${numRequests}`); + } + + res.setHeader('Request-Id', `req_${numRequests}`); + res.writeHead(200, {'Content-Type': 'application/json'}); + res.end('{}'); + }, + (host, port) => { + const stripe = require('../lib/stripe')( + 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' + ); + stripe.setHost(host, port, 'http'); + + stripe.balance + .retrieve() + .then((res) => stripe.balance.retrieve()) + .then((res) => { + expect(numRequests).to.equal(2); + done(); + }) + .catch(done); } - - res.setHeader('Request-Id', `req_${numRequests}`); - res.writeHead(200, {'Content-Type': 'application/json'}); - res.end('{}'); - }, function(host, port) { - const stripe = require('../lib/stripe')('sk_test_FEiILxKZwnmmocJDUjUNO6pa') - stripe.setHost(host, port, 'http'); - - stripe.balance.retrieve().then(function (res) { - return stripe.balance.retrieve(); - }).then(function (res) { - expect(numRequests).to.equal(2); - done(); - }).catch(done); - }); + ); }); - it('Sends client telemetry on the second request when enabled', function(done) { - var numRequests = 0; - - createTestServer(function (req, res) { - numRequests += 1; - - var telemetry = req.headers['x-stripe-client-telemetry']; - - switch (numRequests) { - case 1: - expect(telemetry).to.not.exist; - break; - case 2: - expect(telemetry).to.exist; - expect(JSON.parse(telemetry).last_request_metrics.request_id) - .to.equal('req_1'); - break; - default: - expect.fail(`Should not have reached request ${numRequests}`); + it('Sends client telemetry on the second request when enabled', (done) => { + let numRequests = 0; + + createTestServer( + (req, res) => { + numRequests += 1; + + const telemetry = req.headers['x-stripe-client-telemetry']; + + switch (numRequests) { + case 1: + expect(telemetry).to.not.exist; + break; + case 2: + expect(telemetry).to.exist; + expect( + JSON.parse(telemetry).last_request_metrics.request_id + ).to.equal('req_1'); + break; + default: + expect.fail(`Should not have reached request ${numRequests}`); + } + + res.setHeader('Request-Id', `req_${numRequests}`); + res.writeHead(200, {'Content-Type': 'application/json'}); + res.end('{}'); + }, + (host, port) => { + const stripe = require('../lib/stripe')( + 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' + ); + stripe.setTelemetryEnabled(true); + stripe.setHost(host, port, 'http'); + + stripe.balance + .retrieve() + .then((res) => stripe.balance.retrieve()) + .then((res) => { + expect(numRequests).to.equal(2); + done(); + }) + .catch(done); } - - res.setHeader('Request-Id', `req_${numRequests}`); - res.writeHead(200, {'Content-Type': 'application/json'}); - res.end('{}'); - }, function(host, port) { - const stripe = require('../lib/stripe')('sk_test_FEiILxKZwnmmocJDUjUNO6pa') - stripe.setTelemetryEnabled(true); - stripe.setHost(host, port, 'http'); - - stripe.balance.retrieve().then(function (res) { - return stripe.balance.retrieve(); - }).then(function (res) { - expect(numRequests).to.equal(2); - done(); - }).catch(done); - }); + ); }); - it('Buffers metrics on concurrent requests', function(done) { - var numRequests = 0; - - createTestServer(function (req, res) { - numRequests += 1; - - var telemetry = req.headers['x-stripe-client-telemetry']; - - switch (numRequests) { - case 1: - case 2: - expect(telemetry).to.not.exist; - break; - case 3: - case 4: - expect(telemetry).to.exist; - expect(JSON.parse(telemetry).last_request_metrics.request_id) - .to.be.oneOf(['req_1', 'req_2']); - break; - default: - expect.fail(`Should not have reached request ${numRequests}`); + it('Buffers metrics on concurrent requests', (done) => { + let numRequests = 0; + + createTestServer( + (req, res) => { + numRequests += 1; + + const telemetry = req.headers['x-stripe-client-telemetry']; + + switch (numRequests) { + case 1: + case 2: + expect(telemetry).to.not.exist; + break; + case 3: + case 4: + expect(telemetry).to.exist; + expect( + JSON.parse(telemetry).last_request_metrics.request_id + ).to.be.oneOf(['req_1', 'req_2']); + break; + default: + expect.fail(`Should not have reached request ${numRequests}`); + } + + res.setHeader('Request-Id', `req_${numRequests}`); + res.writeHead(200, {'Content-Type': 'application/json'}); + res.end('{}'); + }, + (host, port) => { + const stripe = require('../lib/stripe')( + 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' + ); + stripe.setTelemetryEnabled(true); + stripe.setHost(host, port, 'http'); + + Promise.all([stripe.balance.retrieve(), stripe.balance.retrieve()]) + .then(() => + Promise.all([stripe.balance.retrieve(), stripe.balance.retrieve()]) + ) + .then(() => { + expect(numRequests).to.equal(4); + done(); + }) + .catch(done); } - - res.setHeader('Request-Id', `req_${numRequests}`); - res.writeHead(200, {'Content-Type': 'application/json'}); - res.end('{}'); - }, function(host, port) { - const stripe = require('../lib/stripe')('sk_test_FEiILxKZwnmmocJDUjUNO6pa') - stripe.setTelemetryEnabled(true); - stripe.setHost(host, port, 'http'); - - Promise.all([ - stripe.balance.retrieve(), - stripe.balance.retrieve() - ]).then(function() { - return Promise.all([ - stripe.balance.retrieve(), - stripe.balance.retrieve() - ]); - }).then(function() { - expect(numRequests).to.equal(4); - done(); - }).catch(done); - }); + ); }); }); diff --git a/test/utils.spec.js b/test/utils.spec.js index f406535825..861998fc76 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -2,22 +2,18 @@ require('../testUtils'); -var utils = require('../lib/utils'); -var expect = require('chai').expect; -var Buffer = require('safe-buffer').Buffer; +const utils = require('../lib/utils'); +const expect = require('chai').expect; +const Buffer = require('safe-buffer').Buffer; -describe('utils', function() { - describe('makeURLInterpolator', function() { - it('Interpolates values into a prepared template', function() { - var template = utils.makeURLInterpolator('/some/url/{foo}/{baz}?ok=1'); +describe('utils', () => { + describe('makeURLInterpolator', () => { + it('Interpolates values into a prepared template', () => { + const template = utils.makeURLInterpolator('/some/url/{foo}/{baz}?ok=1'); - expect( - template({foo: 1, baz: 2}) - ).to.equal('/some/url/1/2?ok=1'); + expect(template({foo: 1, baz: 2})).to.equal('/some/url/1/2?ok=1'); - expect( - template({foo: '', baz: ''}) - ).to.equal('/some/url//?ok=1'); + expect(template({foo: '', baz: ''})).to.equal('/some/url//?ok=1'); expect( // Test encoding: @@ -26,82 +22,105 @@ describe('utils', function() { }); }); - describe('stringifyRequestData', function() { - it('Handles basic types', function() { - expect(utils.stringifyRequestData({ - a: 1, - b: 'foo', - })).to.equal('a=1&b=foo'); + describe('extractUrlParams', () => { + it('works with multiple params', () => { + expect( + utils.extractUrlParams( + 'accounts/{accountId}/external_accounts/{externalAccountId}' + ) + ).to.deep.equal(['accountId', 'externalAccountId']); }); + }); - it('Handles Dates', function() { - expect(utils.stringifyRequestData({ - date: new Date('2009-02-13T23:31:30Z'), - created: { - gte: new Date('2009-02-13T23:31:30Z'), - lt: new Date('2044-05-01T01:28:21Z'), - }, - })).to.equal([ - 'date=1234567890', - 'created[gte]=1234567890', - 'created[lt]=2345678901' - ].join('&')); - }); - - it('Handles deeply nested object', function() { - expect(utils.stringifyRequestData({ - a: { - b: { - c: { - d: 2, + describe('stringifyRequestData', () => { + it('Handles basic types', () => { + expect( + utils.stringifyRequestData({ + a: 1, + b: 'foo', + }) + ).to.equal('a=1&b=foo'); + }); + + it('Handles Dates', () => { + expect( + utils.stringifyRequestData({ + date: new Date('2009-02-13T23:31:30Z'), + created: { + gte: new Date('2009-02-13T23:31:30Z'), + lt: new Date('2044-05-01T01:28:21Z'), + }, + }) + ).to.equal( + [ + 'date=1234567890', + 'created[gte]=1234567890', + 'created[lt]=2345678901', + ].join('&') + ); + }); + + it('Handles deeply nested object', () => { + expect( + utils.stringifyRequestData({ + a: { + b: { + c: { + d: 2, + }, }, }, - }, - })).to.equal('a[b][c][d]=2'); - }); - - it('Handles arrays of objects', function() { - expect(utils.stringifyRequestData({ - a: [ - {b: 'c'}, - {b: 'd'}, - ], - })).to.equal('a[0][b]=c&a[1][b]=d'); - }) - - it('Handles indexed arrays', function() { - expect(utils.stringifyRequestData({ - a: { - 0: {b: 'c'}, - 1: {b: 'd'}, - }, - })).to.equal('a[0][b]=c&a[1][b]=d'); - }) - - it('Creates a string from an object, handling shallow nested objects', function() { - expect(utils.stringifyRequestData({ - test: 1, - foo: 'baz', - somethingElse: '::""%&', - nested: { - 1: 2, - 'a n o t h e r': null, - }, - })).to.equal([ - 'test=1', - 'foo=baz', - 'somethingElse=%3A%3A%22%22%25%26', - 'nested[1]=2', - 'nested[a%20n%20o%20t%20h%20e%20r]=', - ].join('&')); + }) + ).to.equal('a[b][c][d]=2'); + }); + + it('Handles arrays of objects', () => { + expect( + utils.stringifyRequestData({ + a: [{b: 'c'}, {b: 'd'}], + }) + ).to.equal('a[0][b]=c&a[1][b]=d'); + }); + + it('Handles indexed arrays', () => { + expect( + utils.stringifyRequestData({ + a: { + 0: {b: 'c'}, + 1: {b: 'd'}, + }, + }) + ).to.equal('a[0][b]=c&a[1][b]=d'); + }); + + it('Creates a string from an object, handling shallow nested objects', () => { + expect( + utils.stringifyRequestData({ + test: 1, + foo: 'baz', + somethingElse: '::""%&', + nested: { + 1: 2, + 'a n o t h e r': null, + }, + }) + ).to.equal( + [ + 'test=1', + 'foo=baz', + 'somethingElse=%3A%3A%22%22%25%26', + 'nested[1]=2', + 'nested[a%20n%20o%20t%20h%20e%20r]=', + ].join('&') + ); }); }); - describe('protoExtend', function() { - it('Provides an extension mechanism', function() { + describe('protoExtend', () => { + it('Provides an extension mechanism', () => { function A() {} A.extend = utils.protoExtend; - var B = A.extend({ + const B = A.extend({ constructor: function() { this.called = true; }, @@ -113,101 +132,110 @@ describe('utils', function() { }); }); - describe('getDataFromArgs', function() { - it('handles an empty list', function() { + describe('getDataFromArgs', () => { + it('handles an empty list', () => { expect(utils.getDataFromArgs([])).to.deep.equal({}); }); - it('handles a list with no object', function() { - var args = [1, 3]; + it('handles a list with no object', () => { + const args = [1, 3]; expect(utils.getDataFromArgs(args)).to.deep.equal({}); expect(args.length).to.equal(2); }); - it('ignores a hash with only options', function(done) { - var args = [{api_key: 'foo'}]; + it('ignores a hash with only options', (done) => { + const args = [{api_key: 'foo'}]; - handleWarnings(function() { - expect(utils.getDataFromArgs(args)).to.deep.equal({}); - expect(args.length).to.equal(1); + handleWarnings( + () => { + expect(utils.getDataFromArgs(args)).to.deep.equal({}); + expect(args.length).to.equal(1); - done(); - }, function(message) { - throw new Error('Should not have warned, but did: ' + message); - }); + done(); + }, + (message) => { + throw new Error(`Should not have warned, but did: ${message}`); + } + ); }); - it('warns if the hash contains both data and options', function(done) { - var args = [{foo: 'bar', api_key: 'foo', idempotency_key: 'baz'}]; + it('warns if the hash contains both data and options', (done) => { + const args = [{foo: 'bar', api_key: 'foo', idempotency_key: 'baz'}]; - handleWarnings(function() { - utils.getDataFromArgs(args); - }, function(message) { - expect(message).to.equal( - 'Stripe: Options found in arguments (api_key, idempotency_key).' + - ' Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' - ); - - done(); - }); - }); - it('finds the data', function() { - var args = [{foo: 'bar'}, {api_key: 'foo'}]; + handleWarnings( + () => { + utils.getDataFromArgs(args); + }, + (message) => { + expect(message).to.equal( + 'Stripe: Options found in arguments (api_key, idempotency_key).' + + ' Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' + ); + + done(); + } + ); + }); + it('finds the data', () => { + const args = [{foo: 'bar'}, {api_key: 'foo'}]; expect(utils.getDataFromArgs(args)).to.deep.equal({foo: 'bar'}); expect(args.length).to.equal(1); }); }); - describe('getOptsFromArgs', function() { - it('handles an empty list', function() { + describe('getOptsFromArgs', () => { + it('handles an empty list', () => { expect(utils.getOptionsFromArgs([])).to.deep.equal({ auth: null, headers: {}, }); }); - it('handles an list with no object', function() { - var args = [1, 3]; + it('handles an list with no object', () => { + const args = [1, 3]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, headers: {}, }); expect(args.length).to.equal(2); }); - it('ignores a non-options object', function() { - var args = [{foo: 'bar'}]; + it('ignores a non-options object', () => { + const args = [{foo: 'bar'}]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, headers: {}, }); expect(args.length).to.equal(1); }); - it('parses an api key', function() { - var args = ['sk_test_iiiiiiiiiiiiiiiiiiiiiiii']; + it('parses an api key', () => { + const args = ['sk_test_iiiiiiiiiiiiiiiiiiiiiiii']; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', headers: {}, }); expect(args.length).to.equal(0); }); - it('parses an idempotency key', function() { - var args = [{foo: 'bar'}, {idempotency_key: 'foo'}]; + it('parses an idempotency key', () => { + const args = [{foo: 'bar'}, {idempotency_key: 'foo'}]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, headers: {'Idempotency-Key': 'foo'}, }); expect(args.length).to.equal(1); }); - it('parses an api version', function() { - var args = [{foo: 'bar'}, {stripe_version: '2003-03-30'}]; + it('parses an api version', () => { + const args = [{foo: 'bar'}, {stripe_version: '2003-03-30'}]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, headers: {'Stripe-Version': '2003-03-30'}, }); expect(args.length).to.equal(1); }); - it('parses an idempotency key and api key and api version (with data)', function() { - var args = [{foo: 'bar'}, { - api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - idempotency_key: 'foo', - stripe_version: '2010-01-10', - },]; + it('parses an idempotency key and api key and api version (with data)', () => { + const args = [ + {foo: 'bar'}, + { + api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', + idempotency_key: 'foo', + stripe_version: '2010-01-10', + }, + ]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', headers: { @@ -217,12 +245,14 @@ describe('utils', function() { }); expect(args.length).to.equal(1); }); - it('parses an idempotency key and api key and api version', function() { - var args = [{ - api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - idempotency_key: 'foo', - stripe_version: 'hunter2', - },]; + it('parses an idempotency key and api key and api version', () => { + const args = [ + { + api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', + idempotency_key: 'foo', + stripe_version: 'hunter2', + }, + ]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', headers: { @@ -232,148 +262,160 @@ describe('utils', function() { }); expect(args.length).to.equal(0); }); - it('warns if the hash contains something that does not belong', function(done) { - var args = [{foo: 'bar'}, { - api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - idempotency_key: 'foo', - stripe_version: '2010-01-10', - fishsticks: true, - custard: true, - },]; - - handleWarnings(function() { - utils.getOptionsFromArgs(args); - }, function(message) { - expect(message).to.equal( - 'Stripe: Invalid options found (fishsticks, custard); ignoring.' - ); - - done(); - }); + it('warns if the hash contains something that does not belong', (done) => { + const args = [ + {foo: 'bar'}, + { + api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', + idempotency_key: 'foo', + stripe_version: '2010-01-10', + fishsticks: true, + custard: true, + }, + ]; + + handleWarnings( + () => { + utils.getOptionsFromArgs(args); + }, + (message) => { + expect(message).to.equal( + 'Stripe: Invalid options found (fishsticks, custard); ignoring.' + ); + + done(); + } + ); }); }); - describe('secureCompare', function() { - it('returns true given two equal things', function() { + describe('secureCompare', () => { + it('returns true given two equal things', () => { expect(utils.secureCompare('potato', 'potato')).to.equal(true); }); - it('returns false given two unequal things', function() { + it('returns false given two unequal things', () => { expect(utils.secureCompare('potato', 'tomato')).to.equal(false); }); - it('throws an error if not given two things to compare', function() { - expect(function() { utils.secureCompare('potato'); }).to.throw(); + it('throws an error if not given two things to compare', () => { + expect(() => { + utils.secureCompare('potato'); + }).to.throw(); }); }); - describe('removeEmpty', function() { - it('removes empty properties and leaves non-empty ones', function() { - expect(utils.removeEmpty({ - cat: 3, - dog: false, - rabbit: undefined, - pointer: null, - })).to.eql({ + describe('removeEmpty', () => { + it('removes empty properties and leaves non-empty ones', () => { + expect( + utils.removeEmpty({ + cat: 3, + dog: false, + rabbit: undefined, + pointer: null, + }) + ).to.eql({ cat: 3, dog: false, }); }); - it('throws an error if not given two things to compare', function() { - expect(function() { utils.removeEmpty('potato'); }).to.throw(); + it('throws an error if not given two things to compare', () => { + expect(() => { + utils.removeEmpty('potato'); + }).to.throw(); }); }); - describe('safeExec', function() { - var origExec; - beforeEach(function() { + describe('safeExec', () => { + let origExec; + beforeEach(() => { origExec = utils._exec; }); - afterEach(function() { + afterEach(() => { utils._exec = origExec; }); - it('runs exec', function() { - var calls = []; - utils._exec = function(cmd, cb) { + it('runs exec', () => { + const calls = []; + utils._exec = (cmd, cb) => { calls.push([cmd, cb]); - } + }; function myCb() {} utils.safeExec('hello', myCb); - expect(calls).to.deep.equal([ - ['hello', myCb], - ]); + expect(calls).to.deep.equal([['hello', myCb]]); }); - it('passes along normal errors', function() { - var myErr = Error('hi'); - utils._exec = function(cmd, cb) { - cb(myErr, null) - } + it('passes along normal errors', () => { + const myErr = Error('hi'); + utils._exec = (cmd, cb) => { + cb(myErr, null); + }; - var calls = []; + const calls = []; function myCb(err, x) { calls.push([err, x]); } utils.safeExec('hello', myCb); - expect(calls).to.deep.equal([ - [myErr, null], - ]); + expect(calls).to.deep.equal([[myErr, null]]); }); - it('passes along thrown errors as normal callback errors', function() { - var myErr = Error('hi'); - utils._exec = function(cmd, cb) { + it('passes along thrown errors as normal callback errors', () => { + const myErr = Error('hi'); + utils._exec = (cmd, cb) => { throw myErr; - } + }; - var calls = []; + const calls = []; function myCb(err, x) { calls.push([err, x]); } utils.safeExec('hello', myCb); - expect(calls).to.deep.equal([ - [myErr, null], - ]); - }); - }) - - describe('flattenAndStringify', function() { - it('Stringifies primitive types', function() { - expect(utils.flattenAndStringify({ - a: 1, - b: 'foo', - c: true, - d: null, - })).to.eql({'a': '1', 'b': 'foo', 'c': 'true', 'd': 'null'}); + expect(calls).to.deep.equal([[myErr, null]]); }); + }); - it('Flattens nested values', function() { - expect(utils.flattenAndStringify({ - x: { + describe('flattenAndStringify', () => { + it('Stringifies primitive types', () => { + expect( + utils.flattenAndStringify({ a: 1, b: 'foo', - }, - })).to.eql({'x[a]': '1', 'x[b]': 'foo'}); + c: true, + d: null, + }) + ).to.eql({a: '1', b: 'foo', c: 'true', d: 'null'}); }); - it('Does not flatten File objects', function() { - expect(utils.flattenAndStringify({ - file: { - data: 'foo' - }, - x: { - a: 1, - }, - })).to.eql({'file': {data: 'foo'}, 'x[a]': '1'}); + it('Flattens nested values', () => { + expect( + utils.flattenAndStringify({ + x: { + a: 1, + b: 'foo', + }, + }) + ).to.eql({'x[a]': '1', 'x[b]': 'foo'}); + }); + + it('Does not flatten File objects', () => { + expect( + utils.flattenAndStringify({ + file: { + data: 'foo', + }, + x: { + a: 1, + }, + }) + ).to.eql({file: {data: 'foo'}, 'x[a]': '1'}); }); - it('Does not flatten Buffer objects', function() { - var buf = Buffer.from('Hi!'); - var flattened = utils.flattenAndStringify({ - buf: buf, + it('Does not flatten Buffer objects', () => { + const buf = Buffer.from('Hi!'); + const flattened = utils.flattenAndStringify({ + buf, x: { a: 1, }, @@ -391,7 +433,7 @@ function handleWarnings(doWithShimmedConsoleWarn, onWarn) { /* eslint-disable no-console */ // Shim `console.warn` - var _warn = console.warn; + const _warn = console.warn; console.warn = onWarn; doWithShimmedConsoleWarn(); @@ -401,16 +443,17 @@ function handleWarnings(doWithShimmedConsoleWarn, onWarn) { /* eslint-enable no-console */ } else { - function onProcessWarn(warning) { /* eslint-disable-line no-inner-declarations */ - onWarn(warning.name + ': ' + warning.message); + /* eslint-disable-next-line no-inner-declarations */ + function onProcessWarn(warning) { + onWarn(`${warning.name}: ${warning.message}`); } process.on('warning', onProcessWarn); doWithShimmedConsoleWarn(); - process.nextTick(function() { + process.nextTick(() => { process.removeListener('warning', onProcessWarn); - }) + }); } } diff --git a/testUtils/index.js b/testUtils/index.js index dcf8e5d086..8215645e53 100644 --- a/testUtils/index.js +++ b/testUtils/index.js @@ -6,25 +6,26 @@ require('mocha'); // Ensure we are using the 'as promised' libs before any tests are run: require('chai').use(require('chai-as-promised')); -var ResourceNamespace = require('../lib/ResourceNamespace').ResourceNamespace; +const ResourceNamespace = require('../lib/ResourceNamespace').ResourceNamespace; -var utils = module.exports = { - getUserStripeKey: function() { - var key = process.env.STRIPE_TEST_API_KEY || 'tGN0bIwXnHdwOa85VABjPdSn8nWY7G7I'; +const utils = (module.exports = { + getUserStripeKey: () => { + const key = + process.env.STRIPE_TEST_API_KEY || 'tGN0bIwXnHdwOa85VABjPdSn8nWY7G7I'; return key; }, - getSpyableStripe: function() { + getSpyableStripe: () => { // Provide a testable stripe instance // That is, with mock-requests built in and hookable - var stripe = require('../lib/stripe'); - var stripeInstance = stripe('fakeAuthToken'); + const stripe = require('../lib/stripe'); + const stripeInstance = stripe('fakeAuthToken'); stripeInstance.REQUESTS = []; - for (var i in stripeInstance) { + for (const i in stripeInstance) { makeInstanceSpyable(stripeInstance, stripeInstance[i]); } @@ -32,9 +33,9 @@ var utils = module.exports = { if (thisInstance instanceof stripe.StripeResource) { patchRequest(stripeInstance, thisInstance); } else if (thisInstance instanceof ResourceNamespace) { - var namespace = thisInstance; + const namespace = thisInstance; - for (var j in namespace) { + for (const j in namespace) { makeInstanceSpyable(stripeInstance, namespace[j]); } } @@ -42,12 +43,12 @@ var utils = module.exports = { function patchRequest(stripeInstance, instance) { instance._request = function(method, host, url, data, auth, options, cb) { - var req = stripeInstance.LAST_REQUEST = { - method: method, - url: url, - data: data, + const req = (stripeInstance.LAST_REQUEST = { + method, + url, + data, headers: options.headers || {}, - }; + }); if (auth) { req.auth = auth; } @@ -67,11 +68,11 @@ var utils = module.exports = { * CleanupUtility will automatically register on the mocha afterEach hook, * ensuring its called after each descendent-describe block. */ - CleanupUtility: (function() { + CleanupUtility: (() => { CleanupUtility.DEFAULT_TIMEOUT = 20000; function CleanupUtility(timeout) { - var self = this; + const self = this; this._cleanupFns = []; this._stripe = require('../lib/stripe')( utils.getUserStripeKey(), @@ -84,50 +85,55 @@ var utils = module.exports = { } CleanupUtility.prototype = { - - doCleanup: function(done) { - var cleanups = this._cleanupFns; - var total = cleanups.length; - var completed = 0; - for (var fn; (fn = cleanups.shift());) { - var promise = fn.call(this); + doCleanup(done) { + const cleanups = this._cleanupFns; + const total = cleanups.length; + let completed = 0; + let fn; + while ((fn = cleanups.shift())) { + const promise = fn.call(this); if (!promise || !promise.then) { - throw new Error('CleanupUtility expects cleanup functions to return promises!'); + throw new Error( + 'CleanupUtility expects cleanup functions to return promises!' + ); } - promise.then(function() { - // cleanup successful - completed += 1; - if (completed === total) { - done(); + promise.then( + () => { + // cleanup successful + completed += 1; + if (completed === total) { + done(); + } + }, + (err) => { + // not successful + throw err; } - }, function(err) { - // not successful - throw err; - }); + ); } if (total === 0) { done(); } }, - add: function(fn) { + add(fn) { this._cleanupFns.push(fn); }, - deleteCustomer: function(custId) { + deleteCustomer(custId) { this.add(function() { return this._stripe.customers.del(custId); }); }, - deletePlan: function(pId) { + deletePlan(pId) { this.add(function() { return this._stripe.plans.del(pId); }); }, - deleteCoupon: function(cId) { + deleteCoupon(cId) { this.add(function() { return this._stripe.coupons.del(cId); }); }, - deleteInvoiceItem: function(iiId) { + deleteInvoiceItem(iiId) { this.add(function() { return this._stripe.invoiceItems.del(iiId); }); @@ -135,20 +141,22 @@ var utils = module.exports = { }; return CleanupUtility; - }()), + })(), /** - * Get a random string for test Object creation - */ - getRandomString: function() { - return Math.random().toString(36).slice(2); + * Get a random string for test Object creation + */ + getRandomString: () => { + return Math.random() + .toString(36) + .slice(2); }, - envSupportsForAwait: function() { + envSupportsForAwait: () => { return typeof Symbol !== 'undefined' && Symbol.asyncIterator; }, - envSupportsAwait: function() { + envSupportsAwait: () => { try { eval('(async function() {})'); // eslint-disable-line no-eval return true; @@ -156,4 +164,4 @@ var utils = module.exports = { return false; } }, -}; +}); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000000..7f94228727 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,2329 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/code-frame@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" + integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== + dependencies: + "@babel/highlight" "^7.0.0" + +"@babel/generator@^7.4.0", "@babel/generator@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.4.4.tgz#174a215eb843fc392c7edcaabeaa873de6e8f041" + integrity sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ== + dependencies: + "@babel/types" "^7.4.4" + jsesc "^2.5.1" + lodash "^4.17.11" + source-map "^0.5.0" + trim-right "^1.0.1" + +"@babel/helper-function-name@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" + integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== + dependencies: + "@babel/helper-get-function-arity" "^7.0.0" + "@babel/template" "^7.1.0" + "@babel/types" "^7.0.0" + +"@babel/helper-get-function-arity@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" + integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== + dependencies: + "@babel/types" "^7.0.0" + +"@babel/helper-split-export-declaration@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz#ff94894a340be78f53f06af038b205c49d993677" + integrity sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q== + dependencies: + "@babel/types" "^7.4.4" + +"@babel/highlight@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" + integrity sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw== + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^4.0.0" + +"@babel/parser@^7.0.0", "@babel/parser@^7.4.3", "@babel/parser@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.4.4.tgz#5977129431b8fe33471730d255ce8654ae1250b6" + integrity sha512-5pCS4mOsL+ANsFZGdvNLybx4wtqAZJ0MJjMHxvzI3bvIsz6sQvzW8XX92EYIkiPtIvcfG3Aj+Ir5VNyjnZhP7w== + +"@babel/template@^7.1.0", "@babel/template@^7.4.0": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237" + integrity sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/parser" "^7.4.4" + "@babel/types" "^7.4.4" + +"@babel/traverse@^7.0.0", "@babel/traverse@^7.4.3": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.4.4.tgz#0776f038f6d78361860b6823887d4f3937133fe8" + integrity sha512-Gw6qqkw/e6AGzlyj9KnkabJX7VcubqPtkUQVAwkc0wUMldr3A/hezNB3Rc5eIvId95iSGkGIOe5hh1kMKf951A== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.4.4" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.4.4" + "@babel/parser" "^7.4.4" + "@babel/types" "^7.4.4" + debug "^4.1.0" + globals "^11.1.0" + lodash "^4.17.11" + +"@babel/types@^7.0.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.4.4.tgz#8db9e9a629bb7c29370009b4b779ed93fe57d5f0" + integrity sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ== + dependencies: + esutils "^2.0.2" + lodash "^4.17.11" + to-fast-properties "^2.0.0" + +acorn-jsx@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.1.tgz#32a064fd925429216a09b141102bfdd185fae40e" + integrity sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg== + +acorn@^6.0.7: + version "6.1.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f" + integrity sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA== + +ajv@^6.5.5, ajv@^6.9.1: + version "6.10.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.0.tgz#90d0d54439da587cd7e843bfb7045f50bd22bdf1" + integrity sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg== + dependencies: + fast-deep-equal "^2.0.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-colors@3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" + integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== + +ansi-escapes@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" + integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +append-transform@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-1.0.0.tgz#046a52ae582a228bd72f58acfbe2967c678759ab" + integrity sha512-P009oYkeHyU742iSZJzZZywj4QRJdnTWffaKuJQLablCZ1uz6/cW4yaRgcDaoQ+uwOxxnt0gRUcwfsNP2ri0gw== + dependencies: + default-require-extensions "^2.0.0" + +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA= + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +asn1@~0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= + +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + +astral-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" + integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= + +aws4@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" + integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ== + +babel-eslint@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed" + integrity sha512-z7OT1iNV+TjOwHNLLyJk+HN+YVWX+CLE6fPD2SymJZOZQBs+QIexFjhm4keGTm8MW9xr4EC9Q0PbaLB24V5GoQ== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/parser" "^7.0.0" + "@babel/traverse" "^7.0.0" + "@babel/types" "^7.0.0" + eslint-scope "3.7.1" + eslint-visitor-keys "^1.0.0" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= + dependencies: + tweetnacl "^0.14.3" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +caching-transform@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/caching-transform/-/caching-transform-3.0.2.tgz#601d46b91eca87687a281e71cef99791b0efca70" + integrity sha512-Mtgcv3lh3U0zRii/6qVgQODdPA4G3zhG+jtbCWj39RXuUFTMzH0vcdMtaJS1jPowd+It2Pqr6y3NJMQqOqCE2w== + dependencies: + hasha "^3.0.0" + make-dir "^2.0.0" + package-hash "^3.0.0" + write-file-atomic "^2.4.2" + +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= + +chai-as-promised@~7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-7.1.1.tgz#08645d825deb8696ee61725dbf590c012eb00ca0" + integrity sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA== + dependencies: + check-error "^1.0.2" + +chai@^4.1.2, chai@~4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5" + integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.0" + type-detect "^4.0.5" + +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chardet@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" + integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== + +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= + +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" + integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU= + dependencies: + restore-cursor "^2.0.0" + +cli-width@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" + integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= + +cliui@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" + integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== + dependencies: + string-width "^2.1.1" + strip-ansi "^4.0.0" + wrap-ansi "^2.0.0" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +combined-stream@^1.0.6, combined-stream@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" + integrity sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w== + dependencies: + delayed-stream "~1.0.0" + +commander@~2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" + integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== + +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" + integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +convert-source-map@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.6.0.tgz#51b537a8c43e0f04dec1993bffcdd504e758ac20" + integrity sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A== + dependencies: + safe-buffer "~5.1.1" + +core-util-is@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + +coveralls@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-3.0.3.tgz#83b1c64aea1c6afa69beaf50b55ac1bc4d13e2b8" + integrity sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg== + dependencies: + growl "~> 1.10.0" + js-yaml "^3.11.0" + lcov-parse "^0.0.10" + log-driver "^1.2.7" + minimist "^1.2.0" + request "^2.86.0" + +cp-file@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/cp-file/-/cp-file-6.2.0.tgz#40d5ea4a1def2a9acdd07ba5c0b0246ef73dc10d" + integrity sha512-fmvV4caBnofhPe8kOcitBwSn2f39QLjnAnGq3gO9dfd75mUytzKNZB1hde6QHunW2Rt+OwuBOMc3i1tNElbszA== + dependencies: + graceful-fs "^4.1.2" + make-dir "^2.0.0" + nested-error-stacks "^2.0.0" + pify "^4.0.1" + safe-buffer "^5.0.1" + +cross-spawn@^4: + version "4.0.2" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" + integrity sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE= + dependencies: + lru-cache "^4.0.1" + which "^1.2.9" + +cross-spawn@^6.0.0, cross-spawn@^6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= + dependencies: + assert-plus "^1.0.0" + +debug@3.2.6: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + +decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== + dependencies: + type-detect "^4.0.0" + +deep-equal@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" + integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU= + +deep-is@~0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" + integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= + +default-require-extensions@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-2.0.0.tgz#f5f8fbb18a7d6d50b21f641f649ebb522cfe24f7" + integrity sha1-9fj7sYp9bVCyH2QfZJ67Uiz+JPc= + dependencies: + strip-bom "^3.0.0" + +define-properties@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" + integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== + dependencies: + object-keys "^1.0.12" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + +diff@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" + +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +end-of-stream@^1.1.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" + integrity sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q== + dependencies: + once "^1.4.0" + +error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +es-abstract@^1.5.1: + version "1.13.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.13.0.tgz#ac86145fdd5099d8dd49558ccba2eaf9b88e24e9" + integrity sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg== + dependencies: + es-to-primitive "^1.2.0" + function-bind "^1.1.1" + has "^1.0.3" + is-callable "^1.1.4" + is-regex "^1.0.4" + object-keys "^1.0.12" + +es-to-primitive@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" + integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" + +es6-error@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" + integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +eslint-config-prettier@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-4.2.0.tgz#70b946b629cd0e3e98233fd9ecde4cb9778de96c" + integrity sha512-y0uWc/FRfrHhpPZCYflWC8aE0KRJRY04rdZVfl8cL3sEZmOYyaBdhdlQPjKZBnuRMyLVK+JUZr7HaZFClQiH4w== + dependencies: + get-stdin "^6.0.0" + +eslint-plugin-chai-friendly@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.4.1.tgz#9eeb17f92277ba80bb64f0e946c6936a3ae707b4" + integrity sha512-hkpLN7VVoGGsofZjUhcQ+sufC3FgqMJwD0DvAcRfxY1tVRyQyVsqpaKnToPHJQOrRo0FQ0fSEDwW2gr4rsNdGA== + +eslint-plugin-flowtype@^3.8.1: + version "3.8.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-3.8.1.tgz#fefbc160b8f55c0bc0201236471637ad47ca6886" + integrity sha512-7ye/CCdTzytOu54Y1dUed/ejcIPMe0eSlxhfPIhOv2DCMvLMbwYGagEYfEuJ1ylMhkt8Z+rt8VtJXniNwC3hRQ== + dependencies: + lodash "^4.17.11" + +eslint-plugin-prettier@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.1.tgz#19d521e3981f69dd6d14f64aec8c6a6ac6eb0b0d" + integrity sha512-/PMttrarPAY78PLvV3xfWibMOdMDl57hmlQ2XqFeA37wd+CJ7WSxV7txqjVPHi/AAFKd2lX0ZqfsOc/i5yFCSQ== + dependencies: + prettier-linter-helpers "^1.0.0" + +eslint-scope@3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" + integrity sha1-PWPD7f2gLgbgGkUq2IyqzHzctug= + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-scope@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" + integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-utils@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.3.1.tgz#9a851ba89ee7c460346f97cf8939c7298827e512" + integrity sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q== + +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ== + +eslint@^5.16.0: + version "5.16.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea" + integrity sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg== + dependencies: + "@babel/code-frame" "^7.0.0" + ajv "^6.9.1" + chalk "^2.1.0" + cross-spawn "^6.0.5" + debug "^4.0.1" + doctrine "^3.0.0" + eslint-scope "^4.0.3" + eslint-utils "^1.3.1" + eslint-visitor-keys "^1.0.0" + espree "^5.0.1" + esquery "^1.0.1" + esutils "^2.0.2" + file-entry-cache "^5.0.1" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.7.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + inquirer "^6.2.2" + js-yaml "^3.13.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.11" + minimatch "^3.0.4" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.2" + progress "^2.0.0" + regexpp "^2.0.1" + semver "^5.5.1" + strip-ansi "^4.0.0" + strip-json-comments "^2.0.1" + table "^5.2.3" + text-table "^0.2.0" + +espree@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a" + integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A== + dependencies: + acorn "^6.0.7" + acorn-jsx "^5.0.0" + eslint-visitor-keys "^1.0.0" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esquery@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" + integrity sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA== + dependencies: + estraverse "^4.0.0" + +esrecurse@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" + integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== + dependencies: + estraverse "^4.1.0" + +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" + integrity sha1-De4/7TH81GlhjOc0IJn8GvoL2xM= + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= + +execa@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== + dependencies: + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +external-editor@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.0.3.tgz#5866db29a97826dbe4bf3afd24070ead9ea43a27" + integrity sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA== + dependencies: + chardet "^0.7.0" + iconv-lite "^0.4.24" + tmp "^0.0.33" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= + +fast-deep-equal@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" + integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= + +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= + +fast-levenshtein@~2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + integrity sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI= + dependencies: + escape-string-regexp "^1.0.5" + +file-entry-cache@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" + integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== + dependencies: + flat-cache "^2.0.1" + +find-cache-dir@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" + integrity sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ== + dependencies: + commondir "^1.0.1" + make-dir "^2.0.0" + pkg-dir "^3.0.0" + +find-up@3.0.0, find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +flat-cache@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" + integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== + dependencies: + flatted "^2.0.0" + rimraf "2.6.3" + write "1.0.3" + +flat@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.0.tgz#090bec8b05e39cba309747f1d588f04dbaf98db2" + integrity sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw== + dependencies: + is-buffer "~2.0.3" + +flatted@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.0.tgz#55122b6536ea496b4b44893ee2608141d10d9916" + integrity sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg== + +foreground-child@^1.5.6: + version "1.5.6" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" + integrity sha1-T9ca0t/elnibmApcCilZN8svXOk= + dependencies: + cross-spawn "^4" + signal-exit "^3.0.0" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= + +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= + +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== + +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= + +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + +get-stream@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= + dependencies: + assert-plus "^1.0.0" + +glob@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.1.2, glob@^7.1.3: + version "7.1.4" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" + integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^11.1.0, globals@^11.7.0: + version "11.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== + +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: + version "4.1.15" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== + +growl@1.10.5, "growl@~> 1.10.0": + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== + +handlebars@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67" + integrity sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw== + dependencies: + neo-async "^2.6.0" + optimist "^0.6.1" + source-map "^0.6.1" + optionalDependencies: + uglify-js "^3.1.4" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= + +har-validator@~5.1.0: + version "5.1.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080" + integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g== + dependencies: + ajv "^6.5.5" + har-schema "^2.0.0" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" + integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q= + +has@^1.0.1, has@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + +hasha@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/hasha/-/hasha-3.0.0.tgz#52a32fab8569d41ca69a61ff1a214f8eb7c8bd39" + integrity sha1-UqMvq4Vp1BymmmH/GiFPjrfIvTk= + dependencies: + is-stream "^1.0.1" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +hosted-git-info@^2.1.4: + version "2.7.1" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" + integrity sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w== + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +iconv-lite@^0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ignore@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" + integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== + +import-fresh@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.0.0.tgz#a3d897f420cab0e671236897f75bc14b4885c390" + integrity sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + +inquirer@^6.2.2: + version "6.3.1" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.3.1.tgz#7a413b5e7950811013a3db491c61d1f3b776e8e7" + integrity sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA== + dependencies: + ansi-escapes "^3.2.0" + chalk "^2.4.2" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^3.0.3" + figures "^2.0.0" + lodash "^4.17.11" + mute-stream "0.0.7" + run-async "^2.2.0" + rxjs "^6.4.0" + string-width "^2.1.0" + strip-ansi "^5.1.0" + through "^2.3.6" + +invert-kv@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" + integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + +is-buffer@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725" + integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw== + +is-callable@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" + integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== + +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= + +is-regex@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" + integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE= + dependencies: + has "^1.0.1" + +is-stream@^1.0.1, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + +is-symbol@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38" + integrity sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw== + dependencies: + has-symbols "^1.0.0" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= + +istanbul-lib-coverage@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz#675f0ab69503fad4b1d849f736baaca803344f49" + integrity sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA== + +istanbul-lib-hook@^2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-2.0.7.tgz#c95695f383d4f8f60df1f04252a9550e15b5b133" + integrity sha512-vrRztU9VRRFDyC+aklfLoeXyNdTfga2EI3udDGn4cZ6fpSXpHLV9X6CHvfoMCPtggg8zvDDmC4b9xfu0z6/llA== + dependencies: + append-transform "^1.0.0" + +istanbul-lib-instrument@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz#a5f63d91f0bbc0c3e479ef4c5de027335ec6d630" + integrity sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA== + dependencies: + "@babel/generator" "^7.4.0" + "@babel/parser" "^7.4.3" + "@babel/template" "^7.4.0" + "@babel/traverse" "^7.4.3" + "@babel/types" "^7.4.0" + istanbul-lib-coverage "^2.0.5" + semver "^6.0.0" + +istanbul-lib-report@^2.0.8: + version "2.0.8" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz#5a8113cd746d43c4889eba36ab10e7d50c9b4f33" + integrity sha512-fHBeG573EIihhAblwgxrSenp0Dby6tJMFR/HvlerBsrCTD5bkUuoNtn3gVh29ZCS824cGGBPn7Sg7cNk+2xUsQ== + dependencies: + istanbul-lib-coverage "^2.0.5" + make-dir "^2.1.0" + supports-color "^6.1.0" + +istanbul-lib-source-maps@^3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz#284997c48211752ec486253da97e3879defba8c8" + integrity sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw== + dependencies: + debug "^4.1.1" + istanbul-lib-coverage "^2.0.5" + make-dir "^2.1.0" + rimraf "^2.6.3" + source-map "^0.6.1" + +istanbul-reports@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-2.2.4.tgz#4e0d0ddf0f0ad5b49a314069d31b4f06afe49ad3" + integrity sha512-QCHGyZEK0bfi9GR215QSm+NJwFKEShbtc7tfbUdLAEzn3kKhLDDZqvljn8rPZM9v8CEOhzL1nlYoO4r1ryl67w== + dependencies: + handlebars "^4.1.2" + +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-yaml@3.13.1, js-yaml@^3.11.0, js-yaml@^3.13.0, js-yaml@^3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" + integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= + +jsesc@^2.5.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" + integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== + +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +lcid@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" + integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA== + dependencies: + invert-kv "^2.0.0" + +lcov-parse@^0.0.10: + version "0.0.10" + resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" + integrity sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM= + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + +lodash.flattendeep@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" + integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= + +lodash.isplainobject@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= + +lodash@^4.17.11, lodash@^4.17.5: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== + +log-driver@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.7.tgz#63b95021f0702fedfa2c9bb0a24e7797d71871d8" + integrity sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg== + +log-symbols@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" + integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== + dependencies: + chalk "^2.0.1" + +lru-cache@^4.0.1: + version "4.1.5" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" + integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + +make-dir@^2.0.0, make-dir@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" + integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== + dependencies: + pify "^4.0.1" + semver "^5.6.0" + +map-age-cleaner@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" + integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== + dependencies: + p-defer "^1.0.0" + +mem@^4.0.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178" + integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w== + dependencies: + map-age-cleaner "^0.1.1" + mimic-fn "^2.0.0" + p-is-promise "^2.0.0" + +merge-source-map@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646" + integrity sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw== + dependencies: + source-map "^0.6.1" + +mime-db@1.40.0: + version "1.40.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32" + integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA== + +mime-types@^2.1.12, mime-types@~2.1.19: + version "2.1.24" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81" + integrity sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ== + dependencies: + mime-db "1.40.0" + +mimic-fn@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== + +mimic-fn@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimatch@3.0.4, minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= + +minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= + +mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= + dependencies: + minimist "0.0.8" + +mocha@~6.1.4: + version "6.1.4" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.1.4.tgz#e35fada242d5434a7e163d555c705f6875951640" + integrity sha512-PN8CIy4RXsIoxoFJzS4QNnCH4psUCPWc4/rPrst/ecSJJbLBkubMiyGCP2Kj/9YnWbotFqAoeXyXMucj7gwCFg== + dependencies: + ansi-colors "3.2.3" + browser-stdout "1.3.1" + debug "3.2.6" + diff "3.5.0" + escape-string-regexp "1.0.5" + find-up "3.0.0" + glob "7.1.3" + growl "1.10.5" + he "1.2.0" + js-yaml "3.13.1" + log-symbols "2.2.0" + minimatch "3.0.4" + mkdirp "0.5.1" + ms "2.1.1" + node-environment-flags "1.0.5" + object.assign "4.1.0" + strip-json-comments "2.0.1" + supports-color "6.0.0" + which "1.3.1" + wide-align "1.1.3" + yargs "13.2.2" + yargs-parser "13.0.0" + yargs-unparser "1.5.0" + +ms@2.1.1, ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" + integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + +neo-async@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.0.tgz#b9d15e4d71c6762908654b5183ed38b753340835" + integrity sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA== + +nested-error-stacks@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz#0fbdcf3e13fe4994781280524f8b96b0cdff9c61" + integrity sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug== + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +nock@^10.0.6: + version "10.0.6" + resolved "https://registry.yarnpkg.com/nock/-/nock-10.0.6.tgz#e6d90ee7a68b8cfc2ab7f6127e7d99aa7d13d111" + integrity sha512-b47OWj1qf/LqSQYnmokNWM8D88KvUl2y7jT0567NB3ZBAZFz2bWp2PC81Xn7u8F2/vJxzkzNZybnemeFa7AZ2w== + dependencies: + chai "^4.1.2" + debug "^4.1.0" + deep-equal "^1.0.0" + json-stringify-safe "^5.0.1" + lodash "^4.17.5" + mkdirp "^0.5.0" + propagate "^1.0.0" + qs "^6.5.1" + semver "^5.5.0" + +node-environment-flags@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.5.tgz#fa930275f5bf5dae188d6192b24b4c8bbac3d76a" + integrity sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ== + dependencies: + object.getownpropertydescriptors "^2.0.3" + semver "^5.7.0" + +normalize-package-data@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= + dependencies: + path-key "^2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= + +nyc@^14.1.0: + version "14.1.0" + resolved "https://registry.yarnpkg.com/nyc/-/nyc-14.1.0.tgz#ae864913a4c5a947bfaebeb66a488bdb1868c9a3" + integrity sha512-iy9fEV8Emevz3z/AanIZsoGa8F4U2p0JKevZ/F0sk+/B2r9E6Qn+EPs0bpxEhnAt6UPlTL8mQZIaSJy8sK0ZFw== + dependencies: + archy "^1.0.0" + caching-transform "^3.0.2" + convert-source-map "^1.6.0" + cp-file "^6.2.0" + find-cache-dir "^2.1.0" + find-up "^3.0.0" + foreground-child "^1.5.6" + glob "^7.1.3" + istanbul-lib-coverage "^2.0.5" + istanbul-lib-hook "^2.0.7" + istanbul-lib-instrument "^3.3.0" + istanbul-lib-report "^2.0.8" + istanbul-lib-source-maps "^3.0.6" + istanbul-reports "^2.2.4" + js-yaml "^3.13.1" + make-dir "^2.1.0" + merge-source-map "^1.1.0" + resolve-from "^4.0.0" + rimraf "^2.6.3" + signal-exit "^3.0.2" + spawn-wrap "^1.4.2" + test-exclude "^5.2.3" + uuid "^3.3.2" + yargs "^13.2.2" + yargs-parser "^13.0.0" + +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-keys@^1.0.11, object-keys@^1.0.12: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object.assign@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + +object.getownpropertydescriptors@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" + integrity sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY= + dependencies: + define-properties "^1.1.2" + es-abstract "^1.5.1" + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + integrity sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ= + dependencies: + mimic-fn "^1.0.0" + +optimist@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + integrity sha1-2j6nRob6IaGaERwybpDrFaAZZoY= + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +optionator@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" + integrity sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q= + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.4" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + wordwrap "~1.0.0" + +os-homedir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= + +os-locale@^3.0.0, os-locale@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" + integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q== + dependencies: + execa "^1.0.0" + lcid "^2.0.0" + mem "^4.0.0" + +os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + +p-defer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= + +p-is-promise@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" + integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg== + +p-limit@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" + integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +package-hash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-3.0.0.tgz#50183f2d36c9e3e528ea0a8605dff57ce976f88e" + integrity sha512-lOtmukMDVvtkL84rJHI7dpTYq+0rli8N2wlnqUcBuDWCfVhRUfOmnR9SsoHFMLpACvEV60dX7rd0rFaYDZI+FA== + dependencies: + graceful-fs "^4.1.15" + hasha "^3.0.0" + lodash.flattendeep "^4.4.0" + release-zalgo "^1.0.0" + +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-is-inside@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= + +path-key@^2.0.0, path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= + +path-parse@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" + integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== + dependencies: + pify "^3.0.0" + +pathval@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0" + integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA= + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= + +pify@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" + integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== + +pkg-dir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" + integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== + dependencies: + find-up "^3.0.0" + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= + +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@^1.16.4: + version "1.17.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.0.tgz#53b303676eed22cc14a9f0cec09b477b3026c008" + integrity sha512-sXe5lSt2WQlCbydGETgfm1YBShgOX4HxQkFPvbxkcwgDvGDeqVau8h+12+lmSVlP3rHPz0oavfddSZg/q+Szjw== + +progress@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + +propagate@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/propagate/-/propagate-1.0.0.tgz#00c2daeedda20e87e3782b344adba1cddd6ad709" + integrity sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk= + +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= + +psl@^1.1.24: + version "1.1.31" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184" + integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw== + +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= + +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +qs@^6.5.1, qs@^6.6.0: + version "6.7.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" + integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== + +qs@~6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== + +read-pkg-up@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-4.0.0.tgz#1b221c6088ba7799601c808f91161c66e58f8978" + integrity sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA== + dependencies: + find-up "^3.0.0" + read-pkg "^3.0.0" + +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + +regexpp@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" + integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== + +release-zalgo@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/release-zalgo/-/release-zalgo-1.0.0.tgz#09700b7e5074329739330e535c5a90fb67851730" + integrity sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= + dependencies: + es6-error "^4.0.1" + +request@^2.86.0: + version "2.88.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" + integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.0" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.4.3" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +resolve@^1.10.0: + version "1.10.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.1.tgz#664842ac960795bbe758221cdccda61fb64b5f18" + integrity sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA== + dependencies: + path-parse "^1.0.6" + +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" + integrity sha1-n37ih/gv0ybU/RYpI9YhKe7g368= + dependencies: + onetime "^2.0.0" + signal-exit "^3.0.2" + +rimraf@2.6.3, rimraf@^2.6.2, rimraf@^2.6.3: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" + integrity sha1-A3GrSuC91yDUFm19/aZP96RFpsA= + dependencies: + is-promise "^2.1.0" + +rxjs@^6.4.0: + version "6.5.1" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.1.tgz#f7a005a9386361921b8524f38f54cbf80e5d08f4" + integrity sha512-y0j31WJc83wPu31vS1VlAFW5JGrnGC+j+TtGAa1fRQphy48+fDYiDmX8tjGloToEsMkxnouOg/1IzXGKkJnZMg== + dependencies: + tslib "^1.9.0" + +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +"semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: + version "5.7.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" + integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== + +semver@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.0.0.tgz#05e359ee571e5ad7ed641a6eec1e547ba52dea65" + integrity sha512-0UewU+9rFapKFnlbirLi3byoOuhrSsli/z/ihNnvM24vgF+8sNBiI1LZPBSH9wJKUwaUbw+s3hToDLCXkrghrQ== + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + +signal-exit@^3.0.0, signal-exit@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= + +slice-ansi@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" + integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== + dependencies: + ansi-styles "^3.2.0" + astral-regex "^1.0.0" + is-fullwidth-code-point "^2.0.0" + +source-map@^0.5.0: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + +source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spawn-wrap@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.2.tgz#cff58e73a8224617b6561abdc32586ea0c82248c" + integrity sha512-vMwR3OmmDhnxCVxM8M+xO/FtIp6Ju/mNaDfCMMW7FDcLRTPFWUswec4LXJHTJE2hwTI9O0YBfygu4DalFl7Ylg== + dependencies: + foreground-child "^1.5.6" + mkdirp "^0.5.0" + os-homedir "^1.0.1" + rimraf "^2.6.2" + signal-exit "^3.0.2" + which "^1.3.0" + +spdx-correct@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" + integrity sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz#2ea450aee74f2a89bfb94519c07fcd6f41322977" + integrity sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA== + +spdx-expression-parse@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" + integrity sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz#75ecd1a88de8c184ef015eafb51b5b48bfd11bb1" + integrity sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + +sshpk@^1.7.0: + version "1.16.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" + integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + bcrypt-pbkdf "^1.0.0" + dashdash "^1.12.0" + ecc-jsbn "~0.1.1" + getpass "^0.1.1" + jsbn "~0.1.0" + safer-buffer "^2.0.2" + tweetnacl "~0.14.0" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string-width@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= + dependencies: + ansi-regex "^3.0.0" + +strip-ansi@^5.1.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= + +strip-json-comments@2.0.1, strip-json-comments@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + +supports-color@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" + integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== + dependencies: + has-flag "^3.0.0" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + +table@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/table/-/table-5.2.3.tgz#cde0cc6eb06751c009efab27e8c820ca5b67b7f2" + integrity sha512-N2RsDAMvDLvYwFcwbPyF3VmVSSkuF+G1e+8inhBLtHpvwXGw4QRPEZhihQNeEN0i1up6/f6ObCJXNdlRG3YVyQ== + dependencies: + ajv "^6.9.1" + lodash "^4.17.11" + slice-ansi "^2.1.0" + string-width "^3.0.0" + +test-exclude@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0" + integrity sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g== + dependencies: + glob "^7.1.3" + minimatch "^3.0.4" + read-pkg-up "^4.0.0" + require-main-filename "^2.0.0" + +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + +through@^2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= + +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= + +tough-cookie@~2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" + integrity sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ== + dependencies: + psl "^1.1.24" + punycode "^1.4.1" + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + +tslib@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" + integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= + dependencies: + prelude-ls "~1.1.2" + +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + +uglify-js@^3.1.4: + version "3.5.11" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.5.11.tgz#833442c0aa29b3a7d34344c7c63adaa3f3504f6a" + integrity sha512-izPJg8RsSyqxbdnqX36ExpbH3K7tDBsAU/VfNv89VkMFy3z39zFjunQGsSHOlGlyIfGLGprGeosgQno3bo2/Kg== + dependencies: + commander "~2.20.0" + source-map "~0.6.1" + +uri-js@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" + integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + dependencies: + punycode "^2.1.0" + +uuid@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +which@1.3.1, which@^1.2.9, which@^1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +wide-align@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= + +wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +write-file-atomic@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.2.tgz#a7181706dfba17855d221140a9c06e15fcdd87b9" + integrity sha512-s0b6vB3xIVRLWywa6X9TOMA7k9zio0TMOsl9ZnDkliA/cfJlpHXAscj0gbHVJiTdIuAYpIyqS5GW91fqm6gG5g== + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + +write@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" + integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== + dependencies: + mkdirp "^0.5.1" + +"y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= + +yargs-parser@13.0.0: + version "13.0.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.0.0.tgz#3fc44f3e76a8bdb1cc3602e860108602e5ccde8b" + integrity sha512-w2LXjoL8oRdRQN+hOyppuXs+V/fVAYtpcrRxZuF7Kt/Oc+Jr2uAcVntaUTNT6w5ihoWfFDpNY8CPx1QskxZ/pw== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-parser@^11.1.1: + version "11.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4" + integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-parser@^13.0.0: + version "13.1.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.0.tgz#7016b6dd03e28e1418a510e258be4bff5a31138f" + integrity sha512-Yq+32PrijHRri0vVKQEm+ys8mbqWjLiwQkMFNXEENutzLPP0bE4Lcd4iA3OQY5HF+GD3xXxf0MEHb8E4/SA3AA== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-unparser@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.5.0.tgz#f2bb2a7e83cbc87bb95c8e572828a06c9add6e0d" + integrity sha512-HK25qidFTCVuj/D1VfNiEndpLIeJN78aqgR23nL3y4N0U/91cOAzqfHlF8n2BvoNDcZmJKin3ddNSvOxSr8flw== + dependencies: + flat "^4.1.0" + lodash "^4.17.11" + yargs "^12.0.5" + +yargs@13.2.2, yargs@^13.2.2: + version "13.2.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.2.tgz#0c101f580ae95cea7f39d927e7770e3fdc97f993" + integrity sha512-WyEoxgyTD3w5XRpAQNYUB9ycVH/PQrToaTXdYXRdOXvEy1l19br+VJsc0vcO8PTGg5ro/l/GY7F/JMEBmI0BxA== + dependencies: + cliui "^4.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + os-locale "^3.1.0" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.0.0" + +yargs@^12.0.5: + version "12.0.5" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13" + integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw== + dependencies: + cliui "^4.0.0" + decamelize "^1.2.0" + find-up "^3.0.0" + get-caller-file "^1.0.1" + os-locale "^3.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1 || ^4.0.0" + yargs-parser "^11.1.1"