public async Task <bool> PostAccountUpdatesChangeDefaultPaymentMethod(int ownerId, BillingPaymentMethodTypes method) { bool ret = false; try { ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId); IReadOnlyList <Account> accounts = await GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString()); List <PaymentMethod> methods = await GetAccountPaymentMethods(ownerId); PaymentMethod newMethod = methods.Where(e => e.Type.Equals(method.ToString())).First(); UpdateAccountCommand command = GetUpdateAccountCommandFromAccount(accounts.First()); command.DefaultPaymentMethodId = newMethod.Id; RestRequestSpecification req = new RestRequestSpecification(); req.Verb = HttpMethod.Post; req.Headers = Headers; req.ContentType = "application/json"; req.RequestUri = $"v2/AccountUpdates"; req.Content = JsonSerializer.Serialize(command); var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req); ret = returnPost.Success; } catch (Exception ex) { log.Fatal(ex); } return(ret); }
public async Task <PaymentMethod> verifyAccountDefaultPaymentMethod(int ownerId, BillingPaymentMethodTypes method) { List <PaymentMethod> methods = new List <PaymentMethod>(); PaymentMethod curMethod = new PaymentMethod(); try { ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId); accounts = await billingRestClient.GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString()); methods = await billingRestClient.GetAccountPaymentMethods(ownerId); curMethod = methods.Where(m => m.Id == accounts.First().DefaultPaymentMethodId).First(); } catch (Exception ex) { Logger.Log.Fatal(ex); } Assert.IsTrue(curMethod.Type.Equals(method.ToString()), $"default payment method {curMethod.Type} doesn't match expencted {method.ToString()}"); return(curMethod); }