Skip to content

Commit

Permalink
Merge pull request #1 from gin-melodic/dev
Browse files Browse the repository at this point in the history
Pagination support
  • Loading branch information
gin-melodic authored Sep 15, 2022
2 parents 0868445 f99d1be commit 0354cba
Show file tree
Hide file tree
Showing 22 changed files with 1,389 additions and 76 deletions.
8 changes: 4 additions & 4 deletions category.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 40,13 @@ func (s *CategoryService) Get(categoryID string) (*Category, *Response, error) {
}

// GetListWithContext retrieve category list from project with context
func (s *CategoryService) GetListWithContext(ctx context.Context, projectID string) (*CategoryList, *Response, error) {
func (s *CategoryService) GetListWithContext(ctx context.Context, projectID string, offset int, pageSize int) (*CategoryList, *Response, error) {
apiEndpoint := fmt.Sprintf("api/v3/projects/%s/categories", projectID)
Obj, Resp, err := GetListWithContext(ctx, s, apiEndpoint, nil)
Obj, Resp, err := GetListWithContext(ctx, s, apiEndpoint, nil, offset, pageSize)
return Obj.(*CategoryList), Resp, err
}

// GetList wraps GetListWithContext using the background context.
func (s *CategoryService) GetList(projectID string) (*CategoryList, *Response, error) {
return s.GetListWithContext(context.Background(), projectID)
func (s *CategoryService) GetList(projectID string, offset int, pageSize int) (*CategoryList, *Response, error) {
return s.GetListWithContext(context.Background(), projectID, offset, pageSize)
}
2 changes: 1 addition & 1 deletion category_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 50,7 @@ func TestCategoryService_GetList(t *testing.T) {
fmt.Fprint(w, string(raw))
})

categories, _, err := testClient.Category.GetList("demo-project")
categories, _, err := testClient.Category.GetList("demo-project", 0, 10)
if categories == nil {
t.Error("Expected category list from project, but received nil")
}
Expand Down
2 changes: 1 addition & 1 deletion examples/getfilteredlist/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,7 @@ func main() {
},
}

wpResponse, resp, err := client.WorkPackage.GetList(opt)
wpResponse, resp, err := client.WorkPackage.GetList(opt, 0, 10)
if err != nil {
body, err := ioutil.ReadAll(resp.Body)
fmt.Printf(string(body))
Expand Down
15 changes: 11 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 1,18 @@
module github.com/manuelbcd/go-openproject

go 1.15
go 1.19

require (
github.com/dgrijalva/jwt-go v3.2.0 incompatible
github.com/google/go-querystring v1.0.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.0
github.com/trivago/tgo v1.0.7
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
35 changes: 21 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 1,25 @@
github.com/dgrijalva/jwt-go v3.2.0 incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0 incompatible/go.mod h1:E3ru 11k8xSBh hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3 rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI c5H38=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF rwdDfMAkV7OtwuqBVzrE8GR6GFx wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1 rVB AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO kdMU MU=
github.com/trivago/tgo v1.0.7 h1:uaWH/XIy9aWYWpjm2CU3RpcqZXmX2ysQ9/Go d9gyrM=
github.com/trivago/tgo v1.0.7/go.mod h1:w4dpD 3tzNIIiIfkWWa85w5/B77tlvdZckQ 6PkFnhc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0 w=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E M I=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8 F/bnQUVLGDM=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl muw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j osU4=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 h1:qSa Hg9oBe6UJXrznE yYvW51V9UbyIj/nj/KpDigo8=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5 mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E C64Yfv1cQ7kz7rIZviUmN EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E C64Yfv1cQ7kz7rIZviUmN EgEM=
Loading

0 comments on commit 0354cba

Please sign in to comment.