Skip to content

Commit ab6a982

Browse files
committed
feat(responses): accept response ids to filter in list method
1 parent 237df8c commit ab6a982

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,20 @@ Each one of them encapsulates the operations related to it (like listing, updati
198198

199199
### Responses
200200

201-
#### `responses.list({ uid, pageSize, since, until, after, before, completed, sort, query, fields })`
202-
- List responses from the given ID
203-
- `uid`: typeform UID
201+
#### `responses.list({ uid, pageSize, since, until, after, before, ids, completed, sort, query, fields })`
202+
203+
- Returns form responses and date and time of form landing and submission.
204+
- `uid`: Unique ID for the form.
205+
- `pageSize`: Maximum number of responses. Default value is 25. Maximum value is 1000.
206+
- `since`: Limit request to responses submitted since the specified date and time. In ISO 8601 format, UTC time, to the second, with T as a delimiter between the date and time.
207+
- `until`: Limit request to responses submitted until the specified date and time. In ISO 8601 format, UTC time, to the second, with T as a delimiter between the date and time.
208+
- `after`: Limit request to responses submitted after the specified token. If you use the `after` parameter, the responses will be sorted in the order that our system processed them (instead of the default order, `submitted_at`).
209+
- `before`: Limit request to responses submitted before the specified token. If you use the `before` parameter, the responses will be sorted in the order that our system processed them (instead of the default order, `submitted_at`).
210+
- `ids`: Limit request to the specified ids. Accepts either a string or an array of strings.
211+
- `completed`: `true` if form was submitted. Otherwise, `false`.
212+
- `sort`: Order of responses. Currently, responses are automatically sorted by `submitted_at,desc`---the date they were submitted, from newest to oldest. We plan to add more options for sort order soon.
213+
- `query`: Limit request to only responses that that include the specified string. You can specify any string as the `query` value. The string will be escaped, and the query will include Hidden Fields.
214+
- `fields`: Limit request to only responses for the specified fields. Accepts either a string or an array of strings.
204215
- For parameter details check [the documentation](https://developer.typeform.com/responses/reference/retrieve-responses/)
205216

206217
### Webhooks

src/responses.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Responses {
55
this._http = _http
66
}
77

8-
list ({ uid, pageSize, since, until, after, before, completed, sort, query, fields } = {}) {
8+
list ({ uid, pageSize, since, until, after, before, ids, completed, sort, query, fields } = {}) {
99
return this._http.request({
1010
method: 'get',
1111
url: `/forms/${uid}/responses`,
@@ -15,11 +15,20 @@ class Responses {
1515
until,
1616
after,
1717
before,
18+
included_response_ids: toCSL(ids),
1819
completed,
1920
sort,
2021
query,
21-
fields
22+
fields: toCSL(fields)
2223
}
2324
})
2425
}
2526
}
27+
28+
const toCSL = (args) => {
29+
if (!args || !(typeof args === 'string' || Array.isArray(args))) {
30+
return null
31+
}
32+
33+
return (typeof args === 'string') ? args : args.join(',')
34+
}

0 commit comments

Comments
 (0)