-
Notifications
You must be signed in to change notification settings - Fork 4
/
metadata_refresh.go
160 lines (139 loc) · 4.68 KB
/
metadata_refresh.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package imx
import (
"context"
"github.com/immutable/imx-core-sdk-golang/imx/api"
)
/*
ListMetadataRefreshes Gets a list of metadata refreshes
@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background().
@param l1signer Ethereum signer used for ownership authentication.
@param collectionAddress Collection contract address
@param pageSize The page size of the result
@param cursor The cursor
@return GetMetadataRefreshes
*/
func (c *Client) ListMetadataRefreshes(
ctx context.Context,
l1signer L1Signer,
collectionAddress *string,
pageSize *int32,
cursor *string,
) (*api.GetMetadataRefreshes, error) {
timestamp, signature, err := generateIMXAuthorisationHeaders(l1signer)
if err != nil {
return nil, err
}
req := c.MetadataRefreshesAPI.GetAListOfMetadataRefreshes(ctx)
req.XImxEthAddress(l1signer.GetAddress()).
XImxEthSignature(signature).
XImxEthTimestamp(timestamp)
if collectionAddress != nil {
req.CollectionAddress(*collectionAddress)
}
if pageSize != nil {
req.PageSize(*pageSize)
}
if cursor != nil {
req.Cursor(*cursor)
}
metadataRefreshes, httpResponse, err := c.MetadataRefreshesAPI.GetAListOfMetadataRefreshesExecute(req)
defer httpResponse.Body.Close()
if err != nil {
return nil, NewIMXError(httpResponse, err)
}
return metadataRefreshes, nil
}
/*
GetMetadataRefreshErrors Gets metadata refresh errors for the given refresh id
@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background().
@param l1signer Ethereum signer used for ownership authentication.
@param collectionAddress Collection contract address
@param pageSize The page size of the result
@param cursor The cursor
@return GetMetadataRefreshes
*/
func (c *Client) GetMetadataRefreshErrors(
ctx context.Context,
l1signer L1Signer,
refreshID string,
pageSize *int32,
cursor *string,
) (*api.GetMetadataRefreshErrorsResponse, error) {
timestamp, signature, err := generateIMXAuthorisationHeaders(l1signer)
if err != nil {
return nil, err
}
req := c.MetadataRefreshesAPI.GetMetadataRefreshErrors(ctx, refreshID)
req.XImxEthAddress(l1signer.GetAddress()).
XImxEthSignature(signature).
XImxEthTimestamp(timestamp)
if pageSize != nil {
req.PageSize(*pageSize)
}
if cursor != nil {
req.Cursor(*cursor)
}
metadataRefreshErrorsResponse, httpResponse, err := c.MetadataRefreshesAPI.GetMetadataRefreshErrorsExecute(req)
defer httpResponse.Body.Close()
if err != nil {
return nil, NewIMXError(httpResponse, err)
}
return metadataRefreshErrorsResponse, nil
}
/*
GetMetadataRefreshResults Gets metadata refresh results for the given refresh id
@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background().
@param l1signer Ethereum signer used for ownership authentication.
@param collectionAddress Collection contract address
@param pageSize The page size of the result
@param cursor The cursor
@return GetMetadataRefreshes
*/
func (c *Client) GetMetadataRefreshResults(
ctx context.Context,
l1signer L1Signer,
refreshID string,
) (*api.GetMetadataRefreshResponse, error) {
timestamp, signature, err := generateIMXAuthorisationHeaders(l1signer)
if err != nil {
return nil, err
}
req := c.MetadataRefreshesAPI.GetMetadataRefreshResults(ctx, refreshID)
req.XImxEthAddress(l1signer.GetAddress()).
XImxEthSignature(signature).
XImxEthTimestamp(timestamp)
metadataRefreshResponse, httpResponse, err := c.MetadataRefreshesAPI.GetMetadataRefreshResultsExecute(req)
defer httpResponse.Body.Close()
if err != nil {
return nil, NewIMXError(httpResponse, err)
}
return metadataRefreshResponse, nil
}
/*
CreateMetadataRefresh Creates a metadata refresh
@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background().
@param l1signer Ethereum signer used for ownership authentication.
@param createMetadataRefreshRequest The request struct with all the params.
@return CreateMetadataRefreshResponse
*/
func (c *Client) CreateMetadataRefresh(
ctx context.Context,
l1signer L1Signer,
createMetadataRefreshRequest *api.CreateMetadataRefreshRequest,
) (*api.CreateMetadataRefreshResponse, error) {
timestamp, signature, err := generateIMXAuthorisationHeaders(l1signer)
if err != nil {
return nil, err
}
req := c.MetadataRefreshesAPI.RequestAMetadataRefresh(ctx)
req.XImxEthAddress(l1signer.GetAddress()).
XImxEthSignature(signature).
XImxEthTimestamp(timestamp)
req.CreateMetadataRefreshRequest(*createMetadataRefreshRequest)
createMetadataRefreshResponse, httpResponse, err := c.MetadataRefreshesAPI.RequestAMetadataRefreshExecute(req)
defer httpResponse.Body.Close()
if err != nil {
return nil, NewIMXError(httpResponse, err)
}
return createMetadataRefreshResponse, nil
}