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