001package com.box.sdk;
002
003import com.box.sdk.internal.utils.JsonUtils;
004import com.eclipsesource.json.JsonArray;
005import com.eclipsesource.json.JsonObject;
006import java.util.List;
007
008public class BoxAIExtractField extends BoxJSONObject {
009    /**
010     * The type of the field. It include but is not limited to string, float, date, enum, and multiSelect.
011     */
012    private String type;
013    /**
014     * The description of the field.
015     */
016    private String description;
017    /**
018     * The display name of the field.
019     */
020    private String displayName;
021    /**
022     * The key of the field.
023     */
024    private String key;
025    /**
026     * A list of options for this field.
027     * This is most often used in combination with the enum and multiSelect field types.
028     */
029    private List<BoxAIExtractFieldOption> options;
030    /**
031     * The prompt of the field.
032     */
033    private String prompt;
034
035    /**
036     * Constructs a BoxAIExtractField object with a given key.
037     */
038    public BoxAIExtractField(String key) {
039        this.key = key;
040    }
041
042    /**
043     * Constructs a BoxAIExtractField object with a given type, description, display name, key, options, and prompt.
044     *
045     * @param type        the type of the field.
046     * @param description the description of the field.
047     * @param displayName the display name of the field.
048     * @param key         the key of the field.
049     * @param options     a list of options for this field.
050     * @param prompt      the prompt of the field.
051     */
052    public BoxAIExtractField(String type,
053                             String description,
054                             String displayName,
055                             String key, List<BoxAIExtractFieldOption> options,
056                             String prompt) {
057        this.type = type;
058        this.description = description;
059        this.displayName = displayName;
060        this.key = key;
061        this.options = options;
062        this.prompt = prompt;
063    }
064
065    public JsonObject getJSONObject() {
066        JsonObject jsonObject = new JsonObject();
067        JsonUtils.addIfNotNull(jsonObject, "type", this.type);
068        JsonUtils.addIfNotNull(jsonObject, "description", this.description);
069        JsonUtils.addIfNotNull(jsonObject, "displayName", this.displayName);
070        JsonUtils.addIfNotNull(jsonObject, "key", this.key);
071        if (this.options != null) {
072            JsonArray options = new JsonArray();
073            for (BoxAIExtractFieldOption option : this.options) {
074                options.add(option.getJSONObject());
075            }
076            jsonObject.add("options", options);
077        }
078        JsonUtils.addIfNotNull(jsonObject, "prompt", this.prompt);
079        return jsonObject;
080    }
081}