From 379283d987266ef09533d5fcfd91a2c075e457f5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:26:36 +0300 Subject: [PATCH] Generated SDK #7984 (#62) Co-authored-by: fireblocks_dx_team --- .openapi-generator/FILES | 2 + .../com/fireblocks/sdk/ValidationUtils.java | 39 ++ .../com/fireblocks/sdk/api/AssetsApi.java | 10 +- .../sdk/api/ContractInteractionsApi.java | 65 +-- .../sdk/api/ContractTemplatesApi.java | 73 +--- .../com/fireblocks/sdk/api/ContractsApi.java | 54 +-- .../fireblocks/sdk/api/CosignersBetaApi.java | 42 +- .../sdk/api/DeployedContractsApi.java | 26 +- .../sdk/api/ExchangeAccountsApi.java | 52 +-- .../sdk/api/ExternalWalletsApi.java | 87 +--- .../fireblocks/sdk/api/FiatAccountsApi.java | 25 +- .../fireblocks/sdk/api/GasStationsApi.java | 39 +- .../sdk/api/InternalWalletsApi.java | 87 +--- .../fireblocks/sdk/api/JobManagementApi.java | 31 +- .../fireblocks/sdk/api/KeyLinkBetaApi.java | 77 +--- .../sdk/api/NetworkConnectionsApi.java | 99 ++--- .../java/com/fireblocks/sdk/api/NftsApi.java | 76 +--- .../fireblocks/sdk/api/OffExchangesApi.java | 21 +- .../com/fireblocks/sdk/api/OtaBetaApi.java | 10 +- .../fireblocks/sdk/api/PaymentsPayoutApi.java | 14 +- .../sdk/api/PolicyEditorBetaApi.java | 23 +- .../fireblocks/sdk/api/ResetDeviceApi.java | 7 +- .../fireblocks/sdk/api/SmartTransferApi.java | 196 ++------- .../fireblocks/sdk/api/StakingBetaApi.java | 47 +-- .../fireblocks/sdk/api/TokenizationApi.java | 27 +- .../fireblocks/sdk/api/TransactionsApi.java | 77 +--- .../fireblocks/sdk/api/TravelRuleBetaApi.java | 38 +- .../fireblocks/sdk/api/UserGroupsBetaApi.java | 37 +- .../com/fireblocks/sdk/api/VaultsApi.java | 383 ++++-------------- .../sdk/api/Web3ConnectionsApi.java | 28 +- .../com/fireblocks/sdk/api/WebhooksApi.java | 19 +- .../sdk/api/WhitelistIpAddressesApi.java | 8 +- .../fireblocks/sdk/ValidationUtilsTest.java | 66 +++ 33 files changed, 517 insertions(+), 1368 deletions(-) create mode 100644 src/main/java/com/fireblocks/sdk/ValidationUtils.java create mode 100644 src/test/java/com/fireblocks/sdk/ValidationUtilsTest.java diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 62d9643..d67144e 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -506,6 +506,7 @@ src/main/java/com/fireblocks/sdk/ServerConfiguration.java src/main/java/com/fireblocks/sdk/ServerVariable.java src/main/java/com/fireblocks/sdk/SystemWrapper.java src/main/java/com/fireblocks/sdk/UserAgentUtil.java +src/main/java/com/fireblocks/sdk/ValidationUtils.java src/main/java/com/fireblocks/sdk/api/ApiUserApi.java src/main/java/com/fireblocks/sdk/api/AssetsApi.java src/main/java/com/fireblocks/sdk/api/AuditLogsApi.java @@ -986,6 +987,7 @@ src/test/java/com/fireblocks/sdk/ConfigurationOptionsTest.java src/test/java/com/fireblocks/sdk/DummyTestKey.txt src/test/java/com/fireblocks/sdk/FireblocksTest.java src/test/java/com/fireblocks/sdk/UserAgentUtilTest.java +src/test/java/com/fireblocks/sdk/ValidationUtilsTest.java src/test/java/com/fireblocks/sdk/api/ApiUserApiTest.java src/test/java/com/fireblocks/sdk/api/AssetsApiTest.java src/test/java/com/fireblocks/sdk/api/AuditLogsApiTest.java diff --git a/src/main/java/com/fireblocks/sdk/ValidationUtils.java b/src/main/java/com/fireblocks/sdk/ValidationUtils.java new file mode 100644 index 0000000..68930b1 --- /dev/null +++ b/src/main/java/com/fireblocks/sdk/ValidationUtils.java @@ -0,0 +1,39 @@ +/* + * Fireblocks API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.6.2 + * Contact: support@fireblocks.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.fireblocks.sdk; + +public class ValidationUtils { + + public static void assertParamExistsAndNotEmpty( + String functionName, String paramName, String paramValue) throws ApiException { + ValidationUtils.assertParamExists(functionName, paramName, paramValue); + if (paramValue.isEmpty()) { + throw new ApiException( + 400, + String.format( + "The required parameter '%s' was empty when calling '%s'", + paramName, functionName)); + } + } + + public static void assertParamExists(String functionName, String paramName, Object paramValue) + throws ApiException { + if (paramValue == null) { + throw new ApiException( + 400, + String.format( + "The required parameter '%s' is missing from call to '%s'", + paramName, functionName)); + } + } +} diff --git a/src/main/java/com/fireblocks/sdk/api/AssetsApi.java b/src/main/java/com/fireblocks/sdk/api/AssetsApi.java index 3bab81d..47d535a 100644 --- a/src/main/java/com/fireblocks/sdk/api/AssetsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/AssetsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateAssetsBulkRequest; import com.fireblocks.sdk.model.JobCreated; import java.io.IOException; @@ -122,13 +123,8 @@ public CompletableFuture> createAssetsBulk( private HttpRequest.Builder createAssetsBulkRequestBuilder( CreateAssetsBulkRequest createAssetsBulkRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'createAssetsBulkRequest' is set - if (createAssetsBulkRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createAssetsBulkRequest' when calling" - + " createAssetsBulk"); - } + ValidationUtils.assertParamExists( + "createAssetsBulk", "createAssetsBulkRequest", createAssetsBulkRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/ContractInteractionsApi.java b/src/main/java/com/fireblocks/sdk/api/ContractInteractionsApi.java index 5cc7d19..faf3c3c 100644 --- a/src/main/java/com/fireblocks/sdk/api/ContractInteractionsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/ContractInteractionsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.ContractAbiResponseDto; import com.fireblocks.sdk.model.ParameterWithValue; import com.fireblocks.sdk.model.ReadCallFunctionDto; @@ -124,19 +125,9 @@ public CompletableFuture> getDeployedContrac private HttpRequest.Builder getDeployedContractAbiRequestBuilder( String contractAddress, String assetId, String idempotencyKey) throws ApiException { - // verify the required parameter 'contractAddress' is set - if (contractAddress == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractAddress' when calling" - + " getDeployedContractAbi"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getDeployedContractAbi"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getDeployedContractAbi", "contractAddress", contractAddress); + ValidationUtils.assertParamExistsAndNotEmpty("getDeployedContractAbi", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -225,25 +216,11 @@ private HttpRequest.Builder readCallFunctionRequestBuilder( String assetId, String idempotencyKey) throws ApiException { - // verify the required parameter 'readCallFunctionDto' is set - if (readCallFunctionDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'readCallFunctionDto' when calling" - + " readCallFunction"); - } - // verify the required parameter 'contractAddress' is set - if (contractAddress == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractAddress' when calling" - + " readCallFunction"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, "Missing the required parameter 'assetId' when calling readCallFunction"); - } + ValidationUtils.assertParamExists( + "readCallFunction", "readCallFunctionDto", readCallFunctionDto); + ValidationUtils.assertParamExistsAndNotEmpty( + "readCallFunction", "contractAddress", contractAddress); + ValidationUtils.assertParamExistsAndNotEmpty("readCallFunction", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -339,25 +316,11 @@ private HttpRequest.Builder writeCallFunctionRequestBuilder( String assetId, String idempotencyKey) throws ApiException { - // verify the required parameter 'writeCallFunctionDto' is set - if (writeCallFunctionDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'writeCallFunctionDto' when calling" - + " writeCallFunction"); - } - // verify the required parameter 'contractAddress' is set - if (contractAddress == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractAddress' when calling" - + " writeCallFunction"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, "Missing the required parameter 'assetId' when calling writeCallFunction"); - } + ValidationUtils.assertParamExists( + "writeCallFunction", "writeCallFunctionDto", writeCallFunctionDto); + ValidationUtils.assertParamExistsAndNotEmpty( + "writeCallFunction", "contractAddress", contractAddress); + ValidationUtils.assertParamExistsAndNotEmpty("writeCallFunction", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/ContractTemplatesApi.java b/src/main/java/com/fireblocks/sdk/api/ContractTemplatesApi.java index e5e3ff5..fe77e35 100644 --- a/src/main/java/com/fireblocks/sdk/api/ContractTemplatesApi.java +++ b/src/main/java/com/fireblocks/sdk/api/ContractTemplatesApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.AbiFunction; import com.fireblocks.sdk.model.ContractDeployRequest; import com.fireblocks.sdk.model.ContractDeployResponse; @@ -116,13 +117,8 @@ public CompletableFuture> deleteContractTemplateById( private HttpRequest.Builder deleteContractTemplateByIdRequestBuilder(String contractTemplateId) throws ApiException { - // verify the required parameter 'contractTemplateId' is set - if (contractTemplateId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractTemplateId' when calling" - + " deleteContractTemplateById"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "deleteContractTemplateById", "contractTemplateId", contractTemplateId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -203,20 +199,10 @@ private HttpRequest.Builder deployContractRequestBuilder( String contractTemplateId, String idempotencyKey) throws ApiException { - // verify the required parameter 'contractDeployRequest' is set - if (contractDeployRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractDeployRequest' when calling" - + " deployContract"); - } - // verify the required parameter 'contractTemplateId' is set - if (contractTemplateId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractTemplateId' when calling" - + " deployContract"); - } + ValidationUtils.assertParamExists( + "deployContract", "contractDeployRequest", contractDeployRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "deployContract", "contractTemplateId", contractTemplateId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -299,13 +285,8 @@ public CompletableFuture> getConstructorByContractTempl private HttpRequest.Builder getConstructorByContractTemplateIdRequestBuilder( String contractTemplateId, Boolean withDocs) throws ApiException { - // verify the required parameter 'contractTemplateId' is set - if (contractTemplateId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractTemplateId' when calling" - + " getConstructorByContractTemplateId"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getConstructorByContractTemplateId", "contractTemplateId", contractTemplateId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -391,13 +372,8 @@ public CompletableFuture> getContractTemplateBy private HttpRequest.Builder getContractTemplateByIdRequestBuilder(String contractTemplateId) throws ApiException { - // verify the required parameter 'contractTemplateId' is set - if (contractTemplateId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractTemplateId' when calling" - + " getContractTemplateById"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getContractTemplateById", "contractTemplateId", contractTemplateId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -584,20 +560,10 @@ public CompletableFuture> getFunctionAbiByContractTempl private HttpRequest.Builder getFunctionAbiByContractTemplateIdRequestBuilder( String contractTemplateId, String functionSignature) throws ApiException { - // verify the required parameter 'contractTemplateId' is set - if (contractTemplateId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractTemplateId' when calling" - + " getFunctionAbiByContractTemplateId"); - } - // verify the required parameter 'functionSignature' is set - if (functionSignature == null) { - throw new ApiException( - 400, - "Missing the required parameter 'functionSignature' when calling" - + " getFunctionAbiByContractTemplateId"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getFunctionAbiByContractTemplateId", "contractTemplateId", contractTemplateId); + ValidationUtils.assertParamExistsAndNotEmpty( + "getFunctionAbiByContractTemplateId", "functionSignature", functionSignature); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -690,13 +656,8 @@ public CompletableFuture> uploadContractTemplat private HttpRequest.Builder uploadContractTemplateRequestBuilder( ContractUploadRequest contractUploadRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'contractUploadRequest' is set - if (contractUploadRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractUploadRequest' when calling" - + " uploadContractTemplate"); - } + ValidationUtils.assertParamExists( + "uploadContractTemplate", "contractUploadRequest", contractUploadRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/ContractsApi.java b/src/main/java/com/fireblocks/sdk/api/ContractsApi.java index 880af50..6e84f57 100644 --- a/src/main/java/com/fireblocks/sdk/api/ContractsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/ContractsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.AddContractAssetRequest; import com.fireblocks.sdk.model.CreateContractRequest; import com.fireblocks.sdk.model.ExternalWalletAsset; @@ -131,17 +132,8 @@ private HttpRequest.Builder addContractAssetRequestBuilder( AddContractAssetRequest addContractAssetRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'contractId' is set - if (contractId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractId' when calling addContractAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, "Missing the required parameter 'assetId' when calling addContractAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty("addContractAsset", "contractId", contractId); + ValidationUtils.assertParamExistsAndNotEmpty("addContractAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -289,11 +281,7 @@ public CompletableFuture> deleteContract(String contractId) private HttpRequest.Builder deleteContractRequestBuilder(String contractId) throws ApiException { - // verify the required parameter 'contractId' is set - if (contractId == null) { - throw new ApiException( - 400, "Missing the required parameter 'contractId' when calling deleteContract"); - } + ValidationUtils.assertParamExistsAndNotEmpty("deleteContract", "contractId", contractId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -352,18 +340,9 @@ public CompletableFuture> deleteContractAsset( private HttpRequest.Builder deleteContractAssetRequestBuilder(String contractId, String assetId) throws ApiException { - // verify the required parameter 'contractId' is set - if (contractId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractId' when calling deleteContractAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling deleteContractAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "deleteContractAsset", "contractId", contractId); + ValidationUtils.assertParamExistsAndNotEmpty("deleteContractAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -429,11 +408,7 @@ public CompletableFuture> getContract(String contra } private HttpRequest.Builder getContractRequestBuilder(String contractId) throws ApiException { - // verify the required parameter 'contractId' is set - if (contractId == null) { - throw new ApiException( - 400, "Missing the required parameter 'contractId' when calling getContract"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getContract", "contractId", contractId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -501,17 +476,8 @@ public CompletableFuture> getContractAsset( private HttpRequest.Builder getContractAssetRequestBuilder(String contractId, String assetId) throws ApiException { - // verify the required parameter 'contractId' is set - if (contractId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractId' when calling getContractAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, "Missing the required parameter 'assetId' when calling getContractAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getContractAsset", "contractId", contractId); + ValidationUtils.assertParamExistsAndNotEmpty("getContractAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/CosignersBetaApi.java b/src/main/java/com/fireblocks/sdk/api/CosignersBetaApi.java index d7caf9b..d3af338 100644 --- a/src/main/java/com/fireblocks/sdk/api/CosignersBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/CosignersBetaApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.ApiKey; import com.fireblocks.sdk.model.ApiKeysPaginatedResponse; import com.fireblocks.sdk.model.Cosigner; @@ -125,16 +126,9 @@ public CompletableFuture> getApiKey(UUID cosignerId, String private HttpRequest.Builder getApiKeyRequestBuilder(UUID cosignerId, String apiKeyId) throws ApiException { - // verify the required parameter 'cosignerId' is set - if (cosignerId == null) { - throw new ApiException( - 400, "Missing the required parameter 'cosignerId' when calling getApiKey"); - } - // verify the required parameter 'apiKeyId' is set - if (apiKeyId == null) { - throw new ApiException( - 400, "Missing the required parameter 'apiKeyId' when calling getApiKey"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getApiKey", "cosignerId", cosignerId.toString()); + ValidationUtils.assertParamExistsAndNotEmpty("getApiKey", "apiKeyId", apiKeyId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -208,11 +202,8 @@ public CompletableFuture> getApiKeys( private HttpRequest.Builder getApiKeysRequestBuilder( UUID cosignerId, String order, String pageCursor, BigDecimal pageSize) throws ApiException { - // verify the required parameter 'cosignerId' is set - if (cosignerId == null) { - throw new ApiException( - 400, "Missing the required parameter 'cosignerId' when calling getApiKeys"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getApiKeys", "cosignerId", cosignerId.toString()); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -298,11 +289,8 @@ public CompletableFuture> getCosigner(UUID cosignerId) } private HttpRequest.Builder getCosignerRequestBuilder(UUID cosignerId) throws ApiException { - // verify the required parameter 'cosignerId' is set - if (cosignerId == null) { - throw new ApiException( - 400, "Missing the required parameter 'cosignerId' when calling getCosigner"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getCosigner", "cosignerId", cosignerId.toString()); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -458,17 +446,9 @@ public CompletableFuture> renameCosigner( private HttpRequest.Builder renameCosignerRequestBuilder( RenameCosigner renameCosigner, UUID cosignerId) throws ApiException { - // verify the required parameter 'renameCosigner' is set - if (renameCosigner == null) { - throw new ApiException( - 400, - "Missing the required parameter 'renameCosigner' when calling renameCosigner"); - } - // verify the required parameter 'cosignerId' is set - if (cosignerId == null) { - throw new ApiException( - 400, "Missing the required parameter 'cosignerId' when calling renameCosigner"); - } + ValidationUtils.assertParamExists("renameCosigner", "renameCosigner", renameCosigner); + ValidationUtils.assertParamExistsAndNotEmpty( + "renameCosigner", "cosignerId", cosignerId.toString()); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/DeployedContractsApi.java b/src/main/java/com/fireblocks/sdk/api/DeployedContractsApi.java index f78dcf2..bc76f89 100644 --- a/src/main/java/com/fireblocks/sdk/api/DeployedContractsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/DeployedContractsApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.DeployedContractResponseDto; import com.fireblocks.sdk.model.DeployedContractsPaginatedResponse; import java.io.IOException; @@ -123,20 +124,10 @@ public CompletableFuture> getDeployedCo private HttpRequest.Builder getDeployedContractByAddressRequestBuilder( String contractAddress, String assetId) throws ApiException { - // verify the required parameter 'contractAddress' is set - if (contractAddress == null) { - throw new ApiException( - 400, - "Missing the required parameter 'contractAddress' when calling" - + " getDeployedContractByAddress"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " getDeployedContractByAddress"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getDeployedContractByAddress", "contractAddress", contractAddress); + ValidationUtils.assertParamExistsAndNotEmpty( + "getDeployedContractByAddress", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -206,12 +197,7 @@ public CompletableFuture> getDeployedCo private HttpRequest.Builder getDeployedContractByIdRequestBuilder(String id) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - 400, - "Missing the required parameter 'id' when calling getDeployedContractById"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getDeployedContractById", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/ExchangeAccountsApi.java b/src/main/java/com/fireblocks/sdk/api/ExchangeAccountsApi.java index ec8b188..38234e7 100644 --- a/src/main/java/com/fireblocks/sdk/api/ExchangeAccountsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/ExchangeAccountsApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.ConvertAssetsRequest; import com.fireblocks.sdk.model.ConvertAssetsResponse; import com.fireblocks.sdk.model.CreateInternalTransferRequest; @@ -139,13 +140,8 @@ private HttpRequest.Builder convertAssetsRequestBuilder( ConvertAssetsRequest convertAssetsRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'exchangeAccountId' is set - if (exchangeAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'exchangeAccountId' when calling" - + " convertAssets"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "convertAssets", "exchangeAccountId", exchangeAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -225,13 +221,8 @@ public CompletableFuture> getExchangeAccount( private HttpRequest.Builder getExchangeAccountRequestBuilder(String exchangeAccountId) throws ApiException { - // verify the required parameter 'exchangeAccountId' is set - if (exchangeAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'exchangeAccountId' when calling" - + " getExchangeAccount"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getExchangeAccount", "exchangeAccountId", exchangeAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -302,20 +293,9 @@ public CompletableFuture> getExchangeAccountAsset( private HttpRequest.Builder getExchangeAccountAssetRequestBuilder( String exchangeAccountId, String assetId) throws ApiException { - // verify the required parameter 'exchangeAccountId' is set - if (exchangeAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'exchangeAccountId' when calling" - + " getExchangeAccountAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " getExchangeAccountAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getExchangeAccountAsset", "exchangeAccountId", exchangeAccountId); + ValidationUtils.assertParamExistsAndNotEmpty("getExchangeAccountAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -389,12 +369,7 @@ public CompletableFuture>> getPagedExcha private HttpRequest.Builder getPagedExchangeAccountsRequestBuilder( BigDecimal limit, String before, String after) throws ApiException { - // verify the required parameter 'limit' is set - if (limit == null) { - throw new ApiException( - 400, - "Missing the required parameter 'limit' when calling getPagedExchangeAccounts"); - } + ValidationUtils.assertParamExists("getPagedExchangeAccounts", "limit", limit); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -491,13 +466,8 @@ private HttpRequest.Builder internalTransferRequestBuilder( CreateInternalTransferRequest createInternalTransferRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'exchangeAccountId' is set - if (exchangeAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'exchangeAccountId' when calling" - + " internalTransfer"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "internalTransfer", "exchangeAccountId", exchangeAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/ExternalWalletsApi.java b/src/main/java/com/fireblocks/sdk/api/ExternalWalletsApi.java index fdbd628..f62a44e 100644 --- a/src/main/java/com/fireblocks/sdk/api/ExternalWalletsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/ExternalWalletsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.AddAssetToExternalWalletRequest; import com.fireblocks.sdk.model.CreateWalletRequest; import com.fireblocks.sdk.model.ExternalWalletAsset; @@ -133,20 +134,10 @@ private HttpRequest.Builder addAssetToExternalWalletRequestBuilder( AddAssetToExternalWalletRequest addAssetToExternalWalletRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " addAssetToExternalWallet"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " addAssetToExternalWallet"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "addAssetToExternalWallet", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty( + "addAssetToExternalWallet", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -294,12 +285,7 @@ public CompletableFuture> deleteExternalWallet(String walletId private HttpRequest.Builder deleteExternalWalletRequestBuilder(String walletId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling deleteExternalWallet"); - } + ValidationUtils.assertParamExistsAndNotEmpty("deleteExternalWallet", "walletId", walletId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -365,12 +351,7 @@ public CompletableFuture> getExternalWallet(String private HttpRequest.Builder getExternalWalletRequestBuilder(String walletId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling getExternalWallet"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getExternalWallet", "walletId", walletId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -439,19 +420,9 @@ public CompletableFuture> getExternalWalletAsse private HttpRequest.Builder getExternalWalletAssetRequestBuilder( String walletId, String assetId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " getExternalWalletAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getExternalWalletAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getExternalWalletAsset", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty("getExternalWalletAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -575,20 +546,10 @@ public CompletableFuture> removeAssetFromExternalWallet( private HttpRequest.Builder removeAssetFromExternalWalletRequestBuilder( String walletId, String assetId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " removeAssetFromExternalWallet"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " removeAssetFromExternalWallet"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "removeAssetFromExternalWallet", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty( + "removeAssetFromExternalWallet", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -656,20 +617,12 @@ public CompletableFuture> setExternalWalletCustomerRefId( private HttpRequest.Builder setExternalWalletCustomerRefIdRequestBuilder( SetCustomerRefIdRequest setCustomerRefIdRequest, String walletId, String idempotencyKey) throws ApiException { - // verify the required parameter 'setCustomerRefIdRequest' is set - if (setCustomerRefIdRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setCustomerRefIdRequest' when calling" - + " setExternalWalletCustomerRefId"); - } - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " setExternalWalletCustomerRefId"); - } + ValidationUtils.assertParamExists( + "setExternalWalletCustomerRefId", + "setCustomerRefIdRequest", + setCustomerRefIdRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "setExternalWalletCustomerRefId", "walletId", walletId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/FiatAccountsApi.java b/src/main/java/com/fireblocks/sdk/api/FiatAccountsApi.java index 8b32909..00a9ebe 100644 --- a/src/main/java/com/fireblocks/sdk/api/FiatAccountsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/FiatAccountsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.DepositFundsFromLinkedDDAResponse; import com.fireblocks.sdk.model.FiatAccount; import com.fireblocks.sdk.model.Funds; @@ -123,13 +124,8 @@ private String formatExceptionMessage(String operationId, int statusCode, String private HttpRequest.Builder depositFundsFromLinkedDDARequestBuilder( String accountId, Funds funds, String idempotencyKey) throws ApiException { - // verify the required parameter 'accountId' is set - if (accountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'accountId' when calling" - + " depositFundsFromLinkedDDA"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "depositFundsFromLinkedDDA", "accountId", accountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -204,11 +200,7 @@ public CompletableFuture> getFiatAccount(String account } private HttpRequest.Builder getFiatAccountRequestBuilder(String accountId) throws ApiException { - // verify the required parameter 'accountId' is set - if (accountId == null) { - throw new ApiException( - 400, "Missing the required parameter 'accountId' when calling getFiatAccount"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getFiatAccount", "accountId", accountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -341,13 +333,8 @@ public CompletableFuture> redeemFund private HttpRequest.Builder redeemFundsToLinkedDDARequestBuilder( String accountId, Funds funds, String idempotencyKey) throws ApiException { - // verify the required parameter 'accountId' is set - if (accountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'accountId' when calling" - + " redeemFundsToLinkedDDA"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "redeemFundsToLinkedDDA", "accountId", accountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/GasStationsApi.java b/src/main/java/com/fireblocks/sdk/api/GasStationsApi.java index 84ff19f..e356be1 100644 --- a/src/main/java/com/fireblocks/sdk/api/GasStationsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/GasStationsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.EditGasStationConfigurationResponse; import com.fireblocks.sdk.model.GasStationConfiguration; import com.fireblocks.sdk.model.GasStationPropertiesResponse; @@ -117,12 +118,7 @@ public CompletableFuture> getGasStatio private HttpRequest.Builder getGasStationByAssetIdRequestBuilder(String assetId) throws ApiException { - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getGasStationByAssetId"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getGasStationByAssetId", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -259,13 +255,10 @@ private HttpRequest.Builder getGasStationInfoRequestBuilder() throws ApiExceptio private HttpRequest.Builder updateGasStationConfigurationRequestBuilder( GasStationConfiguration gasStationConfiguration, String idempotencyKey) throws ApiException { - // verify the required parameter 'gasStationConfiguration' is set - if (gasStationConfiguration == null) { - throw new ApiException( - 400, - "Missing the required parameter 'gasStationConfiguration' when calling" - + " updateGasStationConfiguration"); - } + ValidationUtils.assertParamExists( + "updateGasStationConfiguration", + "gasStationConfiguration", + gasStationConfiguration); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -353,20 +346,12 @@ private HttpRequest.Builder updateGasStationConfigurationRequestBuilder( private HttpRequest.Builder updateGasStationConfigurationByAssetIdRequestBuilder( GasStationConfiguration gasStationConfiguration, String assetId, String idempotencyKey) throws ApiException { - // verify the required parameter 'gasStationConfiguration' is set - if (gasStationConfiguration == null) { - throw new ApiException( - 400, - "Missing the required parameter 'gasStationConfiguration' when calling" - + " updateGasStationConfigurationByAssetId"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " updateGasStationConfigurationByAssetId"); - } + ValidationUtils.assertParamExists( + "updateGasStationConfigurationByAssetId", + "gasStationConfiguration", + gasStationConfiguration); + ValidationUtils.assertParamExistsAndNotEmpty( + "updateGasStationConfigurationByAssetId", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/InternalWalletsApi.java b/src/main/java/com/fireblocks/sdk/api/InternalWalletsApi.java index 484f935..b29721c 100644 --- a/src/main/java/com/fireblocks/sdk/api/InternalWalletsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/InternalWalletsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateInternalWalletAssetRequest; import com.fireblocks.sdk.model.CreateWalletRequest; import com.fireblocks.sdk.model.SetCustomerRefIdRequest; @@ -211,20 +212,10 @@ private HttpRequest.Builder createInternalWalletAssetRequestBuilder( CreateInternalWalletAssetRequest createInternalWalletAssetRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " createInternalWalletAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " createInternalWalletAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "createInternalWalletAsset", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty( + "createInternalWalletAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -294,12 +285,7 @@ public CompletableFuture> deleteInternalWallet(String walletId private HttpRequest.Builder deleteInternalWalletRequestBuilder(String walletId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling deleteInternalWallet"); - } + ValidationUtils.assertParamExistsAndNotEmpty("deleteInternalWallet", "walletId", walletId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -359,20 +345,10 @@ public CompletableFuture> deleteInternalWalletAsset( private HttpRequest.Builder deleteInternalWalletAssetRequestBuilder( String walletId, String assetId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " deleteInternalWalletAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " deleteInternalWalletAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "deleteInternalWalletAsset", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty( + "deleteInternalWalletAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -439,12 +415,7 @@ public CompletableFuture> getInternalWallet(String private HttpRequest.Builder getInternalWalletRequestBuilder(String walletId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling getInternalWallet"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getInternalWallet", "walletId", walletId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -513,19 +484,9 @@ public CompletableFuture> getInternalWalletAsset( private HttpRequest.Builder getInternalWalletAssetRequestBuilder( String walletId, String assetId) throws ApiException { - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " getInternalWalletAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getInternalWalletAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getInternalWalletAsset", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty("getInternalWalletAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -659,20 +620,12 @@ public CompletableFuture> setCustomerRefIdForInternalWallet( private HttpRequest.Builder setCustomerRefIdForInternalWalletRequestBuilder( SetCustomerRefIdRequest setCustomerRefIdRequest, String walletId, String idempotencyKey) throws ApiException { - // verify the required parameter 'setCustomerRefIdRequest' is set - if (setCustomerRefIdRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setCustomerRefIdRequest' when calling" - + " setCustomerRefIdForInternalWallet"); - } - // verify the required parameter 'walletId' is set - if (walletId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'walletId' when calling" - + " setCustomerRefIdForInternalWallet"); - } + ValidationUtils.assertParamExists( + "setCustomerRefIdForInternalWallet", + "setCustomerRefIdRequest", + setCustomerRefIdRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "setCustomerRefIdForInternalWallet", "walletId", walletId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/JobManagementApi.java b/src/main/java/com/fireblocks/sdk/api/JobManagementApi.java index 463684a..ebadb71 100644 --- a/src/main/java/com/fireblocks/sdk/api/JobManagementApi.java +++ b/src/main/java/com/fireblocks/sdk/api/JobManagementApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.Job; import com.fireblocks.sdk.model.Task; import java.io.IOException; @@ -113,11 +114,7 @@ public CompletableFuture> cancelJob(String jobId, String idemp private HttpRequest.Builder cancelJobRequestBuilder(String jobId, String idempotencyKey) throws ApiException { - // verify the required parameter 'jobId' is set - if (jobId == null) { - throw new ApiException( - 400, "Missing the required parameter 'jobId' when calling cancelJob"); - } + ValidationUtils.assertParamExistsAndNotEmpty("cancelJob", "jobId", jobId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -179,11 +176,7 @@ public CompletableFuture> continueJob(String jobId, String ide private HttpRequest.Builder continueJobRequestBuilder(String jobId, String idempotencyKey) throws ApiException { - // verify the required parameter 'jobId' is set - if (jobId == null) { - throw new ApiException( - 400, "Missing the required parameter 'jobId' when calling continueJob"); - } + ValidationUtils.assertParamExistsAndNotEmpty("continueJob", "jobId", jobId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -248,11 +241,7 @@ public CompletableFuture> getJob(String jobId) throws ApiExcept } private HttpRequest.Builder getJobRequestBuilder(String jobId) throws ApiException { - // verify the required parameter 'jobId' is set - if (jobId == null) { - throw new ApiException( - 400, "Missing the required parameter 'jobId' when calling getJob"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getJob", "jobId", jobId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -316,11 +305,7 @@ public CompletableFuture>> getJobTasks(String jobId) } private HttpRequest.Builder getJobTasksRequestBuilder(String jobId) throws ApiException { - // verify the required parameter 'jobId' is set - if (jobId == null) { - throw new ApiException( - 400, "Missing the required parameter 'jobId' when calling getJobTasks"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getJobTasks", "jobId", jobId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -463,11 +448,7 @@ public CompletableFuture> pauseJob(String jobId, String idempo private HttpRequest.Builder pauseJobRequestBuilder(String jobId, String idempotencyKey) throws ApiException { - // verify the required parameter 'jobId' is set - if (jobId == null) { - throw new ApiException( - 400, "Missing the required parameter 'jobId' when calling pauseJob"); - } + ValidationUtils.assertParamExistsAndNotEmpty("pauseJob", "jobId", jobId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/KeyLinkBetaApi.java b/src/main/java/com/fireblocks/sdk/api/KeyLinkBetaApi.java index 15de36d..d5f1383 100644 --- a/src/main/java/com/fireblocks/sdk/api/KeyLinkBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/KeyLinkBetaApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateSigningKeyDto; import com.fireblocks.sdk.model.CreateValidationKeyDto; import com.fireblocks.sdk.model.CreateValidationKeyResponseDto; @@ -136,13 +137,8 @@ public CompletableFuture> createSigningKey( private HttpRequest.Builder createSigningKeyRequestBuilder( CreateSigningKeyDto createSigningKeyDto, String idempotencyKey) throws ApiException { - // verify the required parameter 'createSigningKeyDto' is set - if (createSigningKeyDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createSigningKeyDto' when calling" - + " createSigningKey"); - } + ValidationUtils.assertParamExists( + "createSigningKey", "createSigningKeyDto", createSigningKeyDto); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -228,13 +224,8 @@ public CompletableFuture> createVali private HttpRequest.Builder createValidationKeyRequestBuilder( CreateValidationKeyDto createValidationKeyDto, String idempotencyKey) throws ApiException { - // verify the required parameter 'createValidationKeyDto' is set - if (createValidationKeyDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createValidationKeyDto' when calling" - + " createValidationKey"); - } + ValidationUtils.assertParamExists( + "createValidationKey", "createValidationKeyDto", createValidationKeyDto); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -317,19 +308,9 @@ public CompletableFuture> disableValidationKey( private HttpRequest.Builder disableValidationKeyRequestBuilder( ModifyValidationKeyDto modifyValidationKeyDto, String keyId) throws ApiException { - // verify the required parameter 'modifyValidationKeyDto' is set - if (modifyValidationKeyDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'modifyValidationKeyDto' when calling" - + " disableValidationKey"); - } - // verify the required parameter 'keyId' is set - if (keyId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'keyId' when calling disableValidationKey"); - } + ValidationUtils.assertParamExists( + "disableValidationKey", "modifyValidationKeyDto", modifyValidationKeyDto); + ValidationUtils.assertParamExistsAndNotEmpty("disableValidationKey", "keyId", keyId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -407,11 +388,7 @@ public CompletableFuture> getSigningKey(String keyId) } private HttpRequest.Builder getSigningKeyRequestBuilder(String keyId) throws ApiException { - // verify the required parameter 'keyId' is set - if (keyId == null) { - throw new ApiException( - 400, "Missing the required parameter 'keyId' when calling getSigningKey"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getSigningKey", "keyId", keyId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -576,11 +553,7 @@ public CompletableFuture> getValidationKey(String } private HttpRequest.Builder getValidationKeyRequestBuilder(String keyId) throws ApiException { - // verify the required parameter 'keyId' is set - if (keyId == null) { - throw new ApiException( - 400, "Missing the required parameter 'keyId' when calling getValidationKey"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getValidationKey", "keyId", keyId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -743,18 +716,9 @@ public CompletableFuture> setAgentId( private HttpRequest.Builder setAgentIdRequestBuilder( ModifySigningKeyAgentIdDto modifySigningKeyAgentIdDto, String keyId) throws ApiException { - // verify the required parameter 'modifySigningKeyAgentIdDto' is set - if (modifySigningKeyAgentIdDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'modifySigningKeyAgentIdDto' when calling" - + " setAgentId"); - } - // verify the required parameter 'keyId' is set - if (keyId == null) { - throw new ApiException( - 400, "Missing the required parameter 'keyId' when calling setAgentId"); - } + ValidationUtils.assertParamExists( + "setAgentId", "modifySigningKeyAgentIdDto", modifySigningKeyAgentIdDto); + ValidationUtils.assertParamExistsAndNotEmpty("setAgentId", "keyId", keyId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -835,18 +799,9 @@ public CompletableFuture> updateSigningKey( private HttpRequest.Builder updateSigningKeyRequestBuilder( ModifySigningKeyDto modifySigningKeyDto, String keyId) throws ApiException { - // verify the required parameter 'modifySigningKeyDto' is set - if (modifySigningKeyDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'modifySigningKeyDto' when calling" - + " updateSigningKey"); - } - // verify the required parameter 'keyId' is set - if (keyId == null) { - throw new ApiException( - 400, "Missing the required parameter 'keyId' when calling updateSigningKey"); - } + ValidationUtils.assertParamExists( + "updateSigningKey", "modifySigningKeyDto", modifySigningKeyDto); + ValidationUtils.assertParamExistsAndNotEmpty("updateSigningKey", "keyId", keyId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/NetworkConnectionsApi.java b/src/main/java/com/fireblocks/sdk/api/NetworkConnectionsApi.java index ca1728b..bc8d013 100644 --- a/src/main/java/com/fireblocks/sdk/api/NetworkConnectionsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/NetworkConnectionsApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateNetworkIdRequest; import com.fireblocks.sdk.model.DeleteNetworkConnectionResponse; import com.fireblocks.sdk.model.DeleteNetworkIdResponse; @@ -131,20 +132,10 @@ public CompletableFuture> checkThirdPartyRouting( private HttpRequest.Builder checkThirdPartyRoutingRequestBuilder( String connectionId, String assetType) throws ApiException { - // verify the required parameter 'connectionId' is set - if (connectionId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'connectionId' when calling" - + " checkThirdPartyRouting"); - } - // verify the required parameter 'assetType' is set - if (assetType == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetType' when calling" - + " checkThirdPartyRouting"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "checkThirdPartyRouting", "connectionId", connectionId); + ValidationUtils.assertParamExistsAndNotEmpty( + "checkThirdPartyRouting", "assetType", assetType); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -409,13 +400,8 @@ public CompletableFuture> deleteNet private HttpRequest.Builder deleteNetworkConnectionRequestBuilder(String connectionId) throws ApiException { - // verify the required parameter 'connectionId' is set - if (connectionId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'connectionId' when calling" - + " deleteNetworkConnection"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "deleteNetworkConnection", "connectionId", connectionId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -492,11 +478,7 @@ public CompletableFuture> deleteNetworkId(S private HttpRequest.Builder deleteNetworkIdRequestBuilder(String networkId) throws ApiException { - // verify the required parameter 'networkId' is set - if (networkId == null) { - throw new ApiException( - 400, "Missing the required parameter 'networkId' when calling deleteNetworkId"); - } + ValidationUtils.assertParamExistsAndNotEmpty("deleteNetworkId", "networkId", networkId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -572,11 +554,7 @@ public CompletableFuture> getNetwork(Stri } private HttpRequest.Builder getNetworkRequestBuilder(String connectionId) throws ApiException { - // verify the required parameter 'connectionId' is set - if (connectionId == null) { - throw new ApiException( - 400, "Missing the required parameter 'connectionId' when calling getNetwork"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getNetwork", "connectionId", connectionId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -726,11 +704,7 @@ public CompletableFuture> getNetworkId(String net } private HttpRequest.Builder getNetworkIdRequestBuilder(String networkId) throws ApiException { - // verify the required parameter 'networkId' is set - if (networkId == null) { - throw new ApiException( - 400, "Missing the required parameter 'networkId' when calling getNetworkId"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getNetworkId", "networkId", networkId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -956,20 +930,12 @@ public CompletableFuture> setNetworkIdDiscover private HttpRequest.Builder setNetworkIdDiscoverabilityRequestBuilder( SetNetworkIdDiscoverabilityRequest setNetworkIdDiscoverabilityRequest, String networkId) throws ApiException { - // verify the required parameter 'setNetworkIdDiscoverabilityRequest' is set - if (setNetworkIdDiscoverabilityRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setNetworkIdDiscoverabilityRequest' when" - + " calling setNetworkIdDiscoverability"); - } - // verify the required parameter 'networkId' is set - if (networkId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'networkId' when calling" - + " setNetworkIdDiscoverability"); - } + ValidationUtils.assertParamExists( + "setNetworkIdDiscoverability", + "setNetworkIdDiscoverabilityRequest", + setNetworkIdDiscoverabilityRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "setNetworkIdDiscoverability", "networkId", networkId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1056,19 +1022,9 @@ public CompletableFuture> setNetworkIdName( private HttpRequest.Builder setNetworkIdNameRequestBuilder( SetNetworkIdNameRequest setNetworkIdNameRequest, String networkId) throws ApiException { - // verify the required parameter 'setNetworkIdNameRequest' is set - if (setNetworkIdNameRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setNetworkIdNameRequest' when calling" - + " setNetworkIdName"); - } - // verify the required parameter 'networkId' is set - if (networkId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'networkId' when calling setNetworkIdName"); - } + ValidationUtils.assertParamExists( + "setNetworkIdName", "setNetworkIdNameRequest", setNetworkIdNameRequest); + ValidationUtils.assertParamExistsAndNotEmpty("setNetworkIdName", "networkId", networkId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1161,13 +1117,8 @@ public CompletableFuture> setNetworkIdRoutingP private HttpRequest.Builder setNetworkIdRoutingPolicyRequestBuilder( String networkId, SetNetworkIdRoutingPolicyRequest setNetworkIdRoutingPolicyRequest) throws ApiException { - // verify the required parameter 'networkId' is set - if (networkId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'networkId' when calling" - + " setNetworkIdRoutingPolicy"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "setNetworkIdRoutingPolicy", "networkId", networkId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1258,12 +1209,8 @@ public CompletableFuture> setRoutingPolicy private HttpRequest.Builder setRoutingPolicyRequestBuilder( String connectionId, SetRoutingPolicyRequest setRoutingPolicyRequest) throws ApiException { - // verify the required parameter 'connectionId' is set - if (connectionId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'connectionId' when calling setRoutingPolicy"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "setRoutingPolicy", "connectionId", connectionId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/NftsApi.java b/src/main/java/com/fireblocks/sdk/api/NftsApi.java index 6244757..7b4c30e 100644 --- a/src/main/java/com/fireblocks/sdk/api/NftsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/NftsApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.GetNFTsResponse; import com.fireblocks.sdk.model.GetOwnershipTokensResponse; import com.fireblocks.sdk.model.ListOwnedCollectionsResponse; @@ -122,10 +123,7 @@ public CompletableFuture> getNFT(String id) throws Ap } private HttpRequest.Builder getNFTRequestBuilder(String id) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException(400, "Missing the required parameter 'id' when calling getNFT"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getNFT", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -200,11 +198,7 @@ public CompletableFuture> getNFTs( private HttpRequest.Builder getNFTsRequestBuilder( String ids, String pageCursor, BigDecimal pageSize, List sort, String order) throws ApiException { - // verify the required parameter 'ids' is set - if (ids == null) { - throw new ApiException( - 400, "Missing the required parameter 'ids' when calling getNFTs"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getNFTs", "ids", ids); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -719,11 +713,7 @@ public CompletableFuture> refreshNFTMetadata(String id, String private HttpRequest.Builder refreshNFTMetadataRequestBuilder(String id, String idempotencyKey) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - 400, "Missing the required parameter 'id' when calling refreshNFTMetadata"); - } + ValidationUtils.assertParamExistsAndNotEmpty("refreshNFTMetadata", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -791,20 +781,10 @@ public CompletableFuture> updateOwnershipTokens( private HttpRequest.Builder updateOwnershipTokensRequestBuilder( String blockchainDescriptor, String vaultAccountId, String idempotencyKey) throws ApiException { - // verify the required parameter 'blockchainDescriptor' is set - if (blockchainDescriptor == null) { - throw new ApiException( - 400, - "Missing the required parameter 'blockchainDescriptor' when calling" - + " updateOwnershipTokens"); - } - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " updateOwnershipTokens"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "updateOwnershipTokens", "blockchainDescriptor", blockchainDescriptor); + ValidationUtils.assertParamExistsAndNotEmpty( + "updateOwnershipTokens", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -894,19 +874,11 @@ private HttpRequest.Builder updateTokenOwnershipStatusRequestBuilder( String id, String idempotencyKey) throws ApiException { - // verify the required parameter 'updateTokenOwnershipStatusDto' is set - if (updateTokenOwnershipStatusDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'updateTokenOwnershipStatusDto' when calling" - + " updateTokenOwnershipStatus"); - } - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - 400, - "Missing the required parameter 'id' when calling updateTokenOwnershipStatus"); - } + ValidationUtils.assertParamExists( + "updateTokenOwnershipStatus", + "updateTokenOwnershipStatusDto", + updateTokenOwnershipStatusDto); + ValidationUtils.assertParamExistsAndNotEmpty("updateTokenOwnershipStatus", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -984,13 +956,10 @@ private HttpRequest.Builder updateTokensOwnershipSpamRequestBuilder( List tokenOwnershipSpamUpdatePayload, String idempotencyKey) throws ApiException { - // verify the required parameter 'tokenOwnershipSpamUpdatePayload' is set - if (tokenOwnershipSpamUpdatePayload == null) { - throw new ApiException( - 400, - "Missing the required parameter 'tokenOwnershipSpamUpdatePayload' when calling" - + " updateTokensOwnershipSpam"); - } + ValidationUtils.assertParamExists( + "updateTokensOwnershipSpam", + "tokenOwnershipSpamUpdatePayload", + tokenOwnershipSpamUpdatePayload); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1066,13 +1035,10 @@ private HttpRequest.Builder updateTokensOwnershipStatusRequestBuilder( List tokenOwnershipStatusUpdatePayload, String idempotencyKey) throws ApiException { - // verify the required parameter 'tokenOwnershipStatusUpdatePayload' is set - if (tokenOwnershipStatusUpdatePayload == null) { - throw new ApiException( - 400, - "Missing the required parameter 'tokenOwnershipStatusUpdatePayload' when" - + " calling updateTokensOwnershipStatus"); - } + ValidationUtils.assertParamExists( + "updateTokensOwnershipStatus", + "tokenOwnershipStatusUpdatePayload", + tokenOwnershipStatusUpdatePayload); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/OffExchangesApi.java b/src/main/java/com/fireblocks/sdk/api/OffExchangesApi.java index e7f6126..bca59bb 100644 --- a/src/main/java/com/fireblocks/sdk/api/OffExchangesApi.java +++ b/src/main/java/com/fireblocks/sdk/api/OffExchangesApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.AddCollateralRequestBody; import com.fireblocks.sdk.model.CreateTransactionResponse; import com.fireblocks.sdk.model.ExchangeAccount; @@ -207,13 +208,8 @@ public CompletableFuture> getOffExchangeCollateralA private HttpRequest.Builder getOffExchangeCollateralAccountsRequestBuilder( String mainExchangeAccountId) throws ApiException { - // verify the required parameter 'mainExchangeAccountId' is set - if (mainExchangeAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'mainExchangeAccountId' when calling" - + " getOffExchangeCollateralAccounts"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getOffExchangeCollateralAccounts", "mainExchangeAccountId", mainExchangeAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -284,13 +280,10 @@ private HttpRequest.Builder getOffExchangeCollateralAccountsRequestBuilder( private HttpRequest.Builder getOffExchangeSettlementTransactionsRequestBuilder( String mainExchangeAccountId) throws ApiException { - // verify the required parameter 'mainExchangeAccountId' is set - if (mainExchangeAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'mainExchangeAccountId' when calling" - + " getOffExchangeSettlementTransactions"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getOffExchangeSettlementTransactions", + "mainExchangeAccountId", + mainExchangeAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/OtaBetaApi.java b/src/main/java/com/fireblocks/sdk/api/OtaBetaApi.java index e19869b..fe0a692 100644 --- a/src/main/java/com/fireblocks/sdk/api/OtaBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/OtaBetaApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.GetOtaStatusResponse; import com.fireblocks.sdk.model.SetOtaStatusRequest; import com.fireblocks.sdk.model.SetOtaStatusResponse; @@ -178,13 +179,8 @@ public CompletableFuture> setOtaStatus( private HttpRequest.Builder setOtaStatusRequestBuilder( SetOtaStatusRequest setOtaStatusRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'setOtaStatusRequest' is set - if (setOtaStatusRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setOtaStatusRequest' when calling" - + " setOtaStatus"); - } + ValidationUtils.assertParamExists( + "setOtaStatus", "setOtaStatusRequest", setOtaStatusRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/PaymentsPayoutApi.java b/src/main/java/com/fireblocks/sdk/api/PaymentsPayoutApi.java index fe1a35f..38ff7c4 100644 --- a/src/main/java/com/fireblocks/sdk/api/PaymentsPayoutApi.java +++ b/src/main/java/com/fireblocks/sdk/api/PaymentsPayoutApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreatePayoutRequest; import com.fireblocks.sdk.model.DispatchPayoutResponse; import com.fireblocks.sdk.model.PayoutResponse; @@ -220,12 +221,7 @@ public CompletableFuture> executePayoutActio private HttpRequest.Builder executePayoutActionRequestBuilder( String payoutId, String idempotencyKey) throws ApiException { - // verify the required parameter 'payoutId' is set - if (payoutId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'payoutId' when calling executePayoutAction"); - } + ValidationUtils.assertParamExistsAndNotEmpty("executePayoutAction", "payoutId", payoutId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -299,11 +295,7 @@ public CompletableFuture> getPayout(String payoutId) } private HttpRequest.Builder getPayoutRequestBuilder(String payoutId) throws ApiException { - // verify the required parameter 'payoutId' is set - if (payoutId == null) { - throw new ApiException( - 400, "Missing the required parameter 'payoutId' when calling getPayout"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getPayout", "payoutId", payoutId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/PolicyEditorBetaApi.java b/src/main/java/com/fireblocks/sdk/api/PolicyEditorBetaApi.java index e9bd919..783a643 100644 --- a/src/main/java/com/fireblocks/sdk/api/PolicyEditorBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/PolicyEditorBetaApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.DraftReviewAndValidationResponse; import com.fireblocks.sdk.model.PolicyAndValidationResponse; import com.fireblocks.sdk.model.PolicyRules; @@ -252,13 +253,8 @@ public CompletableFuture> publishDraft( private HttpRequest.Builder publishDraftRequestBuilder( PublishDraftRequest publishDraftRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'publishDraftRequest' is set - if (publishDraftRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'publishDraftRequest' when calling" - + " publishDraft"); - } + ValidationUtils.assertParamExists( + "publishDraft", "publishDraftRequest", publishDraftRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -341,12 +337,7 @@ public CompletableFuture> publishPolicyRules( private HttpRequest.Builder publishPolicyRulesRequestBuilder( PolicyRules policyRules, String idempotencyKey) throws ApiException { - // verify the required parameter 'policyRules' is set - if (policyRules == null) { - throw new ApiException( - 400, - "Missing the required parameter 'policyRules' when calling publishPolicyRules"); - } + ValidationUtils.assertParamExists("publishPolicyRules", "policyRules", policyRules); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -427,11 +418,7 @@ public CompletableFuture> updateDr private HttpRequest.Builder updateDraftRequestBuilder( PolicyRules policyRules, String idempotencyKey) throws ApiException { - // verify the required parameter 'policyRules' is set - if (policyRules == null) { - throw new ApiException( - 400, "Missing the required parameter 'policyRules' when calling updateDraft"); - } + ValidationUtils.assertParamExists("updateDraft", "policyRules", policyRules); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/ResetDeviceApi.java b/src/main/java/com/fireblocks/sdk/api/ResetDeviceApi.java index 5b2ddfd..e3d9ab8 100644 --- a/src/main/java/com/fireblocks/sdk/api/ResetDeviceApi.java +++ b/src/main/java/com/fireblocks/sdk/api/ResetDeviceApi.java @@ -17,6 +17,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import java.io.InputStream; import java.net.URI; import java.net.http.HttpClient; @@ -104,11 +105,7 @@ public CompletableFuture> resetDevice(String id, String idempo private HttpRequest.Builder resetDeviceRequestBuilder(String id, String idempotencyKey) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - 400, "Missing the required parameter 'id' when calling resetDevice"); - } + ValidationUtils.assertParamExistsAndNotEmpty("resetDevice", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/SmartTransferApi.java b/src/main/java/com/fireblocks/sdk/api/SmartTransferApi.java index 31fcd10..2fc95d3 100644 --- a/src/main/java/com/fireblocks/sdk/api/SmartTransferApi.java +++ b/src/main/java/com/fireblocks/sdk/api/SmartTransferApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.SmartTransferCreateTicket; import com.fireblocks.sdk.model.SmartTransferCreateTicketTerm; import com.fireblocks.sdk.model.SmartTransferFundTerm; @@ -134,11 +135,7 @@ public CompletableFuture> cancelTicket( private HttpRequest.Builder cancelTicketRequestBuilder(String ticketId, String idempotencyKey) throws ApiException { - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling cancelTicket"); - } + ValidationUtils.assertParamExistsAndNotEmpty("cancelTicket", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -213,13 +210,8 @@ public CompletableFuture> createTicket( private HttpRequest.Builder createTicketRequestBuilder( SmartTransferCreateTicket smartTransferCreateTicket, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferCreateTicket' is set - if (smartTransferCreateTicket == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferCreateTicket' when calling" - + " createTicket"); - } + ValidationUtils.assertParamExists( + "createTicket", "smartTransferCreateTicket", smartTransferCreateTicket); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -306,18 +298,9 @@ private HttpRequest.Builder createTicketTermRequestBuilder( String ticketId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferCreateTicketTerm' is set - if (smartTransferCreateTicketTerm == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferCreateTicketTerm' when calling" - + " createTicketTerm"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling createTicketTerm"); - } + ValidationUtils.assertParamExists( + "createTicketTerm", "smartTransferCreateTicketTerm", smartTransferCreateTicketTerm); + ValidationUtils.assertParamExistsAndNotEmpty("createTicketTerm", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -393,11 +376,7 @@ public CompletableFuture> findTicketByI } private HttpRequest.Builder findTicketByIdRequestBuilder(String ticketId) throws ApiException { - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling findTicketById"); - } + ValidationUtils.assertParamExistsAndNotEmpty("findTicketById", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -466,17 +445,8 @@ public CompletableFuture> findTicke private HttpRequest.Builder findTicketTermByIdRequestBuilder(String ticketId, String termId) throws ApiException { - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'ticketId' when calling findTicketTermById"); - } - // verify the required parameter 'termId' is set - if (termId == null) { - throw new ApiException( - 400, "Missing the required parameter 'termId' when calling findTicketTermById"); - } + ValidationUtils.assertParamExistsAndNotEmpty("findTicketTermById", "ticketId", ticketId); + ValidationUtils.assertParamExistsAndNotEmpty("findTicketTermById", "termId", termId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -548,11 +518,7 @@ public CompletableFuture> fulfillTicket private HttpRequest.Builder fulfillTicketRequestBuilder(String ticketId, String idempotencyKey) throws ApiException { - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling fulfillTicket"); - } + ValidationUtils.assertParamExistsAndNotEmpty("fulfillTicket", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -637,23 +603,10 @@ private HttpRequest.Builder fundTicketTermRequestBuilder( String termId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferFundTerm' is set - if (smartTransferFundTerm == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferFundTerm' when calling" - + " fundTicketTerm"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling fundTicketTerm"); - } - // verify the required parameter 'termId' is set - if (termId == null) { - throw new ApiException( - 400, "Missing the required parameter 'termId' when calling fundTicketTerm"); - } + ValidationUtils.assertParamExists( + "fundTicketTerm", "smartTransferFundTerm", smartTransferFundTerm); + ValidationUtils.assertParamExistsAndNotEmpty("fundTicketTerm", "ticketId", ticketId); + ValidationUtils.assertParamExistsAndNotEmpty("fundTicketTerm", "termId", termId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -810,26 +763,13 @@ private HttpRequest.Builder manuallyFundTicketTermRequestBuilder( String termId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferManuallyFundTerm' is set - if (smartTransferManuallyFundTerm == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferManuallyFundTerm' when calling" - + " manuallyFundTicketTerm"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'ticketId' when calling" - + " manuallyFundTicketTerm"); - } - // verify the required parameter 'termId' is set - if (termId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'termId' when calling manuallyFundTicketTerm"); - } + ValidationUtils.assertParamExists( + "manuallyFundTicketTerm", + "smartTransferManuallyFundTerm", + smartTransferManuallyFundTerm); + ValidationUtils.assertParamExistsAndNotEmpty( + "manuallyFundTicketTerm", "ticketId", ticketId); + ValidationUtils.assertParamExistsAndNotEmpty("manuallyFundTicketTerm", "termId", termId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -899,16 +839,8 @@ public CompletableFuture> removeTicketTerm(String ticketId, St private HttpRequest.Builder removeTicketTermRequestBuilder(String ticketId, String termId) throws ApiException { - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling removeTicketTerm"); - } - // verify the required parameter 'termId' is set - if (termId == null) { - throw new ApiException( - 400, "Missing the required parameter 'termId' when calling removeTicketTerm"); - } + ValidationUtils.assertParamExistsAndNotEmpty("removeTicketTerm", "ticketId", ticketId); + ValidationUtils.assertParamExistsAndNotEmpty("removeTicketTerm", "termId", termId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1127,18 +1059,11 @@ private HttpRequest.Builder setExternalRefIdRequestBuilder( String ticketId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferSetTicketExternalId' is set - if (smartTransferSetTicketExternalId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferSetTicketExternalId' when calling" - + " setExternalRefId"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling setExternalRefId"); - } + ValidationUtils.assertParamExists( + "setExternalRefId", + "smartTransferSetTicketExternalId", + smartTransferSetTicketExternalId); + ValidationUtils.assertParamExistsAndNotEmpty("setExternalRefId", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1228,19 +1153,11 @@ private HttpRequest.Builder setTicketExpirationRequestBuilder( String ticketId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferSetTicketExpiration' is set - if (smartTransferSetTicketExpiration == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferSetTicketExpiration' when calling" - + " setTicketExpiration"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'ticketId' when calling setTicketExpiration"); - } + ValidationUtils.assertParamExists( + "setTicketExpiration", + "smartTransferSetTicketExpiration", + smartTransferSetTicketExpiration); + ValidationUtils.assertParamExistsAndNotEmpty("setTicketExpiration", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1323,13 +1240,8 @@ public CompletableFuture> setUserGr private HttpRequest.Builder setUserGroupsRequestBuilder( SmartTransferSetUserGroups smartTransferSetUserGroups, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferSetUserGroups' is set - if (smartTransferSetUserGroups == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferSetUserGroups' when calling" - + " setUserGroups"); - } + ValidationUtils.assertParamExists( + "setUserGroups", "smartTransferSetUserGroups", smartTransferSetUserGroups); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1416,18 +1328,9 @@ private HttpRequest.Builder submitTicketRequestBuilder( String ticketId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferSubmitTicket' is set - if (smartTransferSubmitTicket == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferSubmitTicket' when calling" - + " submitTicket"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling submitTicket"); - } + ValidationUtils.assertParamExists( + "submitTicket", "smartTransferSubmitTicket", smartTransferSubmitTicket); + ValidationUtils.assertParamExistsAndNotEmpty("submitTicket", "ticketId", ticketId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1519,23 +1422,10 @@ private HttpRequest.Builder updateTicketTermRequestBuilder( String termId, String idempotencyKey) throws ApiException { - // verify the required parameter 'smartTransferUpdateTicketTerm' is set - if (smartTransferUpdateTicketTerm == null) { - throw new ApiException( - 400, - "Missing the required parameter 'smartTransferUpdateTicketTerm' when calling" - + " updateTicketTerm"); - } - // verify the required parameter 'ticketId' is set - if (ticketId == null) { - throw new ApiException( - 400, "Missing the required parameter 'ticketId' when calling updateTicketTerm"); - } - // verify the required parameter 'termId' is set - if (termId == null) { - throw new ApiException( - 400, "Missing the required parameter 'termId' when calling updateTicketTerm"); - } + ValidationUtils.assertParamExists( + "updateTicketTerm", "smartTransferUpdateTicketTerm", smartTransferUpdateTicketTerm); + ValidationUtils.assertParamExistsAndNotEmpty("updateTicketTerm", "ticketId", ticketId); + ValidationUtils.assertParamExistsAndNotEmpty("updateTicketTerm", "termId", termId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/StakingBetaApi.java b/src/main/java/com/fireblocks/sdk/api/StakingBetaApi.java index 9b37a74..9e9579b 100644 --- a/src/main/java/com/fireblocks/sdk/api/StakingBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/StakingBetaApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.ChainInfoResponseDto; import com.fireblocks.sdk.model.DelegationDto; import com.fireblocks.sdk.model.DelegationSummaryDto; @@ -129,13 +130,8 @@ public CompletableFuture> approveTermsOfServiceByProviderId( private HttpRequest.Builder approveTermsOfServiceByProviderIdRequestBuilder( String providerId, String idempotencyKey) throws ApiException { - // verify the required parameter 'providerId' is set - if (providerId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'providerId' when calling" - + " approveTermsOfServiceByProviderId"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "approveTermsOfServiceByProviderId", "providerId", providerId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -220,24 +216,11 @@ private HttpRequest.Builder executeActionRequestBuilder( String actionId, String idempotencyKey) throws ApiException { - // verify the required parameter 'executeActionRequest' is set - if (executeActionRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'executeActionRequest' when calling" - + " executeAction"); - } - // verify the required parameter 'chainDescriptor' is set - if (chainDescriptor == null) { - throw new ApiException( - 400, - "Missing the required parameter 'chainDescriptor' when calling executeAction"); - } - // verify the required parameter 'actionId' is set - if (actionId == null) { - throw new ApiException( - 400, "Missing the required parameter 'actionId' when calling executeAction"); - } + ValidationUtils.assertParamExists( + "executeAction", "executeActionRequest", executeActionRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "executeAction", "chainDescriptor", chainDescriptor); + ValidationUtils.assertParamExistsAndNotEmpty("executeAction", "actionId", actionId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -403,12 +386,8 @@ public CompletableFuture> getChainInfo(String private HttpRequest.Builder getChainInfoRequestBuilder(String chainDescriptor) throws ApiException { - // verify the required parameter 'chainDescriptor' is set - if (chainDescriptor == null) { - throw new ApiException( - 400, - "Missing the required parameter 'chainDescriptor' when calling getChainInfo"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getChainInfo", "chainDescriptor", chainDescriptor); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -536,11 +515,7 @@ public CompletableFuture> getDelegationById(String id } private HttpRequest.Builder getDelegationByIdRequestBuilder(String id) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - 400, "Missing the required parameter 'id' when calling getDelegationById"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getDelegationById", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/TokenizationApi.java b/src/main/java/com/fireblocks/sdk/api/TokenizationApi.java index 7eb181b..2189480 100644 --- a/src/main/java/com/fireblocks/sdk/api/TokenizationApi.java +++ b/src/main/java/com/fireblocks/sdk/api/TokenizationApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateTokenRequestDto; import com.fireblocks.sdk.model.TokenLinkDto; import com.fireblocks.sdk.model.TokenLinkRequestDto; @@ -119,11 +120,7 @@ public CompletableFuture> getLinkedToken(String id) } private HttpRequest.Builder getLinkedTokenRequestBuilder(String id) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - 400, "Missing the required parameter 'id' when calling getLinkedToken"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getLinkedToken", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -287,13 +284,8 @@ public CompletableFuture> issueNewToken( private HttpRequest.Builder issueNewTokenRequestBuilder( CreateTokenRequestDto createTokenRequestDto, String idempotencyKey) throws ApiException { - // verify the required parameter 'createTokenRequestDto' is set - if (createTokenRequestDto == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createTokenRequestDto' when calling" - + " issueNewToken"); - } + ValidationUtils.assertParamExists( + "issueNewToken", "createTokenRequestDto", createTokenRequestDto); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -374,11 +366,7 @@ public CompletableFuture> link( private HttpRequest.Builder linkRequestBuilder( TokenLinkRequestDto tokenLinkRequestDto, String idempotencyKey) throws ApiException { - // verify the required parameter 'tokenLinkRequestDto' is set - if (tokenLinkRequestDto == null) { - throw new ApiException( - 400, "Missing the required parameter 'tokenLinkRequestDto' when calling link"); - } + ValidationUtils.assertParamExists("link", "tokenLinkRequestDto", tokenLinkRequestDto); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -441,10 +429,7 @@ public CompletableFuture> unlink(String id) throws ApiExceptio } private HttpRequest.Builder unlinkRequestBuilder(String id) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException(400, "Missing the required parameter 'id' when calling unlink"); - } + ValidationUtils.assertParamExistsAndNotEmpty("unlink", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/TransactionsApi.java b/src/main/java/com/fireblocks/sdk/api/TransactionsApi.java index 8ec505a..a6ce74e 100644 --- a/src/main/java/com/fireblocks/sdk/api/TransactionsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/TransactionsApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CancelTransactionResponse; import com.fireblocks.sdk.model.CreateTransactionResponse; import com.fireblocks.sdk.model.DropTransactionRequest; @@ -135,11 +136,7 @@ public CompletableFuture> cancelTransacti private HttpRequest.Builder cancelTransactionRequestBuilder( String txId, UUID xEndUserWalletId, String idempotencyKey) throws ApiException { - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, "Missing the required parameter 'txId' when calling cancelTransaction"); - } + ValidationUtils.assertParamExistsAndNotEmpty("cancelTransaction", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -313,11 +310,7 @@ private HttpRequest.Builder dropTransactionRequestBuilder( UUID xEndUserWalletId, String idempotencyKey) throws ApiException { - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, "Missing the required parameter 'txId' when calling dropTransaction"); - } + ValidationUtils.assertParamExistsAndNotEmpty("dropTransaction", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -399,12 +392,7 @@ public CompletableFuture> estimateNetwo private HttpRequest.Builder estimateNetworkFeeRequestBuilder(String assetId) throws ApiException { - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling estimateNetworkFee"); - } + ValidationUtils.assertParamExistsAndNotEmpty("estimateNetworkFee", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -569,11 +557,7 @@ public CompletableFuture> freezeTransacti private HttpRequest.Builder freezeTransactionRequestBuilder( String txId, UUID xEndUserWalletId, String idempotencyKey) throws ApiException { - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, "Missing the required parameter 'txId' when calling freezeTransaction"); - } + ValidationUtils.assertParamExistsAndNotEmpty("freezeTransaction", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -644,11 +628,7 @@ public CompletableFuture> getTransaction(String } private HttpRequest.Builder getTransactionRequestBuilder(String txId) throws ApiException { - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, "Missing the required parameter 'txId' when calling getTransaction"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getTransaction", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -717,13 +697,8 @@ public CompletableFuture> getTransactionByExter private HttpRequest.Builder getTransactionByExternalIdRequestBuilder(String externalTxId) throws ApiException { - // verify the required parameter 'externalTxId' is set - if (externalTxId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'externalTxId' when calling" - + " getTransactionByExternalId"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getTransactionByExternalId", "externalTxId", externalTxId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -974,13 +949,8 @@ private HttpRequest.Builder setConfirmationThresholdByTransactionHashRequestBuil SetConfirmationsThresholdRequest setConfirmationsThresholdRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'txHash' is set - if (txHash == null) { - throw new ApiException( - 400, - "Missing the required parameter 'txHash' when calling" - + " setConfirmationThresholdByTransactionHash"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "setConfirmationThresholdByTransactionHash", "txHash", txHash); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1073,13 +1043,8 @@ private HttpRequest.Builder setTransactionConfirmationThresholdRequestBuilder( SetConfirmationsThresholdRequest setConfirmationsThresholdRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'txId' when calling" - + " setTransactionConfirmationThreshold"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "setTransactionConfirmationThreshold", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1164,11 +1129,7 @@ public CompletableFuture> unfreezeTrans private HttpRequest.Builder unfreezeTransactionRequestBuilder( String txId, UUID xEndUserWalletId, String idempotencyKey) throws ApiException { - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, "Missing the required parameter 'txId' when calling unfreezeTransaction"); - } + ValidationUtils.assertParamExistsAndNotEmpty("unfreezeTransaction", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1242,16 +1203,8 @@ public CompletableFuture> validateAddress( private HttpRequest.Builder validateAddressRequestBuilder(String assetId, String address) throws ApiException { - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, "Missing the required parameter 'assetId' when calling validateAddress"); - } - // verify the required parameter 'address' is set - if (address == null) { - throw new ApiException( - 400, "Missing the required parameter 'address' when calling validateAddress"); - } + ValidationUtils.assertParamExistsAndNotEmpty("validateAddress", "assetId", assetId); + ValidationUtils.assertParamExistsAndNotEmpty("validateAddress", "address", address); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/TravelRuleBetaApi.java b/src/main/java/com/fireblocks/sdk/api/TravelRuleBetaApi.java index 849815a..9f410ca 100644 --- a/src/main/java/com/fireblocks/sdk/api/TravelRuleBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/TravelRuleBetaApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.TravelRuleGetAllVASPsResponse; import com.fireblocks.sdk.model.TravelRuleUpdateVASPDetails; import com.fireblocks.sdk.model.TravelRuleVASP; @@ -128,11 +129,7 @@ public CompletableFuture> getVASPByDID(String did, S private HttpRequest.Builder getVASPByDIDRequestBuilder(String did, String fields) throws ApiException { - // verify the required parameter 'did' is set - if (did == null) { - throw new ApiException( - 400, "Missing the required parameter 'did' when calling getVASPByDID"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getVASPByDID", "did", did); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -320,13 +317,8 @@ public CompletableFuture> updateVasp( private HttpRequest.Builder updateVaspRequestBuilder( TravelRuleUpdateVASPDetails travelRuleUpdateVASPDetails, String idempotencyKey) throws ApiException { - // verify the required parameter 'travelRuleUpdateVASPDetails' is set - if (travelRuleUpdateVASPDetails == null) { - throw new ApiException( - 400, - "Missing the required parameter 'travelRuleUpdateVASPDetails' when calling" - + " updateVasp"); - } + ValidationUtils.assertParamExists( + "updateVasp", "travelRuleUpdateVASPDetails", travelRuleUpdateVASPDetails); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -419,13 +411,10 @@ private HttpRequest.Builder validateFullTravelRuleTransactionRequestBuilder( TravelRuleValidateFullTransactionRequest travelRuleValidateFullTransactionRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'travelRuleValidateFullTransactionRequest' is set - if (travelRuleValidateFullTransactionRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'travelRuleValidateFullTransactionRequest' when" - + " calling validateFullTravelRuleTransaction"); - } + ValidationUtils.assertParamExists( + "validateFullTravelRuleTransaction", + "travelRuleValidateFullTransactionRequest", + travelRuleValidateFullTransactionRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -518,13 +507,10 @@ private HttpRequest.Builder validateTravelRuleTransactionRequestBuilder( TravelRuleValidateTransactionRequest travelRuleValidateTransactionRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'travelRuleValidateTransactionRequest' is set - if (travelRuleValidateTransactionRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'travelRuleValidateTransactionRequest' when" - + " calling validateTravelRuleTransaction"); - } + ValidationUtils.assertParamExists( + "validateTravelRuleTransaction", + "travelRuleValidateTransactionRequest", + travelRuleValidateTransactionRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/UserGroupsBetaApi.java b/src/main/java/com/fireblocks/sdk/api/UserGroupsBetaApi.java index 89cf73e..32d5e51 100644 --- a/src/main/java/com/fireblocks/sdk/api/UserGroupsBetaApi.java +++ b/src/main/java/com/fireblocks/sdk/api/UserGroupsBetaApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateUserGroupResponse; import com.fireblocks.sdk.model.UserGroupCreateRequest; import com.fireblocks.sdk.model.UserGroupCreateResponse; @@ -125,13 +126,8 @@ public CompletableFuture> createUserGroup( private HttpRequest.Builder createUserGroupRequestBuilder( UserGroupCreateRequest userGroupCreateRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'userGroupCreateRequest' is set - if (userGroupCreateRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'userGroupCreateRequest' when calling" - + " createUserGroup"); - } + ValidationUtils.assertParamExists( + "createUserGroup", "userGroupCreateRequest", userGroupCreateRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -197,11 +193,7 @@ public CompletableFuture> deleteUserGroup(String groupId) } private HttpRequest.Builder deleteUserGroupRequestBuilder(String groupId) throws ApiException { - // verify the required parameter 'groupId' is set - if (groupId == null) { - throw new ApiException( - 400, "Missing the required parameter 'groupId' when calling deleteUserGroup"); - } + ValidationUtils.assertParamExistsAndNotEmpty("deleteUserGroup", "groupId", groupId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -268,11 +260,7 @@ public CompletableFuture> getUserGroup(String gro } private HttpRequest.Builder getUserGroupRequestBuilder(String groupId) throws ApiException { - // verify the required parameter 'groupId' is set - if (groupId == null) { - throw new ApiException( - 400, "Missing the required parameter 'groupId' when calling getUserGroup"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getUserGroup", "groupId", groupId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -411,18 +399,9 @@ public CompletableFuture> updateUserGroup( private HttpRequest.Builder updateUserGroupRequestBuilder( UserGroupUpdateRequest userGroupUpdateRequest, String groupId, String idempotencyKey) throws ApiException { - // verify the required parameter 'userGroupUpdateRequest' is set - if (userGroupUpdateRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'userGroupUpdateRequest' when calling" - + " updateUserGroup"); - } - // verify the required parameter 'groupId' is set - if (groupId == null) { - throw new ApiException( - 400, "Missing the required parameter 'groupId' when calling updateUserGroup"); - } + ValidationUtils.assertParamExists( + "updateUserGroup", "userGroupUpdateRequest", userGroupUpdateRequest); + ValidationUtils.assertParamExistsAndNotEmpty("updateUserGroup", "groupId", groupId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/VaultsApi.java b/src/main/java/com/fireblocks/sdk/api/VaultsApi.java index 9d59401..b7f39fb 100644 --- a/src/main/java/com/fireblocks/sdk/api/VaultsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/VaultsApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateAddressRequest; import com.fireblocks.sdk.model.CreateAddressResponse; import com.fireblocks.sdk.model.CreateAssetsRequest; @@ -147,20 +148,10 @@ public CompletableFuture> activateAssetFor private HttpRequest.Builder activateAssetForVaultAccountRequestBuilder( String vaultAccountId, String assetId, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " activateAssetForVaultAccount"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " activateAssetForVaultAccount"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "activateAssetForVaultAccount", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "activateAssetForVaultAccount", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -241,25 +232,10 @@ public CompletableFuture> createLegacyAddress private HttpRequest.Builder createLegacyAddressRequestBuilder( String vaultAccountId, String assetId, String addressId, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " createLegacyAddress"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling createLegacyAddress"); - } - // verify the required parameter 'addressId' is set - if (addressId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'addressId' when calling createLegacyAddress"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "createLegacyAddress", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty("createLegacyAddress", "assetId", assetId); + ValidationUtils.assertParamExistsAndNotEmpty("createLegacyAddress", "addressId", addressId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -340,13 +316,10 @@ public CompletableFuture> createMultipleAccounts( private HttpRequest.Builder createMultipleAccountsRequestBuilder( CreateMultipleAccountsRequest createMultipleAccountsRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'createMultipleAccountsRequest' is set - if (createMultipleAccountsRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createMultipleAccountsRequest' when calling" - + " createMultipleAccounts"); - } + ValidationUtils.assertParamExists( + "createMultipleAccounts", + "createMultipleAccountsRequest", + createMultipleAccountsRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -428,13 +401,8 @@ public CompletableFuture> createVaultAccount( private HttpRequest.Builder createVaultAccountRequestBuilder( CreateVaultAccountRequest createVaultAccountRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'createVaultAccountRequest' is set - if (createVaultAccountRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createVaultAccountRequest' when calling" - + " createVaultAccount"); - } + ValidationUtils.assertParamExists( + "createVaultAccount", "createVaultAccountRequest", createVaultAccountRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -526,20 +494,9 @@ private HttpRequest.Builder createVaultAccountAssetRequestBuilder( CreateAssetsRequest createAssetsRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " createVaultAccountAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " createVaultAccountAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "createVaultAccountAsset", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty("createVaultAccountAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -634,20 +591,10 @@ private HttpRequest.Builder createVaultAccountAssetAddressRequestBuilder( CreateAddressRequest createAddressRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " createVaultAccountAssetAddress"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " createVaultAccountAssetAddress"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "createVaultAccountAssetAddress", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "createVaultAccountAssetAddress", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -850,19 +797,9 @@ public CompletableFuture> getMaxSpend private HttpRequest.Builder getMaxSpendableAmountRequestBuilder( String vaultAccountId, String assetId, Boolean manualSignging) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " getMaxSpendableAmount"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getMaxSpendableAmount"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getMaxSpendableAmount", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty("getMaxSpendableAmount", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1078,19 +1015,9 @@ public CompletableFuture> getPublicKeyInfo( private HttpRequest.Builder getPublicKeyInfoRequestBuilder( String derivationPath, String algorithm, Boolean compressed) throws ApiException { - // verify the required parameter 'derivationPath' is set - if (derivationPath == null) { - throw new ApiException( - 400, - "Missing the required parameter 'derivationPath' when calling" - + " getPublicKeyInfo"); - } - // verify the required parameter 'algorithm' is set - if (algorithm == null) { - throw new ApiException( - 400, - "Missing the required parameter 'algorithm' when calling getPublicKeyInfo"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfo", "derivationPath", derivationPath); + ValidationUtils.assertParamExistsAndNotEmpty("getPublicKeyInfo", "algorithm", algorithm); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1192,34 +1119,13 @@ private HttpRequest.Builder getPublicKeyInfoForAddressRequestBuilder( BigDecimal addressIndex, Boolean compressed) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " getPublicKeyInfoForAddress"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " getPublicKeyInfoForAddress"); - } - // verify the required parameter 'change' is set - if (change == null) { - throw new ApiException( - 400, - "Missing the required parameter 'change' when calling" - + " getPublicKeyInfoForAddress"); - } - // verify the required parameter 'addressIndex' is set - if (addressIndex == null) { - throw new ApiException( - 400, - "Missing the required parameter 'addressIndex' when calling" - + " getPublicKeyInfoForAddress"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfoForAddress", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfoForAddress", "assetId", assetId); + ValidationUtils.assertParamExists("getPublicKeyInfoForAddress", "change", change); + ValidationUtils.assertParamExists( + "getPublicKeyInfoForAddress", "addressIndex", addressIndex); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1308,18 +1214,9 @@ public CompletableFuture>> getUnspentInp private HttpRequest.Builder getUnspentInputsRequestBuilder( String vaultAccountId, String assetId) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " getUnspentInputs"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, "Missing the required parameter 'assetId' when calling getUnspentInputs"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getUnspentInputs", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty("getUnspentInputs", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1387,12 +1284,8 @@ public CompletableFuture> getVaultAccount(String vault private HttpRequest.Builder getVaultAccountRequestBuilder(String vaultAccountId) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling getVaultAccount"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getVaultAccount", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1463,19 +1356,9 @@ public CompletableFuture> getVaultAccountAsset( private HttpRequest.Builder getVaultAccountAssetRequestBuilder( String vaultAccountId, String assetId) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " getVaultAccountAsset"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getVaultAccountAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getVaultAccountAsset", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty("getVaultAccountAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1558,20 +1441,10 @@ private HttpRequest.Builder getVaultAccountAssetRequestBuilder( private HttpRequest.Builder getVaultAccountAssetAddressesPaginatedRequestBuilder( String vaultAccountId, String assetId, BigDecimal limit, String before, String after) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " getVaultAccountAssetAddressesPaginated"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " getVaultAccountAssetAddressesPaginated"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "getVaultAccountAssetAddressesPaginated", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "getVaultAccountAssetAddressesPaginated", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1747,12 +1620,7 @@ public CompletableFuture> getVaultBalanceByAsset(String private HttpRequest.Builder getVaultBalanceByAssetRequestBuilder(String assetId) throws ApiException { - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling getVaultBalanceByAsset"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getVaultBalanceByAsset", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1823,13 +1691,8 @@ public CompletableFuture> hideVaultAccount( private HttpRequest.Builder hideVaultAccountRequestBuilder( String vaultAccountId, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " hideVaultAccount"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "hideVaultAccount", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -1925,34 +1788,16 @@ private HttpRequest.Builder setCustomerRefIdForAddressRequestBuilder( String addressId, String idempotencyKey) throws ApiException { - // verify the required parameter 'setCustomerRefIdForAddressRequest' is set - if (setCustomerRefIdForAddressRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setCustomerRefIdForAddressRequest' when" - + " calling setCustomerRefIdForAddress"); - } - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " setCustomerRefIdForAddress"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " setCustomerRefIdForAddress"); - } - // verify the required parameter 'addressId' is set - if (addressId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'addressId' when calling" - + " setCustomerRefIdForAddress"); - } + ValidationUtils.assertParamExists( + "setCustomerRefIdForAddress", + "setCustomerRefIdForAddressRequest", + setCustomerRefIdForAddressRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "setCustomerRefIdForAddress", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "setCustomerRefIdForAddress", "assetId", assetId); + ValidationUtils.assertParamExistsAndNotEmpty( + "setCustomerRefIdForAddress", "addressId", addressId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -2041,20 +1886,10 @@ public CompletableFuture> setVaultAccountAutoFuel private HttpRequest.Builder setVaultAccountAutoFuelRequestBuilder( SetAutoFuelRequest setAutoFuelRequest, String vaultAccountId, String idempotencyKey) throws ApiException { - // verify the required parameter 'setAutoFuelRequest' is set - if (setAutoFuelRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setAutoFuelRequest' when calling" - + " setVaultAccountAutoFuel"); - } - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " setVaultAccountAutoFuel"); - } + ValidationUtils.assertParamExists( + "setVaultAccountAutoFuel", "setAutoFuelRequest", setAutoFuelRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "setVaultAccountAutoFuel", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -2146,20 +1981,10 @@ private HttpRequest.Builder setVaultAccountCustomerRefIdRequestBuilder( String vaultAccountId, String idempotencyKey) throws ApiException { - // verify the required parameter 'setCustomerRefIdRequest' is set - if (setCustomerRefIdRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'setCustomerRefIdRequest' when calling" - + " setVaultAccountCustomerRefId"); - } - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " setVaultAccountCustomerRefId"); - } + ValidationUtils.assertParamExists( + "setVaultAccountCustomerRefId", "setCustomerRefIdRequest", setCustomerRefIdRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "setVaultAccountCustomerRefId", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -2243,13 +2068,8 @@ public CompletableFuture> unhideVaultAccount( private HttpRequest.Builder unhideVaultAccountRequestBuilder( String vaultAccountId, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " unhideVaultAccount"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "unhideVaultAccount", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -2332,20 +2152,10 @@ private HttpRequest.Builder updateVaultAccountRequestBuilder( String vaultAccountId, String idempotencyKey) throws ApiException { - // verify the required parameter 'updateVaultAccountRequest' is set - if (updateVaultAccountRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'updateVaultAccountRequest' when calling" - + " updateVaultAccount"); - } - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " updateVaultAccount"); - } + ValidationUtils.assertParamExists( + "updateVaultAccount", "updateVaultAccountRequest", updateVaultAccountRequest); + ValidationUtils.assertParamExistsAndNotEmpty( + "updateVaultAccount", "vaultAccountId", vaultAccountId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -2449,27 +2259,12 @@ private HttpRequest.Builder updateVaultAccountAssetAddressRequestBuilder( UpdateVaultAccountAssetAddressRequest updateVaultAccountAssetAddressRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " updateVaultAccountAssetAddress"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " updateVaultAccountAssetAddress"); - } - // verify the required parameter 'addressId' is set - if (addressId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'addressId' when calling" - + " updateVaultAccountAssetAddress"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "updateVaultAccountAssetAddress", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "updateVaultAccountAssetAddress", "assetId", assetId); + ValidationUtils.assertParamExistsAndNotEmpty( + "updateVaultAccountAssetAddress", "addressId", addressId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -2556,20 +2351,10 @@ public CompletableFuture> updateVaultAccountAssetBalance private HttpRequest.Builder updateVaultAccountAssetBalanceRequestBuilder( String vaultAccountId, String assetId, String idempotencyKey) throws ApiException { - // verify the required parameter 'vaultAccountId' is set - if (vaultAccountId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'vaultAccountId' when calling" - + " updateVaultAccountAssetBalance"); - } - // verify the required parameter 'assetId' is set - if (assetId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'assetId' when calling" - + " updateVaultAccountAssetBalance"); - } + ValidationUtils.assertParamExistsAndNotEmpty( + "updateVaultAccountAssetBalance", "vaultAccountId", vaultAccountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "updateVaultAccountAssetBalance", "assetId", assetId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/Web3ConnectionsApi.java b/src/main/java/com/fireblocks/sdk/api/Web3ConnectionsApi.java index 81c878f..09aca5b 100644 --- a/src/main/java/com/fireblocks/sdk/api/Web3ConnectionsApi.java +++ b/src/main/java/com/fireblocks/sdk/api/Web3ConnectionsApi.java @@ -19,6 +19,7 @@ import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.CreateConnectionRequest; import com.fireblocks.sdk.model.CreateConnectionResponse; import com.fireblocks.sdk.model.GetConnectionsResponse; @@ -129,12 +130,8 @@ public CompletableFuture> create( private HttpRequest.Builder createRequestBuilder( CreateConnectionRequest createConnectionRequest, String idempotencyKey) throws ApiException { - // verify the required parameter 'createConnectionRequest' is set - if (createConnectionRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'createConnectionRequest' when calling create"); - } + ValidationUtils.assertParamExists( + "create", "createConnectionRequest", createConnectionRequest); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -299,10 +296,7 @@ public CompletableFuture> remove(String id) throws ApiExceptio } private HttpRequest.Builder removeRequestBuilder(String id) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException(400, "Missing the required parameter 'id' when calling remove"); - } + ValidationUtils.assertParamExistsAndNotEmpty("remove", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); @@ -367,17 +361,9 @@ public CompletableFuture> submit( private HttpRequest.Builder submitRequestBuilder( RespondToConnectionRequest respondToConnectionRequest, String id, String idempotencyKey) throws ApiException { - // verify the required parameter 'respondToConnectionRequest' is set - if (respondToConnectionRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'respondToConnectionRequest' when calling" - + " submit"); - } - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException(400, "Missing the required parameter 'id' when calling submit"); - } + ValidationUtils.assertParamExists( + "submit", "respondToConnectionRequest", respondToConnectionRequest); + ValidationUtils.assertParamExistsAndNotEmpty("submit", "id", id); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/WebhooksApi.java b/src/main/java/com/fireblocks/sdk/api/WebhooksApi.java index e38ccfb..398fa35 100644 --- a/src/main/java/com/fireblocks/sdk/api/WebhooksApi.java +++ b/src/main/java/com/fireblocks/sdk/api/WebhooksApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.ResendTransactionWebhooksRequest; import com.fireblocks.sdk.model.ResendWebhooksByTransactionIdResponse; import com.fireblocks.sdk.model.ResendWebhooksResponse; @@ -129,19 +130,11 @@ private HttpRequest.Builder resendTransactionWebhooksRequestBuilder( String txId, String idempotencyKey) throws ApiException { - // verify the required parameter 'resendTransactionWebhooksRequest' is set - if (resendTransactionWebhooksRequest == null) { - throw new ApiException( - 400, - "Missing the required parameter 'resendTransactionWebhooksRequest' when calling" - + " resendTransactionWebhooks"); - } - // verify the required parameter 'txId' is set - if (txId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'txId' when calling resendTransactionWebhooks"); - } + ValidationUtils.assertParamExists( + "resendTransactionWebhooks", + "resendTransactionWebhooksRequest", + resendTransactionWebhooksRequest); + ValidationUtils.assertParamExistsAndNotEmpty("resendTransactionWebhooks", "txId", txId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/main/java/com/fireblocks/sdk/api/WhitelistIpAddressesApi.java b/src/main/java/com/fireblocks/sdk/api/WhitelistIpAddressesApi.java index 0d99cc0..a64c7e5 100644 --- a/src/main/java/com/fireblocks/sdk/api/WhitelistIpAddressesApi.java +++ b/src/main/java/com/fireblocks/sdk/api/WhitelistIpAddressesApi.java @@ -18,6 +18,7 @@ import com.fireblocks.sdk.ApiClient; import com.fireblocks.sdk.ApiException; import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.ValidationUtils; import com.fireblocks.sdk.model.GetWhitelistIpAddressesResponse; import java.io.IOException; import java.io.InputStream; @@ -114,12 +115,7 @@ public CompletableFuture> getWhitel private HttpRequest.Builder getWhitelistIpAddressesRequestBuilder(String userId) throws ApiException { - // verify the required parameter 'userId' is set - if (userId == null) { - throw new ApiException( - 400, - "Missing the required parameter 'userId' when calling getWhitelistIpAddresses"); - } + ValidationUtils.assertParamExistsAndNotEmpty("getWhitelistIpAddresses", "userId", userId); HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); diff --git a/src/test/java/com/fireblocks/sdk/ValidationUtilsTest.java b/src/test/java/com/fireblocks/sdk/ValidationUtilsTest.java new file mode 100644 index 0000000..5e049ee --- /dev/null +++ b/src/test/java/com/fireblocks/sdk/ValidationUtilsTest.java @@ -0,0 +1,66 @@ +import static org.junit.Assert.*; + +import com.fireblocks.sdk.ApiException; +import com.fireblocks.sdk.ValidationUtils; +import org.junit.Test; + +public class ValidationUtilsTest { + + @Test + public void testAssertParamExistsAndNotEmpty() { + String functionName = "testFunction"; + String paramName = "testParam"; + String paramValue = "testValue"; + + try { + ValidationUtils.assertParamExistsAndNotEmpty(functionName, paramName, paramValue); + } catch (ApiException e) { + fail("ApiException was not expected."); + } + } + + @Test + public void testAssertParamExistsAndNotEmptyWithEmptyParamValue() { + String functionName = "testFunction"; + String paramName = "testParam"; + String paramValue = ""; + + try { + ValidationUtils.assertParamExistsAndNotEmpty(functionName, paramName, paramValue); + fail("ApiException was expected but not thrown."); + } catch (ApiException e) { + assertEquals( + "The required parameter 'testParam' was empty when calling 'testFunction'", + e.getMessage()); + } + } + + @Test + public void testAssertParamExists() { + String functionName = "testFunction"; + String paramName = "testParam"; + Object paramValue = new Object(); + + try { + ValidationUtils.assertParamExists(functionName, paramName, paramValue); + } catch (ApiException e) { + fail("ApiException was not expected."); + } + } + + @Test + public void testAssertParamExistsWithNullParamValue() { + String functionName = "testFunction"; + String paramName = "testParam"; + Object paramValue = null; + + try { + ValidationUtils.assertParamExists(functionName, paramName, paramValue); + fail("ApiException was expected but not thrown."); + } catch (ApiException e) { + assertEquals( + "The required parameter 'testParam' is missing from call to 'testFunction'", + e.getMessage()); + } + } +}