Daily engine improvements:

New GetExchangeOTPs API
CLI validation
Standardised pairs for GCTCLI
Expand test coverage
Trim SMS global from name is len > 11
Linter fixes
This commit is contained in:
Adrian Gallagher
2019-06-11 17:02:00 +10:00
parent f777e68716
commit 2ad808e70c
12 changed files with 702 additions and 415 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -9,13 +9,13 @@ It translates gRPC into RESTful JSON APIs.
package gctrpc
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
@@ -45,10 +45,7 @@ func request_GoCryptoTrader_GetExchanges_0(ctx context.Context, marshaler runtim
var protoReq GetExchangesRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchanges_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetExchanges_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@@ -82,10 +79,7 @@ func request_GoCryptoTrader_GetExchangeInfo_0(ctx context.Context, marshaler run
var protoReq GenericExchangeNameRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchangeInfo_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetExchangeInfo_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@@ -102,10 +96,7 @@ func request_GoCryptoTrader_GetExchangeOTPCode_0(ctx context.Context, marshaler
var protoReq GenericExchangeNameRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetExchangeOTPCode_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetExchangeOTPCode_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@@ -114,6 +105,15 @@ func request_GoCryptoTrader_GetExchangeOTPCode_0(ctx context.Context, marshaler
}
func request_GoCryptoTrader_GetExchangeOTPCodes_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetExchangeOTPsRequest
var metadata runtime.ServerMetadata
msg, err := client.GetExchangeOTPCodes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_GoCryptoTrader_EnableExchange_0(ctx context.Context, marshaler runtime.Marshaler, client GoCryptoTraderClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GenericExchangeNameRequest
var metadata runtime.ServerMetadata
@@ -191,10 +191,7 @@ func request_GoCryptoTrader_GetAccountInfo_0(ctx context.Context, marshaler runt
var protoReq GetAccountInfoRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GoCryptoTrader_GetAccountInfo_0); err != nil {
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_GoCryptoTrader_GetAccountInfo_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@@ -616,6 +613,26 @@ func RegisterGoCryptoTraderHandlerClient(ctx context.Context, mux *runtime.Serve
})
mux.Handle("GET", pattern_GoCryptoTrader_GetExchangeOTPCodes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_GoCryptoTrader_GetExchangeOTPCodes_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_GoCryptoTrader_GetExchangeOTPCodes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_GoCryptoTrader_EnableExchange_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -1130,6 +1147,8 @@ var (
pattern_GoCryptoTrader_GetExchangeOTPCode_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeotp"}, ""))
pattern_GoCryptoTrader_GetExchangeOTPCodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getexchangeotps"}, ""))
pattern_GoCryptoTrader_EnableExchange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "enableexchange"}, ""))
pattern_GoCryptoTrader_GetTicker_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getticker"}, ""))
@@ -1192,6 +1211,8 @@ var (
forward_GoCryptoTrader_GetExchangeOTPCode_0 = runtime.ForwardResponseMessage
forward_GoCryptoTrader_GetExchangeOTPCodes_0 = runtime.ForwardResponseMessage
forward_GoCryptoTrader_EnableExchange_0 = runtime.ForwardResponseMessage
forward_GoCryptoTrader_GetTicker_0 = runtime.ForwardResponseMessage

View File

@@ -32,6 +32,12 @@ message GetExchangeOTPReponse {
string otp_code = 1;
}
message GetExchangeOTPsRequest {}
message GetExchangeOTPsResponse {
map<string, string> otp_codes = 1;
}
message DisableExchangeRequest {
string exchange = 1;
}
@@ -422,6 +428,12 @@ service GoCryptoTrader {
};
}
rpc GetExchangeOTPCodes (GetExchangeOTPsRequest) returns (GetExchangeOTPsResponse) {
option (google.api.http) = {
get: "/v1/getexchangeotps"
};
}
rpc EnableExchange (GenericExchangeNameRequest) returns (GenericExchangeNameResponse) {
option (google.api.http) = {
post: "/v1/enableexchange"

View File

@@ -327,6 +327,22 @@
]
}
},
"/v1/getexchangeotps": {
"get": {
"operationId": "GetExchangeOTPCodes",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/gctrpcGetExchangeOTPsResponse"
}
}
},
"tags": [
"GoCryptoTrader"
]
}
},
"/v1/getexchanges": {
"get": {
"operationId": "GetExchanges",
@@ -1104,6 +1120,17 @@
}
}
},
"gctrpcGetExchangeOTPsResponse": {
"type": "object",
"properties": {
"otp_codes": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
},
"gctrpcGetExchangesResponse": {
"type": "object",
"properties": {