From 3ed5d25d95871f757a6a5532cd753a7aabf3308a Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Tue, 30 Jun 2020 15:06:56 -0400
Subject: [PATCH 01/14] have emails use the referral response instead of the
referral
---
.../default/classes/ClientMessageHelper.cls | 10 ++--
.../main/default/classes/EmailService.cls | 5 +-
.../ReferralEmailTemplateController.cls | 51 ++++++++++---------
.../classes/Test_ClientMessageHelper.cls | 12 +----
4 files changed, 33 insertions(+), 45 deletions(-)
diff --git a/force-app/main/default/classes/ClientMessageHelper.cls b/force-app/main/default/classes/ClientMessageHelper.cls
index cd4838f4..fd2dc95a 100644
--- a/force-app/main/default/classes/ClientMessageHelper.cls
+++ b/force-app/main/default/classes/ClientMessageHelper.cls
@@ -2,9 +2,7 @@ public with sharing class ClientMessageHelper {
// email template names
public static final String INITIAL_CLIENT_REFERRAL_TEMPLATE = 'Initial_Client_Referral';
public static final String CLIENT_REFERRAL_FOLLOWUP_TEMPLATE = 'Client_Referral_Followup';
- public static final String CLIENT_REFERRAL_FOLLOWUP_TEMPLATE_NAME = 'Client Referral Followup';
public static final String CLIENT_RATE_SERVICE_TEMPLATE = 'Client_Rate_Service_Experience';
- public static final String CLIENT_RATE_SERVICE_TEMPLATE_NAME = 'Client Rate Service Experience';
public static final String CLIENT_HELP_RESPONSE_TEMPLATE = 'Client_Help_Response';
public static final String CLIENT_CANT_CONNECT_TEMPLATE = 'Client_Cant_Connect';
public static final String RATE_SERVICE_SAVED_TEMPLATE = 'Rate_Service_Saved_Response';
@@ -96,14 +94,12 @@ public with sharing class ClientMessageHelper {
return messages;
}
- public static Referral_Response__c saveReferralQuestion(Messaging.SingleEmailMessage email) {
- // the referral id will be in the what id of the email message
- String referralId = email.getWhatId();
+ public static Referral_Response__c saveReferralQuestion(String referralId, String templateName) {
String question = '';
// determine the question that was asked, based on the email template
- if (CLIENT_REFERRAL_FOLLOWUP_TEMPLATE_NAME.equals(email.getTemplateName())) {
+ if (CLIENT_REFERRAL_FOLLOWUP_TEMPLATE.equals(templateName)) {
question = CLIENT_FOLLOWUP_QUESTION;
- } else if (CLIENT_RATE_SERVICE_TEMPLATE_NAME.equals(email.getTemplateName())) {
+ } else if (CLIENT_RATE_SERVICE_TEMPLATE.equals(templateName)) {
question = CLIENT_RATE_SERVICE_QUESTION;
}
diff --git a/force-app/main/default/classes/EmailService.cls b/force-app/main/default/classes/EmailService.cls
index 22a03e99..521ecf4f 100644
--- a/force-app/main/default/classes/EmailService.cls
+++ b/force-app/main/default/classes/EmailService.cls
@@ -185,10 +185,7 @@ public with sharing class EmailService {
Messaging.SendEmailResult[] results = Messaging.sendEmail( new List{ emailToSend } );
for (Messaging.SendEmailResult result : results) {
- if (result.isSuccess()) {
- // email was sent, save the question to a referral response record...
- ClientMessageHelper.saveReferralQuestion(emailToSend);
- } else {
+ if (!result.isSuccess()) {
Messaging.SendEmailError[] errors = result.getErrors();
for (Messaging.SendEmailError error : errors) {
// TODO is this okay?
diff --git a/force-app/main/default/classes/ReferralEmailTemplateController.cls b/force-app/main/default/classes/ReferralEmailTemplateController.cls
index c08d1bf4..d4df4a08 100644
--- a/force-app/main/default/classes/ReferralEmailTemplateController.cls
+++ b/force-app/main/default/classes/ReferralEmailTemplateController.cls
@@ -1,31 +1,34 @@
global class ReferralEmailTemplateController {
- global String referralId {get;set;}
+ global String referralResponseId {get;set;}
- global Referral__c referral {
+ global Referral_Response__c referralResponse {
get {
- List referrals =
- referralId != null ? [
+ List referralResponses =
+ referralResponseId != null ? [
SELECT
Id,
- Contact__c,
- Contact__r.FirstName,
- Contact__r.LastName,
- Preferred_Channel__c,
- Owner.Name,
- Service__c,
- Service__r.Name,
- Service__r.Type__c,
- Service__r.Street__c,
- Service__r.City__c,
- Service__r.Zip_Code__c,
- Service__r.Phone__c,
- Service__r.Website__c
- FROM Referral__c
- WHERE Id = :referralId
- ]
- : new List();
-
- return referrals.size() > 0 ? referrals[0] : new Referral__c();
+ Question__c,
+ Response__c,
+ Referral__c,
+ Referral__r.Contact__c,
+ Referral__r.Contact__r.FirstName,
+ Referral__r.Contact__r.LastName,
+ Referral__r.Preferred_Channel__c,
+ Referral__r.Owner.Name,
+ Referral__r.Service__c,
+ Referral__r.Service__r.Name,
+ Referral__r.Service__r.Type__c,
+ Referral__r.Service__r.Street__c,
+ Referral__r.Service__r.City__c,
+ Referral__r.Service__r.Zip_Code__c,
+ Referral__r.Service__r.Phone__c,
+ Referral__r.Service__r.Website__c
+ FROM Referral_Response__c
+ WHERE Id = :referralResponseId
+ ]
+ : new List();
+
+ return referralResponses.size() > 0 ? referralResponses[0] : new Referral_Response__c();
}
set;
}
@@ -51,7 +54,7 @@ global class ReferralEmailTemplateController {
End_Time__c,
Start_Time__c
FROM Open_Hours__c
- WHERE Service__c = :referral.Service__c
+ WHERE Service__c = :referralResponse.Referral__r.Service__c
];
return hours;
}
diff --git a/force-app/main/default/classes/Test_ClientMessageHelper.cls b/force-app/main/default/classes/Test_ClientMessageHelper.cls
index 232233eb..1ffaf8e8 100644
--- a/force-app/main/default/classes/Test_ClientMessageHelper.cls
+++ b/force-app/main/default/classes/Test_ClientMessageHelper.cls
@@ -123,18 +123,10 @@ public class Test_ClientMessageHelper {
static testMethod void testSaveReferralQuestion() {
Referral__c ref = getReferral();
- //OrgWideEmailAddress orgWideEmail = ClientMessageHelper.getReferralOrgWideEmailAddress();
- EmailTemplate template = ClientMessageHelper.getEmailTemplateByName(ClientMessageHelper.CLIENT_REFERRAL_FOLLOWUP_TEMPLATE);
-
- Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
- //email.setOrgWideEmailAddressId(orgWideEmail.Id);
- email.setTemplateId(template.Id);
- email.setTargetObjectId(ref.Contact__c);
- email.setWhatId(ref.Id);
- email.setUseSignature(false);
Test.startTest();
- Referral_Response__c response = ClientMessageHelper.saveReferralQuestion(email);
+ Referral_Response__c response =
+ ClientMessageHelper.saveReferralQuestion(ref.Id,ClientMessageHelper.CLIENT_REFERRAL_FOLLOWUP_TEMPLATE);
Test.stopTest();
System.assertEquals(ClientMessageHelper.CLIENT_FOLLOWUP_QUESTION, response.Question__c);
From 9375b0f091930ab295a91ae2f2e46032c0fe4845 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Tue, 30 Jun 2020 16:53:37 -0400
Subject: [PATCH 02/14] update emails to work with referral responses
---
.../default/classes/ClientMessageHelper.cls | 27 +++++++++++++++----
.../main/default/classes/EmailService.cls | 24 +++++++++++++++--
.../classes/Test_ClientMessageHelper.cls | 14 +++++-----
.../components/Client_Cant_Connect.component | 8 +++---
.../components/Client_Help_Response.component | 6 ++---
.../Client_Rate_Service_Experience.component | 8 +++---
.../Client_Referral_Followup_Email.component | 14 +++++-----
.../Initial_Client_Referral_Email.component | 23 ++++++++--------
.../Rate_Service_Saved_Response.component | 12 ++++-----
.../Client_Cant_Connect.email | 4 +--
.../Client_Help_Response.email | 4 +--
.../Client_Rate_Service_Experience.email | 4 +--
.../Client_Referral_Followup.email | 4 +--
.../Initial_Client_Referral.email | 4 +--
.../Rate_Service_Saved_Response.email | 4 +--
15 files changed, 99 insertions(+), 61 deletions(-)
diff --git a/force-app/main/default/classes/ClientMessageHelper.cls b/force-app/main/default/classes/ClientMessageHelper.cls
index fd2dc95a..a73c52f5 100644
--- a/force-app/main/default/classes/ClientMessageHelper.cls
+++ b/force-app/main/default/classes/ClientMessageHelper.cls
@@ -7,8 +7,12 @@ public with sharing class ClientMessageHelper {
public static final String CLIENT_CANT_CONNECT_TEMPLATE = 'Client_Cant_Connect';
public static final String RATE_SERVICE_SAVED_TEMPLATE = 'Rate_Service_Saved_Response';
- public static final String CLIENT_FOLLOWUP_QUESTION = 'Have you met with your referral';
+ public static final String INITIAL_CLIENT_REFERRAL_QUESTION = 'Heres your referral information';
+ public static final String CLIENT_REFERRAL_FOLLOWUP_QUESTION = 'Have you met with your referral';
public static final String CLIENT_RATE_SERVICE_QUESTION = 'Rate your experience on a scale of 1-5';
+ public static final String CLIENT_HELP_RESPONSE_QUESTION = 'Thank you for letting us know you need help';
+ public static final String CLIENT_CANT_CONNECT_QUESTION = 'What’s getting in the way of connecting with the service';
+ public static final String RATE_SERVICE_SAVED_QUESTION = 'Your feedback helps us know which services to recommend to others.';
public static List createInitialClientReferralEmails(Map referralMap) {
@@ -97,10 +101,18 @@ public with sharing class ClientMessageHelper {
public static Referral_Response__c saveReferralQuestion(String referralId, String templateName) {
String question = '';
// determine the question that was asked, based on the email template
- if (CLIENT_REFERRAL_FOLLOWUP_TEMPLATE.equals(templateName)) {
- question = CLIENT_FOLLOWUP_QUESTION;
+ if (INITIAL_CLIENT_REFERRAL_TEMPLATE.equals(templateName)) {
+ question = INITIAL_CLIENT_REFERRAL_QUESTION;
+ } else if (CLIENT_REFERRAL_FOLLOWUP_TEMPLATE.equals(templateName)) {
+ question = CLIENT_REFERRAL_FOLLOWUP_QUESTION;
} else if (CLIENT_RATE_SERVICE_TEMPLATE.equals(templateName)) {
- question = CLIENT_RATE_SERVICE_QUESTION;
+ question = CLIENT_RATE_SERVICE_QUESTION;
+ } else if (CLIENT_HELP_RESPONSE_TEMPLATE.equals(templateName)) {
+ question = CLIENT_HELP_RESPONSE_QUESTION;
+ } else if (CLIENT_CANT_CONNECT_TEMPLATE.equals(templateName)) {
+ question = CLIENT_CANT_CONNECT_QUESTION;
+ } else if (RATE_SERVICE_SAVED_TEMPLATE.equals(templateName)) {
+ question = RATE_SERVICE_SAVED_QUESTION;
}
Referral_Response__c refRec = ReferralResponseHelper.createQuestionRecord(referralId, question);
@@ -123,15 +135,20 @@ public with sharing class ClientMessageHelper {
createEmailMessages(Map referralMap, OrgWideEmailAddress orgWideEmail, EmailTemplate template) {
List messages = new List();
+ List responses = new List();
for (Id referralId : referralMap.keySet()) {
+ // save the referral response record
+ Referral_Response__c refResp = saveReferralQuestion(referralId, template.DeveloperName);
+
+ // create the email message
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
if (orgWideEmail != null) {
message.setOrgWideEmailAddressId(orgWideEmail.Id);
}
message.setTemplateId(template.Id);
message.setTargetObjectId(referralMap.get(referralId).Contact__c);
- message.setWhatId(referralId);
+ message.setWhatId(refResp.Id);
message.setUseSignature(false);
messages.add(message);
}
diff --git a/force-app/main/default/classes/EmailService.cls b/force-app/main/default/classes/EmailService.cls
index 521ecf4f..6f2ca11f 100644
--- a/force-app/main/default/classes/EmailService.cls
+++ b/force-app/main/default/classes/EmailService.cls
@@ -73,6 +73,25 @@ public with sharing class EmailService {
public static void sendMessageToContact (List contactMessages, Map clientContactMap, Map referralMap) {
List contactsToUpdate = new List();
+ // we need to get the referral id from the referral response record
+ // the id to this record will be in the WhatId field on the email
+ Set referralResponseIds = new Set();
+ for (ContactMessage contMsg : contactMessages) {
+ Messaging.SingleEmailMessage email = contMsg.messageToSend;
+ referralResponseIds.add(email.getWhatId());
+ }
+ List referralResponses = [
+ SELECT
+ Id,
+ Referral__c
+ FROM Referral_Response__c
+ WHERE Id IN :referralResponseIds
+ ];
+ Map referralResponseIdToReferralIdMap = new Map();
+ for (Referral_Response__c refResp : referralResponses) {
+ referralResponseIdToReferralIdMap.put(refResp.Id, refResp.Referral__c);
+ }
+
for (ContactMessage contactMsg : contactMessages) {
// handle each contact/message, one record at a time
Contact clientContact = contactMsg.clientContact;
@@ -92,8 +111,9 @@ public with sharing class EmailService {
if (clientContact != null) {
// if their preferred channel is email, this becomes easier
- // get the referral id from the email message, it will be the WhatId
- Id referralId = messageToSend.getWhatId();
+ // get the referral id from the email message, via the referral response
+ Id referralResponseId = messageToSend.getWhatId();
+ Id referralId = referralResponseIdToReferralIdMap.get(referralResponseId);
// get the referral from the map
Referral__c theReferral = referralMap.get(referralId);
diff --git a/force-app/main/default/classes/Test_ClientMessageHelper.cls b/force-app/main/default/classes/Test_ClientMessageHelper.cls
index 1ffaf8e8..2da3ac09 100644
--- a/force-app/main/default/classes/Test_ClientMessageHelper.cls
+++ b/force-app/main/default/classes/Test_ClientMessageHelper.cls
@@ -47,7 +47,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createInitialClientReferralEmails(referralMap);
Test.stopTest();
- System.assertEquals(ref.Id,messages[0].getWhatId());
+ System.assertEquals('Initial Client Referral',messages[0].getTemplateName());
}
static testMethod void testCreateReferralFollowupEmails() {
@@ -60,7 +60,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createReferralFollowupEmails(referralMap);
Test.stopTest();
- System.assertEquals(ref.Id,messages[0].getWhatId());
+ System.assertEquals('Client Referral Followup',messages[0].getTemplateName());
}
static testMethod void testCreateReferralRateServiceEmails() {
@@ -73,7 +73,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createReferralRateServiceEmails(referralMap);
Test.stopTest();
- System.assertEquals(ref.Id,messages[0].getWhatId());
+ System.assertEquals('Client Rate Service Experience',messages[0].getTemplateName());
}
static testMethod void testCreateClientHelpResponseEmails() {
@@ -92,7 +92,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createClientHelpResponseEmails(referralMap);
Test.stopTest();
- System.assertEquals(ref.Id,messages[0].getWhatId());
+ System.assertEquals('Client Help Response',messages[0].getTemplateName());
}
static testMethod void testCreateClientCantConnectEmails() {
@@ -105,7 +105,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createClientCantConnectEmails(referralMap);
Test.stopTest();
- System.assertEquals(ref.Id,messages[0].getWhatId());
+ System.assertEquals('Client Cant Connect',messages[0].getTemplateName());
}
static testMethod void testCreateRateServiceSavedEmails() {
@@ -118,7 +118,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createRateServiceSavedEmails(referralMap);
Test.stopTest();
- System.assertEquals(ref.Id,messages[0].getWhatId());
+ System.assertEquals('Rate Service Saved Response',messages[0].getTemplateName());
}
static testMethod void testSaveReferralQuestion() {
@@ -129,7 +129,7 @@ public class Test_ClientMessageHelper {
ClientMessageHelper.saveReferralQuestion(ref.Id,ClientMessageHelper.CLIENT_REFERRAL_FOLLOWUP_TEMPLATE);
Test.stopTest();
- System.assertEquals(ClientMessageHelper.CLIENT_FOLLOWUP_QUESTION, response.Question__c);
+ System.assertEquals(ClientMessageHelper.CLIENT_REFERRAL_FOLLOWUP_QUESTION, response.Question__c);
}
static testMethod void testGetContactEmailMap() {
diff --git a/force-app/main/default/components/Client_Cant_Connect.component b/force-app/main/default/components/Client_Cant_Connect.component
index f2392ab4..cb706b9c 100644
--- a/force-app/main/default/components/Client_Cant_Connect.component
+++ b/force-app/main/default/components/Client_Cant_Connect.component
@@ -1,8 +1,8 @@
-
@@ -16,7 +16,7 @@
2 - I contacted the service but they didn’t get back to me
3 - I tried to contact the service but the contact information was wrong
4 - Other
- ref#{!referral.Id}
+ ref#{!referralResponse.Id}
diff --git a/force-app/main/default/components/Client_Help_Response.component b/force-app/main/default/components/Client_Help_Response.component
index 0fff6125..9ec2c715 100644
--- a/force-app/main/default/components/Client_Help_Response.component
+++ b/force-app/main/default/components/Client_Help_Response.component
@@ -1,12 +1,12 @@
-
Thank you for letting us know you need help.
- {!referral.Owner.Name} has been alerted that you need assistance and will reach out to you shortly.
+ {!referralResponse.Referral__r.Owner.Name} has been alerted that you need assistance and will reach out to you shortly.
If it’s urgent, please call {!org.Name} directly at [insert phone number]
If you’re experiencing a medical emergency, please call 911.
\ No newline at end of file
diff --git a/force-app/main/default/components/Client_Rate_Service_Experience.component b/force-app/main/default/components/Client_Rate_Service_Experience.component
index e9e706b0..b85b2315 100644
--- a/force-app/main/default/components/Client_Rate_Service_Experience.component
+++ b/force-app/main/default/components/Client_Rate_Service_Experience.component
@@ -1,13 +1,13 @@
That’s great to hear.
- How was your experience with {!referral.Service__r.Name}?
+ How was your experience with {!referralResponse.Referral__r.Service__r.Name}?
Rate your experience on a scale of 1-5 (1 being terrible, 5 being awesome).
- ref#{!referral.Id}
+ ref#{!referralResponse.Id}
diff --git a/force-app/main/default/components/Client_Referral_Followup_Email.component b/force-app/main/default/components/Client_Referral_Followup_Email.component
index be97fc6c..3ad01675 100644
--- a/force-app/main/default/components/Client_Referral_Followup_Email.component
+++ b/force-app/main/default/components/Client_Referral_Followup_Email.component
@@ -1,17 +1,17 @@
- Hi {!referral.Contact__r.FirstName} {!referral.Contact__r.LastName}! It's {!org.Name}.
+ Hi {!referralResponse.Referral__r.Contact__r.FirstName} {!referralResponse.Referral__r.Contact__r.LastName}! It's {!org.Name}.
We wanted to check in and see how you are doing.
- Have you successfully met with your referral {!referral.Service__r.Name}?
+ Have you successfully met with your referral {!referralResponse.Referral__r.Service__r.Name}?
+ ref#{!referralResponse.Id}"/>
\ No newline at end of file
diff --git a/force-app/main/default/components/Initial_Client_Referral_Email.component b/force-app/main/default/components/Initial_Client_Referral_Email.component
index 0e091227..82306bcc 100644
--- a/force-app/main/default/components/Initial_Client_Referral_Email.component
+++ b/force-app/main/default/components/Initial_Client_Referral_Email.component
@@ -1,19 +1,20 @@
- Hi {!referral.Contact__r.FirstName} {!referral.Contact__r.LastName}! It's {!org.Name}. Here's your referral information for {!referral.Service__r.Type__c}.
+ Hi {!referralResponse.Referral__r.Contact__r.FirstName} {!referralResponse.Referral__r.Contact__r.LastName}! It's {!org.Name}.
+ Here's your referral information for {!referralResponse.Referral__r.Service__r.Type__c}.
- Location: {!referral.Service__r.Street__c} {!referral.Service__r.City__c}, {!referral.Service__r.Zip_Code__c}
- Hours: {!openHoursString}
- Phone: {!referral.Service__r.Phone__c}
- Website: {!referral.Service__r.Website__c}
+ Location: {!referralResponse.Referral__r.Service__r.Street__c} {!referralResponse.Referral__r.Service__r.City__c}, {!referralResponse.Referral__r.Service__r.Zip_Code__c}
+ Hours: {!openHoursString}
+ Phone: {!referralResponse.Referral__r.Service__r.Phone__c}
+ Website: {!referralResponse.Referral__r.Service__r.Website__c}
+ rendered="{!IF((referralResponse.Referral__r.Preferred_Channel__c = "Email"),true,false)}"
+ value=" Questions? Reply *Help* and your case manager, {!referralResponse.Referral__r.Owner.Name}, will be alerted.
+ ref#{!referralResponse.Id}"/>
\ No newline at end of file
diff --git a/force-app/main/default/components/Rate_Service_Saved_Response.component b/force-app/main/default/components/Rate_Service_Saved_Response.component
index d9f34782..464cbd1f 100644
--- a/force-app/main/default/components/Rate_Service_Saved_Response.component
+++ b/force-app/main/default/components/Rate_Service_Saved_Response.component
@@ -1,14 +1,14 @@
Thanks for sharing. Your feedback helps us know which services to recommend to others.
+ rendered="{!IF((referralResponse.Referral__r.Preferred_Channel__c = "Email"),true,false)}"
+ value=" Remember, if you ever need assistance, reply Help and your case manager, {!referralResponse.Referral__r.Owner.Name} will be alerted.
+ ref#{!referralResponse.Id}"/>
diff --git a/force-app/main/default/email/Service_Recommendations/Client_Cant_Connect.email b/force-app/main/default/email/Service_Recommendations/Client_Cant_Connect.email
index bf99cd45..ed98987d 100644
--- a/force-app/main/default/email/Service_Recommendations/Client_Cant_Connect.email
+++ b/force-app/main/default/email/Service_Recommendations/Client_Cant_Connect.email
@@ -1,5 +1,5 @@
-
+
-
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Client_Help_Response.email b/force-app/main/default/email/Service_Recommendations/Client_Help_Response.email
index 75b86064..44ef759a 100644
--- a/force-app/main/default/email/Service_Recommendations/Client_Help_Response.email
+++ b/force-app/main/default/email/Service_Recommendations/Client_Help_Response.email
@@ -1,5 +1,5 @@
-
+
-
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Client_Rate_Service_Experience.email b/force-app/main/default/email/Service_Recommendations/Client_Rate_Service_Experience.email
index 564fe6f8..39af90f6 100644
--- a/force-app/main/default/email/Service_Recommendations/Client_Rate_Service_Experience.email
+++ b/force-app/main/default/email/Service_Recommendations/Client_Rate_Service_Experience.email
@@ -1,5 +1,5 @@
-
+
-
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Client_Referral_Followup.email b/force-app/main/default/email/Service_Recommendations/Client_Referral_Followup.email
index fd83213b..bf6a2f59 100644
--- a/force-app/main/default/email/Service_Recommendations/Client_Referral_Followup.email
+++ b/force-app/main/default/email/Service_Recommendations/Client_Referral_Followup.email
@@ -1,5 +1,5 @@
-
+
-
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Initial_Client_Referral.email b/force-app/main/default/email/Service_Recommendations/Initial_Client_Referral.email
index 201ee0be..362cb696 100644
--- a/force-app/main/default/email/Service_Recommendations/Initial_Client_Referral.email
+++ b/force-app/main/default/email/Service_Recommendations/Initial_Client_Referral.email
@@ -1,5 +1,5 @@
-
+
-
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Rate_Service_Saved_Response.email b/force-app/main/default/email/Service_Recommendations/Rate_Service_Saved_Response.email
index 9374f709..9e8f1016 100644
--- a/force-app/main/default/email/Service_Recommendations/Rate_Service_Saved_Response.email
+++ b/force-app/main/default/email/Service_Recommendations/Rate_Service_Saved_Response.email
@@ -1,5 +1,5 @@
-
+
-
+
\ No newline at end of file
From 252727ce3275dd7c17d7838eca06eb38db302ae8 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Tue, 30 Jun 2020 17:20:16 -0400
Subject: [PATCH 03/14] update unit test to add referral response
---
.../Test_ReferralEmailTemplateController.cls | 26 +++++++++++++++----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/force-app/main/default/classes/Test_ReferralEmailTemplateController.cls b/force-app/main/default/classes/Test_ReferralEmailTemplateController.cls
index 9ec6368f..96fc4532 100644
--- a/force-app/main/default/classes/Test_ReferralEmailTemplateController.cls
+++ b/force-app/main/default/classes/Test_ReferralEmailTemplateController.cls
@@ -43,6 +43,12 @@ public class Test_ReferralEmailTemplateController {
);
insert ref;
+ Referral_Response__c refResp = new Referral_Response__c (
+ Referral__c = ref.Id,
+ Question__c = 'How are you',
+ Response__c = 'I am fine'
+ );
+ insert refResp;
}
static testMethod void testGetData() {
@@ -60,15 +66,25 @@ public class Test_ReferralEmailTemplateController {
WHERE Contact__c = :contacts[0].Id
];
+ List referralResponses = [
+ SELECT
+ Id,
+ Referral__c,
+ Question__c,
+ Response__c
+ FROM Referral_Response__c
+ WHERE Referral__c = :referrals[0].Id
+ ];
+
Test.startTest();
ReferralEmailTemplateController controller = new ReferralEmailTemplateController();
- controller.referralId = referrals[0].Id;
+ controller.referralResponseId = referralResponses[0].Id;
Test.stopTest();
- Referral__c referral = controller.referral;
- System.assertEquals('Care',referral.Service__r.Type__c);
- System.assertEquals('Test Service',referral.Service__r.Name);
- System.assertEquals('Tester',referral.Contact__r.LastName);
+ Referral_Response__c referralResponse = controller.referralResponse;
+ System.assertEquals('Care',referralResponse.Referral__r.Service__r.Type__c);
+ System.assertEquals('Test Service',referralResponse.Referral__r.Service__r.Name);
+ System.assertEquals('Tester',referralResponse.Referral__r.Contact__r.LastName);
System.assertEquals('Monday: 9:00 AM - 5:00 PM', controller.openHoursString);
}
From 293555dcba7db9db393ad46e03c93a9f9e23606f Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 08:46:15 -0400
Subject: [PATCH 04/14] fix unit tests
---
force-app/main/default/classes/EmailService.cls | 5 +++++
.../default/classes/Test_ClientMessageHelper.cls | 14 ++++++++++++--
.../main/default/classes/Test_EmailService.cls | 15 ++++++++++++++-
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/force-app/main/default/classes/EmailService.cls b/force-app/main/default/classes/EmailService.cls
index 6f2ca11f..86721ff8 100644
--- a/force-app/main/default/classes/EmailService.cls
+++ b/force-app/main/default/classes/EmailService.cls
@@ -79,6 +79,7 @@ public with sharing class EmailService {
for (ContactMessage contMsg : contactMessages) {
Messaging.SingleEmailMessage email = contMsg.messageToSend;
referralResponseIds.add(email.getWhatId());
+ System.debug('+++ add ref resp id '+email.getWhatId());
}
List referralResponses = [
SELECT
@@ -87,6 +88,7 @@ public with sharing class EmailService {
FROM Referral_Response__c
WHERE Id IN :referralResponseIds
];
+ System.debug('+++ ref responses '+referralResponses);
Map referralResponseIdToReferralIdMap = new Map();
for (Referral_Response__c refResp : referralResponses) {
referralResponseIdToReferralIdMap.put(refResp.Id, refResp.Referral__c);
@@ -113,11 +115,14 @@ public with sharing class EmailService {
// if their preferred channel is email, this becomes easier
// get the referral id from the email message, via the referral response
Id referralResponseId = messageToSend.getWhatId();
+ System.debug('+++ ref resp id '+referralResponseId);
Id referralId = referralResponseIdToReferralIdMap.get(referralResponseId);
+ System.debug('+++ ref id '+referralId);
// get the referral from the map
Referral__c theReferral = referralMap.get(referralId);
// determine their preferred channel of contact
+ System.debug('+++ the ref '+theReferral);
if ('Email'.equalsIgnoreCase(theReferral.Preferred_Channel__c)) {
Messaging.SingleEmailMessage emailToSend =
createEmailForContact (messageToSend, clientContact.Email);
diff --git a/force-app/main/default/classes/Test_ClientMessageHelper.cls b/force-app/main/default/classes/Test_ClientMessageHelper.cls
index 2da3ac09..5d8188e0 100644
--- a/force-app/main/default/classes/Test_ClientMessageHelper.cls
+++ b/force-app/main/default/classes/Test_ClientMessageHelper.cls
@@ -92,7 +92,7 @@ public class Test_ClientMessageHelper {
List messages = ClientMessageHelper.createClientHelpResponseEmails(referralMap);
Test.stopTest();
- System.assertEquals('Client Help Response',messages[0].getTemplateName());
+ System.assertEquals('Client_Help_Response',messages[0].getTemplateName());
}
static testMethod void testCreateClientCantConnectEmails() {
@@ -143,8 +143,18 @@ public class Test_ClientMessageHelper {
Test.startTest();
Map emailMap = ClientMessageHelper.getContactEmailMap(messages);
Test.stopTest();
+
+ List refResponses = [
+ SELECT
+ Id,
+ Referral__c,
+ Question__c,
+ Response__c
+ FROM Referral_Response__c
+ WHERE Referral__c = :ref.Id
+ ];
- System.assertEquals(ref.Id,emailMap.get(ref.Contact__c).getWhatId());
+ System.assertEquals(refResponses[0].Id,emailMap.get(ref.Contact__c).getWhatId());
}
static testMethod void testGetReferralRecords() {
diff --git a/force-app/main/default/classes/Test_EmailService.cls b/force-app/main/default/classes/Test_EmailService.cls
index 7680976c..07efdc94 100644
--- a/force-app/main/default/classes/Test_EmailService.cls
+++ b/force-app/main/default/classes/Test_EmailService.cls
@@ -34,6 +34,13 @@ public with sharing class Test_EmailService {
Service__c = svc.Id
);
insert ref;
+
+ Referral_Response__c refResp = new Referral_Response__c (
+ Referral__c = ref.Id,
+ Question__c = 'how are you',
+ Response__c = 'i am fine'
+ );
+ insert refResp;
}
static testMethod void testSendInitialReferralMessages() {
@@ -329,10 +336,16 @@ public with sharing class Test_EmailService {
FROM Referral__c
WHERE Contact__r.LastName = 'Tester'
];
+ List referralResponses = [
+ SELECT
+ Id
+ FROM Referral_Response__c
+ WHERE Referral__c = :referrals[0].Id
+ ];
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setPlainTextBody('foo message');
- email.setWhatId(referrals[0].Id);
+ email.setWhatId(referralResponses[0].Id);
return email;
}
From 43fcc7348548931dece3fb293452f5257b6f4ecb Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 10:29:54 -0400
Subject: [PATCH 05/14] continue refactor
---
.../RecommendationsInboundEmailHandler.cls | 102 ++++++++++++------
...est_RecommendationsInboundEmailHandler.cls | 31 ++++--
2 files changed, 93 insertions(+), 40 deletions(-)
diff --git a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
index b3366b67..81d4c752 100644
--- a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
@@ -1,7 +1,7 @@
global class RecommendationsInboundEmailHandler implements Messaging.InboundEmailHandler {
- // the referral id should follow this token in the subject line
- private static final String EMAIL_REFERRAL_TOKEN = 'ref#';
- private static final Integer REFERRAL_ID_LENGTH = 18;
+ // the referral response id should follow this token in the subject line
+ private static final String EMAIL_REFERRAL_RESPONSE_TOKEN = 'ref#';
+ private static final Integer REFERRAL_RESPONSE_ID_LENGTH = 18;
private static final String EMAIL_REPLY_YES = 'YES';
private static final String EMAIL_REPLY_NO = 'NO';
private static final String EMAIL_REPLY_HELP = 'HELP';
@@ -9,46 +9,80 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
- Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
- System.debug('RecommendationsInboundEmailHandler received text of email '+email.plainTextBody);
+ Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
+ System.debug('RecommendationsInboundEmailHandler received text of email '+email.plainTextBody);
- if (email.plainTextBody.containsIgnoreCase(EMAIL_REFERRAL_TOKEN)) {
- // get the referral id from the body of the reply
- String referralId =
- email.plainTextBody.substringAfterLast(EMAIL_REFERRAL_TOKEN);
- referralId = referralId.substring(0,REFERRAL_ID_LENGTH);
+ if (email.plainTextBody.containsIgnoreCase(EMAIL_REFERRAL_RESPONSE_TOKEN)) {
+ // get the referral response id from the body of the reply
+ String referralResponseId =
+ email.plainTextBody.substringAfterLast(EMAIL_REFERRAL_RESPONSE_TOKEN);
+ referralResponseId = referralResponseId.substring(0,REFERRAL_RESPONSE_ID_LENGTH);
+
+ if (referralResponseId != null) {
+ // get the referral response record from the database
+ Referral_Response__c refResponse = getReferralResponse(referralResponseId);
+ String referralId = refResponse.Response__c;
- if (referralId != null) {
// we need to parse out their response, which would be in the first portion of the response
String truncatedResponse = email.plainTextBody.left(RESPONSE_TRUNCATION_LEN);
String firstChar = truncatedResponse.substring(0,1);
- // if we can parse out the referral Id, we need to see what they replied with
- if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_YES)) {
- // they met with the referral
- EmailService.sendClientRateExperienceMessage(referralId);
- } else if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_NO)) {
- // they were unable to meet with the referral
- EmailService.sendClientCantConnectMessage(referralId);
- } else if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_HELP)) {
- // they need help
- EmailService.sendClientHelpResponseMessage(referralId);
- } else if (firstChar.equals('1') ||
- firstChar.equals('2') ||
- firstChar.equals('3') ||
- firstChar.equals('4') ||
- firstChar.equals('5') ) {
- // save the score to the referral record, etc
- Integer score = Integer.valueOf(firstChar);
- ReferralResponseHelper.saveReferralScore(referralId, score);
- // send response email to client
- EmailService.sendRateServiceSavedMessage(referralId);
- }
+ // if we can parse out the referral response Id, we need to see what they replied with
+ handleClientResponse(truncatedResponse, firstChar, refResponse, referralId);
}
- }
+ }
- return result;
+ return result;
+ }
+
+ @TestVisible
+ private void handleClientResponse(String truncatedResponse, String firstChar, Referral_Response__c refResponse, String referralId) {
+ String referralResponseId = refResponse.Id;
+
+ if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_YES)) {
+ // they met with the referral
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, EMAIL_REPLY_YES);
+ EmailService.sendClientRateExperienceMessage(referralId);
+ } else if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_NO)) {
+ // they were unable to meet with the referral
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, EMAIL_REPLY_NO);
+ EmailService.sendClientCantConnectMessage(referralId);
+ } else if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_HELP)) {
+ // they need help
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, EMAIL_REPLY_HELP);
+ EmailService.sendClientHelpResponseMessage(referralId);
+ } else if (firstChar.equals('1') ||
+ firstChar.equals('2') ||
+ firstChar.equals('3') ||
+ firstChar.equals('4') ||
+ firstChar.equals('5') ) {
+ // save the score to the referral record, etc
+ Integer score = Integer.valueOf(firstChar);
+ ReferralResponseHelper.saveReferralScore(referralId, score);
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
+ // send response email to client
+ EmailService.sendRateServiceSavedMessage(referralId);
+ }
+
+ }
+
+ @TestVisible
+ private static Referral_Response__c getReferralResponse(String referralResponseId) {
+ Referral_Response__c response = new Referral_Response__c();
+ List responses = [
+ SELECT
+ Id,
+ Referral__c,
+ Question__c,
+ Response__c
+ FROM Referral_Response__c
+ WHERE Id = :referralResponseId
+ ];
+ if (responses.size() > 0) {
+ response = responses[0];
+ }
+ return response;
}
diff --git a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
index aa202215..860e9c12 100644
--- a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
@@ -33,16 +33,35 @@ public class Test_RecommendationsInboundEmailHandler {
Service__c = svc.Id
);
insert ref;
+
+ Referral_Response__c refResp = new Referral_Response__c (
+ Referral__c = ref.Id,
+ Question__c = 'How are you',
+ Response__c = 'I am fine'
+ );
+ insert refResp;
+ }
+
+ static testMethod void testGetReferralResponse() {
+ Referral_Response__c refResp = getReferralResponse();
+
+ Test.startTest();
+ Referral_Response__c refRespCheck = RecommendationsInboundEmailHandler.getReferralResponse(refResp.Id);
+ Test.stopTest();
+
+ System.assertEquals('How are you',refRespCheck.Question__c);
}
- static Referral__c getReferral() {
- List referrals = [
+ static Referral_Response__c getReferralResponse() {
+ List responses = [
SELECT
Id,
- Score__c
- FROM Referral__c
- WHERE Contact__r.LastName = 'Tester'
+ Referral__c,
+ Question__c,
+ Response__c
+ FROM Referral_Response__c
+ WHERE Referral__r.Contact__r.LastName = 'Tester'
];
- return referrals[0];
+ return responses[0];
}
}
From f3ca65b650323e8af6f07247d660da6824197f89 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 10:34:30 -0400
Subject: [PATCH 06/14] update list view for referral responses
---
.../Referral_Response__c/listViews/All.listView-meta.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/force-app/main/default/objects/Referral_Response__c/listViews/All.listView-meta.xml b/force-app/main/default/objects/Referral_Response__c/listViews/All.listView-meta.xml
index d5058512..970671fb 100644
--- a/force-app/main/default/objects/Referral_Response__c/listViews/All.listView-meta.xml
+++ b/force-app/main/default/objects/Referral_Response__c/listViews/All.listView-meta.xml
@@ -1,6 +1,12 @@
All
+ NAME
+ Question__c
+ Response__c
+ Referral__c
+ LAST_UPDATEEverything
+ en_US
From 6781eb5f8f23c84449fa25f97b7daabba1223e4c Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 10:51:17 -0400
Subject: [PATCH 07/14] add unit test after refactor
---
.../RecommendationsInboundEmailHandler.cls | 16 ++---
...est_RecommendationsInboundEmailHandler.cls | 59 ++++++++++++++++++-
2 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
index 81d4c752..6155b87a 100644
--- a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
@@ -1,11 +1,11 @@
global class RecommendationsInboundEmailHandler implements Messaging.InboundEmailHandler {
- // the referral response id should follow this token in the subject line
- private static final String EMAIL_REFERRAL_RESPONSE_TOKEN = 'ref#';
- private static final Integer REFERRAL_RESPONSE_ID_LENGTH = 18;
- private static final String EMAIL_REPLY_YES = 'YES';
- private static final String EMAIL_REPLY_NO = 'NO';
- private static final String EMAIL_REPLY_HELP = 'HELP';
- private static final Integer RESPONSE_TRUNCATION_LEN = 10;
+ // the referral response id should follow this token in the subject line
+ public static final String EMAIL_REFERRAL_RESPONSE_TOKEN = 'ref#';
+ public static final Integer REFERRAL_RESPONSE_ID_LENGTH = 18;
+ public static final String EMAIL_REPLY_YES = 'YES';
+ public static final String EMAIL_REPLY_NO = 'NO';
+ public static final String EMAIL_REPLY_HELP = 'HELP';
+ public static final Integer RESPONSE_TRUNCATION_LEN = 10;
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
@@ -37,7 +37,7 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai
}
@TestVisible
- private void handleClientResponse(String truncatedResponse, String firstChar, Referral_Response__c refResponse, String referralId) {
+ private static void handleClientResponse(String truncatedResponse, String firstChar, Referral_Response__c refResponse, String referralId) {
String referralResponseId = refResponse.Id;
if (truncatedResponse.containsIgnoreCase(EMAIL_REPLY_YES)) {
diff --git a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
index 860e9c12..3b42bb97 100644
--- a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
@@ -36,12 +36,67 @@ public class Test_RecommendationsInboundEmailHandler {
Referral_Response__c refResp = new Referral_Response__c (
Referral__c = ref.Id,
- Question__c = 'How are you',
- Response__c = 'I am fine'
+ Question__c = 'How are you'
);
insert refResp;
}
+ static testMethod void testHandleClientResponseYes() {
+ String truncatedResponse = RecommendationsInboundEmailHandler.EMAIL_REPLY_YES;
+ String firstChar = truncatedResponse.substring(0,1);
+ Referral_Response__c refResponse = getReferralResponse();
+ String referralId = refResponse.Referral__c;
+
+ Test.startTest();
+ RecommendationsInboundEmailHandler.handleClientResponse(truncatedResponse, firstChar, refResponse, referralId);
+ Test.stopTest();
+
+ Referral_Response__c refResponseCheck = getReferralResponse();
+ System.assertEquals(RecommendationsInboundEmailHandler.EMAIL_REPLY_YES,refResponseCheck.Response__c);
+ }
+
+ static testMethod void testHandleClientResponseNo() {
+ String truncatedResponse = RecommendationsInboundEmailHandler.EMAIL_REPLY_NO;
+ String firstChar = truncatedResponse.substring(0,1);
+ Referral_Response__c refResponse = getReferralResponse();
+ String referralId = refResponse.Referral__c;
+
+ Test.startTest();
+ RecommendationsInboundEmailHandler.handleClientResponse(truncatedResponse, firstChar, refResponse, referralId);
+ Test.stopTest();
+
+ Referral_Response__c refResponseCheck = getReferralResponse();
+ System.assertEquals(RecommendationsInboundEmailHandler.EMAIL_REPLY_NO,refResponseCheck.Response__c);
+ }
+
+ static testMethod void testHandleClientResponseHelp() {
+ String truncatedResponse = RecommendationsInboundEmailHandler.EMAIL_REPLY_HELP;
+ String firstChar = truncatedResponse.substring(0,1);
+ Referral_Response__c refResponse = getReferralResponse();
+ String referralId = refResponse.Referral__c;
+
+ Test.startTest();
+ RecommendationsInboundEmailHandler.handleClientResponse(truncatedResponse, firstChar, refResponse, referralId);
+ Test.stopTest();
+
+ Referral_Response__c refResponseCheck = getReferralResponse();
+ System.assertEquals(RecommendationsInboundEmailHandler.EMAIL_REPLY_HELP,refResponseCheck.Response__c);
+ }
+
+ static testMethod void testHandleClientResponseScore() {
+ String truncatedResponse = '3';
+ String firstChar = truncatedResponse.substring(0,1);
+ Referral_Response__c refResponse = getReferralResponse();
+ String referralId = refResponse.Referral__c;
+
+ Test.startTest();
+ RecommendationsInboundEmailHandler.handleClientResponse(truncatedResponse, firstChar, refResponse, referralId);
+ Test.stopTest();
+
+ Referral_Response__c refResponseCheck = getReferralResponse();
+ System.assertEquals('3',refResponseCheck.Response__c);
+ }
+
static testMethod void testGetReferralResponse() {
Referral_Response__c refResp = getReferralResponse();
From 0f64a0f91a3b2cc5c9a09ba501b1c227293e11da Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 11:02:55 -0400
Subject: [PATCH 08/14] handle scoring question correctly
---
.../RecommendationsInboundEmailHandler.cls | 15 +++++++++------
.../Test_RecommendationsInboundEmailHandler.cls | 2 ++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
index 6155b87a..fcfd30f4 100644
--- a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
@@ -57,12 +57,15 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai
firstChar.equals('3') ||
firstChar.equals('4') ||
firstChar.equals('5') ) {
- // save the score to the referral record, etc
- Integer score = Integer.valueOf(firstChar);
- ReferralResponseHelper.saveReferralScore(referralId, score);
- ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
- // send response email to client
- EmailService.sendRateServiceSavedMessage(referralId);
+ // determine the question that was asked so we can handle the response correctly
+ if (ClientMessageHelper.CLIENT_RATE_SERVICE_QUESTION.equals(refResponse.Question__c)) {
+ // save the score to the referral record, etc
+ Integer score = Integer.valueOf(firstChar);
+ ReferralResponseHelper.saveReferralScore(referralId, score);
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
+ // send response email to client
+ EmailService.sendRateServiceSavedMessage(referralId);
+ }
}
}
diff --git a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
index 3b42bb97..a19ffbf4 100644
--- a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
@@ -87,6 +87,8 @@ public class Test_RecommendationsInboundEmailHandler {
String truncatedResponse = '3';
String firstChar = truncatedResponse.substring(0,1);
Referral_Response__c refResponse = getReferralResponse();
+ // we need to ask the right question
+ refResponse.Question__c = ClientMessageHelper.CLIENT_RATE_SERVICE_QUESTION;
String referralId = refResponse.Referral__c;
Test.startTest();
From b7855a084306d3436379121efddbacc890aa62cc Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 13:01:02 -0400
Subject: [PATCH 09/14] add guidance email
---
.../classes/RecommendationsInboundEmailHandler.cls | 2 +-
.../classes/ReferralEmailTemplateController.cls | 3 ++-
.../Test_RecommendationsInboundEmailHandler.cls | 13 +++++++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
index fcfd30f4..5b5a6c7a 100644
--- a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
@@ -21,7 +21,7 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai
if (referralResponseId != null) {
// get the referral response record from the database
Referral_Response__c refResponse = getReferralResponse(referralResponseId);
- String referralId = refResponse.Response__c;
+ String referralId = refResponse.Referral__c;
// we need to parse out their response, which would be in the first portion of the response
String truncatedResponse = email.plainTextBody.left(RESPONSE_TRUNCATION_LEN);
diff --git a/force-app/main/default/classes/ReferralEmailTemplateController.cls b/force-app/main/default/classes/ReferralEmailTemplateController.cls
index d4df4a08..9f0718b2 100644
--- a/force-app/main/default/classes/ReferralEmailTemplateController.cls
+++ b/force-app/main/default/classes/ReferralEmailTemplateController.cls
@@ -22,7 +22,8 @@ global class ReferralEmailTemplateController {
Referral__r.Service__r.City__c,
Referral__r.Service__r.Zip_Code__c,
Referral__r.Service__r.Phone__c,
- Referral__r.Service__r.Website__c
+ Referral__r.Service__r.Website__c,
+ Referral__r.Score__c
FROM Referral_Response__c
WHERE Id = :referralResponseId
]
diff --git a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
index a19ffbf4..e741bfa9 100644
--- a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
@@ -97,6 +97,8 @@ public class Test_RecommendationsInboundEmailHandler {
Referral_Response__c refResponseCheck = getReferralResponse();
System.assertEquals('3',refResponseCheck.Response__c);
+ Referral__c referral = getReferral();
+ System.assertEquals(3,referral.Score__c);
}
static testMethod void testGetReferralResponse() {
@@ -121,4 +123,15 @@ public class Test_RecommendationsInboundEmailHandler {
];
return responses[0];
}
+
+ static Referral__c getReferral() {
+ List referrals = [
+ SELECT
+ Id,
+ Score__c
+ FROM Referral__c
+ WHERE Contact__r.LastName = 'Tester'
+ ];
+ return referrals[0];
+ }
}
From 38f91b3b515fc7ee294eacbc341f734469c36091 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 14:22:32 -0400
Subject: [PATCH 10/14] add guidance emails and tests
---
.../default/classes/ClientMessageHelper.cls | 72 +++++++++++++++++++
.../main/default/classes/EmailService.cls | 5 --
.../classes/Test_ClientMessageHelper.cls | 52 ++++++++++++++
.../components/Client_Cant_Connect.component | 10 +--
4 files changed, 125 insertions(+), 14 deletions(-)
diff --git a/force-app/main/default/classes/ClientMessageHelper.cls b/force-app/main/default/classes/ClientMessageHelper.cls
index a73c52f5..f232955a 100644
--- a/force-app/main/default/classes/ClientMessageHelper.cls
+++ b/force-app/main/default/classes/ClientMessageHelper.cls
@@ -6,6 +6,10 @@ public with sharing class ClientMessageHelper {
public static final String CLIENT_HELP_RESPONSE_TEMPLATE = 'Client_Help_Response';
public static final String CLIENT_CANT_CONNECT_TEMPLATE = 'Client_Cant_Connect';
public static final String RATE_SERVICE_SAVED_TEMPLATE = 'Rate_Service_Saved_Response';
+ public static final String CANT_CONNECT_GUIDANCE_TEMPLATE_1 = 'Cant_Connect_Guidance';
+ public static final String CANT_CONNECT_GUIDANCE_TEMPLATE_2 = 'Cant_Connect_Guidance_2';
+ public static final String CANT_CONNECT_GUIDANCE_TEMPLATE_3 = 'Cant_Connect_Guidance_3';
+ public static final String CANT_CONNECT_GUIDANCE_TEMPLATE_4 = 'Cant_Connect_Guidance_4';
public static final String INITIAL_CLIENT_REFERRAL_QUESTION = 'Heres your referral information';
public static final String CLIENT_REFERRAL_FOLLOWUP_QUESTION = 'Have you met with your referral';
@@ -13,6 +17,10 @@ public with sharing class ClientMessageHelper {
public static final String CLIENT_HELP_RESPONSE_QUESTION = 'Thank you for letting us know you need help';
public static final String CLIENT_CANT_CONNECT_QUESTION = 'What’s getting in the way of connecting with the service';
public static final String RATE_SERVICE_SAVED_QUESTION = 'Your feedback helps us know which services to recommend to others.';
+ public static final String CANT_CONNECT_GUIDANCE_QUESTION_1 = 'We know life gets busy.';
+ public static final String CANT_CONNECT_GUIDANCE_QUESTION_2 = 'We are sorry to hear they didn’t respond.';
+ public static final String CANT_CONNECT_GUIDANCE_QUESTION_3 = 'We are sorry to hear the information was wrong.';
+ public static final String CANT_CONNECT_GUIDANCE_QUESTION_4 = 'Can you tell me what happened';
public static List createInitialClientReferralEmails(Map referralMap) {
@@ -98,6 +106,62 @@ public with sharing class ClientMessageHelper {
return messages;
}
+ public static List createCantConnectGuidance1Emails(Map referralMap) {
+
+ // get the email template for this kind of message
+ EmailTemplate template = getEmailTemplateByName(CANT_CONNECT_GUIDANCE_TEMPLATE_1);
+
+ // get the org wide email for the reply-to
+ OrgWideEmailAddress emailAddress = getReferralOrgWideEmailAddress();
+
+ // create email messages containing this information
+ List messages = createEmailMessages(referralMap, emailAddress, template);
+
+ return messages;
+ }
+
+ public static List createCantConnectGuidance2Emails(Map referralMap) {
+
+ // get the email template for this kind of message
+ EmailTemplate template = getEmailTemplateByName(CANT_CONNECT_GUIDANCE_TEMPLATE_2);
+
+ // get the org wide email for the reply-to
+ OrgWideEmailAddress emailAddress = getReferralOrgWideEmailAddress();
+
+ // create email messages containing this information
+ List messages = createEmailMessages(referralMap, emailAddress, template);
+
+ return messages;
+ }
+
+ public static List createCantConnectGuidance3Emails(Map referralMap) {
+
+ // get the email template for this kind of message
+ EmailTemplate template = getEmailTemplateByName(CANT_CONNECT_GUIDANCE_TEMPLATE_3);
+
+ // get the org wide email for the reply-to
+ OrgWideEmailAddress emailAddress = getReferralOrgWideEmailAddress();
+
+ // create email messages containing this information
+ List messages = createEmailMessages(referralMap, emailAddress, template);
+
+ return messages;
+ }
+
+ public static List createCantConnectGuidance4Emails(Map referralMap) {
+
+ // get the email template for this kind of message
+ EmailTemplate template = getEmailTemplateByName(CANT_CONNECT_GUIDANCE_TEMPLATE_4);
+
+ // get the org wide email for the reply-to
+ OrgWideEmailAddress emailAddress = getReferralOrgWideEmailAddress();
+
+ // create email messages containing this information
+ List messages = createEmailMessages(referralMap, emailAddress, template);
+
+ return messages;
+ }
+
public static Referral_Response__c saveReferralQuestion(String referralId, String templateName) {
String question = '';
// determine the question that was asked, based on the email template
@@ -113,6 +177,14 @@ public with sharing class ClientMessageHelper {
question = CLIENT_CANT_CONNECT_QUESTION;
} else if (RATE_SERVICE_SAVED_TEMPLATE.equals(templateName)) {
question = RATE_SERVICE_SAVED_QUESTION;
+ } else if (CANT_CONNECT_GUIDANCE_TEMPLATE_1.equals(templateName)) {
+ question = CANT_CONNECT_GUIDANCE_QUESTION_1;
+ } else if (CANT_CONNECT_GUIDANCE_TEMPLATE_2.equals(templateName)) {
+ question = CANT_CONNECT_GUIDANCE_QUESTION_2;
+ } else if (CANT_CONNECT_GUIDANCE_TEMPLATE_3.equals(templateName)) {
+ question = CANT_CONNECT_GUIDANCE_QUESTION_3;
+ } else if (CANT_CONNECT_GUIDANCE_TEMPLATE_4.equals(templateName)) {
+ question = CANT_CONNECT_GUIDANCE_QUESTION_4;
}
Referral_Response__c refRec = ReferralResponseHelper.createQuestionRecord(referralId, question);
diff --git a/force-app/main/default/classes/EmailService.cls b/force-app/main/default/classes/EmailService.cls
index 86721ff8..6f2ca11f 100644
--- a/force-app/main/default/classes/EmailService.cls
+++ b/force-app/main/default/classes/EmailService.cls
@@ -79,7 +79,6 @@ public with sharing class EmailService {
for (ContactMessage contMsg : contactMessages) {
Messaging.SingleEmailMessage email = contMsg.messageToSend;
referralResponseIds.add(email.getWhatId());
- System.debug('+++ add ref resp id '+email.getWhatId());
}
List referralResponses = [
SELECT
@@ -88,7 +87,6 @@ public with sharing class EmailService {
FROM Referral_Response__c
WHERE Id IN :referralResponseIds
];
- System.debug('+++ ref responses '+referralResponses);
Map referralResponseIdToReferralIdMap = new Map();
for (Referral_Response__c refResp : referralResponses) {
referralResponseIdToReferralIdMap.put(refResp.Id, refResp.Referral__c);
@@ -115,14 +113,11 @@ public with sharing class EmailService {
// if their preferred channel is email, this becomes easier
// get the referral id from the email message, via the referral response
Id referralResponseId = messageToSend.getWhatId();
- System.debug('+++ ref resp id '+referralResponseId);
Id referralId = referralResponseIdToReferralIdMap.get(referralResponseId);
- System.debug('+++ ref id '+referralId);
// get the referral from the map
Referral__c theReferral = referralMap.get(referralId);
// determine their preferred channel of contact
- System.debug('+++ the ref '+theReferral);
if ('Email'.equalsIgnoreCase(theReferral.Preferred_Channel__c)) {
Messaging.SingleEmailMessage emailToSend =
createEmailForContact (messageToSend, clientContact.Email);
diff --git a/force-app/main/default/classes/Test_ClientMessageHelper.cls b/force-app/main/default/classes/Test_ClientMessageHelper.cls
index 5d8188e0..283bc774 100644
--- a/force-app/main/default/classes/Test_ClientMessageHelper.cls
+++ b/force-app/main/default/classes/Test_ClientMessageHelper.cls
@@ -121,6 +121,58 @@ public class Test_ClientMessageHelper {
System.assertEquals('Rate Service Saved Response',messages[0].getTemplateName());
}
+ static testMethod void testCreateCantConnectGuidance1Emails() {
+ Referral__c ref = getReferral();
+
+ Map referralMap = new Map();
+ referralMap.put(ref.Id,ref);
+
+ Test.startTest();
+ List messages = ClientMessageHelper.createCantConnectGuidance1Emails(referralMap);
+ Test.stopTest();
+
+ System.assertEquals('Cant Connect Guidance',messages[0].getTemplateName());
+ }
+
+ static testMethod void testCreateCantConnectGuidance2Emails() {
+ Referral__c ref = getReferral();
+
+ Map referralMap = new Map();
+ referralMap.put(ref.Id,ref);
+
+ Test.startTest();
+ List messages = ClientMessageHelper.createCantConnectGuidance2Emails(referralMap);
+ Test.stopTest();
+
+ System.assertEquals('Cant Connect Guidance 2',messages[0].getTemplateName());
+ }
+
+ static testMethod void testCreateCantConnectGuidance3Emails() {
+ Referral__c ref = getReferral();
+
+ Map referralMap = new Map();
+ referralMap.put(ref.Id,ref);
+
+ Test.startTest();
+ List messages = ClientMessageHelper.createCantConnectGuidance3Emails(referralMap);
+ Test.stopTest();
+
+ System.assertEquals('Cant Connect Guidance 3',messages[0].getTemplateName());
+ }
+
+ static testMethod void testCreateCantConnectGuidance4Emails() {
+ Referral__c ref = getReferral();
+
+ Map referralMap = new Map();
+ referralMap.put(ref.Id,ref);
+
+ Test.startTest();
+ List messages = ClientMessageHelper.createCantConnectGuidance4Emails(referralMap);
+ Test.stopTest();
+
+ System.assertEquals('Cant Connect Guidance 4',messages[0].getTemplateName());
+ }
+
static testMethod void testSaveReferralQuestion() {
Referral__c ref = getReferral();
diff --git a/force-app/main/default/components/Client_Cant_Connect.component b/force-app/main/default/components/Client_Cant_Connect.component
index cb706b9c..762d6d0b 100644
--- a/force-app/main/default/components/Client_Cant_Connect.component
+++ b/force-app/main/default/components/Client_Cant_Connect.component
@@ -5,11 +5,7 @@
assignTo="{!referralResponseId}"
access="global"
/>
-
-
-
-
- Thank you for letting us know. We want to make sure you’re getting the help you need.
+ Thank you for letting us know. We want to make sure you’re getting the help you need.
What’s getting in the way of connecting with the service? Please respond using one of the following numbers.
1 - I haven’t had time
@@ -17,8 +13,4 @@
3 - I tried to contact the service but the contact information was wrong
4 - Other
ref#{!referralResponse.Id}
-
-
-
-
From 6fe1fcf80eeb8fcacc9894b71a320483e5adc665 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 14:22:59 -0400
Subject: [PATCH 11/14] added emails and components for guidance
---
.../components/Cant_Connect_Guidance.component | 13 +++++++++++++
.../Cant_Connect_Guidance.component-meta.xml | 5 +++++
.../components/Cant_Connect_Guidance_2.component | 14 ++++++++++++++
.../Cant_Connect_Guidance_2.component-meta.xml | 5 +++++
.../components/Cant_Connect_Guidance_3.component | 14 ++++++++++++++
.../Cant_Connect_Guidance_3.component-meta.xml | 5 +++++
.../components/Cant_Connect_Guidance_4.component | 12 ++++++++++++
.../Cant_Connect_Guidance_4.component-meta.xml | 5 +++++
.../Cant_Connect_Guidance.email | 5 +++++
.../Cant_Connect_Guidance.email-meta.xml | 12 ++++++++++++
.../Cant_Connect_Guidance_2.email | 5 +++++
.../Cant_Connect_Guidance_2.email-meta.xml | 12 ++++++++++++
.../Cant_Connect_Guidance_3.email | 5 +++++
.../Cant_Connect_Guidance_3.email-meta.xml | 11 +++++++++++
.../Cant_Connect_Guidance_4.email | 5 +++++
.../Cant_Connect_Guidance_4.email-meta.xml | 12 ++++++++++++
16 files changed, 140 insertions(+)
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance.component
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance.component-meta.xml
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance_2.component
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance_2.component-meta.xml
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance_3.component
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance_3.component-meta.xml
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance_4.component
create mode 100644 force-app/main/default/components/Cant_Connect_Guidance_4.component-meta.xml
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email
create mode 100644 force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml
diff --git a/force-app/main/default/components/Cant_Connect_Guidance.component b/force-app/main/default/components/Cant_Connect_Guidance.component
new file mode 100644
index 00000000..a6763af5
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance.component
@@ -0,0 +1,13 @@
+
+
+
+ We know life gets busy. If you need assistance, reply Help, and your case manager will be in touch.
+ ref#{!referralResponse.Id}
+
+
+
diff --git a/force-app/main/default/components/Cant_Connect_Guidance.component-meta.xml b/force-app/main/default/components/Cant_Connect_Guidance.component-meta.xml
new file mode 100644
index 00000000..742d7dc9
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance.component-meta.xml
@@ -0,0 +1,5 @@
+
+
+ 48.0
+
+
\ No newline at end of file
diff --git a/force-app/main/default/components/Cant_Connect_Guidance_2.component b/force-app/main/default/components/Cant_Connect_Guidance_2.component
new file mode 100644
index 00000000..3a4017e1
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance_2.component
@@ -0,0 +1,14 @@
+
+
+
+ We're sorry to hear they didn't respond.
+ We'll send you a new referral listing for {!referralResponse.Referral__r.Service__r.Type__c}.
+ If you need assistance, reply Help, and your case manager will be in touch.
+ ref#{!referralResponse.Id}
+
+
diff --git a/force-app/main/default/components/Cant_Connect_Guidance_2.component-meta.xml b/force-app/main/default/components/Cant_Connect_Guidance_2.component-meta.xml
new file mode 100644
index 00000000..79eebcff
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance_2.component-meta.xml
@@ -0,0 +1,5 @@
+
+
+ 48.0
+
+
\ No newline at end of file
diff --git a/force-app/main/default/components/Cant_Connect_Guidance_3.component b/force-app/main/default/components/Cant_Connect_Guidance_3.component
new file mode 100644
index 00000000..5ccfff0f
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance_3.component
@@ -0,0 +1,14 @@
+
+
+
+ We're sorry to hear the information was wrong.
+ We'll send you a new referral listing for {!referralResponse.Referral__r.Service__r.Type__c}.
+ If you need assistance, reply Help, and your case manager will be in touch.
+ ref#{!referralResponse.Id}
+
+
diff --git a/force-app/main/default/components/Cant_Connect_Guidance_3.component-meta.xml b/force-app/main/default/components/Cant_Connect_Guidance_3.component-meta.xml
new file mode 100644
index 00000000..6d43c601
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance_3.component-meta.xml
@@ -0,0 +1,5 @@
+
+
+ 48.0
+
+
\ No newline at end of file
diff --git a/force-app/main/default/components/Cant_Connect_Guidance_4.component b/force-app/main/default/components/Cant_Connect_Guidance_4.component
new file mode 100644
index 00000000..f57c020b
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance_4.component
@@ -0,0 +1,12 @@
+
+
+
+ Can you tell me what happened?
+ ref#{!referralResponse.Id}
+
+
diff --git a/force-app/main/default/components/Cant_Connect_Guidance_4.component-meta.xml b/force-app/main/default/components/Cant_Connect_Guidance_4.component-meta.xml
new file mode 100644
index 00000000..e7f1c093
--- /dev/null
+++ b/force-app/main/default/components/Cant_Connect_Guidance_4.component-meta.xml
@@ -0,0 +1,5 @@
+
+
+ 48.0
+
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email
new file mode 100644
index 00000000..ef6e8dc6
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml
new file mode 100644
index 00000000..bf0693dc
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml
@@ -0,0 +1,12 @@
+
+
+ 49.0
+ true
+ Message asking for more info on why the client could not connect with a service
+ ISO-8859-1
+ Cant Connect Guidance
+
+ More Information on Missed Connection Please
+ visualforce
+ Aloha
+
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email
new file mode 100644
index 00000000..210ce51e
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml
new file mode 100644
index 00000000..d4b6e786
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml
@@ -0,0 +1,12 @@
+
+
+ 49.0
+ true
+ Message asking for more info on why the client could not connect with a service
+ ISO-8859-1
+ Cant Connect Guidance 2
+
+ More Information on Missed Connection Please
+ visualforce
+ Aloha
+
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email
new file mode 100644
index 00000000..98c96375
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml
new file mode 100644
index 00000000..453d3e31
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml
@@ -0,0 +1,11 @@
+
+
+ 49.0
+ true
+ Message asking for more info on why the client could not connect with a service
+ ISO-8859-1
+ Cant Connect Guidance 3
+
+ visualforce
+ Aloha
+
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email
new file mode 100644
index 00000000..94208206
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml
new file mode 100644
index 00000000..2fc0bfd1
--- /dev/null
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml
@@ -0,0 +1,12 @@
+
+
+ 49.0
+ true
+ Message asking for more info on why the client could not connect with a service
+ ISO-8859-1
+ Cant Connect Guidance 4
+
+ More Information on Missed Connection Please
+ visualforce
+ Aloha
+
From 62b6f087b88f71ec36e2f9c2d2fe0363a6be939e Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 14:37:24 -0400
Subject: [PATCH 12/14] add email guidance responses
---
.../main/default/classes/EmailService.cls | 36 +++++++++++
.../RecommendationsInboundEmailHandler.cls | 20 ++++++
.../default/classes/Test_EmailService.cls | 64 ++++++++++++++++++-
3 files changed, 118 insertions(+), 2 deletions(-)
diff --git a/force-app/main/default/classes/EmailService.cls b/force-app/main/default/classes/EmailService.cls
index 6f2ca11f..773a4425 100644
--- a/force-app/main/default/classes/EmailService.cls
+++ b/force-app/main/default/classes/EmailService.cls
@@ -54,6 +54,42 @@ public with sharing class EmailService {
prepareAndSendEmails(emails, referralMap);
}
+ public static void sendCantConnectGuidance1Message(Id referralId) {
+ // get the referral records
+ Map referralMap = ClientMessageHelper.getReferralRecords(new List{referralId});
+ // create the emails
+ List emails = ClientMessageHelper.createCantConnectGuidance1Emails(referralMap);
+ // prep and send the emails
+ prepareAndSendEmails(emails, referralMap);
+ }
+
+ public static void sendCantConnectGuidance2Message(Id referralId) {
+ // get the referral records
+ Map referralMap = ClientMessageHelper.getReferralRecords(new List{referralId});
+ // create the emails
+ List emails = ClientMessageHelper.createCantConnectGuidance2Emails(referralMap);
+ // prep and send the emails
+ prepareAndSendEmails(emails, referralMap);
+ }
+
+ public static void sendCantConnectGuidance3Message(Id referralId) {
+ // get the referral records
+ Map referralMap = ClientMessageHelper.getReferralRecords(new List{referralId});
+ // create the emails
+ List emails = ClientMessageHelper.createCantConnectGuidance3Emails(referralMap);
+ // prep and send the emails
+ prepareAndSendEmails(emails, referralMap);
+ }
+
+ public static void sendCantConnectGuidance4Message(Id referralId) {
+ // get the referral records
+ Map referralMap = ClientMessageHelper.getReferralRecords(new List{referralId});
+ // create the emails
+ List emails = ClientMessageHelper.createCantConnectGuidance4Emails(referralMap);
+ // prep and send the emails
+ prepareAndSendEmails(emails, referralMap);
+ }
+
public static void prepareAndSendEmails(List emails, Map referralMap) {
Map contactIdEmailMap = ClientMessageHelper.getContactEmailMap(emails);
diff --git a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
index 5b5a6c7a..18fd567c 100644
--- a/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/RecommendationsInboundEmailHandler.cls
@@ -65,6 +65,26 @@ global class RecommendationsInboundEmailHandler implements Messaging.InboundEmai
ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
// send response email to client
EmailService.sendRateServiceSavedMessage(referralId);
+ } else if (ClientMessageHelper.CANT_CONNECT_GUIDANCE_QUESTION_1.equals(refResponse.Question__c)) {
+ // they didn't have time for the appt
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
+ // send response email to client
+ EmailService.sendCantConnectGuidance1Message(referralId);
+ } else if (ClientMessageHelper.CANT_CONNECT_GUIDANCE_QUESTION_2.equals(refResponse.Question__c)) {
+ // they didn't have time for the appt
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
+ // send response email to client
+ EmailService.sendCantConnectGuidance2Message(referralId);
+ } else if (ClientMessageHelper.CANT_CONNECT_GUIDANCE_QUESTION_3.equals(refResponse.Question__c)) {
+ // they didn't have time for the appt
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
+ // send response email to client
+ EmailService.sendCantConnectGuidance3Message(referralId);
+ } else if (ClientMessageHelper.CANT_CONNECT_GUIDANCE_QUESTION_4.equals(refResponse.Question__c)) {
+ // they didn't have time for the appt
+ ReferralResponseHelper.updateRecordWithResponse(referralResponseId, firstChar);
+ // send response email to client
+ EmailService.sendCantConnectGuidance4Message(referralId);
}
}
diff --git a/force-app/main/default/classes/Test_EmailService.cls b/force-app/main/default/classes/Test_EmailService.cls
index 07efdc94..51e91d57 100644
--- a/force-app/main/default/classes/Test_EmailService.cls
+++ b/force-app/main/default/classes/Test_EmailService.cls
@@ -145,7 +145,7 @@ public with sharing class Test_EmailService {
System.assertEquals(false,exceptionCaught);
}
- static testMethod void testSendRateServiceSavedMessage() {
+ static testMethod void testCantConnectGuidance1Message() {
List referrals = [
SELECT
Id
@@ -156,7 +156,67 @@ public with sharing class Test_EmailService {
Test.startTest();
Boolean exceptionCaught = false;
try {
- EmailService.sendRateServiceSavedMessage(referrals[0].Id);
+ EmailService.sendCantConnectGuidance1Message(referrals[0].Id);
+ } catch (Exception ex) {
+ exceptionCaught = true;
+ }
+ Test.stopTest();
+
+ System.assertEquals(false,exceptionCaught);
+ }
+
+ static testMethod void testCantConnectGuidance2Message() {
+ List referrals = [
+ SELECT
+ Id
+ FROM Referral__c
+ WHERE Contact__r.LastName = 'Tester'
+ ];
+
+ Test.startTest();
+ Boolean exceptionCaught = false;
+ try {
+ EmailService.sendCantConnectGuidance2Message(referrals[0].Id);
+ } catch (Exception ex) {
+ exceptionCaught = true;
+ }
+ Test.stopTest();
+
+ System.assertEquals(false,exceptionCaught);
+ }
+
+ static testMethod void testCantConnectGuidance3Message() {
+ List referrals = [
+ SELECT
+ Id
+ FROM Referral__c
+ WHERE Contact__r.LastName = 'Tester'
+ ];
+
+ Test.startTest();
+ Boolean exceptionCaught = false;
+ try {
+ EmailService.sendCantConnectGuidance3Message(referrals[0].Id);
+ } catch (Exception ex) {
+ exceptionCaught = true;
+ }
+ Test.stopTest();
+
+ System.assertEquals(false,exceptionCaught);
+ }
+
+ static testMethod void testCantConnectGuidance4Message() {
+ List referrals = [
+ SELECT
+ Id
+ FROM Referral__c
+ WHERE Contact__r.LastName = 'Tester'
+ ];
+
+ Test.startTest();
+ Boolean exceptionCaught = false;
+ try {
+ EmailService.sendCantConnectGuidance4Message(referrals[0].Id);
} catch (Exception ex) {
exceptionCaught = true;
}
From a7892bdcc671302d89d1fbce88ab7b965daa9e80 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 14:41:23 -0400
Subject: [PATCH 13/14] update email api version
---
.../Cant_Connect_Guidance_2.email-meta.xml | 2 +-
.../Cant_Connect_Guidance_3.email-meta.xml | 2 +-
.../Cant_Connect_Guidance_4.email-meta.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml
index d4b6e786..b0b55221 100644
--- a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_2.email-meta.xml
@@ -1,6 +1,6 @@
- 49.0
+ 48.0trueMessage asking for more info on why the client could not connect with a serviceISO-8859-1
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml
index 453d3e31..81a3b198 100644
--- a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_3.email-meta.xml
@@ -1,6 +1,6 @@
- 49.0
+ 48.0trueMessage asking for more info on why the client could not connect with a serviceISO-8859-1
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml
index 2fc0bfd1..28d324df 100644
--- a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance_4.email-meta.xml
@@ -1,6 +1,6 @@
- 49.0
+ 48.0trueMessage asking for more info on why the client could not connect with a serviceISO-8859-1
From 231ccb16d59f0eba12008977a31f4905d1cff798 Mon Sep 17 00:00:00 2001
From: Marci Kickliter
Date: Wed, 1 Jul 2020 14:50:04 -0400
Subject: [PATCH 14/14] update testing
---
.../Test_RecommendationsInboundEmailHandler.cls | 16 ++++++++++++++++
.../Cant_Connect_Guidance.email-meta.xml | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
index e741bfa9..97be1866 100644
--- a/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
+++ b/force-app/main/default/classes/Test_RecommendationsInboundEmailHandler.cls
@@ -101,6 +101,22 @@ public class Test_RecommendationsInboundEmailHandler {
System.assertEquals(3,referral.Score__c);
}
+ static testMethod void testHandleClientResponseGuidance1() {
+ String truncatedResponse = '1';
+ String firstChar = truncatedResponse.substring(0,1);
+ Referral_Response__c refResponse = getReferralResponse();
+ // we need to ask the right question
+ refResponse.Question__c = ClientMessageHelper.CANT_CONNECT_GUIDANCE_QUESTION_1;
+ String referralId = refResponse.Referral__c;
+
+ Test.startTest();
+ RecommendationsInboundEmailHandler.handleClientResponse(truncatedResponse, firstChar, refResponse, referralId);
+ Test.stopTest();
+
+ Referral_Response__c refResponseCheck = getReferralResponse();
+ System.assertEquals('1',refResponseCheck.Response__c);
+ }
+
static testMethod void testGetReferralResponse() {
Referral_Response__c refResp = getReferralResponse();
diff --git a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml
index bf0693dc..8bbc4b90 100644
--- a/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml
+++ b/force-app/main/default/email/Service_Recommendations/Cant_Connect_Guidance.email-meta.xml
@@ -1,6 +1,6 @@
- 49.0
+ 48.0trueMessage asking for more info on why the client could not connect with a serviceISO-8859-1