Search in sources :

Example 1 with NotificationDto

use of io.apiman.manager.api.beans.notifications.dto.NotificationDto in project apiman by apiman.

the class DefaultTemplatesTest method contract_approval_response_txt.

@Test
public void contract_approval_response_txt() throws IOException {
    var appDeveloper = new UserDto().setFullName("John Smith Appdev").setUsername("JohnSmith123").setEmail("foo@apiman.io").setLocale(Locale.ENGLISH);
    ContractApprovalEvent approvalEvent = ContractApprovalEvent.builder().setHeaders(ApimanEventHeaders.builder().setId("Event123").setSource(URI.create("https://example.org")).setSubject("Hello").setEventVersion(1L).setTime(OffsetDateTime.now()).setType("X").build()).setApiOrgId("ApiOrg").setApiId("CoolApi").setApiVersion("1.0").setClientOrgId("MobileKompany").setClientId("MobileApp").setClientVersion("2.0").setContractId("1234").setPlanId("Gold").setPlanVersion("1.3").setApprover(appDeveloper).setApproved(true).build();
    UserDto recipient = new UserDto().setEmail("approver@apiman.io").setUsername("ApproverPerson").setFullName("David Approver").setLocale(Locale.ENGLISH);
    NotificationDto<IVersionedApimanEvent> notificationDto = new NotificationDto<>().setId(123L).setCategory(NotificationCategory.API_ADMINISTRATION).setReason("whatever").setReasonMessage("hi").setStatus(NotificationStatus.OPEN).setCreatedOn(OffsetDateTime.now()).setModifiedOn(OffsetDateTime.now()).setRecipient(recipient).setSource("adsadsaad").setPayload(approvalEvent);
    QuteTemplateEngine engine = new QuteTemplateEngine(CONFIG);
    engine.applyTemplate(Files.readString(CONFIG.getConfigDirectory().resolve("notifications/email/tpl/en/apiman.client.contract.approval.granted.txt")), EmailNotificationDispatcher.createDefaultTemplateMap(notificationDto, CONFIG));
}
Also used : IVersionedApimanEvent(io.apiman.manager.api.beans.events.IVersionedApimanEvent) NotificationDto(io.apiman.manager.api.beans.notifications.dto.NotificationDto) QuteTemplateEngine(io.apiman.manager.api.notifications.email.QuteTemplateEngine) UserDto(io.apiman.manager.api.beans.idm.UserDto) ContractApprovalEvent(io.apiman.manager.api.beans.events.ContractApprovalEvent) Test(org.junit.Test)

Example 2 with NotificationDto

use of io.apiman.manager.api.beans.notifications.dto.NotificationDto in project apiman by apiman.

the class ClientAppRegisteredEmailNotification method wants.

/**
 * If a status change event && has transitioned into 'registered' state.
 */
@Override
public boolean wants(NotificationDto<? extends IVersionedApimanEvent> raw) {
    if (raw.getReason().equals(ClientAppStatusNotificationProducer.APIMAN_CLIENT_STATUS_CHANGE)) {
        // Get the event payload
        NotificationDto<ClientVersionStatusEvent> notification = (NotificationDto<ClientVersionStatusEvent>) raw;
        ClientVersionStatusEvent event = notification.getPayload();
        // We only want to send a notification if the previous state was unregistered, and new state is registered (for now).
        return (event.getNewStatus() == ClientStatus.Registered && event.getPreviousStatus() == ClientStatus.AwaitingApproval);
    }
    return false;
}
Also used : NotificationDto(io.apiman.manager.api.beans.notifications.dto.NotificationDto) ClientVersionStatusEvent(io.apiman.manager.api.beans.events.ClientVersionStatusEvent)

Example 3 with NotificationDto

use of io.apiman.manager.api.beans.notifications.dto.NotificationDto in project apiman by apiman.

the class DefaultTemplatesTest method contract_approval_response_html.

