github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/access/rest/request/get_transaction.go (about) 1 package request 2 3 import "github.com/onflow/flow-go/model/flow" 4 5 const resultExpandable = "result" 6 const blockIDQueryParam = "block_id" 7 const collectionIDQueryParam = "collection_id" 8 9 type TransactionOptionals struct { 10 BlockID flow.Identifier 11 CollectionID flow.Identifier 12 } 13 14 func (t *TransactionOptionals) Parse(r *Request) error { 15 var blockId ID 16 err := blockId.Parse(r.GetQueryParam(blockIDQueryParam)) 17 if err != nil { 18 return err 19 } 20 t.BlockID = blockId.Flow() 21 22 var collectionId ID 23 err = collectionId.Parse(r.GetQueryParam(collectionIDQueryParam)) 24 if err != nil { 25 return err 26 } 27 t.CollectionID = collectionId.Flow() 28 29 return nil 30 } 31 32 type GetTransaction struct { 33 GetByIDRequest 34 TransactionOptionals 35 ExpandsResult bool 36 } 37 38 func (g *GetTransaction) Build(r *Request) error { 39 err := g.TransactionOptionals.Parse(r) 40 if err != nil { 41 return err 42 } 43 44 err = g.GetByIDRequest.Build(r) 45 g.ExpandsResult = r.Expands(resultExpandable) 46 47 return err 48 } 49 50 type GetTransactionResult struct { 51 GetByIDRequest 52 TransactionOptionals 53 } 54 55 func (g *GetTransactionResult) Build(r *Request) error { 56 err := g.TransactionOptionals.Parse(r) 57 if err != nil { 58 return err 59 } 60 61 err = g.GetByIDRequest.Build(r) 62 63 return err 64 }