001package com.box.sdkgen.managers.fileversions;
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.fileversionfull.FileVersionFull;
015import com.box.sdkgen.schemas.fileversions.FileVersions;
016import com.box.sdkgen.serialization.json.JsonManager;
017import java.util.Map;
018
019public class FileVersionsManager {
020
021  public Authentication auth;
022
023  public NetworkSession networkSession;
024
025  public FileVersionsManager() {
026    this.networkSession = new NetworkSession();
027  }
028
029  protected FileVersionsManager(Builder builder) {
030    this.auth = builder.auth;
031    this.networkSession = builder.networkSession;
032  }
033
034  /**
035   * Retrieve a list of the past versions for a file.
036   *
037   * <p>Versions are only tracked by Box users with premium accounts. To fetch the ID of the current
038   * version of a file, use the `GET /file/:id` API.
039   *
040   * @param fileId The unique identifier that represents a file.
041   *     <p>The ID for any file can be determined by visiting a file in the web application and
042   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
043   *     `file_id` is `123`. Example: "12345"
044   */
045  public FileVersions getFileVersions(String fileId) {
046    return getFileVersions(fileId, new GetFileVersionsQueryParams(), new GetFileVersionsHeaders());
047  }
048
049  /**
050   * Retrieve a list of the past versions for a file.
051   *
052   * <p>Versions are only tracked by Box users with premium accounts. To fetch the ID of the current
053   * version of a file, use the `GET /file/:id` API.
054   *
055   * @param fileId The unique identifier that represents a file.
056   *     <p>The ID for any file can be determined by visiting a file in the web application and
057   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
058   *     `file_id` is `123`. Example: "12345"
059   * @param queryParams Query parameters of getFileVersions method
060   */
061  public FileVersions getFileVersions(String fileId, GetFileVersionsQueryParams queryParams) {
062    return getFileVersions(fileId, queryParams, new GetFileVersionsHeaders());
063  }
064
065  /**
066   * Retrieve a list of the past versions for a file.
067   *
068   * <p>Versions are only tracked by Box users with premium accounts. To fetch the ID of the current
069   * version of a file, use the `GET /file/:id` API.
070   *
071   * @param fileId The unique identifier that represents a file.
072   *     <p>The ID for any file can be determined by visiting a file in the web application and
073   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
074   *     `file_id` is `123`. Example: "12345"
075   * @param headers Headers of getFileVersions method
076   */
077  public FileVersions getFileVersions(String fileId, GetFileVersionsHeaders headers) {
078    return getFileVersions(fileId, new GetFileVersionsQueryParams(), headers);
079  }
080
081  /**
082   * Retrieve a list of the past versions for a file.
083   *
084   * <p>Versions are only tracked by Box users with premium accounts. To fetch the ID of the current
085   * version of a file, use the `GET /file/:id` API.
086   *
087   * @param fileId The unique identifier that represents a file.
088   *     <p>The ID for any file can be determined by visiting a file in the web application and
089   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
090   *     `file_id` is `123`. Example: "12345"
091   * @param queryParams Query parameters of getFileVersions method
092   * @param headers Headers of getFileVersions method
093   */
094  public FileVersions getFileVersions(
095      String fileId, GetFileVersionsQueryParams queryParams, GetFileVersionsHeaders headers) {
096    Map<String, String> queryParamsMap =
097        prepareParams(
098            mapOf(
099                entryOf("fields", convertToString(queryParams.getFields())),
100                entryOf("limit", convertToString(queryParams.getLimit())),
101                entryOf("offset", convertToString(queryParams.getOffset()))));
102    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
103    FetchResponse response =
104        this.networkSession
105            .getNetworkClient()
106            .fetch(
107                new FetchOptions.Builder(
108                        String.join(
109                            "",
110                            this.networkSession.getBaseUrls().getBaseUrl(),
111                            "/2.0/files/",
112                            convertToString(fileId),
113                            "/versions"),
114                        "GET")
115                    .params(queryParamsMap)
116                    .headers(headersMap)
117                    .responseFormat(ResponseFormat.JSON)
118                    .auth(this.auth)
119                    .networkSession(this.networkSession)
120                    .build());
121    return JsonManager.deserialize(response.getData(), FileVersions.class);
122  }
123
124  /**
125   * Retrieve a specific version of a file.
126   *
127   * <p>Versions are only tracked for Box users with premium accounts.
128   *
129   * @param fileId The unique identifier that represents a file.
130   *     <p>The ID for any file can be determined by visiting a file in the web application and
131   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
132   *     `file_id` is `123`. Example: "12345"
133   * @param fileVersionId The ID of the file version. Example: "1234"
134   */
135  public FileVersionFull getFileVersionById(String fileId, String fileVersionId) {
136    return getFileVersionById(
137        fileId,
138        fileVersionId,
139        new GetFileVersionByIdQueryParams(),
140        new GetFileVersionByIdHeaders());
141  }
142
143  /**
144   * Retrieve a specific version of a file.
145   *
146   * <p>Versions are only tracked for Box users with premium accounts.
147   *
148   * @param fileId The unique identifier that represents a file.
149   *     <p>The ID for any file can be determined by visiting a file in the web application and
150   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
151   *     `file_id` is `123`. Example: "12345"
152   * @param fileVersionId The ID of the file version. Example: "1234"
153   * @param queryParams Query parameters of getFileVersionById method
154   */
155  public FileVersionFull getFileVersionById(
156      String fileId, String fileVersionId, GetFileVersionByIdQueryParams queryParams) {
157    return getFileVersionById(fileId, fileVersionId, queryParams, new GetFileVersionByIdHeaders());
158  }
159
160  /**
161   * Retrieve a specific version of a file.
162   *
163   * <p>Versions are only tracked for Box users with premium accounts.
164   *
165   * @param fileId The unique identifier that represents a file.
166   *     <p>The ID for any file can be determined by visiting a file in the web application and
167   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
168   *     `file_id` is `123`. Example: "12345"
169   * @param fileVersionId The ID of the file version. Example: "1234"
170   * @param headers Headers of getFileVersionById method
171   */
172  public FileVersionFull getFileVersionById(
173      String fileId, String fileVersionId, GetFileVersionByIdHeaders headers) {
174    return getFileVersionById(fileId, fileVersionId, new GetFileVersionByIdQueryParams(), headers);
175  }
176
177  /**
178   * Retrieve a specific version of a file.
179   *
180   * <p>Versions are only tracked for Box users with premium accounts.
181   *
182   * @param fileId The unique identifier that represents a file.
183   *     <p>The ID for any file can be determined by visiting a file in the web application and
184   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
185   *     `file_id` is `123`. Example: "12345"
186   * @param fileVersionId The ID of the file version. Example: "1234"
187   * @param queryParams Query parameters of getFileVersionById method
188   * @param headers Headers of getFileVersionById method
189   */
190  public FileVersionFull getFileVersionById(
191      String fileId,
192      String fileVersionId,
193      GetFileVersionByIdQueryParams queryParams,
194      GetFileVersionByIdHeaders headers) {
195    Map<String, String> queryParamsMap =
196        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
197    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
198    FetchResponse response =
199        this.networkSession
200            .getNetworkClient()
201            .fetch(
202                new FetchOptions.Builder(
203                        String.join(
204                            "",
205                            this.networkSession.getBaseUrls().getBaseUrl(),
206                            "/2.0/files/",
207                            convertToString(fileId),
208                            "/versions/",
209                            convertToString(fileVersionId)),
210                        "GET")
211                    .params(queryParamsMap)
212                    .headers(headersMap)
213                    .responseFormat(ResponseFormat.JSON)
214                    .auth(this.auth)
215                    .networkSession(this.networkSession)
216                    .build());
217    return JsonManager.deserialize(response.getData(), FileVersionFull.class);
218  }
219
220  /**
221   * Move a file version to the trash.
222   *
223   * <p>Versions are only tracked for Box users with premium accounts.
224   *
225   * @param fileId The unique identifier that represents a file.
226   *     <p>The ID for any file can be determined by visiting a file in the web application and
227   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
228   *     `file_id` is `123`. Example: "12345"
229   * @param fileVersionId The ID of the file version. Example: "1234"
230   */
231  public void deleteFileVersionById(String fileId, String fileVersionId) {
232    deleteFileVersionById(fileId, fileVersionId, new DeleteFileVersionByIdHeaders());
233  }
234
235  /**
236   * Move a file version to the trash.
237   *
238   * <p>Versions are only tracked for Box users with premium accounts.
239   *
240   * @param fileId The unique identifier that represents a file.
241   *     <p>The ID for any file can be determined by visiting a file in the web application and
242   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
243   *     `file_id` is `123`. Example: "12345"
244   * @param fileVersionId The ID of the file version. Example: "1234"
245   * @param headers Headers of deleteFileVersionById method
246   */
247  public void deleteFileVersionById(
248      String fileId, String fileVersionId, DeleteFileVersionByIdHeaders headers) {
249    Map<String, String> headersMap =
250        prepareParams(
251            mergeMaps(
252                mapOf(entryOf("if-match", convertToString(headers.getIfMatch()))),
253                headers.getExtraHeaders()));
254    FetchResponse response =
255        this.networkSession
256            .getNetworkClient()
257            .fetch(
258                new FetchOptions.Builder(
259                        String.join(
260                            "",
261                            this.networkSession.getBaseUrls().getBaseUrl(),
262                            "/2.0/files/",
263                            convertToString(fileId),
264                            "/versions/",
265                            convertToString(fileVersionId)),
266                        "DELETE")
267                    .headers(headersMap)
268                    .responseFormat(ResponseFormat.NO_CONTENT)
269                    .auth(this.auth)
270                    .networkSession(this.networkSession)
271                    .build());
272  }
273
274  /**
275   * Restores a specific version of a file after it was deleted. Don't use this endpoint to restore
276   * Box Notes, as it works with file formats such as PDF, DOC, PPTX or similar.
277   *
278   * @param fileId The unique identifier that represents a file.
279   *     <p>The ID for any file can be determined by visiting a file in the web application and
280   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
281   *     `file_id` is `123`. Example: "12345"
282   * @param fileVersionId The ID of the file version. Example: "1234"
283   */
284  public FileVersionFull updateFileVersionById(String fileId, String fileVersionId) {
285    return updateFileVersionById(
286        fileId,
287        fileVersionId,
288        new UpdateFileVersionByIdRequestBody(),
289        new UpdateFileVersionByIdHeaders());
290  }
291
292  /**
293   * Restores a specific version of a file after it was deleted. Don't use this endpoint to restore
294   * Box Notes, as it works with file formats such as PDF, DOC, PPTX or similar.
295   *
296   * @param fileId The unique identifier that represents a file.
297   *     <p>The ID for any file can be determined by visiting a file in the web application and
298   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
299   *     `file_id` is `123`. Example: "12345"
300   * @param fileVersionId The ID of the file version. Example: "1234"
301   * @param requestBody Request body of updateFileVersionById method
302   */
303  public FileVersionFull updateFileVersionById(
304      String fileId, String fileVersionId, UpdateFileVersionByIdRequestBody requestBody) {
305    return updateFileVersionById(
306        fileId, fileVersionId, requestBody, new UpdateFileVersionByIdHeaders());
307  }
308
309  /**
310   * Restores a specific version of a file after it was deleted. Don't use this endpoint to restore
311   * Box Notes, as it works with file formats such as PDF, DOC, PPTX or similar.
312   *
313   * @param fileId The unique identifier that represents a file.
314   *     <p>The ID for any file can be determined by visiting a file in the web application and
315   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
316   *     `file_id` is `123`. Example: "12345"
317   * @param fileVersionId The ID of the file version. Example: "1234"
318   * @param headers Headers of updateFileVersionById method
319   */
320  public FileVersionFull updateFileVersionById(
321      String fileId, String fileVersionId, UpdateFileVersionByIdHeaders headers) {
322    return updateFileVersionById(
323        fileId, fileVersionId, new UpdateFileVersionByIdRequestBody(), headers);
324  }
325
326  /**
327   * Restores a specific version of a file after it was deleted. Don't use this endpoint to restore
328   * Box Notes, as it works with file formats such as PDF, DOC, PPTX or similar.
329   *
330   * @param fileId The unique identifier that represents a file.
331   *     <p>The ID for any file can be determined by visiting a file in the web application and
332   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
333   *     `file_id` is `123`. Example: "12345"
334   * @param fileVersionId The ID of the file version. Example: "1234"
335   * @param requestBody Request body of updateFileVersionById method
336   * @param headers Headers of updateFileVersionById method
337   */
338  public FileVersionFull updateFileVersionById(
339      String fileId,
340      String fileVersionId,
341      UpdateFileVersionByIdRequestBody requestBody,
342      UpdateFileVersionByIdHeaders headers) {
343    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
344    FetchResponse response =
345        this.networkSession
346            .getNetworkClient()
347            .fetch(
348                new FetchOptions.Builder(
349                        String.join(
350                            "",
351                            this.networkSession.getBaseUrls().getBaseUrl(),
352                            "/2.0/files/",
353                            convertToString(fileId),
354                            "/versions/",
355                            convertToString(fileVersionId)),
356                        "PUT")
357                    .headers(headersMap)
358                    .data(JsonManager.serialize(requestBody))
359                    .contentType("application/json")
360                    .responseFormat(ResponseFormat.JSON)
361                    .auth(this.auth)
362                    .networkSession(this.networkSession)
363                    .build());
364    return JsonManager.deserialize(response.getData(), FileVersionFull.class);
365  }
366
367  /**
368   * Promote a specific version of a file.
369   *
370   * <p>If previous versions exist, this method can be used to promote one of the older versions to
371   * the top of the version history.
372   *
373   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
374   * The file will have the exact same contents as the older version, with the same hash digest,
375   * `etag`, and name as the original.
376   *
377   * <p>Other properties such as comments do not get updated to their former values.
378   *
379   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
380   * DOC, PPTX or similar.
381   *
382   * @param fileId The unique identifier that represents a file.
383   *     <p>The ID for any file can be determined by visiting a file in the web application and
384   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
385   *     `file_id` is `123`. Example: "12345"
386   */
387  public FileVersionFull promoteFileVersion(String fileId) {
388    return promoteFileVersion(
389        fileId,
390        new PromoteFileVersionRequestBody(),
391        new PromoteFileVersionQueryParams(),
392        new PromoteFileVersionHeaders());
393  }
394
395  /**
396   * Promote a specific version of a file.
397   *
398   * <p>If previous versions exist, this method can be used to promote one of the older versions to
399   * the top of the version history.
400   *
401   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
402   * The file will have the exact same contents as the older version, with the same hash digest,
403   * `etag`, and name as the original.
404   *
405   * <p>Other properties such as comments do not get updated to their former values.
406   *
407   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
408   * DOC, PPTX or similar.
409   *
410   * @param fileId The unique identifier that represents a file.
411   *     <p>The ID for any file can be determined by visiting a file in the web application and
412   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
413   *     `file_id` is `123`. Example: "12345"
414   * @param requestBody Request body of promoteFileVersion method
415   */
416  public FileVersionFull promoteFileVersion(
417      String fileId, PromoteFileVersionRequestBody requestBody) {
418    return promoteFileVersion(
419        fileId, requestBody, new PromoteFileVersionQueryParams(), new PromoteFileVersionHeaders());
420  }
421
422  /**
423   * Promote a specific version of a file.
424   *
425   * <p>If previous versions exist, this method can be used to promote one of the older versions to
426   * the top of the version history.
427   *
428   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
429   * The file will have the exact same contents as the older version, with the same hash digest,
430   * `etag`, and name as the original.
431   *
432   * <p>Other properties such as comments do not get updated to their former values.
433   *
434   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
435   * DOC, PPTX or similar.
436   *
437   * @param fileId The unique identifier that represents a file.
438   *     <p>The ID for any file can be determined by visiting a file in the web application and
439   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
440   *     `file_id` is `123`. Example: "12345"
441   * @param queryParams Query parameters of promoteFileVersion method
442   */
443  public FileVersionFull promoteFileVersion(
444      String fileId, PromoteFileVersionQueryParams queryParams) {
445    return promoteFileVersion(
446        fileId, new PromoteFileVersionRequestBody(), queryParams, new PromoteFileVersionHeaders());
447  }
448
449  /**
450   * Promote a specific version of a file.
451   *
452   * <p>If previous versions exist, this method can be used to promote one of the older versions to
453   * the top of the version history.
454   *
455   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
456   * The file will have the exact same contents as the older version, with the same hash digest,
457   * `etag`, and name as the original.
458   *
459   * <p>Other properties such as comments do not get updated to their former values.
460   *
461   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
462   * DOC, PPTX or similar.
463   *
464   * @param fileId The unique identifier that represents a file.
465   *     <p>The ID for any file can be determined by visiting a file in the web application and
466   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
467   *     `file_id` is `123`. Example: "12345"
468   * @param requestBody Request body of promoteFileVersion method
469   * @param queryParams Query parameters of promoteFileVersion method
470   */
471  public FileVersionFull promoteFileVersion(
472      String fileId,
473      PromoteFileVersionRequestBody requestBody,
474      PromoteFileVersionQueryParams queryParams) {
475    return promoteFileVersion(fileId, requestBody, queryParams, new PromoteFileVersionHeaders());
476  }
477
478  /**
479   * Promote a specific version of a file.
480   *
481   * <p>If previous versions exist, this method can be used to promote one of the older versions to
482   * the top of the version history.
483   *
484   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
485   * The file will have the exact same contents as the older version, with the same hash digest,
486   * `etag`, and name as the original.
487   *
488   * <p>Other properties such as comments do not get updated to their former values.
489   *
490   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
491   * DOC, PPTX or similar.
492   *
493   * @param fileId The unique identifier that represents a file.
494   *     <p>The ID for any file can be determined by visiting a file in the web application and
495   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
496   *     `file_id` is `123`. Example: "12345"
497   * @param headers Headers of promoteFileVersion method
498   */
499  public FileVersionFull promoteFileVersion(String fileId, PromoteFileVersionHeaders headers) {
500    return promoteFileVersion(
501        fileId, new PromoteFileVersionRequestBody(), new PromoteFileVersionQueryParams(), headers);
502  }
503
504  /**
505   * Promote a specific version of a file.
506   *
507   * <p>If previous versions exist, this method can be used to promote one of the older versions to
508   * the top of the version history.
509   *
510   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
511   * The file will have the exact same contents as the older version, with the same hash digest,
512   * `etag`, and name as the original.
513   *
514   * <p>Other properties such as comments do not get updated to their former values.
515   *
516   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
517   * DOC, PPTX or similar.
518   *
519   * @param fileId The unique identifier that represents a file.
520   *     <p>The ID for any file can be determined by visiting a file in the web application and
521   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
522   *     `file_id` is `123`. Example: "12345"
523   * @param requestBody Request body of promoteFileVersion method
524   * @param headers Headers of promoteFileVersion method
525   */
526  public FileVersionFull promoteFileVersion(
527      String fileId, PromoteFileVersionRequestBody requestBody, PromoteFileVersionHeaders headers) {
528    return promoteFileVersion(fileId, requestBody, new PromoteFileVersionQueryParams(), headers);
529  }
530
531  /**
532   * Promote a specific version of a file.
533   *
534   * <p>If previous versions exist, this method can be used to promote one of the older versions to
535   * the top of the version history.
536   *
537   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
538   * The file will have the exact same contents as the older version, with the same hash digest,
539   * `etag`, and name as the original.
540   *
541   * <p>Other properties such as comments do not get updated to their former values.
542   *
543   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
544   * DOC, PPTX or similar.
545   *
546   * @param fileId The unique identifier that represents a file.
547   *     <p>The ID for any file can be determined by visiting a file in the web application and
548   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
549   *     `file_id` is `123`. Example: "12345"
550   * @param queryParams Query parameters of promoteFileVersion method
551   * @param headers Headers of promoteFileVersion method
552   */
553  public FileVersionFull promoteFileVersion(
554      String fileId, PromoteFileVersionQueryParams queryParams, PromoteFileVersionHeaders headers) {
555    return promoteFileVersion(fileId, new PromoteFileVersionRequestBody(), queryParams, headers);
556  }
557
558  /**
559   * Promote a specific version of a file.
560   *
561   * <p>If previous versions exist, this method can be used to promote one of the older versions to
562   * the top of the version history.
563   *
564   * <p>This creates a new copy of the old version and puts it at the top of the versions history.
565   * The file will have the exact same contents as the older version, with the same hash digest,
566   * `etag`, and name as the original.
567   *
568   * <p>Other properties such as comments do not get updated to their former values.
569   *
570   * <p>Don't use this endpoint to restore Box Notes, as it works with file formats such as PDF,
571   * DOC, PPTX or similar.
572   *
573   * @param fileId The unique identifier that represents a file.
574   *     <p>The ID for any file can be determined by visiting a file in the web application and
575   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
576   *     `file_id` is `123`. Example: "12345"
577   * @param requestBody Request body of promoteFileVersion method
578   * @param queryParams Query parameters of promoteFileVersion method
579   * @param headers Headers of promoteFileVersion method
580   */
581  public FileVersionFull promoteFileVersion(
582      String fileId,
583      PromoteFileVersionRequestBody requestBody,
584      PromoteFileVersionQueryParams queryParams,
585      PromoteFileVersionHeaders headers) {
586    Map<String, String> queryParamsMap =
587        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
588    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
589    FetchResponse response =
590        this.networkSession
591            .getNetworkClient()
592            .fetch(
593                new FetchOptions.Builder(
594                        String.join(
595                            "",
596                            this.networkSession.getBaseUrls().getBaseUrl(),
597                            "/2.0/files/",
598                            convertToString(fileId),
599                            "/versions/current"),
600                        "POST")
601                    .params(queryParamsMap)
602                    .headers(headersMap)
603                    .data(JsonManager.serialize(requestBody))
604                    .contentType("application/json")
605                    .responseFormat(ResponseFormat.JSON)
606                    .auth(this.auth)
607                    .networkSession(this.networkSession)
608                    .build());
609    return JsonManager.deserialize(response.getData(), FileVersionFull.class);
610  }
611
612  public Authentication getAuth() {
613    return auth;
614  }
615
616  public NetworkSession getNetworkSession() {
617    return networkSession;
618  }
619
620  public static class Builder {
621
622    protected Authentication auth;
623
624    protected NetworkSession networkSession;
625
626    public Builder() {}
627
628    public Builder auth(Authentication auth) {
629      this.auth = auth;
630      return this;
631    }
632
633    public Builder networkSession(NetworkSession networkSession) {
634      this.networkSession = networkSession;
635      return this;
636    }
637
638    public FileVersionsManager build() {
639      if (this.networkSession == null) {
640        this.networkSession = new NetworkSession();
641      }
642      return new FileVersionsManager(this);
643    }
644  }
645}