예제 #1
0
        public async Task <IActionResult> RegenerateKey([FromBody] RegenerateKeyRequestModel request)
        {
            var check2FaResult = await _google2FaService.Check2FaAsync <CreateApiKeyResponse>(_requestContext.ClientId, request.Code);

            if (check2FaResult != null)
            {
                return(Ok(check2FaResult));
            }

            var clientKeys = await _hftInternalService.Keys.GetKeys(_requestContext.ClientId);

            var existingApiKey = clientKeys.FirstOrDefault(x => x.WalletId == request.Id);

            if (existingApiKey != null)
            {
                var apiKey = await _hftInternalService.Keys.UpdateKey(new UpdateApiKeyModel
                {
                    ClientId  = _requestContext.ClientId,
                    WalletId  = existingApiKey.WalletId,
                    Apiv2Only = request.Apiv2Only
                });

                var result = new CreateApiKeyResponse {
                    ApiKey = apiKey.ApiKey, WalletId = apiKey.WalletId, Apiv2Only = request.Apiv2Only
                };
                return(Ok(Google2FaResultModel <CreateApiKeyResponse> .Success(result)));
            }

            return(NotFound());
        }
예제 #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateApiKeyResponse response = new CreateApiKeyResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("createdDate", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreatedDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("description", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Description = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("enabled", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.Enabled = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("id", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Id = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("lastUpdatedDate", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastUpdatedDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("stageKeys", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.StageKeys = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateApiKeyResponse response = new CreateApiKeyResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("apiKey", targetDepth))
                {
                    var unmarshaller = ApiKeyUnmarshaller.Instance;
                    response.ApiKey = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }