Exemplo n.º 1
0
 private void GenerateAuthorizeRequestBody(string institution, string userName, string password, bool?save, bool?mostRecentCached, bool?withMfaQuestions, RequestLanguage?requestLanguage, bool?scheduleRefresh, string tag = null)
 {
     AuthorizeBody = new AuthorizeRequestBody()
     {
         UserName         = userName,
         Password         = password,
         Institution      = institution,
         Save             = save?.ToString().ToLower(),
         MostRecentCached = mostRecentCached?.ToString().ToLower(),
         WithMfaQuestions = withMfaQuestions?.ToString().ToLower(),
         Language         = requestLanguage?.ToString().ToLower(),
         ScheduleRefresh  = scheduleRefresh.ToString().ToLower(),
         Tag = tag
     };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Authorize method is used to call the Authorize endpoint at Flinks API using the cached flow. Must be used to only when you already have authorized before and have an LoginId.
        /// </summary>
        /// <param name="loginId">LoginId generated by the previous response of the the Authorize method.</param>
        /// <returns>An AuthorizeResult object contained information regarding the status of the authorization process.</returns>
        public AuthorizeResult Authorize(Guid loginId)
        {
            AuthorizeBody = new AuthorizeRequestBody()
            {
                LoginId          = loginId.ToString(),
                MostRecentCached = true.ToString()
            };

            var request = GetBaseRequest(EndpointConstant.Authorize, Method.POST);

            request.AddParameter(FlinksSettingsConstant.ApplicationJsonUTF8, JsonConvert.SerializeObject(AuthorizeBody, _jsonSerializationSettings), ParameterType.RequestBody);

            var response = RestClient.Execute(request);

            SetClientAuthorizeStatus(response.StatusCode);

            var apiResponse = JsonConvert.DeserializeObject <AuthorizeResult>(response.Content);

            apiResponse.ClientStatus = ClientStatus;

            return(apiResponse);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Used to answer the MFA questions and proceed with the authorization process.
        /// </summary>
        /// <param name="requestId">The requestId generated by the original call to the Authorize method.</param>
        /// <param name="securityChallenges">A list with the SecurityChallanges provided by the original Authorize method filled with the answers for the MFA questions.</param>
        /// <returns>Returns an object containing information about the Authorize process.</returns>
        public AuthorizeResult AnswerMfaQuestionsAndAuthorize(Guid requestId, List <SecurityChallenge> securityChallenges)
        {
            if (!IsClientStatusWaitingForMfaQuestions())
            {
                throw new Exception($"The Authorization status has to be {ClientStatus.PENDING_MFA_ANSWERS} to call this method.");
            }

            var mfaAnswers = new Dictionary <string, List <string> >();

            foreach (var securityChallenge in securityChallenges)
            {
                mfaAnswers.Add(securityChallenge.Prompt, new List <string>()
                {
                    securityChallenge.Answer
                });
            }

            AuthorizeBody = new AuthorizeRequestBody()
            {
                RequestId         = requestId,
                SecurityResponses = mfaAnswers
            };

            var request = GetBaseRequest(EndpointConstant.Authorize, Method.POST);

            request.AddParameter(FlinksSettingsConstant.ApplicationJsonUTF8, JsonConvert.SerializeObject(AuthorizeBody, _jsonSerializationSettings), ParameterType.RequestBody);

            var response = RestClient.Execute(request);

            SetClientAuthorizeStatus(response.StatusCode);

            var apiResponse = JsonConvert.DeserializeObject <AuthorizeResult>(response.Content);

            apiResponse.ClientStatus = ClientStatus;

            return(apiResponse);
        }