Search in sources :

Example 1 with Pair

use of jp.ne.paypay.Pair in project paypayopa-sdk-java by paypay.

the class HmacAuthTest method hmacAuthTest.

@Test
public void hmacAuthTest() {
    HmacAuth hmacAuth = new HmacAuth();
    hmacAuth.setApiKey("API_KEY");
    hmacAuth.setApiSecretKey("SECRET_KEY");
    hmacAuth.setContentType("Application/Json");
    hmacAuth.setHttpMethod("POST");
    hmacAuth.setRequestUrl("/v2/api/test");
    QRCode qrCode = new QRCode();
    qrCode.setMerchantPaymentId(UUID.randomUUID().toString());
    hmacAuth.setRequestBody(qrCode.toString());
    Map<String, String> headerParams = new HashMap<>();
    List<Pair> queryParams = new ArrayList<>();
    hmacAuth.applyToParams(queryParams, headerParams);
    Assert.assertTrue(headerParams.get("Authorization").startsWith("hmac"));
    Assert.assertNotNull(hmacAuth.getApiKey());
    Assert.assertNotNull(hmacAuth.getApiSecretKey());
    Assert.assertNotNull(hmacAuth.getContentType());
    Assert.assertNotNull(hmacAuth.getHttpMethod());
    Assert.assertNotNull(hmacAuth.getRequestBody());
    Assert.assertNotNull(hmacAuth.getRequestUrl());
    hmacAuth.setRequestUrl("/v2/api/test?param=p1");
    hmacAuth.applyToParams(queryParams, headerParams);
    Assert.assertTrue(headerParams.get("Authorization").startsWith("hmac"));
    hmacAuth.setRequestUrl(null);
    hmacAuth.applyToParams(queryParams, headerParams);
    Assert.assertTrue(headerParams.get("Authorization").startsWith("hmac"));
    hmacAuth.setContentType(null);
    headerParams = new HashMap<>();
    hmacAuth.applyToParams(queryParams, headerParams);
    Assert.assertNull(headerParams.get("Authorization"));
}
Also used : QRCode(jp.ne.paypay.model.QRCode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HmacAuth(jp.ne.paypay.auth.HmacAuth) Pair(jp.ne.paypay.Pair) Test(org.junit.jupiter.api.Test)

Example 2 with Pair

use of jp.ne.paypay.Pair in project paypayopa-sdk-java by paypay.

the class CashbackApi method getCashbackDetailsWithHttpInfo.

/**
 * Check Cashback Details
 * Check the cashback details of the cashback given  **Timeout: 15s**
 *
 * @param merchantCashbackId (required)
 * @return ApiResponse&lt;CashbackDetails&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<CashbackDetails> getCashbackDetailsWithHttpInfo(String merchantCashbackId) throws ApiException {
    Call call = ApiUtil.getCallObject(apiClient, "/v2/cashback/{merchantCashbackId}", new Pair(ApiConstants.MERCHANT_CASHBACK_ID, merchantCashbackId), "GET");
    Type localVarReturnType = new TypeToken<CashbackDetails>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.GET_CASHBACK_DETAILS);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) ReverseCashbackDetails(jp.ne.paypay.model.ReverseCashbackDetails) CashbackDetails(jp.ne.paypay.model.CashbackDetails) Pair(jp.ne.paypay.Pair)

Example 3 with Pair

use of jp.ne.paypay.Pair in project paypayopa-sdk-java by paypay.

the class ApiClientTest method buildRequest.

@Test
public void buildRequest() throws ApiException {
    List<Pair> queryParams = new ArrayList<>();
    queryParams.add(new Pair("name", "paypay"));
    QRCode qrCode = new QRCode();
    qrCode.setMerchantPaymentId("maerchant_payemnt_id");
    Map<String, String> headerParams = new HashMap<>();
    headerParams.put("content-type", "application/json");
    String[] localVarAuthNames = new String[] { "HmacAuth" };
    Request request = apiClient.buildRequest("/v2/qrcode", "POST", queryParams, queryParams, qrCode, headerParams, null, localVarAuthNames);
    Assert.assertEquals(request.method(), "POST");
    Assert.assertTrue(request.urlString().contains("/v2/qrcode"));
    request = apiClient.buildRequest("/v2/qrcode", "POST", queryParams, queryParams, null, headerParams, null, localVarAuthNames);
    Assert.assertNotNull(request.body());
    request = apiClient.buildRequest("/v2/qrcode", "DELETE", queryParams, queryParams, null, headerParams, null, localVarAuthNames);
    Assert.assertNull(request.body());
}
Also used : QRCode(jp.ne.paypay.model.QRCode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Request(com.squareup.okhttp.Request) Pair(jp.ne.paypay.Pair) Test(org.junit.jupiter.api.Test)

Example 4 with Pair

use of jp.ne.paypay.Pair in project paypayopa-sdk-java by paypay.

the class CashbackApi method getReversedCashbackDetailsWithHttpInfo.

/**
 * Check Cashback Reversal Details
 * Check the cashback reversal details of the cashback reversed  **Timeout: 15s**
 *
 * @param merchantCashbackReversalId (required)
 * @param merchantCashbackId (required)
 * @return ApiResponse&lt;ReverseCashbackDetails&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
protected ApiResponse<ReverseCashbackDetails> getReversedCashbackDetailsWithHttpInfo(String merchantCashbackReversalId, String merchantCashbackId) throws ApiException {
    if (StringUtils.isEmpty(merchantCashbackReversalId)) {
        throw new IllegalArgumentException("Missing the required parameter merchantCashbackReversalId");
    }
    Call call = ApiUtil.getCallObject(apiClient, "/v2/cashback_reversal/" + apiClient.escapeString(merchantCashbackReversalId) + "/{merchantCashbackId}", new Pair(ApiConstants.MERCHANT_CASHBACK_ID, merchantCashbackId), "GET");
    Type localVarReturnType = new TypeToken<ReverseCashbackDetails>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType, ApiNameConstants.GET_REVERSED_CASHBACK_DETAILS);
}
Also used : Call(com.squareup.okhttp.Call) Type(java.lang.reflect.Type) ReverseCashbackDetails(jp.ne.paypay.model.ReverseCashbackDetails) Pair(jp.ne.paypay.Pair)

Aggregations

Pair (jp.ne.paypay.Pair)4 Call (com.squareup.okhttp.Call)2 Type (java.lang.reflect.Type)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 QRCode (jp.ne.paypay.model.QRCode)2 ReverseCashbackDetails (jp.ne.paypay.model.ReverseCashbackDetails)2 Test (org.junit.jupiter.api.Test)2 Request (com.squareup.okhttp.Request)1 HmacAuth (jp.ne.paypay.auth.HmacAuth)1 CashbackDetails (jp.ne.paypay.model.CashbackDetails)1