예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AddUserOptionsRequest"/> class.
        /// </summary>
        /// <param name="options">The options model to make a contract out of.</param>
        public AddUserOptionsRequest(AddUserOptions options)
            : this()
        {
            if (options == null) return;

            this.EndDate = options.EndDate;
            this.IncludeMfaList = options.IncludeMfaList;
            this.IncludePending = options.IncludePending;
            this.LoginOnly = options.LoginOnly;
            this.StartDate = options.StartDate;
            this.Webhook = options.WebhookUri?.ToString();
        }
예제 #2
0
        /// <inheritdoc />
        public async Task<AddUserResult> AddUserAsync(string username,string password, InstitutionType institution, AddUserOptions options = null, string pin = null, ApiType api = ApiType.Connect)
        {
            Condition.Requires(username).IsNotNullOrWhiteSpace();
            Condition.Requires(password).IsNotNullOrWhiteSpace();
            Condition.Requires(institution).IsNotNull();

            AddUserRequest userRequest = new AddUserRequest(this.clientId, this.clientSecret)
                {
                    Username = username, 
                    Password = password, 
                    Type = institution.Value, 
                    Options = new AddUserOptionsRequest(options), 
                    Pin = pin
                };

            HttpResponseMessage response = await this.httpClient.PostAsJsonAsync(GetEndpoint(api), userRequest);
            return await this.ProcessAddOrAuthResponse(response);
        }
예제 #3
0
        public async Task AddUserListCodeAuth()
        {
            IHttpClientWrapper httpClient = this.GetMockHttpClient("DeviceListMfa.json", HttpStatusCode.Created, HttpMethod.Post);
            IPlaidClient testClient = this.GetPlaidClient(httpClient);
            AddUserOptions options = new AddUserOptions { IncludeMfaList = true };
            AddUserResult result = await testClient.AddUserAsync(BaseTestClass.TestUsername, BaseTestClass.TestPassword, InstitutionType.Chase, options);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.IsError);
            Assert.IsTrue(result.IsMfaRequired);

            Assert.AreEqual(AuthType.Code, result.AuthPrompt.AuthType);
            Assert.IsNotNull(result.AuthPrompt.CodeDeliveryOptions);
            Assert.AreEqual(2, result.AuthPrompt.CodeDeliveryOptions.Count);

            Assert.IsFalse(string.IsNullOrWhiteSpace(result.AuthPrompt.CodeDeliveryOptions[0].Mask));
            Assert.AreEqual(DeliveryType.Phone, result.AuthPrompt.CodeDeliveryOptions[0].Type);
            Assert.IsFalse(string.IsNullOrWhiteSpace(result.AuthPrompt.CodeDeliveryOptions[1].Mask));
            Assert.AreEqual(DeliveryType.Email, result.AuthPrompt.CodeDeliveryOptions[1].Type);
        }