001package com.box.sdk; 002 003import com.eclipsesource.json.JsonObject; 004import com.eclipsesource.json.JsonValue; 005 006/** 007 * Represents an email address that can be used to upload files to a folder on Box. 008 */ 009public class BoxUploadEmail extends BoxJSONObject { 010 private Access access; 011 private String email; 012 013 /** 014 * Constructs a BoxUploadEmail with default settings. 015 */ 016 public BoxUploadEmail() { } 017 018 /** 019 * Constructs a BoxUploadEmail from a JSON string. 020 * @param json the JSON encoded upload email. 021 */ 022 public BoxUploadEmail(String json) { 023 super(json); 024 } 025 026 BoxUploadEmail(JsonObject jsonObject) { 027 super(jsonObject); 028 } 029 030 /** 031 * Gets the access level of this upload email. 032 * @return the access level of this upload email. 033 */ 034 public Access getAccess() { 035 return this.access; 036 } 037 038 /** 039 * Sets the access level of this upload email. 040 * @param access the new access level of this upload email. 041 */ 042 public void setAccess(Access access) { 043 this.access = access; 044 this.addPendingChange("access", access.toJSONValue()); 045 } 046 047 /** 048 * Gets the email address of this upload email. 049 * @return the email address of this upload email. 050 */ 051 public String getEmail() { 052 return this.email; 053 } 054 055 void parseJSONMember(JsonObject.Member member) { 056 JsonValue value = member.getValue(); 057 switch (member.getName()) { 058 case "access": 059 this.access = Access.fromJSONValue(value.asString()); 060 break; 061 case "email": 062 this.email = value.asString(); 063 break; 064 default: 065 break; 066 } 067 } 068 069 /** 070 * Enumerates the possible access levels that can be set on an upload email. 071 */ 072 public enum Access { 073 /** 074 * Anyone can send an upload to this email address. 075 */ 076 OPEN("open"), 077 078 /** 079 * Only collaborators can send an upload to this email address. 080 */ 081 COLLABORATORS("collaborators"); 082 083 private final String jsonValue; 084 085 private Access(String jsonValue) { 086 this.jsonValue = jsonValue; 087 } 088 089 static Access fromJSONValue(String jsonValue) { 090 return Access.valueOf(jsonValue.toUpperCase()); 091 } 092 093 String toJSONValue() { 094 return this.jsonValue; 095 } 096 } 097}