Skip to content

Commit

Permalink
Update go SDK templates to use msgpack format. (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
winder committed Jun 10, 2023
1 parent 0c7680a commit de85c86
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions go_templates/query.vm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type $queryType struct {
#end
#foreach( $p in $q.bodyParameters)
#bodyParamToArgDef($p)

#end
#if( $hasParams )
#set( $queryArg = "s.p" )
Expand Down Expand Up @@ -266,16 +266,6 @@ func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (respo
err = s.c.post(ctx, &response, $processedPath, nil, headers, nil)
return
}
#elseif( $queryType == "GetLedgerStateDelta" )
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) {
err = s.c.get(ctx, &response, $processedPath, $queryArg, headers)
return
}
#elseif( $queryType == "GetLedgerStateDeltaForTransactionGroup" )
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) {
err = s.c.get(ctx, &response, $processedPath, $queryArg, headers)
return
}
#elseif( $queryType == "SetBlockTimeStampOffset" )## TODO: "post" can be generated, there is nothing special here.
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response $returnType, err error) {
err = s.c.post(ctx, &response, $processedPath, nil, headers, nil)
Expand All @@ -286,6 +276,24 @@ func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (respo
err = s.c.post(ctx, &response, $processedPath, s.p, headers, s.request)
return
}
#elseif( $queryType == "GetTransactionGroupLedgerStateDeltasForRound" )
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response $returnType, err error) {
s.p.Format = "msgpack"
err = s.c.getMsgpack(ctx, &response, $processedPath, s.p, headers)
return
}
#elseif( $queryType == "GetLedgerStateDeltaForTransactionGroup" )
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) {
s.p.Format = "msgpack"
err = s.c.getMsgpack(ctx, &response, $processedPath, s.p, headers)
return
}
#elseif( $queryType == "GetLedgerStateDelta" )
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response types.LedgerStateDelta, err error) {
s.p.Format = "msgpack"
err = s.c.getMsgpack(ctx, &response, $processedPath, s.p, headers)
return
}
#else## finally... machine generate the rest
func (s *${queryType}) Do(ctx context.Context, headers ...*common.Header) (response $returnType, err error) {
err = s.c.get(ctx, &response, $processedPath, $queryArg, headers)
Expand Down

0 comments on commit de85c86

Please sign in to comment.