public async Task <PaymentMethod> PostPaymentMethodsETFS(int ownerId, BillingParameters billingParam)
        {
            PaymentMethod ret = null;
            SaveEftPaymentMethodCommand command = new SaveEftPaymentMethodCommand();

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                command             = GetSaveEftPaymentMethodCommandFromBillingParameter(accounts.First(), billingParam);
                command.AccountName = $"bat{billingParam.BankAccountNameOnAccount}";

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/paymentmethods/efts";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <PaymentMethod>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
        public async Task PaymentMethodsEtfs()
        {
            ownerId = EnrollTestSettings.Default.AccountUpdateTestOwnerId;
            iep     = testDataManager.GenerateOwnerPetTestData(numPets: 1);
            BillingParameters billingParams = iep.BillingParams;
            PaymentMethod     respond       = await billingRestClient.PostPaymentMethodsETFS(ownerId, billingParams);

            Assert.IsNotNull(respond, $"failed to update payment methods");
            // TODO: verify payment methods updated
        }
        public async Task SaveUsaBankAccount()
        {
            iep     = testDataManager.GenerateOwnerPetTestData(numPets: 1);
            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);
            BillingParameters       billingParams = iep.BillingParams;
            SaveBankAccountResponse respond       = await billingRestClient.PostSaveUsaBankAccount(ownerId, billingParams);

            Assert.IsNotNull(respond, $"failed to save bank account");
            BankAccount bAccount = await billingRestClient.GetBankAccouintsByOwnerId(ownerId);

            //var acount = qaLibRestClient.GetBillingAccountByOwnerId(ownerId);
        }
        public SaveEftPaymentMethodCommand GetSaveEftPaymentMethodCommandFromBillingParameter(Account account, BillingParameters billingParam)
        {
            SaveEftPaymentMethodCommand ret = new SaveEftPaymentMethodCommand();

            ret.AccountName       = $"518{billingParam.BankAccountNameOnAccount}";
            ret.BankAccountNumber = "632756";
            ret.BankAccountType   = billingParam.BankAccountAccountType == LegacyPlatform.Constants.BankAccountType.Checking ? "Checking" : "Saving";
            ret.BankName          = billingParam.BankAccountBankName;
            ret.BankRoutingNumber = billingParam.BankAccountTransitNumber;
            ret.Currency          = account.Currency;
            //ret.Data = null;
            //ret.DynamicMessage = null;
            ret.IsBillingDefault = false;
            ret.KeyList          = new List <TruFoundation.EnterpriseCatalog.DynamicEntityKey>();
            //ret.MessageInfo = null;
            ret.OriginatingUserId = Guid.NewGuid();
            ret.PartyId           = account.PartyId;
            ret.PaymentMethodId   = Guid.Parse(account.DefaultPaymentMethodId);
            //ret.SensitiveStringProperties = string.Empty;
            ret.Time   = DateTime.UtcNow.ToLocalTime();
            ret.UserId = Guid.NewGuid();
            return(ret);
        }
        public SaveUsaBankAccountCommand GetSaveUsaBankAccountCommandFromBillingParameter(Account account, BillingParameters billingParam)
        {
            SaveUsaBankAccountCommand ret = new SaveUsaBankAccountCommand();

            ret.AccountId     = null;
            ret.AccountNumber = $"518{billingParam.BankAccountTransitNumber}";
            ret.AccountTypeId = billingParam.BankAccountAccountType == LegacyPlatform.Constants.BankAccountType.Checking ? WellKnownBankAccountTypes.Checking : WellKnownBankAccountTypes.Saving;
            ret.BankAccountId = Guid.NewGuid();
            ret.BankName      = billingParam.BankAccountBankName;
            ret.Data          = null;
            //ret.DynamicMessage = string.Empty;
            ret.IsNonReferencedCreditMethod = false;
            ret.IsPaymentMethod             = false;
            ret.KeyList           = new List <TruFoundation.EnterpriseCatalog.DynamicEntityKey>();
            ret.MessageInfo       = null;
            ret.NameOnAccount     = billingParam.BankAccountNameOnAccount;
            ret.OriginatingUserId = Guid.Empty;
            ret.RoutingNumber     = billingParam.BankAccountTransitNumber;
            ret.Time   = DateTime.UtcNow;
            ret.UserId = Guid.Empty;
            return(ret);
        }
        public async Task <SaveBankAccountResponse> PostSaveCanadaBankAccount(int ownerId, BillingParameters billingParam)
        {
            SaveBankAccountResponse   ret     = null;
            SaveUsaBankAccountCommand command = new SaveUsaBankAccountCommand();

            try
            {
                ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
                IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

                command               = GetSaveUsaBankAccountCommandFromBillingParameter(accounts.First(), billingParam);
                command.AccountId     = BillingTestCommonSettings.Default.SaveUsaBankAccountBillingAccountId;
                command.NameOnAccount = $"bat{billingParam.BankAccountNameOnAccount}";

                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Post;
                req.Headers     = Headers;
                req.ContentType = "application/json";
                req.RequestUri  = $"v2/bankaccounts/canada";
                req.Content     = JsonSerializer.Serialize(command);
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                ret = JsonSerializer.Deserialize <SaveBankAccountResponse>(returnPost.Value);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }