Skip to content

Commit

Permalink
Merge pull request #69 from recurly/convert-array-to-csv
Browse files Browse the repository at this point in the history
Convert Array params to CSV strings
  • Loading branch information
bhelx authored Dec 10, 2019
2 parents eed4bb0 + a98fba8 commit cc7fc21
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.2.0
current_version = 3.2.1
parse = (?P<major>\d+)
\.(?P<minor>\d+)
\.(?P<patch>\d+)
Expand Down
2 changes: 1 addition & 1 deletion doc/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Or manually insert the dependency into the `dependencies` section of your `packa
```
{
// ...
"recurly" : "^3.2.0"
"recurly" : "^3.2.1"
// ...
}
```
Expand Down
16 changes: 15 additions & 1 deletion lib/recurly/Pager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Pager {
constructor (client, path, params) {
this.client = client
this.path = path
this.params = params
this.params = this._mapArrayParams(params)
}

/**
Expand Down Expand Up @@ -123,6 +123,20 @@ class Pager {
this._paramsConsumed = true
return this.params
}

// Converts array parameters to CSV strings to maintain consistency with
// how the server expects the request to be formatted while providing the
// developer with an array type to maintain developer happiness!
_mapArrayParams (params) {
return Object.keys(params).reduce((res, key) => {
if (Array.isArray(params[key])) {
res[key] = params[key].join(',')
} else {
res[key] = params[key]
}
return res
}, {})
}
}

module.exports = Pager
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recurly",
"version": "3.2.0",
"version": "3.2.1",
"description": "Recurly V3 node client",
"main": "lib/recurly.js",
"scripts": {
Expand Down

0 comments on commit cc7fc21

Please sign in to comment.