/
userapi.go
46 lines (40 loc) · 2.29 KB
/
userapi.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
package userapi
import (
"github.com/centrifuge/go-centrifuge/bootstrap"
"github.com/centrifuge/go-centrifuge/documents"
"github.com/centrifuge/go-centrifuge/httpapi/coreapi"
"github.com/go-chi/chi"
)
const (
transferIDParam = "transfer_id"
agreementIDParam = "agreement_id"
)
// Register registers the core apis to the router.
func Register(ctx map[string]interface{}, r chi.Router) {
tokenRegistry := ctx[bootstrap.BootstrappedNFTService].(documents.TokenRegistry)
userAPISrv := ctx[BootstrappedUserAPIService].(Service)
h := handler{
tokenRegistry: tokenRegistry,
srv: userAPISrv,
}
// transfer details api
r.Post("/documents/{"+coreapi.DocumentIDParam+"}/transfer_details", h.CreateTransferDetail)
r.Put("/documents/{"+coreapi.DocumentIDParam+"}/transfer_details/{"+transferIDParam+"}", h.UpdateTransferDetail)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/transfer_details", h.GetTransferDetailList)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/transfer_details/{"+transferIDParam+"}", h.GetTransferDetail)
// entity api
r.Post("/entities", h.CreateEntity)
r.Put("/entities/{"+coreapi.DocumentIDParam+"}", h.UpdateEntity)
r.Get("/entities/{"+coreapi.DocumentIDParam+"}", h.GetEntity)
r.Post("/entities/{"+coreapi.DocumentIDParam+"}/share", h.ShareEntity)
r.Post("/entities/{"+coreapi.DocumentIDParam+"}/revoke", h.RevokeEntity)
r.Get("/relationships/{"+coreapi.DocumentIDParam+"}/entity", h.GetEntityThroughRelationship)
// funding api
r.Post("/documents/{"+coreapi.DocumentIDParam+"}/funding_agreements", h.CreateFundingAgreement)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/funding_agreements", h.GetFundingAgreements)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/funding_agreements/{"+agreementIDParam+"}", h.GetFundingAgreement)
r.Put("/documents/{"+coreapi.DocumentIDParam+"}/funding_agreements/{"+agreementIDParam+"}", h.UpdateFundingAgreement)
r.Post("/documents/{"+coreapi.DocumentIDParam+"}/funding_agreements/{"+agreementIDParam+"}/sign", h.SignFundingAgreement)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/versions/{"+coreapi.VersionIDParam+"}/funding_agreements/{"+agreementIDParam+"}", h.GetFundingAgreementFromVersion)
r.Get("/documents/{"+coreapi.DocumentIDParam+"}/versions/{"+coreapi.VersionIDParam+"}/funding_agreements", h.GetFundingAgreementsFromVersion)
}