Skip to content

Commit

Permalink
feat: add optional url param support to account activity List()
Browse files Browse the repository at this point in the history
Depends on ns1#234
  • Loading branch information
tjhop committed Apr 4, 2024
1 parent 5ed1f9e commit 733809b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion mockns1/account_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mockns1
import (
"net/http"

api "gopkg.in/ns1/ns1-go.v2/rest"
"gopkg.in/ns1/ns1-go.v2/rest/model/account"
)

Expand All @@ -11,9 +12,10 @@ import (
func (s *Service) AddActivityListTestCase(
requestHeaders, responseHeaders http.Header,
response []*account.Activity,
params ...api.Param,
) error {
return s.AddTestCase(
http.MethodGet, "/account/activity", http.StatusOK, requestHeaders,
responseHeaders, "", response,
responseHeaders, "", response, params...,
)
}
10 changes: 6 additions & 4 deletions rest/account_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import (
// ActivityService handles 'account/activity' endpoint.
type ActivityService service

// List returns all activity in the account.
// List returns all activity in the account. It accepts a variadic number of
// optional URL parameters that can be used to edit the endpoint's behavior.
// Parameters are in the form of a `rest.Param` struct. The full list of valid
// parameters for this endpoint are available in the documentation.
//
// NS1 API docs: https://developer.ibm.com/apis/catalog/ns1--ibm-ns1-connect-api/api/API--ns1--ibm-ns1-connect-api#getActivity
func (s *ActivityService) List() ([]*account.Activity, *http.Response, error) {
// TODO: add support for url parameters to adjust endpoint behavior?
func (s *ActivityService) List(params ...Param) ([]*account.Activity, *http.Response, error) {
req, err := s.client.NewRequest("GET", "account/activity", nil)
if err != nil {
return nil, nil, err
}

al := []*account.Activity{}
resp, err := s.client.Do(req, &al)
resp, err := s.client.Do(req, &al, params...)
if err != nil {
return nil, resp, err
}
Expand Down

0 comments on commit 733809b

Please sign in to comment.