-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcollections.go
36 lines (31 loc) · 1.03 KB
/
collections.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package opensea
import (
"context"
"github.com/casiphia/gopkg/restgo"
"github.com/casiphia/opensea-go/model"
)
// Collections Use this endpoint to fetch collections on OpenSea
func (c *Client) Collections(ctx context.Context, req *CollectionsRequest) ([]*model.Collection, error) {
var rsp, err = c.get(ctx, "/api/v1/collections", restgo.ObjectParams(req)...)
if err != nil {
return nil, err
}
var response CollectionsResponse
err = ParseRsp(rsp, &response)
if err != nil {
return nil, err
}
return response.Collections, nil
}
type CollectionsRequest struct {
// A wallet address. If specified, will return collections where the owner owns at least one asset belonging to smart contracts in the collection.
// The number of assets the account owns is shown as owned_asset_count for each collection.
AssetOwner string `query:"asset_owner"`
// Offset
Offset int32 `query:"offset,required"`
// Limit
Limit int32 `query:"limit,required"`
}
type CollectionsResponse struct {
Collections []*model.Collection `opensea:"collections"`
}