Skip to content

Commit 8113130

Browse files
PATCH 14
1 parent 86df1fc commit 8113130

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/java/uk/ac/cam/cl/dtg/segue/dao/users/PgExternalAccountPersistenceManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ private String normalizeStage(String stage) {
338338
case "gcse,a_level":
339339
case "gcse, a level":
340340
return "GCSE and A Level";
341+
case "all":
342+
return "ALL";
341343
default:
342344
// Warn about unexpected stage values
343345
log.warn("MAILJETT - Unexpected stage value '{}' encountered. Returning 'unknown'. "

src/main/java/uk/ac/cam/cl/dtg/util/email/MailJetApiClientWrapper.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public JSONObject getAccountByIdOrEmail(final String mailjetIdOrEmail) throws Ma
120120
MailjetRequest request = new MailjetRequest(Contact.resource, mailjetIdOrEmail);
121121
MailjetResponse response = mailjetClient.get(request);
122122

123+
log.info("MAILJETT - response: {}", response.getRawResponseContent());
124+
123125
if (response.getStatus() == 404) {
124126
log.info("MAILJETT - Mailjet account not found: {}", mailjetIdOrEmail);
125127
return null;
@@ -181,6 +183,8 @@ public void permanentlyDeleteAccountById(final String mailjetId) throws MailjetE
181183
MailjetRequest request = new MailjetRequest(Contacts.resource, mailjetId);
182184
MailjetResponse response = mailjetClient.delete(request);
183185

186+
log.info("MAILJETT - response: {}", response.getRawResponseContent());
187+
184188
if (response.getStatus() == 204 || response.getStatus() == 200) {
185189
log.info("MAILJETT - Successfully deleted Mailjet account: {}", mailjetId);
186190
} else if (response.getStatus() == 404) {
@@ -240,6 +244,8 @@ public String addNewUserOrGetUserIfExists(final String email) throws MailjetExce
240244
.property(Contact.EMAIL, normalizedEmail);
241245
MailjetResponse response = mailjetClient.post(request);
242246

247+
log.info("MAILJETT - response: {}", response.getRawResponseContent());
248+
243249
if (response.getStatus() == 201 || response.getStatus() == 200) {
244250
JSONObject responseData = response.getData().getJSONObject(0);
245251
log.info("MAILJETT - responseData : {}", responseData.toString());
@@ -262,7 +268,7 @@ public String addNewUserOrGetUserIfExists(final String email) throws MailjetExce
262268
try {
263269
JSONObject existingAccount = getAccountByIdOrEmail(normalizedEmail);
264270
if (existingAccount != null) {
265-
String mailjetId = Integer.toString(existingAccount.getInt("ID"));
271+
String mailjetId = existingAccount.getString("ID");
266272
log.info("MAILJETT - Retrieved existing Mailjet account {} for email: {}",
267273
mailjetId, maskEmail(normalizedEmail));
268274
return mailjetId;
@@ -333,6 +339,8 @@ public void updateUserProperties(final String mailjetId, final String firstName,
333339

334340
MailjetResponse response = mailjetClient.put(request);
335341

342+
log.info("MAILJETT - response: {}", response.getRawResponseContent());
343+
336344
if (response.getStatus() == 200 && response.getTotal() == 1) {
337345
log.info("MAILJETT - Successfully updated properties for Mailjet account: {}", mailjetId);
338346
} else {
@@ -407,6 +415,8 @@ public void updateUserSubscriptions(final String mailjetId,
407415

408416
MailjetResponse response = mailjetClient.post(request);
409417

418+
log.info("MAILJETT - response: {}", response.getRawResponseContent());
419+
410420
if (response.getStatus() == 201 && response.getTotal() == 1) {
411421
log.info("MAILJETT - Successfully updated subscriptions for Mailjet account: {}", mailjetId);
412422
} else {

0 commit comments

Comments
 (0)