Skip to content

Commit 2534f34

Browse files
authored
fix: Add missing constructor to BoxNotificationEmail class (#1098)
Closes: SDK-2607
1 parent 14c91fc commit 2534f34

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/main/java/com/box/sdk/BoxNotificationEmail.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.box.sdk;
22

3+
import com.eclipsesource.json.Json;
34
import com.eclipsesource.json.JsonObject;
45
import com.eclipsesource.json.JsonValue;
56

@@ -10,13 +11,27 @@ public class BoxNotificationEmail extends BoxJSONObject {
1011
private boolean isConfirmed;
1112
private String email;
1213

14+
15+
/**
16+
* Constructs a BoxNotificationEmail object.
17+
*
18+
* @param email The email address to send the notifications to.
19+
* @param isConfirmed Specifies if this email address has been confirmed.
20+
*/
21+
public BoxNotificationEmail(String email, boolean isConfirmed) {
22+
this(new JsonObject()
23+
.add("email", email)
24+
.add("is_confirmed", isConfirmed)
25+
);
26+
}
27+
1328
/**
1429
* Constructs a BoxNotificationEmail from a JSON string.
1530
*
1631
* @param json the json encoded email alias.
1732
*/
1833
public BoxNotificationEmail(String json) {
19-
super(json);
34+
this(Json.parse(json).asObject());
2035
}
2136

2237
/**
@@ -29,7 +44,7 @@ public BoxNotificationEmail(String json) {
2944
}
3045

3146
/**
32-
* Gets whether or not the email address has been confirmed.
47+
* Gets if this email address has been confirmed.
3348
*
3449
* @return true if this email address has been confirmed; otherwise false.
3550
*/

src/test/java/com/box/sdk/BoxUserTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,17 @@ public void deleteAvatar() {
547547
user.deleteAvatar();
548548
}
549549

550+
@Test
551+
public void createBoxNotificationEmailSetsAllFields() {
552+
final String email = "mail@box.com";
553+
final boolean isConfirmed = true;
554+
555+
BoxNotificationEmail boxNotificationEmail = new BoxNotificationEmail(email, isConfirmed);
556+
557+
assertEquals(email, boxNotificationEmail.getEmail());
558+
assertEquals(isConfirmed, boxNotificationEmail.getIsConfirmed());
559+
}
560+
550561
private static String getSampleFilePath(String fileName) {
551562
URL fileURL = BoxUserTest.class.getResource("/sample-files/" + fileName);
552563
try {

0 commit comments

Comments
 (0)