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
011   * multiSelect.
012   */
013  private String type;
014  /** The description of the field. */
015  private String description;
016  /** The display name of the field. */
017  private String displayName;
018  /** The key of the field. */
019  private String key;
020  /**
021   * A list of options for this field. This is most often used in combination with the enum and
022   * multiSelect field types.
023   */
024  private List<BoxAIExtractFieldOption> options;
025  /** The prompt of the field. */
026  private String prompt;
027
028  /** Constructs a BoxAIExtractField object with a given key. */
029  public BoxAIExtractField(String key) {
030    this.key = key;
031  }
032
033  /**
034   * Constructs a BoxAIExtractField object with a given type, description, display name, key,
035   * options, and prompt.
036   *
037   * @param type the type of the field.
038   * @param description the description of the field.
039   * @param displayName the display name of the field.
040   * @param key the key of the field.
041   * @param options a list of options for this field.
042   * @param prompt the prompt of the field.
043   */
044  public BoxAIExtractField(
045      String type,
046      String description,
047      String displayName,
048      String key,
049      List<BoxAIExtractFieldOption> options,
050      String prompt) {
051    this.type = type;
052    this.description = description;
053    this.displayName = displayName;
054    this.key = key;
055    this.options = options;
056    this.prompt = prompt;
057  }
058
059  public JsonObject getJSONObject() {
060    JsonObject jsonObject = new JsonObject();
061    JsonUtils.addIfNotNull(jsonObject, "type", this.type);
062    JsonUtils.addIfNotNull(jsonObject, "description", this.description);
063    JsonUtils.addIfNotNull(jsonObject, "displayName", this.displayName);
064    JsonUtils.addIfNotNull(jsonObject, "key", this.key);
065    if (this.options != null) {
066      JsonArray options = new JsonArray();
067      for (BoxAIExtractFieldOption option : this.options) {
068        options.add(option.getJSONObject());
069      }
070      jsonObject.add("options", options);
071    }
072    JsonUtils.addIfNotNull(jsonObject, "prompt", this.prompt);
073    return jsonObject;
074  }
075}