1
1
package endpoints
2
2
3
3
import (
4
+ "fmt"
5
+
4
6
"github.com/ic-matcom/api.dapp/repo/hlf"
5
7
"github.com/ic-matcom/api.dapp/schema"
6
8
"github.com/ic-matcom/api.dapp/schema/dto"
@@ -57,12 +59,12 @@ func NewFilesTxsHandler(app *iris.Application, mdwAuthChecker *context.Handler,
57
59
// we use the hero handler to inject the depObtainUserDid dependency. If we don't need to inject any dependencies we jus call guardTxsRouter.Get("/identity/identity/{id:string}", h.Identity_DevPopulate)
58
60
59
61
guardTxsRouter .Post ("/file" , h .CreateFile )
60
- guardTxsRouter .Patch ("/file/{id:string}" , h .UpdateFile )
61
62
guardTxsRouter .Delete ("/file/{id:string}" , h .DeleteFile )
63
+ guardTxsRouter .Patch ("/file/{id:string}" , h .UpdateFile )
62
64
guardTxsRouter .Patch ("/transfer/file/{id:string}" , h .TransferFile )
63
- guardTxsRouter .Get ("/file/{id:string}" , h .GetFileById )
64
65
guardTxsRouter .Get ("/file" , h .GetAllFiles )
65
- guardTxsRouter .Get ("/history/file" , h .FilesHistory )
66
+ guardTxsRouter .Get ("/file/{id:string}" , h .GetFileById )
67
+ guardTxsRouter .Get ("/history/file/{id:string}" , h .FilesHistory )
66
68
}
67
69
68
70
return h
@@ -71,14 +73,13 @@ func NewFilesTxsHandler(app *iris.Application, mdwAuthChecker *context.Handler,
71
73
// region ======== ENDPOINT HANDLERS DEV =================================================
72
74
73
75
// CreateFile
74
- // @description.markdown SetElection_Request
75
76
// @Tags Txs.eVote
76
77
// @Security ApiKeyAuth
77
78
// @Accept json
78
79
// @Produce json
79
80
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
80
81
// @Param tx body dto.FilesCreateDto true "Test data"
81
- // @Success 200 {object} []dto.TestRequest "OK"
82
+ // @Success 200 {object} interface{} "OK"
82
83
// @Failure 401 {object} dto.Problem "err.unauthorized"
83
84
// @Failure 400 {object} dto.Problem "err.processing_param"
84
85
// @Failure 502 {object} dto.Problem "err.bad_gateway"
@@ -108,15 +109,16 @@ func (h HFilesTxs) CreateFile(ctx iris.Context) {
108
109
// @Accept json
109
110
// @Produce json
110
111
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
111
- // @Param tx path string true "file id"
112
+ // @Param id path string true "ID" Format(string) default(mockAssect1)
112
113
// @Param tx body dto.FilesUpdateDto true "Test data"
113
- // @Success 200 {object} []dto.TestRequest "OK"
114
+ // @Success 200 {object} interface{} "OK"
114
115
// @Failure 401 {object} dto.Problem "err.unauthorized"
115
116
// @Failure 400 {object} dto.Problem "err.processing_param"
116
117
// @Failure 502 {object} dto.Problem "err.bad_gateway"
117
118
// @Failure 504 {object} dto.Problem "err.network"
118
119
// @Router /txs/file/{id} [patch]
119
120
func (h HFilesTxs ) UpdateFile (ctx iris.Context ) {
121
+ fmt .Printf ("Aqui estoy" )
120
122
121
123
id := ctx .Params ().GetString ("id" )
122
124
if id == "" {
@@ -146,8 +148,8 @@ func (h HFilesTxs) UpdateFile(ctx iris.Context) {
146
148
// @Accept json
147
149
// @Produce json
148
150
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
149
- // @Param tx path string true "file id"
150
- // @Success 200 {object} []dto.TestRequest "OK"
151
+ // @Param id path string true "ID" Format(string) default(mockAssect1)
152
+ // @Success 200 {object} interface{} "OK"
151
153
// @Failure 401 {object} dto.Problem "err.unauthorized"
152
154
// @Failure 400 {object} dto.Problem "err.processing_param"
153
155
// @Failure 502 {object} dto.Problem "err.bad_gateway"
@@ -176,9 +178,9 @@ func (h HFilesTxs) DeleteFile(ctx iris.Context) {
176
178
// @Accept json
177
179
// @Produce json
178
180
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
179
- // @Param tx path string true "file id"
181
+ // @Param id path string true "ID" Format(string) default(mockAssect1)
180
182
// @Param tx body dto.FileTransferDto true "Test data"
181
- // @Success 200 {object} []dto.TestRequest "OK"
183
+ // @Success 200 {object} interface{} "OK"
182
184
// @Failure 401 {object} dto.Problem "err.unauthorized"
183
185
// @Failure 400 {object} dto.Problem "err.processing_param"
184
186
// @Failure 502 {object} dto.Problem "err.bad_gateway"
@@ -214,8 +216,7 @@ func (h HFilesTxs) TransferFile(ctx iris.Context) {
214
216
// @Accept json
215
217
// @Produce json
216
218
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
217
- // @Param tx path dto.FilesCreateDto true "Test data"
218
- // @Success 200 {object} []dto.Files "OK"
219
+ // @Param id path string true "ID" Format(string) default(mockAssect1)
219
220
// @Failure 401 {object} dto.Problem "err.unauthorized"
220
221
// @Failure 400 {object} dto.Problem "err.processing_param"
221
222
// @Failure 502 {object} dto.Problem "err.bad_gateway"
@@ -244,24 +245,18 @@ func (h HFilesTxs) GetFileById(ctx iris.Context) {
244
245
// @Accept json
245
246
// @Produce json
246
247
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
247
- // @Param tx query dto.FileGetAllQuery true "filter query"
248
+ // @Param owner query string false "ownerID" Format(string) default([email protected] )
248
249
// @Success 200 {object} []dto.Files "OK"
249
250
// @Failure 401 {object} dto.Problem "err.unauthorized"
250
251
// @Failure 400 {object} dto.Problem "err.processing_param"
251
252
// @Failure 502 {object} dto.Problem "err.bad_gateway"
252
253
// @Failure 504 {object} dto.Problem "err.network"
253
- // @Router /txs/file/ [get]
254
+ // @Router /txs/file [get]
254
255
func (h HFilesTxs ) GetAllFiles (ctx iris.Context ) {
255
- var request dto. FileGetAllQuery
256
+ owner := ctx . URLParam ( "owner" )
256
257
257
- e := ctx .ReadQuery (request )
258
- if e != nil {
259
- (* h .response ).ResErr (& dto.Problem {Status : iris .StatusBadRequest , Title : schema .ErrProcParam , Detail : e .Error ()}, & ctx )
260
- return
261
- }
262
-
263
- if request .Owner != "" {
264
- res , problem := (* h .service ).GetAllFilesByOwner (request .Owner )
258
+ if owner != "" {
259
+ res , problem := (* h .service ).GetAllFilesByOwner (owner )
265
260
if problem != nil {
266
261
(* h .response ).ResErr (problem , & ctx )
267
262
return
@@ -285,8 +280,8 @@ func (h HFilesTxs) GetAllFiles(ctx iris.Context) {
285
280
// @Accept json
286
281
// @Produce json
287
282
// @Param Authorization header string true "Insert access token" default(Bearer <Add access token here>)
288
- // @Param tx path string true "file id"
289
- // @Success 200 {object} []dto.Files "OK"
283
+ // @Param id path string true "ID" Format(string) default(mockAssect1)
284
+ // @Success 200 {object} []dto.FileHistoryDto "OK"
290
285
// @Failure 401 {object} dto.Problem "err.unauthorized"
291
286
// @Failure 400 {object} dto.Problem "err.processing_param"
292
287
// @Failure 502 {object} dto.Problem "err.bad_gateway"
0 commit comments