Skip to content

Commit

Permalink
Merge pull request #300 from vimeo/feature/VA-3117-GDPR
Browse files Browse the repository at this point in the history
GDPR
  • Loading branch information
msya authored May 17, 2018
2 parents 6202ca0 + ba2c036 commit d8e687f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public final class Vimeo {
public static final String PARAMETER_PASSWORD = "password";
public static final String PARAMETER_USERS_LOCATION = "location";
public static final String PARAMETER_USERS_BIO = "bio";
public static final String PARAMETER_MARKETING_OPT_IN = "marketing_opt_in";

public static final String PARAMETER_VIDEO_VIEW = "view";
public static final String PARAMETER_VIDEO_COMMENTS = "comments";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,24 @@ public Call<VimeoAccount> singleSignOnTokenExchange(@NotNull String token, AuthC
return call;
}

/**
* This method is used to create an account on Vimeo with the credentials {@code email} and
* {@code password}. It is used to join with an email and password.
*
* @param displayName The display name for the account.
* @param email Account's email.
* @param password Account's password.
* @param marketingOptIn Flag to opt in or out of email marketing emails.
* @param callback Callback to inform you of the result of login.
*
* @return A Call object.
*/
@Nullable
public Call<VimeoAccount> join(String displayName, String email, String password, AuthCallback callback) {
public Call<VimeoAccount> join(@Nullable final String displayName,
@Nullable final String email,
@Nullable final String password,
final boolean marketingOptIn,
@Nullable final AuthCallback callback) {
if (callback == null) {
throw new AssertionError("Callback cannot be null");
}
Expand Down Expand Up @@ -464,14 +480,27 @@ public Call<VimeoAccount> join(String displayName, String email, String password
parameters.put(Vimeo.PARAMETER_EMAIL, email);
parameters.put(Vimeo.PARAMETER_PASSWORD, password);
parameters.put(Vimeo.PARAMETER_SCOPE, mConfiguration.mScope);
parameters.put(Vimeo.PARAMETER_MARKETING_OPT_IN, Boolean.toString(marketingOptIn));

final Call<VimeoAccount> call = mVimeoService.join(getBasicAuthHeader(), parameters);
call.enqueue(new AccountCallback(this, email, callback));
return call;
}

/**
* This method is used to create an account on Vimeo with Facebook.
*
* @param facebookToken Facebook token.
* @param email Account's email.
* @param marketingOptIn Flag to opt in or out of email marketing emails.
* @param callback Callback to inform you of the result of login.
*
* @return A Call object.
*/
@Nullable
public Call<VimeoAccount> joinWithFacebookToken(@NotNull final String facebookToken, @NotNull final String email,
public Call<VimeoAccount> joinWithFacebookToken(@NotNull final String facebookToken,
@NotNull final String email,
final boolean marketingOptIn,
@NotNull final AuthCallback callback) {
if (facebookToken.isEmpty()) {
final VimeoError error = new VimeoError("Facebook authentication error.");
Expand All @@ -484,6 +513,7 @@ public Call<VimeoAccount> joinWithFacebookToken(@NotNull final String facebookTo
final HashMap<String, String> parameters = new HashMap<>();
parameters.put(Vimeo.PARAMETER_TOKEN, facebookToken);
parameters.put(Vimeo.PARAMETER_SCOPE, mConfiguration.mScope);
parameters.put(Vimeo.PARAMETER_MARKETING_OPT_IN, Boolean.toString(marketingOptIn));

final Call<VimeoAccount> call = mVimeoService.join(getBasicAuthHeader(), parameters);
call.enqueue(new AccountCallback(this, email, callback));
Expand All @@ -493,13 +523,16 @@ public Call<VimeoAccount> joinWithFacebookToken(@NotNull final String facebookTo
/**
* Register the user using a Google authentication token.
*
* @param googleToken {@code id_token} value received by Google after authenticating.
* @param email User email address.
* @param callback This callback will be executed after the request succeeds or fails.
* @param googleToken {@code id_token} value received by Google after authenticating.
* @param email User email address.
* @param marketingOptIn Flag to opt in or out of marketing emails.
* @param callback This callback will be executed after the request succeeds or fails.
* @return a retrofit {@link Call} object, which <b>has already been enqueued</b>.
*/
@Nullable
public Call<VimeoAccount> joinWithGoogleToken(@NotNull final String googleToken, @NotNull final String email,
public Call<VimeoAccount> joinWithGoogleToken(@NotNull final String googleToken,
@NotNull final String email,
final boolean marketingOptIn,
@NotNull final AuthCallback callback) {
if (googleToken.isEmpty()) {
final VimeoError error = new VimeoError("Google authentication error.");
Expand All @@ -512,6 +545,7 @@ public Call<VimeoAccount> joinWithGoogleToken(@NotNull final String googleToken,
final HashMap<String, String> parameters = new HashMap<>();
parameters.put(Vimeo.PARAMETER_ID_TOKEN, googleToken);
parameters.put(Vimeo.PARAMETER_SCOPE, mConfiguration.mScope);
parameters.put(Vimeo.PARAMETER_MARKETING_OPT_IN, Boolean.toString(marketingOptIn));

final Call<VimeoAccount> call = mVimeoService.join(getBasicAuthHeader(), parameters);
call.enqueue(new AccountCallback(this, email, callback));
Expand Down Expand Up @@ -588,7 +622,8 @@ public VimeoAccount logIn(String email, String password) {
}

@Nullable
public Call<VimeoAccount> loginWithFacebookToken(@NotNull final String facebookToken, @NotNull final String email,
public Call<VimeoAccount> loginWithFacebookToken(@NotNull final String facebookToken,
@NotNull final String email,
@NotNull final AuthCallback callback) {
if (facebookToken.isEmpty()) {
final VimeoError error = new VimeoError("Facebook authentication error.");
Expand All @@ -615,7 +650,8 @@ public Call<VimeoAccount> loginWithFacebookToken(@NotNull final String facebookT
* @return a retrofit {@link Call} object, which <b>has already been enqueued</b>.
*/
@Nullable
public Call<VimeoAccount> loginWithGoogleToken(@NotNull final String googleToken, @NotNull final String email,
public Call<VimeoAccount> loginWithGoogleToken(@NotNull final String googleToken,
@NotNull final String email,
@NotNull final AuthCallback callback) {
if (googleToken.isEmpty()) {
final VimeoError error = new VimeoError("Google authentication error.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ Call<VimeoAccount> logIn(@Header("Authorization") String authHeader, @Field("use
@FormUrlEncoded
@POST("oauth/authorize/facebook")
Call<VimeoAccount> logInWithFacebook(@Header("Authorization") String authHeader,
@Field("grant_type") String grantType, @Field("token") String token,
@Field("grant_type") String grantType,
@Field("token") String token,
@Field("scope") String scope);

@FormUrlEncoded
Expand Down

0 comments on commit d8e687f

Please sign in to comment.