|
21 | 21 | import com.coinbase.cdp.openapi.model.CreateEvmEip7702DelegationWithEndUserAccountRequest; |
22 | 22 | import com.coinbase.cdp.openapi.model.Error; |
23 | 23 | import com.coinbase.cdp.openapi.model.EvmUserOperation; |
| 24 | +import com.coinbase.cdp.openapi.model.GetDelegationForEndUser200Response; |
24 | 25 | import com.coinbase.cdp.openapi.model.RevokeDelegationForEndUserRequest; |
25 | 26 | import com.coinbase.cdp.openapi.model.SendEvmAssetWithEndUserAccount200Response; |
26 | 27 | import com.coinbase.cdp.openapi.model.SendEvmAssetWithEndUserAccountRequest; |
@@ -231,6 +232,107 @@ private HttpRequest.Builder createEvmEip7702DelegationWithEndUserAccountRequestB |
231 | 232 | return localVarRequestBuilder; |
232 | 233 | } |
233 | 234 |
|
| 235 | + /** |
| 236 | + * Get delegation for end user |
| 237 | + * Returns the active delegation for the specified end user, if one exists. This operation can be performed by the end user themselves or by a developer using their API key. |
| 238 | + * @param userId The ID of the end user. (required) |
| 239 | + * @param projectID The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider). (optional) |
| 240 | + * @return GetDelegationForEndUser200Response |
| 241 | + * @throws ApiException if fails to make API call |
| 242 | + */ |
| 243 | + public GetDelegationForEndUser200Response getDelegationForEndUser(String userId, String projectID) throws ApiException { |
| 244 | + ApiResponse<GetDelegationForEndUser200Response> localVarResponse = getDelegationForEndUserWithHttpInfo(userId, projectID); |
| 245 | + return localVarResponse.getData(); |
| 246 | + } |
| 247 | + |
| 248 | + /** |
| 249 | + * Get delegation for end user |
| 250 | + * Returns the active delegation for the specified end user, if one exists. This operation can be performed by the end user themselves or by a developer using their API key. |
| 251 | + * @param userId The ID of the end user. (required) |
| 252 | + * @param projectID The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider). (optional) |
| 253 | + * @return ApiResponse<GetDelegationForEndUser200Response> |
| 254 | + * @throws ApiException if fails to make API call |
| 255 | + */ |
| 256 | + public ApiResponse<GetDelegationForEndUser200Response> getDelegationForEndUserWithHttpInfo(String userId, String projectID) throws ApiException { |
| 257 | + HttpRequest.Builder localVarRequestBuilder = getDelegationForEndUserRequestBuilder(userId, projectID); |
| 258 | + try { |
| 259 | + HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send( |
| 260 | + localVarRequestBuilder.build(), |
| 261 | + HttpResponse.BodyHandlers.ofInputStream()); |
| 262 | + if (memberVarResponseInterceptor != null) { |
| 263 | + memberVarResponseInterceptor.accept(localVarResponse); |
| 264 | + } |
| 265 | + try { |
| 266 | + if (localVarResponse.statusCode()/ 100 != 2) { |
| 267 | + throw getApiException("getDelegationForEndUser", localVarResponse); |
| 268 | + } |
| 269 | + if (localVarResponse.body() == null) { |
| 270 | + return new ApiResponse<GetDelegationForEndUser200Response>( |
| 271 | + localVarResponse.statusCode(), |
| 272 | + localVarResponse.headers().map(), |
| 273 | + null |
| 274 | + ); |
| 275 | + } |
| 276 | + |
| 277 | + String responseBody = new String(localVarResponse.body().readAllBytes()); |
| 278 | + localVarResponse.body().close(); |
| 279 | + |
| 280 | + return new ApiResponse<GetDelegationForEndUser200Response>( |
| 281 | + localVarResponse.statusCode(), |
| 282 | + localVarResponse.headers().map(), |
| 283 | + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<GetDelegationForEndUser200Response>() {}) |
| 284 | + ); |
| 285 | + } finally { |
| 286 | + } |
| 287 | + } catch (IOException e) { |
| 288 | + throw new ApiException(e); |
| 289 | + } |
| 290 | + catch (InterruptedException e) { |
| 291 | + Thread.currentThread().interrupt(); |
| 292 | + throw new ApiException(e); |
| 293 | + } |
| 294 | + } |
| 295 | + |
| 296 | + private HttpRequest.Builder getDelegationForEndUserRequestBuilder(String userId, String projectID) throws ApiException { |
| 297 | + // verify the required parameter 'userId' is set |
| 298 | + if (userId == null) { |
| 299 | + throw new ApiException(400, "Missing the required parameter 'userId' when calling getDelegationForEndUser"); |
| 300 | + } |
| 301 | + |
| 302 | + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); |
| 303 | + |
| 304 | + String localVarPath = "/v2/embedded-wallet-api/end-users/{userId}/delegation" |
| 305 | + .replace("{userId}", ApiClient.urlEncode(userId.toString())); |
| 306 | + |
| 307 | + List<Pair> localVarQueryParams = new ArrayList<>(); |
| 308 | + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); |
| 309 | + String localVarQueryParameterBaseName; |
| 310 | + localVarQueryParameterBaseName = "projectID"; |
| 311 | + localVarQueryParams.addAll(ApiClient.parameterToPairs("projectID", projectID)); |
| 312 | + |
| 313 | + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { |
| 314 | + StringJoiner queryJoiner = new StringJoiner("&"); |
| 315 | + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); |
| 316 | + if (localVarQueryStringJoiner.length() != 0) { |
| 317 | + queryJoiner.add(localVarQueryStringJoiner.toString()); |
| 318 | + } |
| 319 | + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); |
| 320 | + } else { |
| 321 | + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); |
| 322 | + } |
| 323 | + |
| 324 | + localVarRequestBuilder.header("Accept", "application/json"); |
| 325 | + |
| 326 | + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); |
| 327 | + if (memberVarReadTimeout != null) { |
| 328 | + localVarRequestBuilder.timeout(memberVarReadTimeout); |
| 329 | + } |
| 330 | + if (memberVarInterceptor != null) { |
| 331 | + memberVarInterceptor.accept(localVarRequestBuilder); |
| 332 | + } |
| 333 | + return localVarRequestBuilder; |
| 334 | + } |
| 335 | + |
234 | 336 | /** |
235 | 337 | * Revoke delegation for end user |
236 | 338 | * Revokes all active delegations for the specified end user. This operation can be performed by the end user themselves or by a developer using their API key. |
|
0 commit comments