/*
 * The Plaid API
 * The Plaid REST API. Please see https://plaid.com/docs/api for more details.
 *
 * The version of the OpenAPI document: 2020-09-14_1.680.0
 * 
 *
 * 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.plaid.client.model;

import java.util.Objects;
import java.util.Arrays;
import io.swagger.annotations.ApiModel;
import com.google.gson.annotations.SerializedName;

import java.io.IOException;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

/**
 * The type of the subject token. &#x60;urn:plaid:params:tokens:user&#x60; allows exchanging a Plaid-issued user token for an OAuth token. When using this token type, &#x60;audience&#x60; must be the same as the &#x60;client_id&#x60;. &#x60;subject_token&#x60; must be a Plaid-issued user token issued from the &#x60;/user/create&#x60; endpoint. &#x60;urn:plaid:params:oauth:user-token&#x60; allows exchanging a refresh token for an OAuth token to another &#x60;client_id&#x60;. The other &#x60;client_id&#x60; is provided in &#x60;audience&#x60;. &#x60;subject_token&#x60; must be an OAuth refresh token issued from the &#x60;/oauth/token&#x60; endpoint. &#x60;urn:plaid:params:credit:multi-user&#x60; allows exchanging a Plaid-issued user token for an OAuth token. When using this token type, &#x60;audience&#x60; may be a client id or a supported CRA partner URN. &#x60;audience&#x60; supports a comma-delimited list of clients. When multiple clients are specified in the &#x60;audience&#x60; a multi-party token is created which can be used by all parties in the audience in conjunction with their &#x60;client_id&#x60; and &#x60;client_secret&#x60;.
 */
@JsonAdapter(OAuthSubjectTokenType.Adapter.class)
public enum OAuthSubjectTokenType {
  
  TOKENS_USER("urn:plaid:params:tokens:user"),
  
  OAUTH_USER_TOKEN("urn:plaid:params:oauth:user-token"),
  
  CREDIT_MULTI_USER("urn:plaid:params:credit:multi-user"),

  // This is returned when an enum is returned from the API that doesn't exist in the OpenAPI file.
  // Try upgrading your client-library version.
  ENUM_UNKNOWN("ENUM_UNKNOWN");

  private String value;

  OAuthSubjectTokenType(String value) {
    this.value = value;
  }

  public String getValue() {
    return value;
  }

  @Override
  public String toString() {
    return String.valueOf(value);
  }

  public static OAuthSubjectTokenType fromValue(String value) {
    for (OAuthSubjectTokenType b : OAuthSubjectTokenType.values()) {
      if (b.value.equals(value)) {
        return b;
      }
    }
    
    return OAuthSubjectTokenType.ENUM_UNKNOWN;
  }

  public static class Adapter extends TypeAdapter<OAuthSubjectTokenType> {
    @Override
    public void write(final JsonWriter jsonWriter, final OAuthSubjectTokenType enumeration) throws IOException {
      jsonWriter.value(enumeration.getValue());
    }

    @Override
    public OAuthSubjectTokenType read(final JsonReader jsonReader) throws IOException {
      String value = jsonReader.nextString();
      return OAuthSubjectTokenType.fromValue(value);
    }
  }
}

