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