All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dropbox.sign.model.FaxListResponse Maven / Gradle / Ivy

Go to download

Use the Dropbox Sign Java SDK to connect your Java app to the service of Dropbox Sign in microseconds!

The newest version!
/*
 * Dropbox Sign API
 * Dropbox Sign v3 API
 *
 * The version of the OpenAPI document: 3.0.0
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.dropbox.sign.model;

import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import com.dropbox.sign.model.FaxResponse;
import com.dropbox.sign.model.ListInfoResponse;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.dropbox.sign.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;


import com.dropbox.sign.ApiException;
/**
 * FaxListResponse
 */
@JsonPropertyOrder({
  FaxListResponse.JSON_PROPERTY_FAXES,
  FaxListResponse.JSON_PROPERTY_LIST_INFO
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.8.0")
@JsonIgnoreProperties(ignoreUnknown=true)
public class FaxListResponse {
  public static final String JSON_PROPERTY_FAXES = "faxes";
  private List faxes = new ArrayList<>();

  public static final String JSON_PROPERTY_LIST_INFO = "list_info";
  private ListInfoResponse listInfo;

  public FaxListResponse() { 
  }

  /**
   * Attempt to instantiate and hydrate a new instance of this class
   * @param jsonData String of JSON data representing target object
   */
  static public FaxListResponse init(String jsonData) throws Exception {
    return new ObjectMapper().readValue(jsonData, FaxListResponse.class);
  }

  static public FaxListResponse init(HashMap data) throws Exception {
    return new ObjectMapper().readValue(
      new ObjectMapper().writeValueAsString(data),
      FaxListResponse.class
    );
  }

  public FaxListResponse faxes(List faxes) {
    this.faxes = faxes;
    return this;
  }

  public FaxListResponse addFaxesItem(FaxResponse faxesItem) {
    if (this.faxes == null) {
      this.faxes = new ArrayList<>();
    }
    this.faxes.add(faxesItem);
    return this;
  }

  /**
   * Get faxes
   * @return faxes
   */
  @jakarta.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_FAXES)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public List getFaxes() {
    return faxes;
  }


  @JsonProperty(JSON_PROPERTY_FAXES)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setFaxes(List faxes) {
    this.faxes = faxes;
  }


  public FaxListResponse listInfo(ListInfoResponse listInfo) {
    this.listInfo = listInfo;
    return this;
  }

  /**
   * Get listInfo
   * @return listInfo
   */
  @jakarta.annotation.Nonnull
  @JsonProperty(JSON_PROPERTY_LIST_INFO)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)

  public ListInfoResponse getListInfo() {
    return listInfo;
  }


  @JsonProperty(JSON_PROPERTY_LIST_INFO)
  @JsonInclude(value = JsonInclude.Include.ALWAYS)
  public void setListInfo(ListInfoResponse listInfo) {
    this.listInfo = listInfo;
  }


  /**
   * Return true if this FaxListResponse object is equal to o.
   */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    FaxListResponse faxListResponse = (FaxListResponse) o;
    return Objects.equals(this.faxes, faxListResponse.faxes) &&
        Objects.equals(this.listInfo, faxListResponse.listInfo);
  }

  @Override
  public int hashCode() {
    return Objects.hash(faxes, listInfo);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class FaxListResponse {\n");
    sb.append("    faxes: ").append(toIndentedString(faxes)).append("\n");
    sb.append("    listInfo: ").append(toIndentedString(listInfo)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  public Map createFormData() throws ApiException {
    Map map = new HashMap<>();
    boolean fileTypeFound = false;
    try {
    if (faxes != null) {
        if (isFileTypeOrListOfFiles(faxes)) {
            fileTypeFound = true;
        }

        if (faxes.getClass().equals(java.io.File.class) ||
            faxes.getClass().equals(Integer.class) ||
            faxes.getClass().equals(String.class) ||
            faxes.getClass().isEnum()) {
            map.put("faxes", faxes);
        } else if (isListOfFile(faxes)) {
            for(int i = 0; i< getListSize(faxes); i++) {
                map.put("faxes[" + i + "]", getFromList(faxes, i));
            }
        }
        else {
            map.put("faxes", JSON.getDefault().getMapper().writeValueAsString(faxes));
        }
    }
    if (listInfo != null) {
        if (isFileTypeOrListOfFiles(listInfo)) {
            fileTypeFound = true;
        }

        if (listInfo.getClass().equals(java.io.File.class) ||
            listInfo.getClass().equals(Integer.class) ||
            listInfo.getClass().equals(String.class) ||
            listInfo.getClass().isEnum()) {
            map.put("list_info", listInfo);
        } else if (isListOfFile(listInfo)) {
            for(int i = 0; i< getListSize(listInfo); i++) {
                map.put("list_info[" + i + "]", getFromList(listInfo, i));
            }
        }
        else {
            map.put("list_info", JSON.getDefault().getMapper().writeValueAsString(listInfo));
        }
    }
    } catch (Exception e) {
        throw new ApiException(e);
    }

    return fileTypeFound ? map : new HashMap<>();
  }

  private boolean isFileTypeOrListOfFiles(Object obj) throws Exception {
    return obj.getClass().equals(java.io.File.class) || isListOfFile(obj);
  }

  private boolean isListOfFile(Object obj) throws Exception {
      return obj instanceof java.util.List && !isListEmpty(obj) && getFromList(obj, 0) instanceof java.io.File;
  }

  private boolean isListEmpty(Object obj) throws Exception {
    return (boolean) Class.forName(java.util.List.class.getName()).getMethod("isEmpty").invoke(obj);
  }

  private Object getFromList(Object obj, int index) throws Exception {
    return Class.forName(java.util.List.class.getName()).getMethod("get", int.class).invoke(obj, index);
  }

  private int getListSize(Object obj) throws Exception {
    return (int) Class.forName(java.util.List.class.getName()).getMethod("size").invoke(obj);
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy