001package com.box.sdk;
002
003import com.box.sdk.internal.utils.JsonUtils;
004import com.eclipsesource.json.JsonObject;
005import com.eclipsesource.json.JsonValue;
006
007/** Represents an AI Agent used to handle queries. */
008@BoxResourceType("ai_agent_ask")
009public class BoxAIAgentAsk extends BoxAIAgent {
010
011  /** The type of the AI Ask agent. */
012  public static final String TYPE = "ai_agent_ask";
013
014  /** AI agent tool used to handle basic text. */
015  private BoxAIAgentAskBasicText basicText;
016  /** AI agent tool used to handle basic text. */
017  private BoxAIAgentAskBasicText basicTextMulti;
018  /** AI agent tool used to handle longer text. */
019  private BoxAIAgentAskLongText longText;
020  /** AI agent tool used to handle longer text. */
021  private BoxAIAgentAskLongText longTextMulti;
022
023  /**
024   * Constructs an AI agent with default settings.
025   *
026   * @param basicText AI agent tool used to handle basic text.
027   * @param basicTextMulti AI agent tool used to handle basic text.
028   * @param longText AI agent tool used to handle longer text.
029   * @param longTextMulti AI agent tool used to handle longer text.
030   */
031  public BoxAIAgentAsk(
032      BoxAIAgentAskBasicText basicText,
033      BoxAIAgentAskBasicText basicTextMulti,
034      BoxAIAgentAskLongText longText,
035      BoxAIAgentAskLongText longTextMulti) {
036    super(TYPE);
037    this.basicText = basicText;
038    this.basicTextMulti = basicTextMulti;
039    this.longText = longText;
040    this.longTextMulti = longTextMulti;
041  }
042
043  /**
044   * Constructs an AI agent with default settings.
045   *
046   * @param jsonObject JSON object representing the AI agent.
047   */
048  public BoxAIAgentAsk(JsonObject jsonObject) {
049    super(jsonObject);
050  }
051
052  /**
053   * Gets the AI agent tool used to handle basic text.
054   *
055   * @return The AI agent tool used to handle basic text.
056   */
057  public BoxAIAgentAskBasicText getBasicText() {
058    return basicText;
059  }
060
061  /**
062   * Sets the AI agent tool used to handle basic text.
063   *
064   * @param basicText The AI agent tool used to handle basic text.
065   */
066  public void setBasicText(BoxAIAgentAskBasicText basicText) {
067    this.basicText = basicText;
068  }
069
070  /**
071   * Gets the AI agent tool used to handle basic text.
072   *
073   * @return The AI agent tool used to handle basic text.
074   */
075  public BoxAIAgentAskBasicText getBasicTextMulti() {
076    return basicTextMulti;
077  }
078
079  /**
080   * Sets the AI agent tool used to handle basic text.
081   *
082   * @param basicTextMulti The AI agent tool used to handle basic text.
083   */
084  public void setBasicTextMulti(BoxAIAgentAskBasicText basicTextMulti) {
085    this.basicTextMulti = basicTextMulti;
086  }
087
088  /**
089   * Gets the AI agent tool used to handle longer text.
090   *
091   * @return The AI agent tool used to handle longer text.
092   */
093  public BoxAIAgentAskLongText getLongText() {
094    return longText;
095  }
096
097  /**
098   * Sets the AI agent tool used to handle longer text.
099   *
100   * @param longText The AI agent tool used to handle longer text.
101   */
102  public void setLongText(BoxAIAgentAskLongText longText) {
103    this.longText = longText;
104  }
105
106  /**
107   * Gets the AI agent tool used to handle longer text.
108   *
109   * @return The AI agent tool used to handle longer text.
110   */
111  public BoxAIAgentAskLongText getLongTextMulti() {
112    return longTextMulti;
113  }
114
115  /**
116   * Sets the AI agent tool used to handle longer text.
117   *
118   * @param longTextMulti The AI agent tool used to handle longer text.
119   */
120  public void setLongTextMulti(BoxAIAgentAskLongText longTextMulti) {
121    this.longTextMulti = longTextMulti;
122  }
123
124  @Override
125  void parseJSONMember(JsonObject.Member member) {
126    super.parseJSONMember(member);
127    String memberName = member.getName();
128    JsonValue memberValue = member.getValue();
129    try {
130      switch (memberName) {
131        case "basic_text":
132          this.basicText = new BoxAIAgentAskBasicText(memberValue.asObject());
133          break;
134        case "basic_text_multi":
135          this.basicTextMulti = new BoxAIAgentAskBasicText(memberValue.asObject());
136          break;
137        case "long_text":
138          this.longText = new BoxAIAgentAskLongText(memberValue.asObject());
139          break;
140        case "long_text_multi":
141          this.longTextMulti = new BoxAIAgentAskLongText(memberValue.asObject());
142          break;
143        default:
144          break;
145      }
146    } catch (Exception e) {
147      throw new BoxAPIException("Could not parse JSON response.", e);
148    }
149  }
150
151  @Override
152  public JsonObject getJSONObject() {
153    JsonObject jsonObject = new JsonObject();
154    JsonUtils.addIfNotNull(jsonObject, "type", this.getType());
155    if (this.basicText != null) {
156      jsonObject.add("basic_text", this.basicText.getJSONObject());
157    }
158    if (this.basicTextMulti != null) {
159      jsonObject.add("basic_text_multi", this.basicTextMulti.getJSONObject());
160    }
161    if (this.longText != null) {
162      jsonObject.add("long_text", this.longText.getJSONObject());
163    }
164    if (this.longTextMulti != null) {
165      jsonObject.add("long_text_multi", this.longTextMulti.getJSONObject());
166    }
167    return jsonObject;
168  }
169}