From 94ca8e25d787b2a63bb52ae9cf8b160d8f0ae72d Mon Sep 17 00:00:00 2001 From: Will Herrin Date: Mon, 26 Sep 2022 16:44:55 -0700 Subject: [PATCH] Pagination for site rules --- api.go | 2 ++ api_test.go | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index ba4a311..c438b85 100644 --- a/api.go +++ b/api.go @@ -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 diff --git a/api_test.go b/api_test.go index ebe06b3..5353e1a 100644 --- a/api_test.go +++ b/api_test.go @@ -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) } @@ -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) }