|
10 | 10 | * Do not edit the class manually. |
11 | 11 | */ |
12 | 12 |
|
13 | | - |
14 | 13 | package Api; |
15 | 14 |
|
| 15 | +import java.io.IOException; |
| 16 | +import java.lang.reflect.Type; |
| 17 | +import java.util.ArrayList; |
| 18 | +import java.util.HashMap; |
| 19 | +import java.util.List; |
| 20 | +import java.util.Map; |
| 21 | + |
| 22 | +import com.google.gson.reflect.TypeToken; |
| 23 | + |
16 | 24 | import Invokers.ApiCallback; |
17 | 25 | import Invokers.ApiClient; |
18 | 26 | import Invokers.ApiException; |
|
21 | 29 | import Invokers.Pair; |
22 | 30 | import Invokers.ProgressRequestBody; |
23 | 31 | import Invokers.ProgressResponseBody; |
24 | | - |
25 | | -import com.cybersource.authsdk.core.MerchantConfig; |
26 | | -import com.google.gson.reflect.TypeToken; |
27 | | - |
28 | | -import java.io.IOException; |
29 | | - |
30 | | - |
31 | 32 | import Model.CreatePaymentRequest; |
32 | 33 | import Model.PtsV2PaymentsPost201Response; |
33 | | -import Model.PtsV2PaymentsPost400Response; |
34 | | -import Model.PtsV2PaymentsPost502Response; |
35 | | - |
36 | | -import java.lang.reflect.Type; |
37 | | -import java.util.ArrayList; |
38 | | -import java.util.HashMap; |
39 | | -import java.util.List; |
40 | | -import java.util.Map; |
41 | 34 |
|
42 | 35 | public class PaymentsApi { |
43 | | - private ApiClient apiClient; |
44 | | - public MerchantConfig merchantConfig; |
45 | | - |
46 | | - public PaymentsApi() { |
47 | | - this(Configuration.getDefaultApiClient()); |
48 | | - } |
49 | | - |
50 | | - public PaymentsApi(ApiClient apiClient) { |
51 | | - this.apiClient = apiClient; |
52 | | - } |
53 | | - |
54 | | - public ApiClient getApiClient() { |
55 | | - return apiClient; |
56 | | - } |
57 | | - |
58 | | - public void setApiClient(ApiClient apiClient) { |
59 | | - this.apiClient = apiClient; |
60 | | - } |
61 | | - |
62 | | - /** |
63 | | - * Build call for createPayment |
64 | | - * @param createPaymentRequest (required) |
65 | | - * @param progressListener Progress listener |
66 | | - * @param progressRequestListener Progress request listener |
67 | | - * @return Call to execute |
68 | | - * @throws ApiException If fail to serialize the request body object |
69 | | - */ |
70 | | - public com.squareup.okhttp.Call createPaymentCall(CreatePaymentRequest createPaymentRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
71 | | - Object localVarPostBody = createPaymentRequest; |
72 | | - |
73 | | - // create path and map variables |
74 | | - String localVarPath = "/pts/v2/payments/"; |
75 | | - |
76 | | - List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
77 | | - |
78 | | - Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
79 | | - |
80 | | - Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
81 | | - |
82 | | - final String[] localVarAccepts = { |
83 | | - "application/hal+json" |
84 | | - }; |
85 | | - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
86 | | - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
87 | | - |
88 | | - final String[] localVarContentTypes = { |
89 | | - "application/json" |
90 | | - }; |
91 | | - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
92 | | - localVarHeaderParams.put("Content-Type", localVarContentType); |
93 | | - |
94 | | - if(progressListener != null) { |
95 | | - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
96 | | - @Override |
97 | | - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { |
98 | | - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); |
99 | | - return originalResponse.newBuilder() |
100 | | - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
101 | | - .build(); |
102 | | - } |
103 | | - }); |
104 | | - } |
105 | | - |
106 | | - String[] localVarAuthNames = new String[] { }; |
107 | | - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
108 | | - } |
109 | | - |
110 | | - @SuppressWarnings("rawtypes") |
111 | | - private com.squareup.okhttp.Call createPaymentValidateBeforeCall(CreatePaymentRequest createPaymentRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
112 | | - |
113 | | - // verify the required parameter 'createPaymentRequest' is set |
114 | | - if (createPaymentRequest == null) { |
115 | | - throw new ApiException("Missing the required parameter 'createPaymentRequest' when calling createPayment(Async)"); |
116 | | - } |
117 | | - |
118 | | - |
119 | | - com.squareup.okhttp.Call call = createPaymentCall(createPaymentRequest, progressListener, progressRequestListener); |
120 | | - return call; |
121 | | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - } |
127 | | - |
128 | | - /** |
129 | | - * Process a Payment |
130 | | - * Authorize the payment for the transaction. |
131 | | - * @param createPaymentRequest (required) |
132 | | - * @return PtsV2PaymentsPost201Response |
133 | | - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
134 | | - */ |
135 | | - public PtsV2PaymentsPost201Response createPayment(CreatePaymentRequest createPaymentRequest) throws ApiException { |
136 | | - ApiResponse<PtsV2PaymentsPost201Response> resp = createPaymentWithHttpInfo(createPaymentRequest); |
137 | | - return resp.getData(); |
138 | | - } |
139 | | - |
140 | | - /** |
141 | | - * Process a Payment |
142 | | - * Authorize the payment for the transaction. |
143 | | - * @param createPaymentRequest (required) |
144 | | - * @return ApiResponse<PtsV2PaymentsPost201Response> |
145 | | - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
146 | | - */ |
147 | | - public ApiResponse<PtsV2PaymentsPost201Response> createPaymentWithHttpInfo(CreatePaymentRequest createPaymentRequest) throws ApiException { |
148 | | - com.squareup.okhttp.Call call = createPaymentValidateBeforeCall(createPaymentRequest, null, null); |
149 | | - Type localVarReturnType = new TypeToken<PtsV2PaymentsPost201Response>(){}.getType(); |
150 | | - return apiClient.execute(call, localVarReturnType); |
151 | | - } |
152 | | - |
153 | | - /** |
154 | | - * Process a Payment (asynchronously) |
155 | | - * Authorize the payment for the transaction. |
156 | | - * @param createPaymentRequest (required) |
157 | | - * @param callback The callback to be executed when the API call finishes |
158 | | - * @return The request call |
159 | | - * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
160 | | - */ |
161 | | - public com.squareup.okhttp.Call createPaymentAsync(CreatePaymentRequest createPaymentRequest, final ApiCallback<PtsV2PaymentsPost201Response> callback) throws ApiException { |
162 | | - |
163 | | - ProgressResponseBody.ProgressListener progressListener = null; |
164 | | - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
165 | | - |
166 | | - if (callback != null) { |
167 | | - progressListener = new ProgressResponseBody.ProgressListener() { |
168 | | - @Override |
169 | | - public void update(long bytesRead, long contentLength, boolean done) { |
170 | | - callback.onDownloadProgress(bytesRead, contentLength, done); |
171 | | - } |
172 | | - }; |
173 | | - |
174 | | - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
175 | | - @Override |
176 | | - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
177 | | - callback.onUploadProgress(bytesWritten, contentLength, done); |
178 | | - } |
179 | | - }; |
180 | | - } |
181 | | - |
182 | | - com.squareup.okhttp.Call call = createPaymentValidateBeforeCall(createPaymentRequest, progressListener, progressRequestListener); |
183 | | - Type localVarReturnType = new TypeToken<PtsV2PaymentsPost201Response>(){}.getType(); |
184 | | - apiClient.executeAsync(call, localVarReturnType, callback); |
185 | | - return call; |
186 | | - } |
| 36 | + private ApiClient apiClient; |
| 37 | + |
| 38 | + public PaymentsApi() { |
| 39 | + this(Configuration.getDefaultApiClient()); |
| 40 | + } |
| 41 | + |
| 42 | + public PaymentsApi(ApiClient apiClient) { |
| 43 | + this.apiClient = apiClient; |
| 44 | + } |
| 45 | + |
| 46 | + public ApiClient getApiClient() { |
| 47 | + return apiClient; |
| 48 | + } |
| 49 | + |
| 50 | + public void setApiClient(ApiClient apiClient) { |
| 51 | + this.apiClient = apiClient; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Build call for createPayment |
| 56 | + * |
| 57 | + * @param createPaymentRequest |
| 58 | + * (required) |
| 59 | + * @param progressListener |
| 60 | + * Progress listener |
| 61 | + * @param progressRequestListener |
| 62 | + * Progress request listener |
| 63 | + * @return Call to execute |
| 64 | + * @throws ApiException |
| 65 | + * If fail to serialize the request body object |
| 66 | + */ |
| 67 | + public com.squareup.okhttp.Call createPaymentCall(CreatePaymentRequest createPaymentRequest, |
| 68 | + final ProgressResponseBody.ProgressListener progressListener, |
| 69 | + final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 70 | + Object localVarPostBody = createPaymentRequest; |
| 71 | + |
| 72 | + // create path and map variables |
| 73 | + String localVarPath = "/pts/v2/payments/"; |
| 74 | + |
| 75 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 76 | + |
| 77 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 78 | + |
| 79 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 80 | + |
| 81 | + final String[] localVarAccepts = { "application/hal+json" }; |
| 82 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 83 | + if (localVarAccept != null) |
| 84 | + localVarHeaderParams.put("Accept", localVarAccept); |
| 85 | + |
| 86 | + final String[] localVarContentTypes = { "application/json" }; |
| 87 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 88 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 89 | + |
| 90 | + if (progressListener != null) { |
| 91 | + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
| 92 | + @Override |
| 93 | + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) |
| 94 | + throws IOException { |
| 95 | + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); |
| 96 | + return originalResponse.newBuilder() |
| 97 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); |
| 98 | + } |
| 99 | + }); |
| 100 | + } |
| 101 | + |
| 102 | + String[] localVarAuthNames = new String[] {}; |
| 103 | + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, |
| 104 | + localVarFormParams, localVarAuthNames, progressRequestListener); |
| 105 | + } |
| 106 | + |
| 107 | + @SuppressWarnings("rawtypes") |
| 108 | + private com.squareup.okhttp.Call createPaymentValidateBeforeCall(CreatePaymentRequest createPaymentRequest, |
| 109 | + final ProgressResponseBody.ProgressListener progressListener, |
| 110 | + final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 111 | + |
| 112 | + // verify the required parameter 'createPaymentRequest' is set |
| 113 | + if (createPaymentRequest == null) { |
| 114 | + throw new ApiException( |
| 115 | + "Missing the required parameter 'createPaymentRequest' when calling createPayment(Async)"); |
| 116 | + } |
| 117 | + |
| 118 | + com.squareup.okhttp.Call call = createPaymentCall(createPaymentRequest, progressListener, |
| 119 | + progressRequestListener); |
| 120 | + return call; |
| 121 | + |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Process a Payment Authorize the payment for the transaction. |
| 126 | + * |
| 127 | + * @param createPaymentRequest |
| 128 | + * (required) |
| 129 | + * @return PtsV2PaymentsPost201Response |
| 130 | + * @throws ApiException |
| 131 | + * If fail to call the API, e.g. server error or cannot |
| 132 | + * deserialize the response body |
| 133 | + */ |
| 134 | + public PtsV2PaymentsPost201Response createPayment(CreatePaymentRequest createPaymentRequest) throws ApiException { |
| 135 | + ApiResponse<PtsV2PaymentsPost201Response> resp = createPaymentWithHttpInfo(createPaymentRequest); |
| 136 | + return resp.getData(); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Process a Payment Authorize the payment for the transaction. |
| 141 | + * |
| 142 | + * @param createPaymentRequest |
| 143 | + * (required) |
| 144 | + * @return ApiResponse<PtsV2PaymentsPost201Response> |
| 145 | + * @throws ApiException |
| 146 | + * If fail to call the API, e.g. server error or cannot |
| 147 | + * deserialize the response body |
| 148 | + */ |
| 149 | + public ApiResponse<PtsV2PaymentsPost201Response> createPaymentWithHttpInfo( |
| 150 | + CreatePaymentRequest createPaymentRequest) throws ApiException { |
| 151 | + com.squareup.okhttp.Call call = createPaymentValidateBeforeCall(createPaymentRequest, null, null); |
| 152 | + Type localVarReturnType = new TypeToken<PtsV2PaymentsPost201Response>() { |
| 153 | + }.getType(); |
| 154 | + return apiClient.execute(call, localVarReturnType); |
| 155 | + } |
| 156 | + |
| 157 | + /** |
| 158 | + * Process a Payment (asynchronously) Authorize the payment for the |
| 159 | + * transaction. |
| 160 | + * |
| 161 | + * @param createPaymentRequest |
| 162 | + * (required) |
| 163 | + * @param callback |
| 164 | + * The callback to be executed when the API call finishes |
| 165 | + * @return The request call |
| 166 | + * @throws ApiException |
| 167 | + * If fail to process the API call, e.g. serializing the request |
| 168 | + * body object |
| 169 | + */ |
| 170 | + public com.squareup.okhttp.Call createPaymentAsync(CreatePaymentRequest createPaymentRequest, |
| 171 | + final ApiCallback<PtsV2PaymentsPost201Response> callback) throws ApiException { |
| 172 | + |
| 173 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 174 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 175 | + |
| 176 | + if (callback != null) { |
| 177 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 178 | + @Override |
| 179 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 180 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 181 | + } |
| 182 | + }; |
| 183 | + |
| 184 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 185 | + @Override |
| 186 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 187 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 188 | + } |
| 189 | + }; |
| 190 | + } |
| 191 | + |
| 192 | + com.squareup.okhttp.Call call = createPaymentValidateBeforeCall(createPaymentRequest, progressListener, |
| 193 | + progressRequestListener); |
| 194 | + Type localVarReturnType = new TypeToken<PtsV2PaymentsPost201Response>() { |
| 195 | + }.getType(); |
| 196 | + apiClient.executeAsync(call, localVarReturnType, callback); |
| 197 | + return call; |
| 198 | + } |
187 | 199 | } |
0 commit comments