Exemplo n.º 1
0
        public object OTP(InputCredentialsSendOTP sendOTP)
        {
            JsonSerializer serializer  = new JsonSerializer();
            ErrorLogger    errorLogger = new ErrorLogger();
            string         baseURL     = _configuration.GetSection("Transsped").GetSection("BaseURL").Value;

            CredentialsSendOTPClient sendOTPClient = new CredentialsSendOTPClient(serializer, errorLogger, baseURL);

            Microsoft.Extensions.Primitives.StringValues value;
            string access_token = "";

            if (Request.Headers.TryGetValue("Authorization", out value))
            {
                access_token = value.ToString().Replace("Bearer ", "");
            }
            else
            {
                OutputError error = new OutputError()
                {
                    error             = "invalid_access_token",
                    error_description = "Invalid access_token"
                };
                return(serializer.Serialize(error));
            }


            object response = sendOTPClient.GetCredentialsSendOTP(access_token, sendOTP);

            return(response);
        }
        public virtual IActionResult CredentialsSendOTP([FromBody] InputCredentialsSendOTP body)
        {
            //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
            // return StatusCode(400);

            throw new NotImplementedException();
        }
Exemplo n.º 3
0
        public string SendOTP(string access_token, InputCredentialsSendOTP sendOTP)
        {
            RestRequest request = new RestRequest("csc_api/otp", Method.POST);

            request.AddParameter("Authorization", "Bearer " + access_token, ParameterType.HttpHeader);
            JsonSerializer serializer = new JsonSerializer();
            var            postData   = serializer.Serialize(sendOTP);

            request.AddJsonBody(postData);

            IRestResponse response = Execute(request);

            return(response.Content);
        }
        public object GetCredentialsSendOTP(string access_token, InputCredentialsSendOTP inputCredentialsSendOTP)
        {
            RestRequest request = new RestRequest("credentials/sendOTP", Method.POST);

            request.AddParameter("Authorization", "Bearer " + access_token, ParameterType.HttpHeader);

            JsonSerializer serializer = new JsonSerializer();
            var            postData   = serializer.Serialize(inputCredentialsSendOTP);

            request.AddJsonBody(postData);

            IRestResponse response = Execute(request);
            var           data     = serializer.Deserialize <object>(response);

            return(data);
        }
Exemplo n.º 5
0
        public string SendOTP(string credentialID)
        {
            InputCredentialsSendOTP credentialsSendOTP = new InputCredentialsSendOTP()
            {
                credentialID = credentialID
            };
            JsonSerializer serializer  = new JsonSerializer();
            ErrorLogger    errorLogger = new ErrorLogger();
            string         baseURL     = _configuration.GetSection("CSC_API").GetSection("BaseURL").Value;

            MyHttpClient myHttpClient = new MyHttpClient(serializer, errorLogger, baseURL);
            var          response     = myHttpClient.SendOTP(_accessToken.GetAccessToken().access_token, credentialsSendOTP);

            if (response == null || response.Contains("error"))
            {
                return("fail");
            }
            else
            {
                return("ok");
            }
        }