@Test
public void contract_approval_response_html() throws IOException {
    var appDeveloper = new UserDto().setFullName("John Smith Appdev").setUsername("JohnSmith123").setEmail("foo@apiman.io").setLocale(Locale.ENGLISH);
    ContractApprovalEvent approvalEvent = ContractApprovalEvent.builder().setHeaders(ApimanEventHeaders.builder().setId("Event123").setSource(URI.create("https://example.org")).setSubject("Hello").setEventVersion(1L).setTime(OffsetDateTime.now()).setType("X").build()).setApiOrgId("ApiOrg").setApiId("CoolApi").setApiVersion("1.0").setClientOrgId("MobileKompany").setClientId("MobileApp").setClientVersion("2.0").setContractId("1234").setPlanId("Gold").setPlanVersion("1.3").setApprover(appDeveloper).setApproved(true).build();
    UserDto recipient = new UserDto().setEmail("approver@apiman.io").setUsername("ApproverPerson").setFullName("David Approver").setLocale(Locale.ENGLISH);
    NotificationDto<IVersionedApimanEvent> notificationDto = new NotificationDto<>().setId(123L).setCategory(NotificationCategory.API_ADMINISTRATION).setReason("whatever").setReasonMessage("hi").setStatus(NotificationStatus.OPEN).setCreatedOn(OffsetDateTime.now()).setModifiedOn(OffsetDateTime.now()).setRecipient(recipient).setSource("adsadsaad").setPayload(approvalEvent);
    QuteTemplateEngine engine = new QuteTemplateEngine(CONFIG);
    engine.applyTemplate(Files.readString(CONFIG.getConfigDirectory().resolve("notifications/email/tpl/en/apiman.client.contract.approval.granted.html")), EmailNotificationDispatcher.createDefaultTemplateMap(notificationDto, CONFIG));
}
Also used : IVersionedApimanEvent(io.apiman.manager.api.beans.events.IVersionedApimanEvent) NotificationDto(io.apiman.manager.api.beans.notifications.dto.NotificationDto) QuteTemplateEngine(io.apiman.manager.api.notifications.email.QuteTemplateEngine) UserDto(io.apiman.manager.api.beans.idm.UserDto) ContractApprovalEvent(io.apiman.manager.api.beans.events.ContractApprovalEvent) Test(org.junit.Test)

Example 4 with NotificationDto

use of io.apiman.manager.api.beans.notifications.dto.NotificationDto in project apiman by apiman.

the class DefaultTemplatesTest method contract_approval_request_html.

@Test
public void contract_approval_request_html() throws IOException {
    var appDeveloper = new UserDto().setFullName("John Smith Appdev").setUsername("JohnSmith123").setEmail("foo@apiman.io").setLocale(Locale.ENGLISH);
    ContractCreatedEvent contractCreated = ContractCreatedEvent.builder().setHeaders(ApimanEventHeaders.builder().setId("Event123").setSource(URI.create("https://example.org")).setSubject("Hello").setEventVersion(1L).setTime(OffsetDateTime.now()).setType("X").build()).setApiOrgId("ApiOrg").setApiId("CoolApi").setApiVersion("1.0").setClientOrgId("MobileKompany").setClientId("MobileApp").setClientVersion("2.0").setContractId("1234").setPlanId("Gold").setPlanVersion("1.3").setApprovalRequired(true).setUser(appDeveloper).build();
    UserDto recipient = new UserDto().setEmail("approver@apiman.io").setUsername("ApproverPerson").setFullName("David Approver").setLocale(Locale.ENGLISH);
    NotificationDto<IVersionedApimanEvent> notificationDto = new NotificationDto<>().setId(123L).setCategory(NotificationCategory.API_ADMINISTRATION).setReason("whatever").setReasonMessage("hi").setStatus(NotificationStatus.OPEN).setCreatedOn(OffsetDateTime.now()).setModifiedOn(OffsetDateTime.now()).setRecipient(recipient).setSource("adsadsaad").setPayload(contractCreated);
    QuteTemplateEngine engine = new QuteTemplateEngine(CONFIG);
    engine.applyTemplate(Files.readString(CONFIG.getConfigDirectory().resolve("notifications/email/tpl/en/apiman.client.contract.approval.request.html")), EmailNotificationDispatcher.createDefaultTemplateMap(notificationDto, CONFIG));
}
Also used : IVersionedApimanEvent(io.apiman.manager.api.beans.events.IVersionedApimanEvent) NotificationDto(io.apiman.manager.api.beans.notifications.dto.NotificationDto) QuteTemplateEngine(io.apiman.manager.api.notifications.email.QuteTemplateEngine) ContractCreatedEvent(io.apiman.manager.api.beans.events.ContractCreatedEvent) UserDto(io.apiman.manager.api.beans.idm.UserDto) Test(org.junit.Test)

