-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49411aa
commit 5477223
Showing
5 changed files
with
191 additions
and
49 deletions.
There are no files selected for viewing
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,63 @@ | ||
package com.box.sdk; | ||
|
||
import com.eclipsesource.json.JsonObject; | ||
import com.eclipsesource.json.JsonValue; | ||
|
||
/** | ||
* Represents a notification email object | ||
*/ | ||
public class BoxNotificationEmail extends BoxJSONObject { | ||
private boolean isConfirmed; | ||
private String email; | ||
|
||
/** | ||
* Constructs a BoxNotificationEmail from a JSON string. | ||
* | ||
* @param json the json encoded email alias. | ||
*/ | ||
public BoxNotificationEmail(String json) { | ||
super(json); | ||
} | ||
|
||
/** | ||
* Constructs a BoxNotificationEmail using an already parsed JSON object. | ||
* | ||
* @param jsonObject the parsed JSON object. | ||
*/ | ||
BoxNotificationEmail(JsonObject jsonObject) { | ||
super(jsonObject); | ||
} | ||
|
||
/** | ||
* Gets whether or not the email address has been confirmed. | ||
* | ||
* @return true if this email address has been confirmed; otherwise false. | ||
*/ | ||
public boolean getIsConfirmed() { | ||
return this.isConfirmed; | ||
} | ||
|
||
/** | ||
* Gets the email address to send notifications to. | ||
* | ||
* @return The email address to send the notifications to. | ||
*/ | ||
public String getEmail() { | ||
return this.email; | ||
} | ||
|
||
@Override | ||
void parseJSONMember(JsonObject.Member member) { | ||
JsonValue value = member.getValue(); | ||
String memberName = member.getName(); | ||
try { | ||
if (memberName.equals("is_confirmed")) { | ||
this.isConfirmed = value.asBoolean(); | ||
} else if (memberName.equals("email")) { | ||
this.email = value.asString(); | ||
} | ||
} catch (Exception e) { | ||
throw new BoxDeserializationException(memberName, value.toString(), e); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,9 @@ | |
"job_title": "", | ||
"phone": "1111111111", | ||
"address": "", | ||
"avatar_url": "https://test.app.box.com/api/avatar/large/12345" | ||
"avatar_url": "https://test.app.box.com/api/avatar/large/12345", | ||
"notification_email": { | ||
"email": "[email protected]", | ||
"is_confirmed": true | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/Fixtures/BoxUser/GetCurrentUserInfoWithNoNotifcationEmail200.json
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,19 @@ | ||
{ | ||
"type": "user", | ||
"id": "12345", | ||
"name": "Test User", | ||
"login": "[email protected]", | ||
"created_at": "2015-04-09T12:32:40-07:00", | ||
"modified_at": "2018-04-25T11:00:20-07:00", | ||
"language": "en", | ||
"timezone": "America/Los_Angeles", | ||
"space_amount": 1000000000000000, | ||
"space_used": 22392578035, | ||
"max_upload_size": 16106127360, | ||
"status": "active", | ||
"job_title": "", | ||
"phone": "1111111111", | ||
"address": "", | ||
"avatar_url": "https://test.app.box.com/api/avatar/large/12345", | ||
"notification_email": [] | ||
} |
Oops, something went wrong.