Search in sources :

Example 6 with Url

use of retrofit2.http.Url in project azure-sdk-for-java by Azure.

the class GroupsInner method addMemberWithServiceResponseAsync.

/**
     * Add a member to a group.
     *
     * @param groupObjectId The object ID of the group to which to add the member.
     * @param url A member object URL, such as "https://graph.windows.net/0b1f9851-1bf0-433f-aec3-cb9272f093dc/directoryObjects/f260bbc4-c254-447b-94cf-293b5ec434dd", where "0b1f9851-1bf0-433f-aec3-cb9272f093dc" is the tenantId and "f260bbc4-c254-447b-94cf-293b5ec434dd" is the objectId of the member (user, application, servicePrincipal, group) to be added.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
public Observable<ServiceResponse<Void>> addMemberWithServiceResponseAsync(String groupObjectId, String url) {
    if (groupObjectId == null) {
        throw new IllegalArgumentException("Parameter groupObjectId is required and cannot be null.");
    }
    if (this.client.tenantID() == null) {
        throw new IllegalArgumentException("Parameter this.client.tenantID() is required and cannot be null.");
    }
    if (this.client.apiVersion() == null) {
        throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
    }
    if (url == null) {
        throw new IllegalArgumentException("Parameter url is required and cannot be null.");
    }
    GroupAddMemberParameters parameters = new GroupAddMemberParameters();
    parameters.withUrl(url);
    return service.addMember(groupObjectId, this.client.tenantID(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {

        @Override
        public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<Void> clientResponse = addMemberDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) GroupAddMemberParameters(com.microsoft.azure.management.graphrbac.GroupAddMemberParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Example 7 with Url

use of retrofit2.http.Url in project plaid by nickbutcher.

the class DribbbleShot method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dribbble_shot);
    dribbblePrefs = DribbblePrefs.get(this);
    circleTransform = new CircleTransform(this);
    ButterKnife.bind(this);
    shotDescription = getLayoutInflater().inflate(R.layout.dribbble_shot_description, commentsList, false);
    shotSpacer = shotDescription.findViewById(R.id.shot_spacer);
    title = shotDescription.findViewById(R.id.shot_title);
    description = shotDescription.findViewById(R.id.shot_description);
    likeCount = (Button) shotDescription.findViewById(R.id.shot_like_count);
    viewCount = (Button) shotDescription.findViewById(R.id.shot_view_count);
    share = (Button) shotDescription.findViewById(R.id.shot_share_action);
    playerName = (TextView) shotDescription.findViewById(R.id.player_name);
    playerAvatar = (ImageView) shotDescription.findViewById(R.id.player_avatar);
    shotTimeAgo = (TextView) shotDescription.findViewById(R.id.shot_time_ago);
    setupCommenting();
    commentsList.addOnScrollListener(scrollListener);
    commentsList.setOnFlingListener(flingListener);
    back.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setResultAndFinish();
        }
    });
    fab.setOnClickListener(fabClick);
    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this) {

        @Override
        public void onDragDismissed() {
            setResultAndFinish();
        }
    };
    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_SHOT)) {
        shot = intent.getParcelableExtra(EXTRA_SHOT);
        bindShot(true);
    } else if (intent.getData() != null) {
        final HttpUrl url = HttpUrl.parse(intent.getDataString());
        if (url.pathSize() == 2 && url.pathSegments().get(0).equals("shots")) {
            try {
                final String shotPath = url.pathSegments().get(1);
                final long id = Long.parseLong(shotPath.substring(0, shotPath.indexOf("-")));
                final Call<Shot> shotCall = dribbblePrefs.getApi().getShot(id);
                shotCall.enqueue(new Callback<Shot>() {

                    @Override
                    public void onResponse(Call<Shot> call, Response<Shot> response) {
                        shot = response.body();
                        bindShot(false);
                    }

                    @Override
                    public void onFailure(Call<Shot> call, Throwable t) {
                        reportUrlError();
                    }
                });
            } catch (NumberFormatException | StringIndexOutOfBoundsException ex) {
                reportUrlError();
            }
        } else {
            reportUrlError();
        }
    }
}
Also used : Call(retrofit2.Call) CircleTransform(io.plaidapp.util.glide.CircleTransform) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) ForegroundImageView(io.plaidapp.ui.widget.ForegroundImageView) TextView(android.widget.TextView) FabOverlapTextView(io.plaidapp.ui.widget.FabOverlapTextView) ParallaxScrimageView(io.plaidapp.ui.widget.ParallaxScrimageView) RecyclerView(android.support.v7.widget.RecyclerView) HttpUrl(okhttp3.HttpUrl) Response(retrofit2.Response) ElasticDragDismissFrameLayout(io.plaidapp.ui.widget.ElasticDragDismissFrameLayout) Callback(retrofit2.Callback)

Example 8 with Url

use of retrofit2.http.Url in project Pokemap by omkarmoghe.

the class GoogleManager method authUser.

@Deprecated
@SuppressWarnings({ "deprecation", "unused" })
public void authUser(final LoginListener listener) {
    HttpUrl url = HttpUrl.parse(OAUTH_ENDPOINT).newBuilder().addQueryParameter("client_id", CLIENT_ID).addQueryParameter("scope", "openid email https://www.googleapis.com/auth/userinfo.email").addQueryParameter("response_type", "code").addQueryParameter("redirect_uri", "http://127.0.0.1:9004").build();
    Callback<GoogleService.AuthRequest> googleCallback = new Callback<GoogleService.AuthRequest>() {

        @Override
        public void onResponse(Call<GoogleService.AuthRequest> call, Response<GoogleService.AuthRequest> response) {
            GoogleService.AuthRequest body = response.body();
            if (body != null) {
                listener.authRequested(body);
            } else {
                Log.e(TAG, "Google login failed while authenticating. response.body() is null.");
                listener.authFailed("Google login failed while authenticating");
            }
        }

        @Override
        public void onFailure(Call<GoogleService.AuthRequest> call, Throwable t) {
            t.printStackTrace();
            Log.e(TAG, "Google authentication failed when calling  authUser(). googleCallback's onFailure() threw: " + t.getMessage());
            listener.authFailed("Failed on getting the information for the user auth");
        }
    };
    if (mGoogleService != null) {
        Call<GoogleService.AuthRequest> call = mGoogleService.requestAuth(url.toString());
        call.enqueue(googleCallback);
    }
}
Also used : Response(retrofit2.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) HttpUrl(okhttp3.HttpUrl)

Example 9 with Url

use of retrofit2.http.Url in project Pokemap by omkarmoghe.

the class GoogleManager method requestToken.

public void requestToken(String deviceCode, final LoginListener listener) {
    HttpUrl url = HttpUrl.parse(OAUTH_TOKEN_ENDPOINT).newBuilder().build();
    RequestBody body = new FormBody.Builder().add("code", deviceCode).add("client_id", CLIENT_ID).add("client_secret", SECRET).add("redirect_uri", "http://127.0.0.1:8080").add("grant_type", "authorization_code").build();
    Callback<GoogleService.TokenResponse> googleCallback = new Callback<GoogleService.TokenResponse>() {

        @Override
        public void onResponse(Call<GoogleService.TokenResponse> call, Response<GoogleService.TokenResponse> response) {
            if (response.body() != null) {
                listener.authSuccessful(response.body().getIdToken(), response.body().getRefreshToken());
            } else {
                Log.e(TAG, "Google login failed while fetching token. response.body() is null.");
                listener.authFailed("Google login failed while authenticating. Token missing.");
            }
        }

        @Override
        public void onFailure(Call<GoogleService.TokenResponse> call, Throwable t) {
            t.printStackTrace();
            Log.e(TAG, "Google authentication failed while fetching request token using requestToken(). googleCallback's onFailure() threw: " + t.getMessage());
            listener.authFailed("Failed on requesting the id token");
        }
    };
    if (mGoogleService != null) {
        Call<GoogleService.TokenResponse> call = mGoogleService.requestToken(url.toString(), body);
        call.enqueue(googleCallback);
    }
}
Also used : Response(retrofit2.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) HttpUrl(okhttp3.HttpUrl) RequestBody(okhttp3.RequestBody)

Example 10 with Url

use of retrofit2.http.Url in project Pokemap by omkarmoghe.

the class NianticManager method requestToken.

private void requestToken(String code, final LoginListener loginListener) {
    Log.d(TAG, "requestToken() called with: code = [" + code + "]");
    HttpUrl url = HttpUrl.parse(LOGIN_OAUTH).newBuilder().addQueryParameter("client_id", CLIENT_ID).addQueryParameter("redirect_uri", REDIRECT_URI).addQueryParameter("client_secret", CLIENT_SECRET).addQueryParameter("grant_type", "refresh_token").addQueryParameter("code", code).build();
    Callback<ResponseBody> authCallback = new Callback<ResponseBody>() {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                String token = response.body().string().split("token=")[1];
                if (token != null) {
                    token = token.split("&")[0];
                    loginListener.authSuccessful(token);
                } else {
                    Log.e(TAG, "PTC login failed while fetching a requestToken via requestToken(). Token is null.");
                    loginListener.authFailed("Pokemon Trainer Club Login Failed");
                }
            } catch (IOException e) {
                e.printStackTrace();
                Log.e(TAG, "PTC login failed while fetching a requestToken authCallback.onResponse() raised: " + e.getMessage());
                loginListener.authFailed("Pokemon Trainer Club Authentication Failed");
            }
        }

        @Override
        public void onFailure(Call<ResponseBody> call, Throwable t) {
            t.printStackTrace();
            Log.e(TAG, "PTC login failed while fetching a requestToken authCallback.onResponse() threw: " + t.getMessage());
            loginListener.authFailed("Pokemon Trainer Club Authentication Failed");
        }
    };
    Call<ResponseBody> call = mNianticService.requestToken(url.toString());
    call.enqueue(authCallback);
}
Also used : Response(retrofit2.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) IOException(java.io.IOException) HttpUrl(okhttp3.HttpUrl) ResponseBody(okhttp3.ResponseBody)

Aggregations

HttpUrl (okhttp3.HttpUrl)15 ResponseBody (okhttp3.ResponseBody)14 Request (okhttp3.Request)11 Test (org.junit.Test)10 Url (retrofit2.http.Url)10 Response (retrofit2.Response)9 OkHttpClient (okhttp3.OkHttpClient)6 Call (retrofit2.Call)6 Callback (retrofit2.Callback)6 Intent (android.content.Intent)4 View (android.view.View)3 TextView (android.widget.TextView)3 BindView (butterknife.BindView)3 Retrofit (retrofit2.Retrofit)3 ValueAnimator (android.animation.ValueAnimator)2 Application (android.app.Application)2 Context (android.content.Context)2 Uri (android.net.Uri)2 Build (android.os.Build)2 AlertDialog (android.support.v7.app.AlertDialog)2