001package com.box.sdk;
002
003import com.eclipsesource.json.JsonObject;
004import com.eclipsesource.json.JsonValue;
005
006/** Represents a Box user's email alias. */
007public class EmailAlias extends BoxJSONObject {
008  private String id;
009  private boolean isConfirmed;
010  private String email;
011
012  /** Constructs an empty EmailAlias. */
013  public EmailAlias() {}
014
015  /**
016   * Constructs an EmailAlias from a JSON string.
017   *
018   * @param json the json encoded email alias.
019   */
020  public EmailAlias(String json) {
021    super(json);
022  }
023
024  EmailAlias(JsonObject jsonObject) {
025    super(jsonObject);
026  }
027
028  /**
029   * Gets the ID of this email alias.
030   *
031   * @return the ID of this email alias.
032   */
033  public String getID() {
034    return this.id;
035  }
036
037  /**
038   * Gets whether or not the user has confirmed this email alias.
039   *
040   * @return true if the user has confirmed this email alias; otherwise false.
041   */
042  public boolean getIsConfirmed() {
043    return this.isConfirmed;
044  }
045
046  /**
047   * Gets the email address of this email alias.
048   *
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}