Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for setting URL parameters on client requests #234

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

tjhop
Copy link
Contributor

@tjhop tjhop commented Apr 4, 2024

Several NS1 API endpoints allow setting URL parameters to alter the behavior of the endpoint. For instance, a limit parameter can be set on the /account/activity endpoint to control how many events are returned in the response. This would be useful in #233.

This commit adds support for URL parameters by adding a new struct Param to the rest package, and updating rest.client.Do() and rest.client.DoWithPagination() to accept a variable amount of params. In order for higher level services based off of the common service to set url params, they will need to pass them through when invoking the client's Do() method, like so:

resp, err := s.client.Do(req, &al, params...)

Several NS1 API endpoints allow setting URL parameters to alter the
behavior of the endpoint. For instance, a `limit` parameter can be set
on the `/account/activity` endpoint to control how many events are
returned in the response. This would be useful in ns1#233.

This commit adds support for URL parameters by adding a new struct
`Param` to the `rest` package, and updating `rest.client.Do()` and
`rest.client.DoWithPagination()` to accept a variable amount of params.
In order for higher level services based off of the common service to
set url params, they will need to pass them through when invoking the
client's `Do()` method, like so:

```golang
resp, err := s.client.Do(req, &al, params...)
```
tjhop added a commit to tjhop/ns1-go that referenced this pull request Apr 4, 2024
tjhop added a commit to tjhop/ns1-go that referenced this pull request Apr 4, 2024
mockns1/testcase.go Outdated Show resolved Hide resolved
tjhop added a commit to tjhop/ns1-go that referenced this pull request Apr 4, 2024
Depends on ns1#234

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
tjhop added a commit to tjhop/ns1-go that referenced this pull request Apr 4, 2024
Depends on ns1#234

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
tjhop added 2 commits April 4, 2024 15:50
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
Updating doc comments to reflect what these URL parameter configs
are/do.

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
@bduggan-ns1 bduggan-ns1 merged commit affe463 into ns1:v2 Apr 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants