• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #4027

11 Oct 2024 12:22PM CUT coverage: 71.745% (+0.04%) from 71.703%
#4027

push

github

web-flow
feat: Support AI extract and AI extract structured (#1266)

125 of 167 new or added lines in 8 files covered. (74.85%)

1 existing line in 1 file now uncovered.

8039 of 11205 relevant lines covered (71.74%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.07
/src/main/java/com/box/sdk/BoxAIAgentExtract.java
1
package com.box.sdk;
2

3
import com.box.sdk.internal.utils.JsonUtils;
4
import com.eclipsesource.json.JsonObject;
5
import com.eclipsesource.json.JsonValue;
6

7
/**
8
 * Represents an AI Agent used for extraction.
9
 */
10
@BoxResourceType("ai_agent_extract")
11
public class BoxAIAgentExtract extends BoxAIAgent {
12

13
    /**
14
     * The type of the AI Ask agent.
15
     */
16
    public static final String TYPE = "ai_agent_extract";
17

18
    /**
19
     * AI agent tool used to handle basic text.
20
     */
21
    private BoxAIAgentAskBasicText basicText;
22
    /**
23
     * AI agent tool used to handle longer text.
24
     */
25
    private BoxAIAgentAskLongText longText;
26

27
    /**
28
     * Constructs an AI agent with default settings.
29
     * @param basicText AI agent tool used to handle basic text.
30
     * @param longText AI agent tool used to handle longer text.
31
     */
32
    public BoxAIAgentExtract(BoxAIAgentAskBasicText basicText,
33
                             BoxAIAgentAskLongText longText) {
NEW
34
        super(TYPE);
×
NEW
35
        this.basicText = basicText;
×
NEW
36
        this.longText = longText;
×
NEW
37
    }
×
38

39
    /**
40
     * Constructs an AI agent with default settings.
41
     * @param jsonObject JSON object representing the AI agent.
42
     */
43
    public BoxAIAgentExtract(JsonObject jsonObject) {
44
        super(jsonObject);
1✔
45
    }
1✔
46

47
    /**
48
     * Gets the AI agent tool used to handle basic text.
49
     * @return The AI agent tool used to handle basic text.
50
     */
51
    public BoxAIAgentAskBasicText getBasicText() {
52
        return basicText;
1✔
53
    }
54

55
    /**
56
     * Sets the AI agent tool used to handle basic text.
57
     * @param basicText The AI agent tool used to handle basic text.
58
     */
59
    public void setBasicText(BoxAIAgentAskBasicText basicText) {
NEW
60
        this.basicText = basicText;
×
NEW
61
    }
×
62

63
    /**
64
     * Gets the AI agent tool used to handle longer text.
65
     * @return The AI agent tool used to handle longer text.
66
     */
67
    public BoxAIAgentAskLongText getLongText() {
NEW
68
        return longText;
×
69
    }
70

71
    /**
72
     * Sets the AI agent tool used to handle longer text.
73
     * @param longText The AI agent tool used to handle longer text.
74
     */
75
    public void setLongText(BoxAIAgentAskLongText longText) {
NEW
76
        this.longText = longText;
×
NEW
77
    }
×
78

79
    @Override
80
    void parseJSONMember(JsonObject.Member member) {
81
        super.parseJSONMember(member);
1✔
82
        String memberName = member.getName();
1✔
83
        JsonValue memberValue = member.getValue();
1✔
84
        try {
85
            switch (memberName) {
1✔
86
                case "basic_text":
87
                    this.basicText = new BoxAIAgentAskBasicText(memberValue.asObject());
1✔
88
                    break;
1✔
89
                case "long_text":
90
                    this.longText = new BoxAIAgentAskLongText(memberValue.asObject());
1✔
91
                    break;
1✔
92
                default:
93
                    break;
94
            }
NEW
95
        } catch (Exception e) {
×
NEW
96
            throw new BoxAPIException("Could not parse JSON response.", e);
×
97
        }
1✔
98
    }
1✔
99

100
    @Override
101
    public JsonObject getJSONObject() {
102
        JsonObject jsonObject = new JsonObject();
1✔
103
        JsonUtils.addIfNotNull(jsonObject, "type", this.getType());
1✔
104
        JsonUtils.addIfNotNull(jsonObject, "basic_text", this.basicText.getJSONObject());
1✔
105
        JsonUtils.addIfNotNull(jsonObject, "long_text", this.longText.getJSONObject());
1✔
106
        return jsonObject;
1✔
107
    }
108
}
109

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc