@@ -12,12 +12,17 @@ import (
1212 "strings"
1313)
1414
15- func GetGroup (id string ) (types.GroupCreateResponse , error ) {
15+ func GetGroup (id string , network string ) (types.GroupCreateResponse , error ) {
1616 jwt , err := common .FindToken ()
1717 if err != nil {
1818 return types.GroupCreateResponse {}, err
1919 }
20- url := fmt .Sprintf ("https://%s/v3/files/groups/%s" , config .GetAPIHost (), id )
20+ networkParam , err := config .GetNetworkParam (network )
21+ if err != nil {
22+ return types.GroupCreateResponse {}, err
23+ }
24+
25+ url := fmt .Sprintf ("https://%s/v3/groups/%s/%s" , config .GetAPIHost (), networkParam , id )
2126
2227 req , err := http .NewRequest ("GET" , url , nil )
2328 if err != nil {
@@ -53,23 +58,24 @@ func GetGroup(id string) (types.GroupCreateResponse, error) {
5358
5459}
5560
56- func ListGroups (amount string , isPublic bool , name string , token string ) (types.GroupListResponse , error ) {
61+ func ListGroups (amount string , name string , token string , network string ) (types.GroupListResponse , error ) {
5762 jwt , err := common .FindToken ()
5863 if err != nil {
5964 return types.GroupListResponse {}, err
6065 }
61- url := fmt .Sprintf ("https://%s/v3/files/groups?" , config .GetAPIHost ())
66+ networkParam , err := config .GetNetworkParam (network )
67+ if err != nil {
68+ return types.GroupListResponse {}, err
69+ }
70+
71+ url := fmt .Sprintf ("https://%s/v3/groups/%s?" , config .GetAPIHost (), networkParam )
6272
6373 params := []string {}
6474
6575 if amount != "" {
6676 params = append (params , "limit=" + amount )
6777 }
6878
69- if isPublic {
70- params = append (params , "isPublic=true" )
71- }
72-
7379 if name != "" {
7480 params = append (params , "name=" + name )
7581 }
@@ -117,15 +123,14 @@ func ListGroups(amount string, isPublic bool, name string, token string) (types.
117123
118124}
119125
120- func CreateGroup (name string , isPublic bool ) (types.GroupCreateResponse , error ) {
126+ func CreateGroup (name string , network string ) (types.GroupCreateResponse , error ) {
121127 jwt , err := common .FindToken ()
122128 if err != nil {
123129 return types.GroupCreateResponse {}, err
124130 }
125131
126132 payload := types.GroupCreateBody {
127- Name : name ,
128- IsPublic : isPublic ,
133+ Name : name ,
129134 }
130135
131136 jsonPayload , err := json .Marshal (payload )
@@ -134,7 +139,12 @@ func CreateGroup(name string, isPublic bool) (types.GroupCreateResponse, error)
134139 return types.GroupCreateResponse {}, errors .Join (err , errors .New ("Failed to marshal paylod" ))
135140 }
136141
137- url := fmt .Sprintf ("https://%s/v3/files/groups" , config .GetAPIHost ())
142+ networkParam , err := config .GetNetworkParam (network )
143+ if err != nil {
144+ return types.GroupCreateResponse {}, err
145+ }
146+
147+ url := fmt .Sprintf ("https://%s/v3/groups/%s" , config .GetAPIHost (), networkParam )
138148 req , err := http .NewRequest ("POST" , url , bytes .NewBuffer (jsonPayload ))
139149 if err != nil {
140150 return types.GroupCreateResponse {}, errors .Join (err , errors .New ("failed to create the request" ))
@@ -170,24 +180,27 @@ func CreateGroup(name string, isPublic bool) (types.GroupCreateResponse, error)
170180
171181}
172182
173- func UpdateGroup (id string , name string , isPublic bool ) (types.GroupCreateResponse , error ) {
183+ func UpdateGroup (id string , name string , network string ) (types.GroupCreateResponse , error ) {
174184 jwt , err := common .FindToken ()
175185 if err != nil {
176186 return types.GroupCreateResponse {}, err
177187 }
178188
179189 payload := types.GroupCreateBody {
180- Name : name ,
181- IsPublic : isPublic ,
190+ Name : name ,
182191 }
183192
184193 jsonPayload , err := json .Marshal (payload )
185194
186195 if err != nil {
187196 return types.GroupCreateResponse {}, errors .Join (err , errors .New ("Failed to marshal paylod" ))
188197 }
198+ networkParam , err := config .GetNetworkParam (network )
199+ if err != nil {
200+ return types.GroupCreateResponse {}, err
201+ }
189202
190- url := fmt .Sprintf ("https://%s/v3/files/ groups/%s" , config .GetAPIHost (), id )
203+ url := fmt .Sprintf ("https://%s/v3/groups/%s/%s " , config .GetAPIHost (), networkParam , id )
191204 req , err := http .NewRequest ("PUT" , url , bytes .NewBuffer (jsonPayload ))
192205 if err != nil {
193206 return types.GroupCreateResponse {}, errors .Join (err , errors .New ("failed to create the request" ))
@@ -223,12 +236,17 @@ func UpdateGroup(id string, name string, isPublic bool) (types.GroupCreateRespon
223236
224237}
225238
226- func DeleteGroup (id string ) error {
239+ func DeleteGroup (id string , network string ) error {
227240 jwt , err := common .FindToken ()
228241 if err != nil {
229242 return err
230243 }
231- url := fmt .Sprintf ("https://%s/v3/files/groups/%s" , config .GetAPIHost (), id )
244+ networkParam , err := config .GetNetworkParam (network )
245+ if err != nil {
246+ return err
247+ }
248+
249+ url := fmt .Sprintf ("https://%s/v3/groups/%s/%s" , config .GetAPIHost (), networkParam , id )
232250
233251 req , err := http .NewRequest ("DELETE" , url , nil )
234252 if err != nil {
@@ -254,13 +272,18 @@ func DeleteGroup(id string) error {
254272
255273}
256274
257- func AddFile (groupId string , fileId string ) error {
275+ func AddFile (groupId string , fileId string , network string ) error {
258276
259277 jwt , err := common .FindToken ()
260278 if err != nil {
261279 return err
262280 }
263- url := fmt .Sprintf ("https://%s/v3/files/groups/%s/ids/%s" , config .GetAPIHost (), groupId , fileId )
281+ networkParam , err := config .GetNetworkParam (network )
282+ if err != nil {
283+ return err
284+ }
285+
286+ url := fmt .Sprintf ("https://%s/v3/groups/%s/%s/ids/%s" , config .GetAPIHost (), networkParam , groupId , fileId )
264287
265288 req , err := http .NewRequest ("PUT" , url , nil )
266289 if err != nil {
@@ -285,13 +308,18 @@ func AddFile(groupId string, fileId string) error {
285308 return nil
286309}
287310
288- func RemoveFile (groupId string , fileId string ) error {
311+ func RemoveFile (groupId string , fileId string , network string ) error {
289312
290313 jwt , err := common .FindToken ()
291314 if err != nil {
292315 return err
293316 }
294- url := fmt .Sprintf ("https://%s/v3/files/groups/%s/ids/%s" , config .GetAPIHost (), groupId , fileId )
317+ networkParam , err := config .GetNetworkParam (network )
318+ if err != nil {
319+ return err
320+ }
321+
322+ url := fmt .Sprintf ("https://%s/v3/groups/%s/%s/ids/%s" , config .GetAPIHost (), networkParam , groupId , fileId )
295323
296324 req , err := http .NewRequest ("DELETE" , url , nil )
297325 if err != nil {
0 commit comments