001package com.box.sdk;
002
003import com.eclipsesource.json.JsonObject;
004import com.eclipsesource.json.JsonValue;
005
006/**
007 * Represents a notification email object
008 */
009public class BoxNotificationEmail extends BoxJSONObject {
010    private boolean isConfirmed;
011    private String email;
012
013    /**
014     * Constructs a BoxNotificationEmail from a JSON string.
015     *
016     * @param json the json encoded email alias.
017     */
018    public BoxNotificationEmail(String json) {
019        super(json);
020    }
021
022    /**
023     * Constructs a BoxNotificationEmail using an already parsed JSON object.
024     *
025     * @param jsonObject the parsed JSON object.
026     */
027    BoxNotificationEmail(JsonObject jsonObject) {
028        super(jsonObject);
029    }
030
031    /**
032     * Gets whether or not the email address has been confirmed.
033     *
034     * @return true if this email address has been confirmed; otherwise false.
035     */
036    public boolean getIsConfirmed() {
037        return this.isConfirmed;
038    }
039
040    /**
041     * Gets the email address to send notifications to.
042     *
043     * @return The email address to send the notifications to.
044     */
045    public String getEmail() {
046        return this.email;
047    }
048
049    @Override
050    void parseJSONMember(JsonObject.Member member) {
051        JsonValue value = member.getValue();
052        String memberName = member.getName();
053        try {
054            if (memberName.equals("is_confirmed")) {
055                this.isConfirmed = value.asBoolean();
056            } else if (memberName.equals("email")) {
057                this.email = value.asString();
058            }
059        } catch (Exception e) {
060            throw new BoxDeserializationException(memberName, value.toString(), e);
061        }
062    }
063}