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

com.konfigthis.client.model.PartnerData Maven / Gradle / Ivy

Go to download

Connect brokerage accounts to your app for live positions and trading This library was generated by https://konfigthis.com

There is a newer version: 5.0.55
Show newest version
/*
 * SnapTrade
 * Connect brokerage accounts to your app for live positions and trading
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by Konfig (https://konfigthis.com).
 * Do not edit the class manually.
 */


package com.konfigthis.client.model;

import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.konfigthis.client.model.Brokerage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.konfigthis.client.JSON;

/**
 * SnapTrade Partner metadata
 */
@ApiModel(description = "SnapTrade Partner metadata")@javax.annotation.Generated(value = "Generated by https://konfigthis.com")
public class PartnerData {
  public static final String SERIALIZED_NAME_REDIRECT_URI = "redirect_uri";
  @SerializedName(SERIALIZED_NAME_REDIRECT_URI)
  private String redirectUri;

  public static final String SERIALIZED_NAME_ALLOWED_BROKERAGES = "allowed_brokerages";
  @SerializedName(SERIALIZED_NAME_ALLOWED_BROKERAGES)
  private List allowedBrokerages = null;

  public static final String SERIALIZED_NAME_NAME = "name";
  @SerializedName(SERIALIZED_NAME_NAME)
  private String name;

  public static final String SERIALIZED_NAME_SLUG = "slug";
  @SerializedName(SERIALIZED_NAME_SLUG)
  private String slug;

  public static final String SERIALIZED_NAME_LOGO_URL = "logo_url";
  @SerializedName(SERIALIZED_NAME_LOGO_URL)
  private String logoUrl;

  public static final String SERIALIZED_NAME_PIN_REQUIRED = "pin_required";
  @SerializedName(SERIALIZED_NAME_PIN_REQUIRED)
  private Boolean pinRequired;

  public static final String SERIALIZED_NAME_CAN_ACCESS_TRADES = "can_access_trades";
  @SerializedName(SERIALIZED_NAME_CAN_ACCESS_TRADES)
  private Boolean canAccessTrades;

  public static final String SERIALIZED_NAME_CAN_ACCESS_HOLDINGS = "can_access_holdings";
  @SerializedName(SERIALIZED_NAME_CAN_ACCESS_HOLDINGS)
  private Boolean canAccessHoldings;

  public static final String SERIALIZED_NAME_CAN_ACCESS_ACCOUNT_HISTORY = "can_access_account_history";
  @SerializedName(SERIALIZED_NAME_CAN_ACCESS_ACCOUNT_HISTORY)
  private Boolean canAccessAccountHistory;

  public static final String SERIALIZED_NAME_CAN_ACCESS_REFERENCE_DATA = "can_access_reference_data";
  @SerializedName(SERIALIZED_NAME_CAN_ACCESS_REFERENCE_DATA)
  private Boolean canAccessReferenceData;

  public static final String SERIALIZED_NAME_CAN_ACCESS_PORTFOLIO_MANAGEMENT = "can_access_portfolio_management";
  @SerializedName(SERIALIZED_NAME_CAN_ACCESS_PORTFOLIO_MANAGEMENT)
  private Boolean canAccessPortfolioManagement;

  public static final String SERIALIZED_NAME_CAN_ACCESS_ORDERS = "can_access_orders";
  @SerializedName(SERIALIZED_NAME_CAN_ACCESS_ORDERS)
  private Boolean canAccessOrders;

  public PartnerData() {
  }

  public PartnerData redirectUri(String redirectUri) {
    
    
    
    
    this.redirectUri = redirectUri;
    return this;
  }