Example 5 with NotificationDto

use of io.apiman.manager.api.beans.notifications.dto.NotificationDto in project apiman by apiman.

the class DefaultTemplatesTest method contract_approval_request_txt.

@Test
public void contract_approval_request_txt() throws IOException {
    var appDeveloper = new UserDto().setFullName("John Smith Appdev").setUsername("JohnSmith123").setEmail("foo@apiman.io").setLocale(Locale.ENGLISH);
    ContractCreatedEvent contractCreated = ContractCreatedEvent.builder().setHeaders(ApimanEventHeaders.builder().setId("Event123").setSource(URI.create("https://example.org")).setSubject("Hello").setEventVersion(1L).setTime(OffsetDateTime.now()).setType("X").build()).setApiOrgId("ApiOrg").setApiId("CoolApi").setApiVersion("1.0").setClientOrgId("MobileKompany").setClientId("MobileApp").setClientVersion("2.0").setContractId("1234").setPlanId("Gold").setPlanVersion("1.3").setApprovalRequired(true).setUser(appDeveloper).build();
    UserDto recipient = new UserDto().setEmail("approver@apiman.io").setUsername("ApproverPerson").setFullName("David Approver").setLocale(Locale.ENGLISH);
    NotificationDto<IVersionedApimanEvent> notificationDto = new NotificationDto<>().setId(123L).setCategory(NotificationCategory.API_ADMINISTRATION).setReason("whatever").setReasonMessage("hi").setStatus(NotificationStatus.OPEN).setCreatedOn(OffsetDateTime.now()).setModifiedOn(OffsetDateTime.now()).setRecipient(recipient).setSource("adsadsaad").setPayload(contractCreated);
    QuteTemplateEngine engine = new QuteTemplateEngine(CONFIG);
    engine.applyTemplate(Files.readString(CONFIG.getConfigDirectory().resolve("notifications/email/tpl/en/apiman.client.contract.approval.request.txt")), EmailNotificationDispatcher.createDefaultTemplateMap(notificationDto, CONFIG));
}
Also used : IVersionedApimanEvent(io.apiman.manager.api.beans.events.IVersionedApimanEvent) NotificationDto(io.apiman.manager.api.beans.notifications.dto.NotificationDto) QuteTemplateEngine(io.apiman.manager.api.notifications.email.QuteTemplateEngine) ContractCreatedEvent(io.apiman.manager.api.beans.events.ContractCreatedEvent) UserDto(io.apiman.manager.api.beans.idm.UserDto) Test(org.junit.Test)

Aggregations

NotificationDto (io.apiman.manager.api.beans.notifications.dto.NotificationDto)5 IVersionedApimanEvent (io.apiman.manager.api.beans.events.IVersionedApimanEvent)4 UserDto (io.apiman.manager.api.beans.idm.UserDto)4 QuteTemplateEngine (io.apiman.manager.api.notifications.email.QuteTemplateEngine)4 Test (org.junit.Test)4 ContractApprovalEvent (io.apiman.manager.api.beans.events.ContractApprovalEvent)2 ContractCreatedEvent (io.apiman.manager.api.beans.events.ContractCreatedEvent)2 ClientVersionStatusEvent (io.apiman.manager.api.beans.events.ClientVersionStatusEvent)1