Search in sources :

Example 6 with MutableAccountData

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);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountTestUtils.createTestAccount(org.killbill.billing.account.AccountTestUtils.createTestAccount) Account(org.killbill.billing.account.api.Account) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) Test(org.testng.annotations.Test)

Example 7 with MutableAccountData

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);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountTestUtils.createTestAccount(org.killbill.billing.account.AccountTestUtils.createTestAccount) Account(org.killbill.billing.account.api.Account) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) Test(org.testng.annotations.Test)

Example 8 with MutableAccountData

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();
}
Also used : Account(org.killbill.billing.account.api.Account) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.annotations.ApiResponses)

Example 9 with MutableAccountData

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);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) Account(org.killbill.billing.account.api.Account) AccountModelDao(org.killbill.billing.account.dao.AccountModelDao) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) AccountApiException(org.killbill.billing.account.api.AccountApiException)

Example 10 with MutableAccountData

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);
}
Also used : DefaultAccount(org.killbill.billing.account.api.DefaultAccount) AccountTestUtils.createTestAccount(org.killbill.billing.account.AccountTestUtils.createTestAccount) Account(org.killbill.billing.account.api.Account) DefaultAccount(org.killbill.billing.account.api.DefaultAccount) DefaultMutableAccountData(org.killbill.billing.account.api.DefaultMutableAccountData) MutableAccountData(org.killbill.billing.account.api.MutableAccountData) Test(org.testng.annotations.Test)

Aggregations

MutableAccountData (org.killbill.billing.account.api.MutableAccountData)16 Account (org.killbill.billing.account.api.Account)15 DefaultAccount (org.killbill.billing.account.api.DefaultAccount)15 DefaultMutableAccountData (org.killbill.billing.account.api.DefaultMutableAccountData)15 Test (org.testng.annotations.Test)14 AccountTestUtils.createTestAccount (org.killbill.billing.account.AccountTestUtils.createTestAccount)13 AccountModelDao (org.killbill.billing.account.dao.AccountModelDao)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 UUID (java.util.UUID)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 AccountTestUtils.createAccountData (org.killbill.billing.account.AccountTestUtils.createAccountData)1 AccountApiException (org.killbill.billing.account.api.AccountApiException)1 AccountData (org.killbill.billing.account.api.AccountData)1 CallContext (org.killbill.billing.util.callcontext.CallContext)1 TimedResource (org.killbill.commons.metrics.TimedResource)1