   /**
   * URI to redirect user back to after user is done adding brokerage connections
   * @return redirectUri
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "https://example.com/oauth/snaptrade", value = "URI to redirect user back to after user is done adding brokerage connections")

  public String getRedirectUri() {
    return redirectUri;
  }


  public void setRedirectUri(String redirectUri) {
    
    
    
    this.redirectUri = redirectUri;
  }


  public PartnerData allowedBrokerages(List allowedBrokerages) {
    
    
    
    
    this.allowedBrokerages = allowedBrokerages;
    return this;
  }

  public PartnerData addAllowedBrokeragesItem(Brokerage allowedBrokeragesItem) {
    if (this.allowedBrokerages == null) {
      this.allowedBrokerages = new ArrayList<>();
    }
    this.allowedBrokerages.add(allowedBrokeragesItem);
    return this;
  }

   /**
   * Brokerages that can be accessed by partners
   * @return allowedBrokerages
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(value = "Brokerages that can be accessed by partners")

  public List getAllowedBrokerages() {
    return allowedBrokerages;
  }


  public void setAllowedBrokerages(List allowedBrokerages) {
    
    
    
    this.allowedBrokerages = allowedBrokerages;
  }


  public PartnerData name(String name) {
    
    
    
    
    this.name = name;
    return this;
  }

   /**
   * Name of Snaptrade Partner
   * @return name
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "Wealthy Chimpmunk", value = "Name of Snaptrade Partner")

  public String getName() {
    return name;
  }


  public void setName(String name) {
    
    
    
    this.name = name;
  }


  public PartnerData slug(String slug) {
    
    
    
    
    this.slug = slug;
    return this;
  }

   /**
   * Slug of Snaptrade Partner
   * @return slug
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "WEALTHYCHIPMUNK", value = "Slug of Snaptrade Partner")

  public String getSlug() {
    return slug;
  }


  public void setSlug(String slug) {
    
    
    
    this.slug = slug;
  }


  public PartnerData logoUrl(String logoUrl) {
    
    
    
    
    this.logoUrl = logoUrl;
    return this;
  }

   /**
   * URL to partner's logo
   * @return logoUrl
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "https://example.com/logo.png", value = "URL to partner's logo")

  public String getLogoUrl() {
    return logoUrl;
  }


  public void setLogoUrl(String logoUrl) {
    
    
    
    this.logoUrl = logoUrl;
  }


  public PartnerData pinRequired(Boolean pinRequired) {
    
    
    
    
    this.pinRequired = pinRequired;
    return this;
  }

   /**
   * Shows if pin is required by users to access connection page
   * @return pinRequired
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "false", value = "Shows if pin is required by users to access connection page")

  public Boolean getPinRequired() {
    return pinRequired;
  }


  public void setPinRequired(Boolean pinRequired) {
    
    
    
    this.pinRequired = pinRequired;
  }


  public PartnerData canAccessTrades(Boolean canAccessTrades) {
    
    
    
    
    this.canAccessTrades = canAccessTrades;
    return this;
  }

   /**
   * Shows if users of Snaptrade partners can access trade endpoints
   * @return canAccessTrades
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "Shows if users of Snaptrade partners can access trade endpoints")

  public Boolean getCanAccessTrades() {
    return canAccessTrades;
  }


  public void setCanAccessTrades(Boolean canAccessTrades) {
    
    
    
    this.canAccessTrades = canAccessTrades;
  }


  public PartnerData canAccessHoldings(Boolean canAccessHoldings) {
    
    
    
    
    this.canAccessHoldings = canAccessHoldings;
    return this;
  }

   /**
   * Shows if Snaptrade partners can get user holdings data
   * @return canAccessHoldings
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "Shows if Snaptrade partners can get user holdings data")

  public Boolean getCanAccessHoldings() {
    return canAccessHoldings;
  }


  public void setCanAccessHoldings(Boolean canAccessHoldings) {
    
    
    
    this.canAccessHoldings = canAccessHoldings;
  }


  public PartnerData canAccessAccountHistory(Boolean canAccessAccountHistory) {
    
    
    
    
    this.canAccessAccountHistory = canAccessAccountHistory;
    return this;
  }

   /**
   * Shows if Snaptrade partners can get users account history data
   * @return canAccessAccountHistory
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "Shows if Snaptrade partners can get users account history data")

  public Boolean getCanAccessAccountHistory() {
    return canAccessAccountHistory;
  }


  public void setCanAccessAccountHistory(Boolean canAccessAccountHistory) {
    
    
    
    this.canAccessAccountHistory = canAccessAccountHistory;
  }


  public PartnerData canAccessReferenceData(Boolean canAccessReferenceData) {
    
    
    
    
    this.canAccessReferenceData = canAccessReferenceData;
    return this;
  }

   /**
   * Shows if Snaptrade partners can get users holdings data
   * @return canAccessReferenceData
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "Shows if Snaptrade partners can get users holdings data")

  public Boolean getCanAccessReferenceData() {
    return canAccessReferenceData;
  }


  public void setCanAccessReferenceData(Boolean canAccessReferenceData) {
    
    
    
    this.canAccessReferenceData = canAccessReferenceData;
  }


  public PartnerData canAccessPortfolioManagement(Boolean canAccessPortfolioManagement) {
    
    
    
    
    this.canAccessPortfolioManagement = canAccessPortfolioManagement;
    return this;
  }

   /**
   * Shows if users Snaptrade partners can access portfolio group management features
   * @return canAccessPortfolioManagement
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "Shows if users Snaptrade partners can access portfolio group management features")

  public Boolean getCanAccessPortfolioManagement() {
    return canAccessPortfolioManagement;
  }


  public void setCanAccessPortfolioManagement(Boolean canAccessPortfolioManagement) {
    
    
    
    this.canAccessPortfolioManagement = canAccessPortfolioManagement;
  }


  public PartnerData canAccessOrders(Boolean canAccessOrders) {
    
    
    
    
    this.canAccessOrders = canAccessOrders;
    return this;
  }

   /**
   * Shows if Snaptrade partners can get users account order history
   * @return canAccessOrders
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "Shows if Snaptrade partners can get users account order history")

  public Boolean getCanAccessOrders() {
    return canAccessOrders;
  }


  public void setCanAccessOrders(Boolean canAccessOrders) {
    
    
    
    this.canAccessOrders = canAccessOrders;
  }

  /**
   * A container for additional, undeclared properties.
   * This is a holder for any undeclared properties as specified with
   * the 'additionalProperties' keyword in the OAS document.
   */
  private Map additionalProperties;

