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 for extraction. 009 */ 010@BoxResourceType("ai_agent_extract") 011public class BoxAIAgentExtract extends BoxAIAgent { 012 013 /** 014 * The type of the AI Ask agent. 015 */ 016 public static final String TYPE = "ai_agent_extract"; 017 018 /** 019 * AI agent tool used to handle basic text. 020 */ 021 private BoxAIAgentAskBasicText basicText; 022 /** 023 * AI agent tool used to handle longer text. 024 */ 025 private BoxAIAgentAskLongText longText; 026 027 /** 028 * Constructs an AI agent with default settings. 029 * @param basicText AI agent tool used to handle basic text. 030 * @param longText AI agent tool used to handle longer text. 031 */ 032 public BoxAIAgentExtract(BoxAIAgentAskBasicText basicText, 033 BoxAIAgentAskLongText longText) { 034 super(TYPE); 035 this.basicText = basicText; 036 this.longText = longText; 037 } 038 039 /** 040 * Constructs an AI agent with default settings. 041 * @param jsonObject JSON object representing the AI agent. 042 */ 043 public BoxAIAgentExtract(JsonObject jsonObject) { 044 super(jsonObject); 045 } 046 047 /** 048 * Gets the AI agent tool used to handle basic text. 049 * @return The AI agent tool used to handle basic text. 050 */ 051 public BoxAIAgentAskBasicText getBasicText() { 052 return basicText; 053 } 054 055 /** 056 * Sets the AI agent tool used to handle basic text. 057 * @param basicText The AI agent tool used to handle basic text. 058 */ 059 public void setBasicText(BoxAIAgentAskBasicText basicText) { 060 this.basicText = basicText; 061 } 062 063 /** 064 * Gets the AI agent tool used to handle longer text. 065 * @return The AI agent tool used to handle longer text. 066 */ 067 public BoxAIAgentAskLongText getLongText() { 068 return longText; 069 } 070 071 /** 072 * Sets the AI agent tool used to handle longer text. 073 * @param longText The AI agent tool used to handle longer text. 074 */ 075 public void setLongText(BoxAIAgentAskLongText longText) { 076 this.longText = longText; 077 } 078 079 @Override 080 void parseJSONMember(JsonObject.Member member) { 081 super.parseJSONMember(member); 082 String memberName = member.getName(); 083 JsonValue memberValue = member.getValue(); 084 try { 085 switch (memberName) { 086 case "basic_text": 087 this.basicText = new BoxAIAgentAskBasicText(memberValue.asObject()); 088 break; 089 case "long_text": 090 this.longText = new BoxAIAgentAskLongText(memberValue.asObject()); 091 break; 092 default: 093 break; 094 } 095 } catch (Exception e) { 096 throw new BoxAPIException("Could not parse JSON response.", e); 097 } 098 } 099 100 @Override 101 public JsonObject getJSONObject() { 102 JsonObject jsonObject = new JsonObject(); 103 JsonUtils.addIfNotNull(jsonObject, "type", this.getType()); 104 JsonUtils.addIfNotNull(jsonObject, "basic_text", this.basicText.getJSONObject()); 105 JsonUtils.addIfNotNull(jsonObject, "long_text", this.longText.getJSONObject()); 106 return jsonObject; 107 } 108} 109