use of org.killbill.billing.account.api.AccountEmail in project killbill by killbill.
the class AccountResource method getEmails.
/*
* ************************* EMAILS *****************************
*/
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve an account emails", response = AccountEmailJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response getEmails(@PathParam(ID_PARAM_NAME) final String id, @javax.ws.rs.core.Context final HttpServletRequest request) {
final UUID accountId = UUID.fromString(id);
final List<AccountEmail> emails = accountUserApi.getEmails(accountId, context.createContext(request));
final List<AccountEmailJson> emailsJson = new ArrayList<AccountEmailJson>();
for (final AccountEmail email : emails) {
emailsJson.add(new AccountEmailJson(email.getAccountId().toString(), email.getEmail()));
}
return Response.status(Status.OK).entity(emailsJson).build();
}
use of org.killbill.billing.account.api.AccountEmail in project killbill by killbill.
the class TestAccountDao method testAddRemoveAccountEmail.
@Test(groups = "slow", description = "Test Account DAO: add and remove email")
public void testAddRemoveAccountEmail() throws AccountApiException {
final UUID accountId = UUID.randomUUID();
// Add a new e-mail
final AccountEmail email = new DefaultAccountEmail(accountId, "test@gmail.com");
accountDao.addEmail(new AccountEmailModelDao(email), internalCallContext);
final List<AccountEmailModelDao> accountEmails = accountDao.getEmailsByAccountId(accountId, internalCallContext);
Assert.assertEquals(accountEmails.size(), 1);
Assert.assertEquals(accountEmails.get(0).getAccountId(), accountId);
Assert.assertEquals(accountEmails.get(0).getEmail(), email.getEmail());
// Verify audits
final List<AuditLog> auditLogsForAccountEmail = auditDao.getAuditLogsForId(TableName.ACCOUNT_EMAIL, email.getId(), AuditLevel.FULL, internalCallContext);
Assert.assertEquals(auditLogsForAccountEmail.size(), 1);
Assert.assertEquals(auditLogsForAccountEmail.get(0).getChangeType(), ChangeType.INSERT);
// Delete the e-mail
accountDao.removeEmail(new AccountEmailModelDao(email), internalCallContext);
Assert.assertEquals(accountDao.getEmailsByAccountId(accountId, internalCallContext).size(), 0);
}
use of org.killbill.billing.account.api.AccountEmail in project killbill by killbill.
the class DefaultAccountInternalApi method getEmails.
@Override
public List<AccountEmail> getEmails(final UUID accountId, final InternalTenantContext context) {
final List<AccountEmailModelDao> childrenAccountsModelDao = accountDao.getEmailsByAccountId(accountId, context);
final List<AccountEmail> emails = new LinkedList<AccountEmail>();
for (final AccountEmailModelDao emailsModelDao : childrenAccountsModelDao) {
emails.add(new DefaultAccountEmail(emailsModelDao));
}
return emails;
}
use of org.killbill.billing.account.api.AccountEmail in project killbill by killbill.
the class DefaultAccountUserApi method getEmails.
@Override
public List<AccountEmail> getEmails(final UUID accountId, final TenantContext context) {
final List<AccountEmailModelDao> childrenAccountsModelDao = accountDao.getEmailsByAccountId(accountId, internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(context));
final List<AccountEmail> emails = new LinkedList<AccountEmail>();
for (final AccountEmailModelDao emailsModelDao : childrenAccountsModelDao) {
emails.add(new DefaultAccountEmail(emailsModelDao));
}
return emails;
}
use of org.killbill.billing.account.api.AccountEmail in project killbill by killbill.
the class TestAccountEmailJson method testToAccountEmail.
@Test(groups = "fast")
public void testToAccountEmail() throws Exception {
final UUID accountId = UUID.randomUUID();
final String email = UUID.randomUUID().toString();
final AccountEmailJson accountEmailJson = new AccountEmailJson(accountId, email);
Assert.assertEquals(accountEmailJson.getAccountId(), accountId);
Assert.assertEquals(accountEmailJson.getEmail(), email);
final AccountEmail accountEmail = accountEmailJson.toAccountEmail(UUID.randomUUID());
Assert.assertEquals(accountEmail.getAccountId(), accountId);
Assert.assertEquals(accountEmail.getEmail(), email);
}
Aggregations