From de85c86f7d3ffbfcf473865b70ad3573d2eed058 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Fri, 9 Jun 2023 20:38:23 -0400 Subject: [PATCH] Update go SDK templates to use msgpack format. (#64) --- go_templates/query.vm | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/go_templates/query.vm b/go_templates/query.vm index cb9ee13..dbcd256 100644 --- a/go_templates/query.vm +++ b/go_templates/query.vm @@ -78,7 +78,7 @@ type $queryType struct { #end #foreach( $p in $q.bodyParameters) #bodyParamToArgDef($p) - + #end #if( $hasParams ) #set( $queryArg = "s.p" ) @@ -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) @@ -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)