  /**
   * Set the additional (undeclared) property with the specified name and value.
   * If the property does not already exist, create it otherwise replace it.
   *
   * @param key name of the property
   * @param value value of the property
   * @return the PartnerData instance itself
   */
  public PartnerData putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map getAdditionalProperties() {
    return additionalProperties;
  }

  /**
   * Return the additional (undeclared) property with the specified name.
   *
   * @param key name of the property
   * @return an object
   */
  public Object getAdditionalProperty(String key) {
    if (this.additionalProperties == null) {
        return null;
    }
    return this.additionalProperties.get(key);
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    PartnerData partnerData = (PartnerData) o;
    return Objects.equals(this.redirectUri, partnerData.redirectUri) &&
        Objects.equals(this.allowedBrokerages, partnerData.allowedBrokerages) &&
        Objects.equals(this.name, partnerData.name) &&
        Objects.equals(this.slug, partnerData.slug) &&
        Objects.equals(this.logoUrl, partnerData.logoUrl) &&
        Objects.equals(this.pinRequired, partnerData.pinRequired) &&
        Objects.equals(this.canAccessTrades, partnerData.canAccessTrades) &&
        Objects.equals(this.canAccessHoldings, partnerData.canAccessHoldings) &&
        Objects.equals(this.canAccessAccountHistory, partnerData.canAccessAccountHistory) &&
        Objects.equals(this.canAccessReferenceData, partnerData.canAccessReferenceData) &&
        Objects.equals(this.canAccessPortfolioManagement, partnerData.canAccessPortfolioManagement) &&
        Objects.equals(this.canAccessOrders, partnerData.canAccessOrders)&&
        Objects.equals(this.additionalProperties, partnerData.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(redirectUri, allowedBrokerages, name, slug, logoUrl, pinRequired, canAccessTrades, canAccessHoldings, canAccessAccountHistory, canAccessReferenceData, canAccessPortfolioManagement, canAccessOrders, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class PartnerData {\n");
    sb.append("    redirectUri: ").append(toIndentedString(redirectUri)).append("\n");
    sb.append("    allowedBrokerages: ").append(toIndentedString(allowedBrokerages)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    slug: ").append(toIndentedString(slug)).append("\n");
    sb.append("    logoUrl: ").append(toIndentedString(logoUrl)).append("\n");
    sb.append("    pinRequired: ").append(toIndentedString(pinRequired)).append("\n");
    sb.append("    canAccessTrades: ").append(toIndentedString(canAccessTrades)).append("\n");
    sb.append("    canAccessHoldings: ").append(toIndentedString(canAccessHoldings)).append("\n");
    sb.append("    canAccessAccountHistory: ").append(toIndentedString(canAccessAccountHistory)).append("\n");
    sb.append("    canAccessReferenceData: ").append(toIndentedString(canAccessReferenceData)).append("\n");
    sb.append("    canAccessPortfolioManagement: ").append(toIndentedString(canAccessPortfolioManagement)).append("\n");
    sb.append("    canAccessOrders: ").append(toIndentedString(canAccessOrders)).append("\n");
    sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * 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    ");
  }


  public static HashSet openapiFields;
  public static HashSet openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet();
    openapiFields.add("redirect_uri");
    openapiFields.add("allowed_brokerages");
    openapiFields.add("name");
    openapiFields.add("slug");
    openapiFields.add("logo_url");
    openapiFields.add("pin_required");
    openapiFields.add("can_access_trades");
    openapiFields.add("can_access_holdings");
    openapiFields.add("can_access_account_history");
    openapiFields.add("can_access_reference_data");
    openapiFields.add("can_access_portfolio_management");
    openapiFields.add("can_access_orders");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
  }

 /**
  * Validates the JSON Object and throws an exception if issues found
  *
  * @param jsonObj JSON Object
  * @throws IOException if the JSON Object is invalid with respect to PartnerData
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!PartnerData.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in PartnerData is not found in the empty JSON string", PartnerData.openapiRequiredFields.toString()));
        }
      }
      if ((jsonObj.get("redirect_uri") != null && !jsonObj.get("redirect_uri").isJsonNull()) && !jsonObj.get("redirect_uri").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `redirect_uri` to be a primitive type in the JSON string but got `%s`", jsonObj.get("redirect_uri").toString()));
      }
      if (jsonObj.get("allowed_brokerages") != null && !jsonObj.get("allowed_brokerages").isJsonNull()) {
        JsonArray jsonArrayallowedBrokerages = jsonObj.getAsJsonArray("allowed_brokerages");
        if (jsonArrayallowedBrokerages != null) {
          // ensure the json data is an array
          if (!jsonObj.get("allowed_brokerages").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `allowed_brokerages` to be an array in the JSON string but got `%s`", jsonObj.get("allowed_brokerages").toString()));
          }

          // validate the optional field `allowed_brokerages` (array)
          for (int i = 0; i < jsonArrayallowedBrokerages.size(); i++) {
            Brokerage.validateJsonObject(jsonArrayallowedBrokerages.get(i).getAsJsonObject());
          };
        }
      }
      if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
      }
      if ((jsonObj.get("slug") != null && !jsonObj.get("slug").isJsonNull()) && !jsonObj.get("slug").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `slug` to be a primitive type in the JSON string but got `%s`", jsonObj.get("slug").toString()));
      }
      if ((jsonObj.get("logo_url") != null && !jsonObj.get("logo_url").isJsonNull()) && !jsonObj.get("logo_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `logo_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("logo_url").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!PartnerData.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'PartnerData' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(PartnerData.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, PartnerData value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");
             // serialize additonal properties
             if (value.getAdditionalProperties() != null) {
               for (Map.Entry entry : value.getAdditionalProperties().entrySet()) {
                 if (entry.getValue() instanceof String)
                   obj.addProperty(entry.getKey(), (String) entry.getValue());
                 else if (entry.getValue() instanceof Number)
                   obj.addProperty(entry.getKey(), (Number) entry.getValue());
                 else if (entry.getValue() instanceof Boolean)
                   obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                 else if (entry.getValue() instanceof Character)
                   obj.addProperty(entry.getKey(), (Character) entry.getValue());
                 else if (entry.getValue() == null) {
                   obj.addProperty(entry.getKey(), (String) null);
                 } else {
                   obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
                 }
               }
             }
             elementAdapter.write(out, obj);
           }

           @Override
           public PartnerData read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             // store additional fields in the deserialized instance
             PartnerData instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry entry : jsonObj.entrySet()) {
               if (!openapiFields.contains(entry.getKey())) {
                 if (entry.getValue().isJsonPrimitive()) { // primitive type
                   if (entry.getValue().getAsJsonPrimitive().isString())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                   else if (entry.getValue().getAsJsonPrimitive().isNumber())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                   else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                   else
                     throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                 } else if (entry.getValue().isJsonArray()) {
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
                 } else { // JSON object
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                 }
               }
             }
             return instance;
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of PartnerData given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of PartnerData
  * @throws IOException if the JSON string is invalid with respect to PartnerData
  */
  public static PartnerData fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, PartnerData.class);
  }

 /**
  * Convert an instance of PartnerData to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy