001package com.box.sdkgen.managers.notes;
002
003import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
004import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
005import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
006import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
007import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
008
009import com.box.sdkgen.networking.auth.Authentication;
010import com.box.sdkgen.networking.fetchoptions.FetchOptions;
011import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
012import com.box.sdkgen.networking.fetchresponse.FetchResponse;
013import com.box.sdkgen.networking.network.NetworkSession;
014import com.box.sdkgen.schemas.v2026r0.notesconvertrequestbodyv2026r0.NotesConvertRequestBodyV2026R0;
015import com.box.sdkgen.schemas.v2026r0.notesconvertresponsev2026r0.NotesConvertResponseV2026R0;
016import com.box.sdkgen.serialization.json.JsonManager;
017import java.util.Map;
018
019public class NotesManager {
020
021  public Authentication auth;
022
023  public NetworkSession networkSession;
024
025  public NotesManager() {
026    this.networkSession = new NetworkSession();
027  }
028
029  protected NotesManager(Builder builder) {
030    this.auth = builder.auth;
031    this.networkSession = builder.networkSession;
032  }
033
034  /**
035   * Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format`
036   * field for supported formats.
037   *
038   * @param requestBody Request body of createNoteConvertV2026R0 method
039   */
040  public NotesConvertResponseV2026R0 createNoteConvertV2026R0(
041      NotesConvertRequestBodyV2026R0 requestBody) {
042    return createNoteConvertV2026R0(requestBody, new CreateNoteConvertV2026R0Headers());
043  }
044
045  /**
046   * Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format`
047   * field for supported formats.
048   *
049   * @param requestBody Request body of createNoteConvertV2026R0 method
050   * @param headers Headers of createNoteConvertV2026R0 method
051   */
052  public NotesConvertResponseV2026R0 createNoteConvertV2026R0(
053      NotesConvertRequestBodyV2026R0 requestBody, CreateNoteConvertV2026R0Headers headers) {
054    Map<String, String> headersMap =
055        prepareParams(
056            mergeMaps(
057                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
058                headers.getExtraHeaders()));
059    FetchResponse response =
060        this.networkSession
061            .getNetworkClient()
062            .fetch(
063                new FetchOptions.Builder(
064                        String.join(
065                            "",
066                            this.networkSession.getBaseUrls().getBaseUrl(),
067                            "/2.0/notes/convert"),
068                        "POST")
069                    .headers(headersMap)
070                    .data(JsonManager.serialize(requestBody))
071                    .contentType("application/json")
072                    .responseFormat(ResponseFormat.JSON)
073                    .auth(this.auth)
074                    .networkSession(this.networkSession)
075                    .build());
076    return JsonManager.deserialize(response.getData(), NotesConvertResponseV2026R0.class);
077  }
078
079  public Authentication getAuth() {
080    return auth;
081  }
082
083  public NetworkSession getNetworkSession() {
084    return networkSession;
085  }
086
087  public static class Builder {
088
089    protected Authentication auth;
090
091    protected NetworkSession networkSession;
092
093    public Builder() {}
094
095    public Builder auth(Authentication auth) {
096      this.auth = auth;
097      return this;
098    }
099
100    public Builder networkSession(NetworkSession networkSession) {
101      this.networkSession = networkSession;
102      return this;
103    }
104
105    public NotesManager build() {
106      if (this.networkSession == null) {
107        this.networkSession = new NetworkSession();
108      }
109      return new NotesManager(this);
110    }
111  }
112}