Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.constructor.client;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/** Constructor.io Catalog Request */
Expand All @@ -13,7 +15,7 @@ public enum OnMissing {

private Map<String, File> files;
private String section;
private String notificationEmail;
private List<String> notificationEmails;
private OnMissing onMissing;
private Boolean force;

Expand All @@ -34,6 +36,7 @@ public CatalogRequest(Map<String, File> files, String section) {
this.files = files;
this.section = section;
this.onMissing = OnMissing.FAIL;
this.notificationEmails = new ArrayList<String>();
}

/**
Expand Down Expand Up @@ -82,18 +85,46 @@ public String getSection() {
}

/**
* @param email the email address where you'd like to receive a notifcation in case the task
* fails
* @param email the email address to receive a notification in case the task fails
*/
public void setNotificationEmail(String email) {
this.notificationEmail = email;
this.notificationEmails.clear();
if (email != null) {
this.notificationEmails.add(email);
}
}

/**
* @return the notification email
* @param emails list of email addresses where you'd like to receive notifications in case the
* task fails
*/
public void setNotificationEmail(List<String> emails) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a typo or you intentionally overloaded the above method, do you think we should change it to setNotificationEmails to match the getter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I intentionally overloaded it. There's no overloading a function with a different return however so that's why it's different (also I want to deprecate the old getter bc it doesn't make much sense anymore). If you think it's better to be separate, I can make the change as well, but lmk what you think

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, now I'm hesitating 😅 I'm ok to leave it like this but slightly leaning towards changing the name since it's already a new different method and from the consumer perspective when I call catalogRequest.setNotificationEmail() while I'm actually sending a list might not be the best

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that invested in overloading. I'll split them up and mark the old ones as deprecated 👍

this.notificationEmails.clear();
if (emails != null) {
this.notificationEmails.addAll(emails);
}
Comment thread
Mudaafi marked this conversation as resolved.
Outdated
}

/**
* @return the first notification email, or null if none set
* @deprecated Use {@link #getNotificationEmails()} instead to support multiple emails.
*/
@Deprecated
public String getNotificationEmail() {
return notificationEmail;
if (notificationEmails != null && !notificationEmails.isEmpty()) {
return notificationEmails.get(0);
}
return null;
}

/**
* @return the list of notification emails, or null if none set
*/
public List<String> getNotificationEmails() {
Comment thread
Mudaafi marked this conversation as resolved.
if (notificationEmails.isEmpty()) {
Comment thread
constructor-claude-bedrock[bot] marked this conversation as resolved.
return null;
}
return notificationEmails;
Comment thread
Mudaafi marked this conversation as resolved.
Comment thread
Mudaafi marked this conversation as resolved.
}

/**
Expand Down
Loading