-
Notifications
You must be signed in to change notification settings - Fork 3
/
schema.go
86 lines (68 loc) · 2.56 KB
/
schema.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package atomicasset
import (
"github.com/eosswedenorg-go/unixtime"
)
// Types
type Schema struct {
Name string `json:"schema_name"`
Contract string `json:"contract"`
Format []SchemaFormat `json:"format"`
Collection Collection `json:"collection"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime unixtime.Time `json:"created_at_time"`
}
type InlineSchema struct {
Name string `json:"schema_name"`
Format []SchemaFormat `json:"format"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime unixtime.Time `json:"created_at_time"`
}
type SchemaFormat struct {
Name string `json:"name"`
Type string `json:"type"`
}
// Request Parameters
type SchemaSortColumn string
const (
// SchemaSortDefault sorts by the default column (created)
SchemaSortDefault SchemaSortColumn = ""
// SchemaSortCreated sorts by the created column
SchemaSortCreated SchemaSortColumn = "created"
// SchemaSortAssets sorts by the assets column
SchemaSortAssets SchemaSortColumn = "assets"
// SchemaSortName sorts by the schema name column
SchemaSortName SchemaSortColumn = "schema_name"
)
type SchemasRequestParams struct {
Author string `qs:"author,omitempty"`
Match string `qs:"match,omitempty"`
AuthorizedAccount string `qs:"authorized_account,omitempty"`
NotifyAccount string `qs:"notify_account,omitempty"`
Blacklist ReqList[string] `qs:"collection_blacklist,omitempty"`
Whitelist ReqList[string] `qs:"collection_whitelist,omitempty"`
IDs ReqList[int] `qs:"ids,omitempty"`
LowerBound string `qs:"lower_bound,omitempty"`
UpperBound string `qs:"upper_bound,omitempty"`
Before int `qs:"before,omitempty"`
After int `qs:"after,omitempty"`
Page int `qs:"page,omitempty"`
Limit int `qs:"limit,omitempty"`
Order SortOrder `qs:"order,omitempty"`
Sort SchemaSortColumn `qs:"sort,omitempty"`
}
// Responses
type SchemasResponse struct {
APIResponse
Data []Schema
}
// Client API Functions
// GetSchemas fetches "/atomicassets/v1/schemas" from API
func (c *Client) GetSchemas(params SchemasRequestParams) (SchemasResponse, error) {
var resp SchemasResponse
r, err := c.fetch("GET", "/atomicassets/v1/schemas", params, &resp.APIResponse)
if err == nil {
// Parse json
err = r.Unmarshal(&resp)
}
return resp, err
}