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     * Constructs an EmailAlias from a JSON string.
021     * @param  json the json encoded email alias.
022     */
023    public EmailAlias(String json) {
024        super(json);
025    }
026
027    EmailAlias(JsonObject jsonObject) {
028        super(jsonObject);
029    }
030
031    /**
032     * Gets the ID of this email alias.
033     * @return the ID of this email alias.
034     */
035    public String getID() {
036        return this.id;
037    }
038
039    /**
040     * Gets whether or not the user has confirmed this email alias.
041     * @return true if the user has confirmed this email alias; otherwise false.
042     */
043    public boolean getIsConfirmed() {
044        return this.isConfirmed;
045    }
046
047    /**
048     * Gets the email address of this email alias.
049     * @return the email address of this email alias.
050     */
051    public String getEmail() {
052        return this.email;
053    }
054
055    @Override
056    void parseJSONMember(JsonObject.Member member) {
057        JsonValue value = member.getValue();
058        String memberName = member.getName();
059        try {
060            if (memberName.equals("id")) {
061                this.id = value.asString();
062            } else if (memberName.equals("is_confirmed")) {
063                this.isConfirmed = value.asBoolean();
064            } else if (memberName.equals("email")) {
065                this.email = value.asString();
066            }
067        } catch (Exception e) {
068            throw new BoxDeserializationException(memberName, value.toString(), e);
069        }
070    }
071}