Search in sources :

Example 11 with Call

use of com.squareup.okhttp.Call in project paypayopa-sdk-java by paypay.

the class UserApi method unlinkUserWithHttpInfo.

/**
 * Unlink user
 * Unlink a user from the client  **Timeout: 15s**
 * @param userAuthorizationId  (required)
 * @return ApiResponse<NotDataResponse>
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<NotDataResponse> unlinkUserWithHttpInfo(String userAuthorizationId) throws ApiException {
    Call call = unlinkUserValidateBeforeCall(userAuthorizationId);
    Type localVarReturnType = new TypeToken<NotDataResponse>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.UNLINK_USER);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) NotDataResponse(jp.ne.paypay.model.NotDataResponse)

Example 12 with Call

use of com.squareup.okhttp.Call in project paypayopa-sdk-java by paypay.

the class UserApi method getUserAuthorizationStatusWithHttpInfo.

/**
 * Get user authorization status
 * Get the authorization status of a user  **Timeout: 15s**
 * @param userAuthorizationId  (required)
 * @return ApiResponse&lt;UserAuthorizationStatus&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<UserAuthorizationStatus> getUserAuthorizationStatusWithHttpInfo(String userAuthorizationId) throws ApiException {
    Call call = getUserAuthorizationStatusValidateBeforeCall(userAuthorizationId);
    Type localVarReturnType = new TypeToken<UserAuthorizationStatus>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.GET_USER_AUTH_STATUS);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) UserAuthorizationStatus(jp.ne.paypay.model.UserAuthorizationStatus)

Example 13 with Call

use of com.squareup.okhttp.Call in project casa by GluuFederation.

the class StytchService method deleteUser.

// curl --request DELETE --url
// https://test.stytch.com/v1/users/user-test-2a80900ef -u
// 'project-test-918d-74cde970a61e:secret-test-N6SYPKrD6RdEk8KJis=' -H
// 'Content-Type: application/json'
public boolean deleteUser(String stytchUserId) {
    OkHttpClient httpClient = new OkHttpClient();
    String asB64 = new String(new Base64().encode((properties.get("PROJECT_ID") + ":" + properties.get("SECRET")).getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
    String authHeader = "Basic " + new String(asB64);
    Request request = new Request.Builder().url(getScriptPropertyValue("DELETE_USER_ENDPOINT") + stytchUserId).delete().addHeader(HttpHeaders.AUTHORIZATION, authHeader).addHeader("Content-Type", "application/json").build();
    Call call = httpClient.newCall(request);
    logger.debug(request.toString() + "-" + request.headers() + "-" + request.body().toString());
    try {
        Response response = call.execute();
        if (response.code() == 200 || response.code() == 201) {
            return true;
        } else {
            logger.debug("Response for enrolling user was : " + response.code() + "---" + response.message());
            return false;
        }
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        return false;
    }
}
Also used : Response(com.squareup.okhttp.Response) Call(com.squareup.okhttp.Call) OkHttpClient(com.squareup.okhttp.OkHttpClient) Base64(org.apache.commons.codec.binary.Base64) Request(com.squareup.okhttp.Request) IOException(java.io.IOException)

Example 14 with Call

use of com.squareup.okhttp.Call in project yoo_home_Android by culturer.

the class OkHttpStack method performRequest.

@Override
public URLHttpResponse performRequest(Request<?> request, ArrayList<HttpParamsEntry> additionalHeaders) throws IOException {
    OkHttpClient client = mClient.clone();
    int timeoutMs = request.getTimeoutMs();
    client.setConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    client.setReadTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    client.setWriteTimeout(timeoutMs, TimeUnit.MILLISECONDS);
    com.squareup.okhttp.Request.Builder okHttpRequestBuilder = new com.squareup.okhttp.Request.Builder();
    okHttpRequestBuilder.url(request.getUrl());
    for (final HttpParamsEntry entry : request.getHeaders()) {
        okHttpRequestBuilder.addHeader(entry.k, entry.v);
    }
    for (final HttpParamsEntry entry : additionalHeaders) {
        okHttpRequestBuilder.addHeader(entry.k, entry.v);
    }
    setConnectionParametersForRequest(okHttpRequestBuilder, request);
    com.squareup.okhttp.Request okHttpRequest = okHttpRequestBuilder.build();
    Call okHttpCall = client.newCall(okHttpRequest);
    Response okHttpResponse = okHttpCall.execute();
    return responseFromConnection(okHttpResponse);
}
Also used : Response(com.squareup.okhttp.Response) URLHttpResponse(com.kymjs.rxvolley.http.URLHttpResponse) Call(com.squareup.okhttp.Call) OkHttpClient(com.squareup.okhttp.OkHttpClient) Request(com.kymjs.rxvolley.http.Request) HttpParamsEntry(com.kymjs.rxvolley.toolbox.HttpParamsEntry)

Example 15 with Call

use of com.squareup.okhttp.Call in project apiman by apiman.

the class EnrichPre21ExportCommand method downloadExportJson.

private File downloadExportJson(DownloadBean downloadBean) throws IOException {
    LOGGER.info("Successfully triggered an export operation on the Manager API.");
    HttpUrl downloadUrl = HttpUrl.parse(endpoint).newBuilder().addPathSegment("downloads").addPathSegment(downloadBean.getId()).build();
    Request downloadRequest = buildRequest(downloadUrl);
    Call downloadCall = client.newCall(downloadRequest);
    Response downloadResponse = downloadCall.execute();
    checkStatusOk(downloadResponse);
    File downloadedFileTmp = File.createTempFile("EnrichPre21Export", ".json");
    // Get the underlying okio source, as it has some nice methods for writing directly without loads of copying.
    BufferedSource source = downloadResponse.body().source();
    BufferedSink buff = Okio.buffer(Okio.sink(downloadedFileTmp));
    buff.writeAll(source);
    buff.close();
    LOGGER.debug("Successfully downloaded an Apiman export to tmp: {}", downloadedFileTmp);
    return downloadedFileTmp;
}
Also used : Response(com.squareup.okhttp.Response) Call(com.squareup.okhttp.Call) Request(com.squareup.okhttp.Request) BufferedSink(okio.BufferedSink) File(java.io.File) HttpUrl(com.squareup.okhttp.HttpUrl) BufferedSource(okio.BufferedSource)

Aggregations

Call (com.squareup.okhttp.Call)46 Type (java.lang.reflect.Type)28 Request (com.squareup.okhttp.Request)13 Response (com.squareup.okhttp.Response)13 OkHttpClient (com.squareup.okhttp.OkHttpClient)9 PaymentDetails (jp.ne.paypay.model.PaymentDetails)8 RequestBody (com.squareup.okhttp.RequestBody)5 IOException (java.io.IOException)5 HttpUrl (com.squareup.okhttp.HttpUrl)4 HashMap (java.util.HashMap)4 ReverseCashbackDetails (jp.ne.paypay.model.ReverseCashbackDetails)4 TypeToken (com.google.gson.reflect.TypeToken)3 NotDataResponse (jp.ne.paypay.model.NotDataResponse)3 Base64 (org.apache.commons.codec.binary.Base64)3 Pair (jp.ne.paypay.Pair)2 Request (com.android.volley.Request)1 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)1 ApiCommandList (com.cloudera.api.swagger.model.ApiCommandList)1 ApiHost (com.cloudera.api.swagger.model.ApiHost)1 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)1