use of org.killbill.billing.account.api.MutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testAccountChangingTimeZone.
@Test(groups = "slow", description = "Test failure on changing timeZone", expectedExceptions = IllegalArgumentException.class)
public void testAccountChangingTimeZone() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
mutableAccountData.setTimeZone(DateTimeZone.UTC);
DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData);
accountUserApi.updateAccount(newAccount, callContext);
}
use of org.killbill.billing.account.api.MutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testAccountResetExternalKey.
@Test(groups = "slow", description = "Test failure on resetting externalKey", expectedExceptions = IllegalArgumentException.class)
public void testAccountResetExternalKey() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
// Update the address and leave other fields null
final MutableAccountData mutableAccountData = new DefaultMutableAccountData(account);
mutableAccountData.setExternalKey(null);
DefaultAccount newAccount = new DefaultAccount(account.getId(), mutableAccountData);
accountUserApi.updateAccount(newAccount, callContext);
}
use of org.killbill.billing.account.api.MutableAccountData in project killbill by killbill.
the class AccountResource method setEmailNotificationsForAccount.
@TimedResource
@PUT
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAIL_NOTIFICATIONS)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Set account email notification")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response setEmailNotificationsForAccount(final InvoiceEmailJson json, @PathParam("accountId") final String accountIdString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
verifyNonNullOrEmpty(json, "InvoiceEmailJson body should be specified");
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final UUID accountId = UUID.fromString(accountIdString);
final Account account = accountUserApi.getAccountById(accountId, callContext);
final MutableAccountData mutableAccountData = account.toMutableAccountData();
mutableAccountData.setIsNotifiedForInvoices(json.isNotifiedForInvoices());
accountUserApi.updateAccount(accountId, mutableAccountData, callContext);
return Response.status(Status.OK).build();
}
use of org.killbill.billing.account.api.MutableAccountData in project killbill by killbill.
the class DefaultAccountInternalApi method updateBCD.
@Override
public void updateBCD(final String externalKey, final int bcd, final InternalCallContext context) throws AccountApiException {
final Account currentAccount = getAccountByKey(externalKey, context);
if (currentAccount == null) {
throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_KEY, externalKey);
}
if (currentAccount.getBillCycleDayLocal() != DefaultMutableAccountData.DEFAULT_BILLING_CYCLE_DAY_LOCAL) {
throw new AccountApiException(ErrorCode.ACCOUNT_UPDATE_FAILED);
}
final MutableAccountData mutableAccountData = currentAccount.toMutableAccountData();
mutableAccountData.setBillCycleDayLocal(bcd);
final AccountModelDao accountToUpdate = new AccountModelDao(currentAccount.getId(), mutableAccountData);
bcdCacheController.remove(currentAccount.getId());
bcdCacheController.putIfAbsent(currentAccount.getId(), new Integer(bcd));
accountDao.update(accountToUpdate, context);
}
use of org.killbill.billing.account.api.MutableAccountData in project killbill by killbill.
the class TestDefaultAccountUserApi method testShouldntBeAbleToUpdateExternalKey.
@Test(groups = "slow", expectedExceptions = IllegalArgumentException.class, description = "Test updating Account externalKey throws an exception")
public void testShouldntBeAbleToUpdateExternalKey() throws Exception {
final Account account = createAccount(new DefaultAccount(createTestAccount()));
final MutableAccountData otherAccount = new DefaultAccount(account.getId(), account).toMutableAccountData();
otherAccount.setExternalKey(UUID.randomUUID().toString());
accountUserApi.updateAccount(new DefaultAccount(account.getId(), otherAccount), callContext);
}
Aggregations