forked from killbill/killbill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to send emails when the overdue state change. For now, these emails are not localized. Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
- Loading branch information
Pierre-Alexandre Meyer
committed
Sep 22, 2012
1 parent
bb536ab
commit c494c0f
Showing
14 changed files
with
317 additions
and
44 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
api/src/main/java/com/ning/billing/overdue/EmailNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2010-2012 Ning, Inc. | ||
* | ||
* Ning licenses this file to you under the Apache License, version 2.0 | ||
* (the "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.ning.billing.overdue; | ||
|
||
public interface EmailNotification { | ||
|
||
public String getSubject(); | ||
|
||
public String getTemplateName(); | ||
|
||
public Boolean isHTML(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
overdue/src/main/java/com/ning/billing/overdue/applicator/OverdueEmailGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2010-2012 Ning, Inc. | ||
* | ||
* Ning licenses this file to you under the Apache License, version 2.0 | ||
* (the "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.ning.billing.overdue.applicator; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.ning.billing.account.api.Account; | ||
import com.ning.billing.junction.api.Blockable; | ||
import com.ning.billing.overdue.OverdueState; | ||
import com.ning.billing.overdue.config.api.BillingState; | ||
import com.ning.billing.util.email.templates.TemplateEngine; | ||
|
||
import com.google.inject.Inject; | ||
|
||
public class OverdueEmailGenerator { | ||
|
||
private final TemplateEngine templateEngine; | ||
|
||
@Inject | ||
public OverdueEmailGenerator(final TemplateEngine templateEngine) { | ||
this.templateEngine = templateEngine; | ||
} | ||
|
||
public <T extends Blockable> String generateEmail(final Account account, final BillingState<T> billingState, | ||
final T overdueable, final OverdueState<T> nextOverdueState) throws IOException { | ||
final Map<String, Object> data = new HashMap<String, Object>(); | ||
|
||
// TODO raw objects for now. We eventually should respect the account locale and support translations | ||
data.put("account", account); | ||
data.put("billingState", billingState); | ||
data.put("overdueable", overdueable); | ||
data.put("nextOverdueState", nextOverdueState); | ||
|
||
// TODO single template for all languages for now | ||
return templateEngine.executeTemplate(nextOverdueState.getEnterStateEmailNotification().getTemplateName(), data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
overdue/src/main/java/com/ning/billing/overdue/config/DefaultEmailNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2010-2012 Ning, Inc. | ||
* | ||
* Ning licenses this file to you under the Apache License, version 2.0 | ||
* (the "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.ning.billing.overdue.config; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlElement; | ||
|
||
import com.ning.billing.overdue.EmailNotification; | ||
|
||
@XmlAccessorType(XmlAccessType.NONE) | ||
public class DefaultEmailNotification implements EmailNotification { | ||
|
||
@XmlElement(required = true, name = "subject") | ||
private String subject; | ||
|
||
@XmlElement(required = true, name = "templateName") | ||
private String templateName; | ||
|
||
@XmlElement(required = false, name = "isHTML") | ||
private Boolean isHTML = false; | ||
|
||
@Override | ||
public String getSubject() { | ||
return subject; | ||
} | ||
|
||
@Override | ||
public String getTemplateName() { | ||
return templateName; | ||
} | ||
|
||
@Override | ||
public Boolean isHTML() { | ||
return isHTML; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.