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

Pagination for site rules #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,8 @@ func getResponseSiteRuleBody(response []byte) (ResponseSiteRuleBody, error) {
// GetAllSiteRules Lists the Site Rules
func (sc *Client) GetAllSiteRules(corpName, siteName string) (ResponseSiteRuleBodyList, error) {
resp, err := sc.doRequest("GET", fmt.Sprintf("/v0/corps/%s/sites/%s/rules", corpName, siteName), "")
func (sc *Client) GetAllSiteRules(corpName, siteName string, limit, page int) (ResponseSiteRuleBodyList, error) {
resp, err := sc.doRequest("GET", fmt.Sprintf("/v0/corps/%s/sites/%s/rules?limit=%d&page=%d", corpName, siteName, limit, page), "")

if err != nil {
return ResponseSiteRuleBodyList{}, err
Expand Down
6 changes: 3 additions & 3 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestCreateReadUpdateDeleteSiteRules(t *testing.T) {
t.Errorf("CreateSiteRules got: %v expected %v", updateResp, updateSiteRuleBody)
}

readall, err := sc.GetAllSiteRules(corp, site)
readall, err := sc.GetAllSiteRules(corp, site, 20, 1)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -336,14 +336,14 @@ func TestDeleteAllSiteRules(t *testing.T) {
sc := NewTokenClient(testcreds.email, testcreds.token)
corp := testcreds.corp
site := testcreds.site
respList, err := sc.GetAllSiteRules(corp, site)
respList, err := sc.GetAllSiteRules(corp, site, 20, 1)
if err != nil {
t.Fatal(err)
}
for _, rule := range respList.Data {
sc.DeleteSiteRuleByID(corp, site, rule.ID)
}
respList, err = sc.GetAllSiteRules(corp, site)
respList, err = sc.GetAllSiteRules(corp, site, 20, 1)
if err != nil {
t.Fatal(err)
}
Expand Down