001package com.box.sdk;
002
003import com.eclipsesource.json.JsonObject;
004
005/** Represents a Box File to be included in a sign request. */
006public class BoxAIItem {
007  private String id;
008  private Type type;
009  private String content;
010
011  /**
012   * Created a BoxAIItem - the item to be processed by the LLM.
013   *
014   * @param id The id of the item
015   * @param type The type of the item. Currently, only "file" is supported.
016   * @param content The content of the item, often the text representation.
017   */
018  public BoxAIItem(String id, Type type, String content) {
019    this.id = id;
020    this.type = type;
021    this.content = content;
022  }
023
024  /**
025   * Created a BoxAIItem - the item to be processed by the LLM.
026   *
027   * @param id The id of the item
028   * @param type The type of the item. Currently, only "file" is supported.
029   */
030  public BoxAIItem(String id, Type type) {
031    this.id = id;
032    this.type = type;
033  }
034
035  /**
036   * Gets the id of the item.
037   *
038   * @return the id of the item.
039   */
040  public String getId() {
041    return id;
042  }
043
044  /**
045   * Sets the id of the item.
046   *
047   * @param id the id of the item.
048   */
049  public void setId(String id) {
050    this.id = id;
051  }
052
053  /**
054   * Gets the type of the item.
055   *
056   * @return the type of the item.
057   */
058  public Type getType() {
059    return type;
060  }
061
062  /**
063   * Sets the type of the item.
064   *
065   * @param type the type of the item.
066   */
067  public void setType(Type type) {
068    this.type = type;
069  }
070
071  /**
072   * Gets the content of the item.
073   *
074   * @return the content of the item.
075   */
076  public String getContent() {
077    return content;
078  }
079
080  /**
081   * Sets the content of the item.
082   *
083   * @param content the content of the item.
084   */
085  public void setContent(String content) {
086    this.content = content;
087  }
088
089  /**
090   * Gets a JSON object representing this class.
091   *
092   * @return the JSON object representing this class.
093   */
094  public JsonObject getJSONObject() {
095    JsonObject itemJSON = new JsonObject().add("id", this.id).add("type", this.type.toJSONValue());
096
097    if (this.content != null) {
098      itemJSON.add("content", this.content);
099    }
100
101    return itemJSON;
102  }
103
104  public enum Type {
105    /** A file. */
106    FILE("file");
107
108    private final String jsonValue;
109
110    Type(String jsonValue) {
111      this.jsonValue = jsonValue;
112    }
113
114    static BoxAIItem.Type fromJSONValue(String jsonValue) {
115      return BoxAIItem.Type.valueOf(jsonValue.toUpperCase(java.util.Locale.ROOT));
116    }
117
118    String toJSONValue() {
119      return this.jsonValue;
120    }
121  }
122}