javastrava.auth.ref.AuthorisationApprovalPrompt Maven / Gradle / Ivy
Show all versions of javastrava-api Show documentation
package javastrava.auth.ref;
import javastrava.config.StravaConfig;
import javastrava.json.impl.serializer.AuthorisationApprovalPromptSerializer;
/**
*
* {@link #FORCE} or {@link #AUTO}
*
*
*
* Use {@link #FORCE} to always show the authorisation prompt even if the user has already authorised the current application
*
*
*
* Default is {@link #AUTO}
*
*
* @author Dan Shannon
*
*/
public enum AuthorisationApprovalPrompt {
/**
*
* Forces Strava's authorisation process to show the authorisation prompt page, even if the user has already authorised the application with the requested authorisation scope(s)
*
*/
FORCE(StravaConfig.string("AuthorisationApprovalPrompt.force")), //$NON-NLS-1$
/**
*
* Tells Strava's authorisation process not to show the authorisation prompt page if the user hqs already authorised the application with the requested authorisation scope(s)
*
*/
AUTO(StravaConfig.string("AuthorisationApprovalPrompt.auto")), //$NON-NLS-1$
/**
*
* Should never occur but may if Strava API behaviour has changed
*
*/
UNKNOWN(StravaConfig.string("Common.unknown")); //$NON-NLS-1$
/**
* Used by {@link AuthorisationApprovalPromptSerializer#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type, com.google.gson.JsonDeserializationContext)} when deserialising JSON returned by the Strava API
* @param id The text representation returned by Strava
* @return The instance of {@link AuthorisationApprovalPrompt} with the correct id
*/
public static AuthorisationApprovalPrompt create(final String id) {
for (final AuthorisationApprovalPrompt prompt : AuthorisationApprovalPrompt.values()) {
if (prompt.getId().equals(id)) {
return prompt;
}
}
return AuthorisationApprovalPrompt.UNKNOWN;
}
/**
* Identifier
*/
private String id;
/**
*
* Private constructor - this is an enum
*
* @param id The identifier of the approval prompt
*/
private AuthorisationApprovalPrompt(final String id) {
this.id = id;
}
/**
*
* Note that this is also used by {@link AuthorisationApprovalPromptSerializer#serialize(AuthorisationApprovalPrompt, java.lang.reflect.Type, com.google.gson.JsonSerializationContext)} when serialising to JSON
*
* @return the id
*/
public String getId() {
return this.id;
}
/**
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return this.id;
}
}