From 2ff206a35b35a1a6314f633eef1d77232ae9a70f Mon Sep 17 00:00:00 2001 From: optclblast Date: Thu, 30 May 2024 22:50:27 +0300 Subject: [PATCH] get -> post /fetch --- backend/README.md | 26 +++++++++++------------ backend/internal/interface/rest/server.go | 19 ++++++++--------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/backend/README.md b/backend/README.md index 5fc12f0..9dd3f45 100644 --- a/backend/README.md +++ b/backend/README.md @@ -126,7 +126,7 @@ Get new token ### Example Request: ``` bash -curl --location --request GET 'http://localhost:8081/refresh' \ +curl --location --request POST 'http://localhost:8081/refresh' \ --header 'Content-Type: application/json' \ --data '{ "token": "token", @@ -170,7 +170,7 @@ Response: } ``` -## GET **/organizations** +## POST **/organizations/fetch** Fets list of organizations ### Request body: * cursor (string, optional) @@ -180,7 +180,7 @@ Fets list of organizations ### Example Request: ``` bash -curl --location --request GET 'http://localhost:8081/organizations' \ +curl --location --request POST 'http://localhost:8081/organizations' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTU4OTU4MTc3MDYsInVpZCI6IjUyNTNkMzdjLTMxZDQtNDgxMi1iZTcxLWE5ODQwMTVlNGVlMyJ9.YjjHWz7FiMM73e-98pZYHCW9tKDZ_mRWKG3m1PcVTo0' \ --data '{ @@ -271,7 +271,7 @@ Response: "is_active": false } ``` -## GET **/organizations/{organization_id}/participants** +## POST **/organizations/{organization_id}/participants/fetch** Get organization participants ### Request body: * ids (string array) @@ -279,7 +279,7 @@ Get organization participants ### Example Request: ``` bash -curl --request GET \ +curl --request POST \ --url http://localhost:8081/organizations/018fb419-c3ad-7cda-81b8-cad30211b5fb/participants \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTY3OTk5MjgzMzIsInVpZCI6IjAxOGZiNDE5LTliZjctN2QwOS05MzViLTNiOTAyNDc3ZDJkYiJ9.V_d3b8MvuOp01xDGX0g5Ab2nOvdyGL84WO01xPodTro' \ --header 'content-type: application/json' \ @@ -388,14 +388,14 @@ Response: } ``` -## GET **/organizations/{organization_id}/multisig** -Multisig deployment +## POST **/organizations/{organization_id}/multisig/fetch** +fetch multisigs ### Request body: ### Example Request: ``` bash -curl --request GET \ +curl --request POST \ --url http://localhost:8081/organizations/018fb246-1616-7f1b-9fe2-1a3202224695/multisig \ --header 'Authorization: Bearer token' \ --header 'content-type: application/json' \ @@ -478,7 +478,7 @@ Response: } ``` -## GET **/organizations/{organization_id}/payrolls** +## POST **/organizations/{organization_id}/payrolls/fetch** Fetch payrolls ### Request body: * ids ([]string) @@ -492,8 +492,6 @@ curl --request POST \ --header 'Authorization: Bearer TOKEN' \ --header 'content-type: application/json' \ --data '{ - "title":"sdjkhfjsdk", - "multisig_id":"018fbb03-d4c5-73be-ab07-6c5f8d3afebc" }' ``` @@ -508,7 +506,7 @@ Response: Confirm payroll // todo -## GET **/organizations/{organization_id}/license** +## POST **/organizations/{organization_id}/license/fetch** Fetch licenses ## POST **/organizations/{organization_id}/license** @@ -584,7 +582,7 @@ Response: } ``` -## GET **/{organization_id}/transactions** +## POST **/{organization_id}/transactions/fetch** Fetch txs ### Request body: ready_to_confirm (optional) @@ -593,7 +591,7 @@ pending (optional) ### Example Request: ``` bash -curl --location --request GET 'http://localhost:8081/organizations/018f9078-af60-7589-af64-9312b97aa7be/transactions' \ +curl --location --request POST 'http://localhost:8081/organizations/018f9078-af60-7589-af64-9312b97aa7be/transactions' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer TOKEN' \ --data '{ diff --git a/backend/internal/interface/rest/server.go b/backend/internal/interface/rest/server.go index 91ded68..d4f5590 100644 --- a/backend/internal/interface/rest/server.go +++ b/backend/internal/interface/rest/server.go @@ -106,7 +106,7 @@ func (s *Server) buildRouter() { router.Post("/join", s.handle(s.controllers.Auth.Join, "join")) router.Post("/login", s.handle(s.controllers.Auth.Login, "login")) - router.Get("/refresh", s.handle(s.controllers.Auth.Refresh, "refresh")) + router.Post("/refresh", s.handle(s.controllers.Auth.Refresh, "refresh")) // open invite link router.Get("/invite/{hash}", s.handle(s.controllers.Auth.InviteGet, "invite_open")) @@ -116,31 +116,31 @@ func (s *Server) buildRouter() { router.Route("/organizations", func(r chi.Router) { r = r.With(s.withAuthorization) - r.Get("/", s.handle(s.controllers.Organizations.ListOrganizations, "list_organizations")) + r.Post("/fetch", s.handle(s.controllers.Organizations.ListOrganizations, "list_organizations")) r.Post("/", s.handle(s.controllers.Organizations.NewOrganization, "new_organization")) r.Route("/{organization_id}", func(r chi.Router) { r.Route("/payrolls", func(r chi.Router) { - r.Get("/", s.handle(s.controllers.Transactions.ListPayrolls, "list_payrolls")) + r.Post("/fetch", s.handle(s.controllers.Transactions.ListPayrolls, "list_payrolls")) r.Post("/", s.handle(s.controllers.Transactions.NewPayroll, "new_payroll")) r.Put("/", s.handle(s.controllers.Transactions.ConfirmPayroll, "confirm_payroll")) r.Post("/salaries", s.handle(nil, "set_salary")) - r.Get("/salaries", s.handle(nil, "get_salaries")) + r.Post("/salaries/fetch", s.handle(nil, "get_salaries")) }) r.Route("/multisig", func(r chi.Router) { r.Post("/", s.handle(s.controllers.Transactions.NewMultisig, "new_multisig")) - r.Get("/", s.handle(s.controllers.Transactions.ListMultisigs, "list_multisig")) + r.Post("/fetch", s.handle(s.controllers.Transactions.ListMultisigs, "list_multisig")) }) r.Route("/license", func(r chi.Router) { - r.Get("/", nil) // list license - r.Post("/", nil) // deploy contract + r.Post("/fetch", nil) // list license + r.Post("/", nil) // deploy contract }) r.Route("/participants", func(r chi.Router) { - r.Get("/", s.handle(s.controllers.Participants.List, "participants_list")) + r.Post("/fetch", s.handle(s.controllers.Participants.List, "participants_list")) r.Post("/", s.handle(s.controllers.Participants.New, "new_participant")) // generate new invite link @@ -151,9 +151,8 @@ func (s *Server) buildRouter() { }) }) - // Deprecated?? r.Route("/transactions", func(r chi.Router) { - r.Get("/", s.handle(s.controllers.Transactions.List, "tx_list")) + r.Post("/fetch", s.handle(s.controllers.Transactions.List, "tx_list")) r.Post("/", s.handle(s.controllers.Transactions.New, "new_tx")) r.Put( "/{tx_id}",