From 72b129e5fe752a1dfe082c843a70cb51f30fa64e Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Fri, 24 Apr 2026 11:46:06 -0700 Subject: [PATCH 1/8] add generation and update SDK per generated files --- .gitignore | 3 + CHANGELOG.md | 1 + CLAUDE.md | 82 ++-- README.md | 27 +- pom.xml | 13 +- .../activities/ListPortfolioActivities.java | 62 +-- .../addressbook/ListAddressBookEntries.java | 27 ++ .../CancelAdvancedTransfer.java | 27 ++ .../CreateAdvancedTransfer.java | 27 ++ .../GetPortfolioCounterparty.java | 27 ++ .../GetPortfolioCounterpartyId.java | 27 ++ .../ListAdvancedTransferTransactions.java | 27 ++ .../ListAdvancedTransfers.java | 27 ++ .../allocations/CreateAllocation.java | 27 ++ .../allocations/CreateNetAllocation.java | 27 ++ .../examples/allocations/GetAllocation.java | 27 ++ .../ListAllocationsByClientNettingId.java | 27 ++ .../ListAllocationsByNettingId.java | 27 ++ .../allocations/ListPortfolioAllocations.java | 27 ++ .../examples/financing/CreateNewLocates.java | 27 ++ .../financing/GetCrossMarginOverview.java | 27 ++ .../GetEntityLocateAvailabilities.java | 27 ++ .../financing/GetMarginInformation.java | 27 ++ .../financing/GetPortfolioBuyingPower.java | 27 ++ .../GetPortfolioCreditInformation.java | 27 ++ .../GetPortfolioWithdrawalPower.java | 27 ++ .../GetTradeFinanceTieredPricingFees.java | 27 ++ .../financing/ListExistingLocates.java | 27 ++ .../financing/ListInterestAccruals.java | 27 ++ .../ListInterestAccrualsForPortfolio.java | 27 ++ .../financing/ListMarginCallSummaries.java | 27 ++ .../financing/ListMarginConversions.java | 27 ++ .../ListTradeFinanceObligations.java | 27 ++ .../financing/UpdateFundingSettings.java | 27 ++ .../futures/CancelEntityFuturesSweep.java | 27 ++ .../examples/futures/GetEntityFcmBalance.java | 27 ++ .../examples/futures/GetFcmEquity.java | 27 ++ .../futures/GetFcmMarginCallDetails.java | 27 ++ .../examples/futures/GetFcmRiskLimits.java | 27 ++ .../examples/futures/GetPositions.java | 27 ++ .../futures/ListEntityFuturesSweeps.java | 27 ++ .../futures/ScheduleEntityFuturesSweep.java | 27 ++ .../examples/futures/SetAutoSweep.java | 27 ++ .../coinbase/examples/orders/GetOrder.java | 27 ++ .../examples/orders/GetOrderByOrderId.java | 27 ++ .../examples/orders/GetOrderPreview.java | 27 ++ .../GetPaymentMethodDetails.java | 36 +- .../paymentmethods/ListPaymentMethods.java | 31 +- .../ListAggregateEntityPositions.java | 27 ++ .../positions/ListEntityPositions.java | 27 ++ .../examples/products/GetCandles.java | 27 ++ .../examples/staking/ClaimStakingRewards.java | 27 ++ .../staking/CreatePortfolioStake.java | 27 ++ .../staking/CreatePortfolioUnstake.java | 27 ++ .../CreateOnchainTransaction.java | 27 ++ .../examples/transactions/CreateTransfer.java | 27 ++ .../transactions/CreateWithdrawal.java | 27 ++ .../SubmitDepositTravelRuleData.java | 27 ++ .../coinbase/examples/users/ListUsers.java | 27 ++ .../examples/wallets/ListWallets.java | 27 ++ .../prime/activities/ActivitiesService.java | 10 +- .../activities/ActivitiesServiceImpl.java | 23 +- .../prime/activities/GetActivityRequest.java | 33 +- .../prime/activities/GetActivityResponse.java | 7 +- .../GetPortfolioActivityRequest.java | 22 +- .../GetPortfolioActivityResponse.java | 5 +- .../ListEntityActivitiesRequest.java | 67 +++- .../ListEntityActivitiesResponse.java | 11 +- .../ListPortfolioActivitiesRequest.java | 43 +- .../ListPortfolioActivitiesResponse.java | 11 +- .../prime/addressbook/AddressBookService.java | 5 +- .../addressbook/AddressBookServiceImpl.java | 5 +- .../CreateAddressBookEntryRequest.java | 44 ++- .../CreateAddressBookEntryResponse.java | 3 + .../ListAddressBookEntriesRequest.java | 124 ++++++ .../ListAddressBookEntriesResponse.java | 52 +++ .../addressbook/ListAddressBookRequest.java | 16 +- .../addressbook/ListAddressBookResponse.java | 6 + .../AdvancedTransferService.java | 33 ++ .../AdvancedTransferServiceImpl.java | 82 ++++ .../CancelAdvancedTransferRequest.java | 92 +++++ .../CancelAdvancedTransferResponse.java | 39 ++ .../CreateAdvancedTransferRequest.java | 89 +++++ .../CreateAdvancedTransferResponse.java | 40 ++ .../GetPortfolioCounterpartyIdRequest.java | 70 ++++ .../GetPortfolioCounterpartyIdResponse.java | 40 ++ .../GetPortfolioCounterpartyRequest.java | 70 ++++ .../GetPortfolioCounterpartyResponse.java | 40 ++ ...stAdvancedTransferTransactionsRequest.java | 92 +++++ ...tAdvancedTransferTransactionsResponse.java | 40 ++ .../ListAdvancedTransfersRequest.java | 180 +++++++++ .../ListAdvancedTransfersResponse.java | 52 +++ .../prime/allocations/AllocationsService.java | 12 +- .../allocations/AllocationsServiceImpl.java | 24 +- .../allocations/CreateAllocationRequest.java | 19 +- .../allocations/CreateAllocationResponse.java | 41 +- .../CreateNetAllocationRequest.java | 15 +- .../CreateNetAllocationResponse.java | 76 +--- .../allocations/GetAllocationRequest.java | 20 +- .../allocations/GetAllocationResponse.java | 7 +- ...stAllocationsByClientNettingIdRequest.java | 92 +++++ ...tAllocationsByClientNettingIdResponse.java | 40 ++ .../ListAllocationsByNettingIdRequest.java | 20 +- .../ListAllocationsByNettingIdResponse.java | 7 +- .../ListPortfolioAllocationsRequest.java | 46 +-- .../ListPortfolioAllocationsResponse.java | 22 +- .../coinbase/prime/assets/AssetsService.java | 4 +- .../prime/assets/AssetsServiceImpl.java | 4 +- .../prime/assets/ListAssetsRequest.java | 15 +- .../prime/assets/ListAssetsResponse.java | 5 +- .../prime/balances/BalancesService.java | 7 +- .../prime/balances/BalancesServiceImpl.java | 5 +- .../balances/GetWalletBalanceRequest.java | 8 +- .../balances/GetWalletBalanceResponse.java | 5 +- .../balances/ListEntityBalancesRequest.java | 38 +- .../balances/ListEntityBalancesResponse.java | 12 +- .../ListOnchainWalletBalancesRequest.java | 17 +- .../ListOnchainWalletBalancesResponse.java | 22 +- .../ListPortfolioBalancesRequest.java | 35 +- .../ListPortfolioBalancesResponse.java | 24 +- .../prime/commission/CommissionService.java | 4 +- .../commission/CommissionServiceImpl.java | 3 +- .../GetPortfolioCommissionRequest.java | 9 +- .../GetPortfolioCommissionResponse.java | 5 +- .../prime/factory/PrimeServiceFactory.java | 17 +- .../financing/CreateNewLocatesRequest.java | 159 +++++--- .../financing/CreateNewLocatesResponse.java | 24 +- .../prime/financing/FinancingService.java | 33 +- .../prime/financing/FinancingServiceImpl.java | 85 ++-- .../GetCrossMarginOverviewRequest.java | 17 +- .../GetCrossMarginOverviewResponse.java | 4 +- .../GetEntityLocateAvailabilitiesRequest.java | 17 +- ...GetEntityLocateAvailabilitiesResponse.java | 5 + .../GetMarginInformationRequest.java | 17 +- .../GetMarginInformationResponse.java | 3 +- .../GetPortfolioBuyingPowerRequest.java | 21 +- .../GetPortfolioBuyingPowerResponse.java | 3 + .../GetPortfolioCreditInformationRequest.java | 11 +- ...GetPortfolioCreditInformationResponse.java | 7 +- .../GetPortfolioWithdrawalPowerRequest.java | 19 +- .../GetPortfolioWithdrawalPowerResponse.java | 8 +- ...tTradeFinanceTieredPricingFeesRequest.java | 17 +- ...TradeFinanceTieredPricingFeesResponse.java | 5 + .../financing/ListExistingLocatesRequest.java | 51 ++- .../ListExistingLocatesResponse.java | 13 +- .../ListFinancingEligibleAssetsResponse.java | 12 +- ...stInterestAccrualsForPortfolioRequest.java | 19 +- ...tInterestAccrualsForPortfolioResponse.java | 4 + .../ListInterestAccrualsRequest.java | 17 +- .../ListInterestAccrualsResponse.java | 4 + .../ListMarginCallSummariesRequest.java | 17 +- .../ListMarginCallSummariesResponse.java | 3 + .../ListMarginConversionsRequest.java | 17 +- .../ListMarginConversionsResponse.java | 5 + .../ListTradeFinanceObligationsRequest.java | 70 ++++ .../ListTradeFinanceObligationsResponse.java | 40 ++ .../UpdateFundingSettingsRequest.java | 160 ++++++++ .../UpdateFundingSettingsResponse.java | 61 +++ .../CancelEntityFuturesSweepRequest.java | 7 +- .../CancelEntityFuturesSweepResponse.java | 10 +- .../prime/futures/FuturesService.java | 20 +- .../prime/futures/FuturesServiceImpl.java | 60 +-- .../futures/GetEntityFcmBalanceRequest.java | 7 +- .../futures/GetEntityFcmBalanceResponse.java | 4 + .../prime/futures/GetFcmEquityRequest.java | 19 +- .../prime/futures/GetFcmEquityResponse.java | 48 +-- .../GetFcmMarginCallDetailsRequest.java | 7 +- .../GetFcmMarginCallDetailsResponse.java | 4 + .../futures/GetFcmRiskLimitsRequest.java | 7 +- .../futures/GetFcmRiskLimitsResponse.java | 33 +- .../prime/futures/GetFcmSettingsRequest.java | 17 +- .../prime/futures/GetFcmSettingsResponse.java | 4 + .../prime/futures/GetPositionsRequest.java | 9 +- .../prime/futures/GetPositionsResponse.java | 11 +- .../ListEntityFuturesSweepsRequest.java | 10 +- .../ListEntityFuturesSweepsResponse.java | 11 +- .../ScheduleEntityFuturesSweepRequest.java | 23 +- .../ScheduleEntityFuturesSweepResponse.java | 10 +- .../prime/futures/SetAutoSweepRequest.java | 17 +- .../prime/futures/SetAutoSweepResponse.java | 12 +- .../prime/futures/SetFcmSettingsRequest.java | 17 +- .../prime/futures/SetFcmSettingsResponse.java | 4 + .../prime/invoice/InvoiceService.java | 4 +- .../prime/invoice/InvoiceServiceImpl.java | 3 +- .../prime/invoice/ListInvoicesRequest.java | 60 +-- .../prime/invoice/ListInvoicesResponse.java | 5 + .../prime/model/ActiveLiquidationSummary.java | 2 +- .../prime/model/AdvancedTransfer.java | 2 +- .../prime/model/BlindMatchMetadata.java | 2 +- .../prime/model/CommissionDetailTotal.java | 2 +- .../prime/model/FcmScheduledMaintenance.java | 2 +- .../prime/model/FcmTradingSessionDetails.java | 2 +- .../coinbase/prime/model/FundMovement.java | 2 +- .../prime/model/FutureProductDetails.java | 2 +- .../prime/model/PerpetualProductDetails.java | 2 +- ...leDataForAnExistingDepositTransaction.java | 2 +- .../coinbase/prime/model/StakingStatus.java | 2 +- .../coinbase/prime/model/TravelRuleData.java | 2 +- .../prime/model/ValidatorAllocation.java | 2 +- .../prime/model/ValidatorStakingInfo.java | 2 +- .../prime/model/ValidatorUnstakePreview.java | 2 +- .../model/enums/AdvancedTransferState.java | 2 +- .../model/enums/AdvancedTransferType.java | 2 +- .../prime/model/enums/ContractExpiryType.java | 2 +- .../model/enums/ExpiringContractStatus.java | 2 +- .../model/enums/FcmMarginHealthState.java | 2 +- .../enums/FcmTradingSessionClosedReason.java | 2 +- .../model/enums/FcmTradingSessionState.java | 2 +- .../prime/model/enums/ProductType.java | 2 +- .../prime/model/enums/RiskManagementType.java | 2 +- .../model/enums/SecondaryPermission.java | 2 +- .../coinbase/prime/model/enums/StakeType.java | 2 +- .../model/enums/XmLiquidationStatus.java | 2 +- .../CreateOnchainAddressBookEntryRequest.java | 15 +- ...CreateOnchainAddressBookEntryResponse.java | 9 +- .../DeleteOnchainAddressGroupRequest.java | 19 +- .../DeleteOnchainAddressGroupResponse.java | 9 +- .../ListOnchainAddressGroupsRequest.java | 46 +-- .../ListOnchainAddressGroupsResponse.java | 12 +- .../OnchainAddressBookService.java | 6 +- .../OnchainAddressBookServiceImpl.java | 24 +- .../UpdateOnchainAddressBookEntryRequest.java | 21 +- ...UpdateOnchainAddressBookEntryResponse.java | 9 +- .../prime/orders/AcceptQuoteRequest.java | 213 +++++----- .../prime/orders/AcceptQuoteResponse.java | 27 +- .../prime/orders/CancelOrderRequest.java | 11 +- .../prime/orders/CancelOrderResponse.java | 7 +- .../prime/orders/CreateOrderRequest.java | 135 ++++--- .../prime/orders/CreateOrderResponse.java | 5 +- .../prime/orders/CreateQuoteRequest.java | 274 ++++++------- .../prime/orders/CreateQuoteResponse.java | 95 +++-- .../prime/orders/EditOrderRequest.java | 44 +-- .../prime/orders/EditOrderResponse.java | 3 +- .../orders/GetOrderByOrderIdRequest.java | 50 +-- .../orders/GetOrderByOrderIdResponse.java | 7 +- .../prime/orders/GetOrderPreviewRequest.java | 132 ++++--- .../prime/orders/GetOrderPreviewResponse.java | 28 ++ .../prime/orders/GetOrderRequest.java | 92 +++++ .../GetOrderResponse.java} | 28 +- .../prime/orders/ListOpenOrdersRequest.java | 44 ++- .../prime/orders/ListOpenOrdersResponse.java | 12 +- .../orders/ListOrderEditHistoryRequest.java | 16 +- .../orders/ListOrderEditHistoryResponse.java | 19 +- .../prime/orders/ListOrderFillsRequest.java | 23 +- .../prime/orders/ListOrderFillsResponse.java | 7 + .../orders/ListPortfolioFillsRequest.java | 23 +- .../orders/ListPortfolioFillsResponse.java | 7 + .../orders/ListPortfolioOrdersRequest.java | 25 +- .../orders/ListPortfolioOrdersResponse.java | 7 + .../coinbase/prime/orders/OrdersService.java | 19 +- .../prime/orders/OrdersServiceImpl.java | 78 ++-- .../GetPaymentMethodDetailsRequest.java | 9 +- .../GetPaymentMethodDetailsResponse.java | 3 + .../ListPaymentMethodsRequest.java | 15 +- .../ListPaymentMethodsResponse.java | 3 + .../paymentmethods/PaymentMethodsService.java | 10 +- .../PaymentMethodsServiceImpl.java | 5 +- .../prime/portfolios/GetPortfolioRequest.java | 15 +- .../portfolios/GetPortfolioResponse.java | 5 + .../portfolios/ListPortfoliosResponse.java | 15 +- .../prime/portfolios/PortfoliosService.java | 8 +- .../portfolios/PortfoliosServiceImpl.java | 19 +- .../ListAggregateEntityPositionsRequest.java | 88 +++++ .../ListAggregateEntityPositionsResponse.java | 52 +++ .../ListAggregatePositionsRequest.java | 32 +- .../ListAggregatePositionsResponse.java | 11 +- .../positions/ListEntityPositionsRequest.java | 88 +++++ .../ListEntityPositionsResponse.java | 52 +++ .../prime/positions/ListPositionsRequest.java | 31 +- .../positions/ListPositionsResponse.java | 12 +- .../prime/positions/PositionsService.java | 2 + .../prime/positions/PositionsServiceImpl.java | 10 +- .../prime/products/GetCandlesRequest.java | 143 +++++++ .../GetCandlesResponse.java} | 28 +- .../ListPortfolioProductsRequest.java | 70 +++- .../ListPortfolioProductsResponse.java | 10 +- .../prime/products/ProductsService.java | 7 +- .../prime/products/ProductsServiceImpl.java | 15 +- .../prime/staking/ClaimRewardsRequest.java | 17 +- .../prime/staking/ClaimRewardsResponse.java | 10 +- .../staking/ClaimStakingRewardsRequest.java | 129 ++++++ .../staking/ClaimStakingRewardsResponse.java | 61 +++ .../staking/CreatePortfolioStakeRequest.java | 143 +++++++ .../staking/CreatePortfolioStakeResponse.java | 50 +++ .../CreatePortfolioUnstakeRequest.java | 143 +++++++ .../CreatePortfolioUnstakeResponse.java | 50 +++ .../prime/staking/CreateStakeRequest.java | 23 +- .../prime/staking/CreateStakeResponse.java | 3 + .../prime/staking/CreateUnstakeRequest.java | 33 +- .../prime/staking/CreateUnstakeResponse.java | 3 + .../staking/GetStakingStatusRequest.java | 24 +- .../staking/GetStakingStatusResponse.java | 14 +- .../staking/GetUnstakingStatusRequest.java | 22 +- .../staking/GetUnstakingStatusResponse.java | 12 +- .../ListTransactionValidatorsRequest.java | 70 +++- .../ListTransactionValidatorsResponse.java | 11 +- .../PortfolioStakingInitiateRequest.java | 19 +- .../PortfolioStakingInitiateResponse.java | 3 + .../PortfolioStakingUnstakeRequest.java | 19 +- .../PortfolioStakingUnstakeResponse.java | 3 + .../prime/staking/PreviewUnstakeRequest.java | 22 +- .../prime/staking/PreviewUnstakeResponse.java | 49 +++ .../prime/staking/StakingService.java | 13 +- .../prime/staking/StakingServiceImpl.java | 60 +-- .../transactions/CreateConversionRequest.java | 29 +- .../CreateConversionResponse.java | 12 + .../CreateOnchainTransactionRequest.java | 21 +- .../CreateOnchainTransactionResponse.java | 5 +- .../transactions/CreateTransferRequest.java | 164 ++++++++ .../transactions/CreateTransferResponse.java | 138 +++++++ .../CreateWalletTransferRequest.java | 75 ++-- .../CreateWalletTransferResponse.java | 40 +- .../CreateWalletWithdrawalRequest.java | 79 ++-- .../CreateWalletWithdrawalResponse.java | 29 +- .../transactions/CreateWithdrawalRequest.java | 241 ++++++++++++ .../CreateWithdrawalResponse.java | 151 ++++++++ .../transactions/GetTransactionRequest.java | 22 +- .../transactions/GetTransactionResponse.java | 8 +- .../GetTransactionTravelRuleDataRequest.java | 5 +- .../GetTransactionTravelRuleDataResponse.java | 92 +++-- .../ListPortfolioTransactionsRequest.java | 58 ++- .../ListPortfolioTransactionsResponse.java | 11 +- .../ListWalletTransactionsRequest.java | 23 +- .../ListWalletTransactionsResponse.java | 16 +- .../SubmitDepositTravelRuleDataRequest.java | 30 +- .../SubmitDepositTravelRuleDataResponse.java | 7 +- .../transactions/TransactionsService.java | 26 +- .../transactions/TransactionsServiceImpl.java | 81 ++-- .../prime/users/ListEntityUsersRequest.java | 23 +- .../prime/users/ListEntityUsersResponse.java | 8 +- .../users/ListPortfolioUsersRequest.java | 20 +- .../users/ListPortfolioUsersResponse.java | 15 +- .../prime/users/ListUsersRequest.java | 88 +++++ .../prime/users/ListUsersResponse.java | 52 +++ .../coinbase/prime/users/UsersService.java | 5 +- .../prime/users/UsersServiceImpl.java | 3 +- .../CreateWalletDepositAddressRequest.java | 20 +- .../CreateWalletDepositAddressResponse.java | 6 +- .../prime/wallets/CreateWalletRequest.java | 92 ++++- .../prime/wallets/CreateWalletResponse.java | 23 +- .../GetWalletDepositInstructionsRequest.java | 35 +- .../GetWalletDepositInstructionsResponse.java | 28 +- .../prime/wallets/GetWalletRequest.java | 22 +- .../prime/wallets/GetWalletResponse.java | 7 +- .../wallets/ListWalletAddressesRequest.java | 34 +- .../wallets/ListWalletAddressesResponse.java | 18 +- .../prime/wallets/ListWalletsRequest.java | 41 +- .../prime/wallets/ListWalletsResponse.java | 14 +- .../prime/wallets/WalletsService.java | 9 +- .../prime/wallets/WalletsServiceImpl.java | 31 +- .../ListEntityActivitiesRequestTest.java | 13 +- .../OrdersServiceSerializationTest.java | 4 +- .../RequestSerializationTest.java | 169 ++++---- .../WalletsServiceSerializationTest.java | 15 +- tools/model-generator/README.md | 107 ++--- .../config/generator-config.json | 98 +++++ .../config/operations-overrides.json | 166 ++++++++ tools/model-generator/generate.sh | 6 + tools/model-generator/pom.xml | 22 +- .../coinbase/tools/modelgenerator/Main.java | 75 +--- .../tools/sdkgenerator/CopyrightHelper.java | 43 ++ .../tools/sdkgenerator/GeneratorPaths.java | 53 +++ .../tools/sdkgenerator/SdkGeneratorMain.java | 112 ++++++ .../phases/ClientSurfacePhase.java | 179 +++++++++ .../sdkgenerator/phases/ExamplePhase.java | 89 +++++ .../sdkgenerator/phases/FactoryPhase.java | 47 +++ .../sdkgenerator/phases/ModelEnumPhase.java | 26 ++ .../sdkgenerator/phases/RequestPhase.java | 366 ++++++++++++++++++ .../sdkgenerator/phases/ResponsePhase.java | 116 ++++++ .../sdkgenerator/phases/ServicePhase.java | 255 ++++++++++++ .../processing/GeneratorConfiguration.java | 270 +++++++++++++ .../processing/NamingResolver.java | 14 + .../processing/OpenApiSchemaCodegen.java | 300 ++++++++++++++ .../processing/OperationBindingGenerator.java | 150 +++++++ .../processing/OperationBindingValidator.java | 95 +++++ .../processing/SchemaProperty.java | 65 ++++ .../processing/ServiceDefinition.java | 35 ++ .../processing/SharedTransforms.java | 98 +++++ .../sdkgenerator/processing/SpecAnalyzer.java | 182 +++++++++ .../spec/ParsedOpenApiDocument.java | 29 ++ .../sdkgenerator/spec/ParsedOperation.java | 82 ++++ .../sdkgenerator/spec/ParsedParameter.java | 36 ++ .../spec/SdkOperationBinding.java | 64 +++ .../tools/sdkgenerator/spec/SpecParser.java | 185 +++++++++ .../tools/sdkgenerator/spec/SpecRef.java | 47 +++ .../sdkgenerator/spec/SpecResponseSchema.java | 111 ++++++ .../tools/sdkgenerator/SpecParserTest.java | 46 +++ .../src/test/resources/openapi-minimal.yaml | 45 +++ 388 files changed, 11854 insertions(+), 2513 deletions(-) create mode 100644 src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java create mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java create mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java create mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java create mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java create mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java create mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java create mode 100644 src/main/java/com/coinbase/examples/allocations/CreateAllocation.java create mode 100644 src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java create mode 100644 src/main/java/com/coinbase/examples/allocations/GetAllocation.java create mode 100644 src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java create mode 100644 src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java create mode 100644 src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java create mode 100644 src/main/java/com/coinbase/examples/financing/CreateNewLocates.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetMarginInformation.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java create mode 100644 src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java create mode 100644 src/main/java/com/coinbase/examples/financing/ListExistingLocates.java create mode 100644 src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java create mode 100644 src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java create mode 100644 src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java create mode 100644 src/main/java/com/coinbase/examples/financing/ListMarginConversions.java create mode 100644 src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java create mode 100644 src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java create mode 100644 src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java create mode 100644 src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java create mode 100644 src/main/java/com/coinbase/examples/futures/GetFcmEquity.java create mode 100644 src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java create mode 100644 src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java create mode 100644 src/main/java/com/coinbase/examples/futures/GetPositions.java create mode 100644 src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java create mode 100644 src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java create mode 100644 src/main/java/com/coinbase/examples/futures/SetAutoSweep.java create mode 100644 src/main/java/com/coinbase/examples/orders/GetOrder.java create mode 100644 src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java create mode 100644 src/main/java/com/coinbase/examples/orders/GetOrderPreview.java create mode 100644 src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java create mode 100644 src/main/java/com/coinbase/examples/positions/ListEntityPositions.java create mode 100644 src/main/java/com/coinbase/examples/products/GetCandles.java create mode 100644 src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java create mode 100644 src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java create mode 100644 src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java create mode 100644 src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java create mode 100644 src/main/java/com/coinbase/examples/transactions/CreateTransfer.java create mode 100644 src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java create mode 100644 src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java create mode 100644 src/main/java/com/coinbase/examples/users/ListUsers.java create mode 100644 src/main/java/com/coinbase/examples/wallets/ListWallets.java create mode 100644 src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java create mode 100644 src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java create mode 100644 src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java create mode 100644 src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java create mode 100644 src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java create mode 100644 src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java create mode 100644 src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java create mode 100644 src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java create mode 100644 src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java create mode 100644 src/main/java/com/coinbase/prime/orders/GetOrderRequest.java rename src/main/java/com/coinbase/prime/{financing/ListFinancingEligibleAssetsRequest.java => orders/GetOrderResponse.java} (61%) create mode 100644 src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java create mode 100644 src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java create mode 100644 src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java create mode 100644 src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java create mode 100644 src/main/java/com/coinbase/prime/products/GetCandlesRequest.java rename src/main/java/com/coinbase/prime/{portfolios/ListPortfoliosRequest.java => products/GetCandlesResponse.java} (56%) create mode 100644 src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java create mode 100644 src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java create mode 100644 src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java create mode 100644 src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java create mode 100644 src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java create mode 100644 src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java create mode 100644 src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java create mode 100644 src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java create mode 100644 src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java create mode 100644 src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java create mode 100644 src/main/java/com/coinbase/prime/users/ListUsersRequest.java create mode 100644 src/main/java/com/coinbase/prime/users/ListUsersResponse.java create mode 100644 tools/model-generator/config/generator-config.json create mode 100644 tools/model-generator/config/operations-overrides.json create mode 100644 tools/model-generator/generate.sh create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/GeneratorPaths.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/FactoryPhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ModelEnumPhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/RequestPhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ResponsePhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ServicePhase.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/GeneratorConfiguration.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/NamingResolver.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OpenApiSchemaCodegen.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingGenerator.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingValidator.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SchemaProperty.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/ServiceDefinition.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SharedTransforms.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SpecAnalyzer.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOpenApiDocument.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOperation.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedParameter.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SdkOperationBinding.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecParser.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecRef.java create mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecResponseSchema.java create mode 100644 tools/model-generator/src/test/java/com/coinbase/tools/sdkgenerator/SpecParserTest.java create mode 100644 tools/model-generator/src/test/resources/openapi-minimal.yaml diff --git a/.gitignore b/.gitignore index e1640ecb..834c7b69 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ ai-docs/ # OpenAPI spec - fetch dynamically instead of committing apiSpec/*.yaml +# SDK generator download + OpenAPI CLI output +generated/ + .java-version \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index db6b2b0f..ab7f89f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - `GetStakingStatus` - Wallet staking status ### Changed +- **SDK generator (tools/model-generator)**: Holistic generation aligned with .NET — models, enums, per-operation `*Request`/`*Response`, `*Service`/`*ServiceImpl`, `PrimeServiceFactory`, and missing example stubs via `com.coinbase.tools.sdkgenerator`; config in `tools/model-generator/config/generator-config.json` and `operations-overrides.json`. Root Maven profile renamed from `generate-models` to **`generate`** (`mvn -Pgenerate`); use `-Dgenerator.args=--diff` or `--dry-run` as needed. - Regenerated `com.coinbase.prime.model` and `model.enums` from latest Prime OpenAPI spec (`https://api.prime.coinbase.com/v1/openapi.yaml`) - **Model generator** (`PostProcessor`): map `GoogleTypeDate` to `DateOfBirth` so `TravelRuleParty.date_of_birth` compiles when `Google*` types are excluded - `ActivityMetadataConsensus`, `Asset`, `CreateAllocationResponseBody`, `CreateNetAllocationResponseBody`, `CrossMarginOverview`, `EvmParams`, `FcmTradingSessionDetails`, `FuturesSweep`, `MarginSummary`, `NetworkDetails`, `OnchainTransactionDetails`, `Order`, `PmAssetInfo`, `PostTradeCreditInformation`, `RequestToSubmitTravelRuleDataForAnExistingDepositTransaction`, `RfqProductDetails`, `RiskAssessment`, `RpcConfig`, `TravelRuleData`, `TravelRuleParty`, `XmPosition`, `XmRiskNettingInfo`, `UserRole` - field updates per spec diff --git a/CLAUDE.md b/CLAUDE.md index 6a1c9fbc..c10b665b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -30,14 +30,14 @@ This is a Maven-based Java project (Java 11+). Common development commands: This is the **Coinbase Prime Java SDK** - a sample library for interacting with Coinbase Prime REST APIs. Key architectural patterns: ### Service Layer Pattern -- **PrimeServiceFactory**: Factory class that creates service instances for different API domains -- **Service interfaces**: Each API domain (Orders, Portfolios, Wallets, etc.) has a corresponding service interface -- **Service implementations**: Concrete implementations ending with `ServiceImpl` that handle HTTP communication +- **PrimeServiceFactory**: Factory class that creates service instances for different API domains (regenerate with `tools/model-generator`; do not hand-edit) +- **Service interfaces**: Each API domain (Orders, Portfolios, Wallets, etc.) has a corresponding service interface (**generated**) +- **Service implementations**: Concrete implementations ending with `ServiceImpl` that handle HTTP communication (**generated**) ### Core Components - **CoinbasePrimeClient**: Main HTTP client that extends `CoinbaseNetHttpClient` from `coinbase-core-java` - **CoinbasePrimeCredentials**: Handles API authentication using access key, passphrase, and signing key -- **Request/Response pattern**: Each API operation has dedicated request and response classes using Builder patterns +- **Request/Response pattern**: Each API operation has dedicated request and response classes using Builder patterns (**generated**; do not hand-write) ### Package Structure - `com.coinbase.prime.client`: Core HTTP client @@ -107,17 +107,28 @@ Working examples available in `src/main/java/com/coinbase/examples/` including: ### AI Agent Code Generation -#### Model Generation - IMPORTANT -**DO NOT create domain models or enums by hand!** +#### SDK code generation - IMPORTANT +**Do not hand-write domain models, enums, per-operation `*Request`/`*Response`, or `*Service`/`*ServiceImpl` files** — they are produced by the holistic generator in `tools/model-generator` (see `com.coinbase.tools.sdkgenerator`). Configuration mirrors the .NET generator: `tools/model-generator/config/generator-config.json` and `operations-overrides.json`. -Use the model generator from the repository root: +From the **repository root** (recommended): ```bash -cd tools/model-generator mvn -Pgenerate ``` +Optional: `--dry-run` or `--diff` (no writes; compare to disk): +```bash +mvn -Pgenerate -Dgenerator.args=--diff +``` + +From `tools/model-generator` only: +```bash +mvn -Pgenerate +# or: mvn -q compile exec:java@generate-models -Dgenerator.args=--diff +``` + This tool: -- Generates models and enums from the OpenAPI spec +- Downloads the OpenAPI spec, generates models and enums (OpenAPI Generator + `PostProcessor`) +- Generates `*Request`, `*Response`, `*Service`, `*ServiceImpl` per tag/operation, `PrimeServiceFactory`, and missing example stubs under `com.coinbase.examples` - Maintains SDK conventions (Builder pattern, proper annotations) - Prevents drift between spec and implementation - Processes all models from the spec, updating existing files to catch changes @@ -125,55 +136,16 @@ This tool: **Manual model creation is prohibited.** All domain models in `com.coinbase.prime.model` and enums in `com.coinbase.prime.model.enums` must be generated from the OpenAPI specification. -**Exception**: Request/Response classes in service packages (e.g., `orders/GetOrderRequest.java`) are hand-crafted and co-located with their service. - -#### Speed Optimization for Service Generation -**PRIORITY: Execute quickly, validate afterwards** - -**Parallelized Fast Generation Strategy:** -1. **Analyze entire OpenAPI spec** first to identify all missing endpoints -2. **Run model generator first** - `cd tools/model-generator && mvn -Pgenerate` -3. **Plan batches by domain** - group related services together (e.g., FCM, Staking, Orders) -4. **Execute multiple Task agents in parallel** - generate 5-10 services simultaneously across domains -5. **NO premature validation** - generate ALL files first, validate once at the end -6. **Template-based rapid creation** - copy existing files and modify rather than create from scratch -7. **Single build validation** - run `mvn compile` only after all generation is complete - -**Parallelization Implementation:** -``` -// Execute multiple Task agents simultaneously in a single message -Task 1: Generate FCM models (3 files) -Task 2: Generate Staking models (5 files) -Task 3: Generate Invoice models (5 files) -Task 4: Generate Margin models (7 files) -Task 5: Generate Misc models (7 files) -Task 6: Generate Wallet models (3 files) -Task 7: Generate Order models (3 files) -Task 8: Generate Service A -Task 9: Generate Service B -``` - -**Fast Template-Based Approach:** -1. **Use existing files as templates** - copy/modify instead of creating from scratch -2. **Batch creation** - generate 5-10 files rapidly per task -3. **Focus on compilation first** - get objects created and building, refine schema compliance later -4. **Template pattern**: Copy existing request/response pair → Search/replace service names → Adjust properties - -**Template Locations:** -- Request template: `activities/ListActivitiesRequest.java` -- Response template: `activities/ListActivitiesResponse.java` -- Single object response: `activities/GetActivityResponse.java` -- Service interface: `activities/ActivitiesService.java` -- Service implementation: `activities/ActivitiesServiceImpl.java` +The profile id was formerly `generate-models`; use **`mvn -Pgenerate`** from the repo root. ### Development Workflow -When implementing new endpoints, pull endpoint definitions directly from the OpenAPI specification: +When the OpenAPI spec adds or changes operations: + +1. **Reference the live spec** (or `apiSpec/prime-public-spec.yaml` when fetched) as the source of truth +2. **Run the holistic generator** from the repo root: `mvn -Pgenerate` (or `-Dgenerator.args=--diff` to compare without writing) +3. **Build**: `mvn clean install` and fix any generator gaps in `tools/model-generator` (not by editing generated Java by hand, except where noted below) -1. **Reference OpenAPI spec**: Use `apiSpec/prime-public-spec.yaml` as the source of truth for all endpoint definitions -2. **Extract by tags**: Organize endpoints by their OpenAPI tags to determine package structure -3. **Follow Java patterns**: Use existing service implementations as templates -4. **Generate classes**: Create Request/Response classes using Builder patterns -5. **Update factory**: Add new services to `PrimeServiceFactory` +Hand-maintained (not overwritten by the generator) includes: `com.coinbase.prime.common` (e.g. `PrimeListRequest`, `Pagination`), credentials/client/utils, and **curated** examples under `com.coinbase.examples` (the generator only adds a missing stub if no file exists) ### Endpoint Discovery To identify available endpoints: diff --git a/README.md b/README.md index 1617ec48..2c6ebb4f 100644 --- a/README.md +++ b/README.md @@ -133,31 +133,18 @@ mvn exec:java -Dexec.mainClass="com.coinbase.examples.wallets.GetWalletDepositIn mvn exec:java -Dexec.mainClass="com.coinbase.examples.wallets.GetWalletDepositInstructions" -Dexec.args="wallet-id WIRE" ``` -## Model Generation +## Code generation -The SDK includes an automated model generator that creates Java domain models and enums from the OpenAPI specification. This ensures the SDK stays in sync with the Prime API specification. +The SDK is generated from the published OpenAPI spec (`https://api.prime.coinbase.com/v1/openapi.yaml`). The spec is downloaded at generation time (not committed). -The OpenAPI spec is fetched automatically from the live API (`https://api.prime.coinbase.com/v1/openapi.yaml`) during model generation and is not committed to source control. - -### Generate Models from Root Directory - -To generate new models from the OpenAPI spec: +From the repository root: ```bash -mvn -Pgenerate-models +mvn -Pgenerate ``` -This command: -- Runs in **incremental mode** (safe - only creates new models that don't exist) -- Generates domain models in `src/main/java/com/coinbase/prime/model/` -- Generates enums in `src/main/java/com/coinbase/prime/model/enums/` -- Automatically applies SDK conventions (Builder patterns, license headers, etc.) - -### Advanced Model Generation +Optional: compare without writing files: `mvn -Pgenerate -Dgenerator.args=--diff`, or dry run: `-Dgenerator.args=--dry-run`. -For more control over model generation, see the detailed documentation in [`tools/model-generator/README.md`](tools/model-generator/README.md), which covers: +This regenerates domain models and enums, per-operation `*Request` / `*Response` types, `*Service` / `*ServiceImpl`, `PrimeServiceFactory`, and adds missing example stubs only when an example file does not already exist. -- Force regenerating all models (dangerous - use with caution) -- Regenerating specific models -- Understanding the generation pipeline -- Troubleshooting generation issues +See [`tools/model-generator/README.md`](tools/model-generator/README.md) for configuration (`config/generator-config.json`, `operations-overrides.json`) and module details. diff --git a/pom.xml b/pom.xml index b5b5b4bd..1e9797ad 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,7 @@ 2.16.1 1.1.1 5.10.0 + @@ -77,12 +78,21 @@ 11 11 + + + com/coinbase/examples/**/*.java + org.apache.maven.plugins maven-javadoc-plugin 3.7.0 + + + com/coinbase/examples/**/*.java + + attach-javadocs @@ -141,7 +151,7 @@ - generate-models + generate generate-sources @@ -175,6 +185,7 @@ ${project.basedir}/tools/model-generator -Pgenerate + -Dgenerator.args=${generator.args} diff --git a/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java b/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java index 543faa29..daf93d1d 100644 --- a/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java +++ b/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,60 +16,12 @@ package com.coinbase.examples.activities; -import com.coinbase.prime.activities.ActivitiesService; -import com.coinbase.prime.activities.ListPortfolioActivitiesRequest; -import com.coinbase.prime.activities.ListPortfolioActivitiesResponse; -import com.coinbase.prime.client.CoinbasePrimeClient; -import com.coinbase.prime.credentials.CoinbasePrimeCredentials; -import com.coinbase.prime.factory.PrimeServiceFactory; -import com.coinbase.prime.model.enums.ActivityCategory; -import com.coinbase.prime.utils.Utils; - +/** + * Example stub for ListPortfolioActivities (GET /v1/portfolios/{portfolio_id}/activities). + * Replace with a real example using requests from this package. + */ public class ListPortfolioActivities { - public static void main(String[] args) { - try { - CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS")); - CoinbasePrimeClient client = new CoinbasePrimeClient(credentials); - String portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID"); - - System.out.println("Using Portfolio ID: " + portfolioId); - - // Parse symbols from CSV if provided as first argument - // Parse categories from CSV if provided as second argument - ListPortfolioActivitiesRequest.Builder builder = new ListPortfolioActivitiesRequest.Builder(portfolioId); - - if (args.length > 0 && !args[0].isEmpty()) { - String[] symbols = args[0].split(","); - for (int i = 0; i < symbols.length; i++) { - symbols[i] = symbols[i].trim(); - } - builder.symbols(symbols); - System.out.println("Filtering by symbols: " + String.join(", ", symbols)); - } - - if (args.length > 1 && !args[1].isEmpty()) { - String[] categoryStrings = args[1].split(","); - ActivityCategory[] categories = new ActivityCategory[categoryStrings.length]; - - for (int i = 0; i < categoryStrings.length; i++) { - try { - categories[i] = ActivityCategory.valueOf(categoryStrings[i].trim()); - } catch (IllegalArgumentException e) { - System.err.println("Invalid category: " + categoryStrings[i].trim()); - return; - } - } - - builder.categories(categories); - System.out.println("Filtering by categories: " + String.join(", ", categoryStrings)); - } - - ActivitiesService service = PrimeServiceFactory.createActivitiesService(client); - ListPortfolioActivitiesResponse response = service.listPortfolioActivities(builder.build()); - - System.out.println(Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); - } catch (Exception e) { - e.printStackTrace(); + public static void main(String[] args) { + System.out.println("TODO: implement example for ListPortfolioActivities"); } - } } diff --git a/src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java b/src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java new file mode 100644 index 00000000..07fa86b6 --- /dev/null +++ b/src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.addressbook; + +/** + * Example stub for ListAddressBookEntries (GET /v1/portfolios/{portfolio_id}/address_book). + * Replace with a real example using requests from this package. + */ +public class ListAddressBookEntries { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListAddressBookEntries"); + } +} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java b/src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java new file mode 100644 index 00000000..150546e7 --- /dev/null +++ b/src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.advancedtransfer; + +/** + * Example stub for CancelAdvancedTransfer (POST /v1/portfolios/{portfolio_id}/advanced_transfers/{advanced_transfer_id}/cancel). + * Replace with a real example using requests from this package. + */ +public class CancelAdvancedTransfer { + public static void main(String[] args) { + System.out.println("TODO: implement example for CancelAdvancedTransfer"); + } +} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java b/src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java new file mode 100644 index 00000000..d5ca0507 --- /dev/null +++ b/src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.advancedtransfer; + +/** + * Example stub for CreateAdvancedTransfer (POST /v1/portfolios/{portfolio_id}/advanced_transfers). + * Replace with a real example using requests from this package. + */ +public class CreateAdvancedTransfer { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateAdvancedTransfer"); + } +} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java b/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java new file mode 100644 index 00000000..3eb9db32 --- /dev/null +++ b/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.advancedtransfer; + +/** + * Example stub for GetPortfolioCounterparty (GET /v1/portfolios/{portfolio_id}/counterparty). + * Replace with a real example using requests from this package. + */ +public class GetPortfolioCounterparty { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetPortfolioCounterparty"); + } +} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java b/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java new file mode 100644 index 00000000..762b2a08 --- /dev/null +++ b/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java @@ -0,0 +1,27 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.advancedtransfer; + +/** + * Example stub for GetPortfolioCounterpartyId (GET /v1/portfolios/{portfolio_id}/counterparty). + * Replace with a real example using requests from this package. + */ +public class GetPortfolioCounterpartyId { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetPortfolioCounterpartyId"); + } +} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java b/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java new file mode 100644 index 00000000..4175e947 --- /dev/null +++ b/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.advancedtransfer; + +/** + * Example stub for ListAdvancedTransferTransactions (GET /v1/portfolios/{portfolio_id}/advanced_transfers/{advanced_transfer_id}/transactions). + * Replace with a real example using requests from this package. + */ +public class ListAdvancedTransferTransactions { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListAdvancedTransferTransactions"); + } +} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java b/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java new file mode 100644 index 00000000..82df5e42 --- /dev/null +++ b/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.advancedtransfer; + +/** + * Example stub for ListAdvancedTransfers (GET /v1/portfolios/{portfolio_id}/advanced_transfers). + * Replace with a real example using requests from this package. + */ +public class ListAdvancedTransfers { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListAdvancedTransfers"); + } +} diff --git a/src/main/java/com/coinbase/examples/allocations/CreateAllocation.java b/src/main/java/com/coinbase/examples/allocations/CreateAllocation.java new file mode 100644 index 00000000..b5b8488e --- /dev/null +++ b/src/main/java/com/coinbase/examples/allocations/CreateAllocation.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.allocations; + +/** + * Example stub for CreateAllocation (POST /v1/allocations). + * Replace with a real example using requests from this package. + */ +public class CreateAllocation { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateAllocation"); + } +} diff --git a/src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java b/src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java new file mode 100644 index 00000000..012c3e9d --- /dev/null +++ b/src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.allocations; + +/** + * Example stub for CreateNetAllocation (POST /v1/allocations/net). + * Replace with a real example using requests from this package. + */ +public class CreateNetAllocation { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateNetAllocation"); + } +} diff --git a/src/main/java/com/coinbase/examples/allocations/GetAllocation.java b/src/main/java/com/coinbase/examples/allocations/GetAllocation.java new file mode 100644 index 00000000..77ab2a27 --- /dev/null +++ b/src/main/java/com/coinbase/examples/allocations/GetAllocation.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.allocations; + +/** + * Example stub for GetAllocation (GET /v1/portfolios/{portfolio_id}/allocations/{allocation_id}). + * Replace with a real example using requests from this package. + */ +public class GetAllocation { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetAllocation"); + } +} diff --git a/src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java b/src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java new file mode 100644 index 00000000..c3f2eaca --- /dev/null +++ b/src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.allocations; + +/** + * Example stub for ListAllocationsByClientNettingId (GET /v1/portfolios/{portfolio_id}/allocations/net/{netting_id}). + * Replace with a real example using requests from this package. + */ +public class ListAllocationsByClientNettingId { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListAllocationsByClientNettingId"); + } +} diff --git a/src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java b/src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java new file mode 100644 index 00000000..63fb3821 --- /dev/null +++ b/src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java @@ -0,0 +1,27 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.allocations; + +/** + * Example stub for ListAllocationsByNettingId (GET /v1/portfolios/{portfolio_id}/allocations/net/{netting_id}). + * Replace with a real example using requests from this package. + */ +public class ListAllocationsByNettingId { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListAllocationsByNettingId"); + } +} diff --git a/src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java b/src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java new file mode 100644 index 00000000..09659326 --- /dev/null +++ b/src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.allocations; + +/** + * Example stub for ListPortfolioAllocations (GET /v1/portfolios/{portfolio_id}/allocations). + * Replace with a real example using requests from this package. + */ +public class ListPortfolioAllocations { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListPortfolioAllocations"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/CreateNewLocates.java b/src/main/java/com/coinbase/examples/financing/CreateNewLocates.java new file mode 100644 index 00000000..37304191 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/CreateNewLocates.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for CreateNewLocates (POST /v1/portfolios/{portfolio_id}/locates). + * Replace with a real example using requests from this package. + */ +public class CreateNewLocates { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateNewLocates"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java b/src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java new file mode 100644 index 00000000..5e341653 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetCrossMarginOverview (GET /v1/entities/{entity_id}/cross_margin). + * Replace with a real example using requests from this package. + */ +public class GetCrossMarginOverview { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetCrossMarginOverview"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java b/src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java new file mode 100644 index 00000000..5beb5544 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetEntityLocateAvailabilities (GET /v1/entities/{entity_id}/locates_availability). + * Replace with a real example using requests from this package. + */ +public class GetEntityLocateAvailabilities { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetEntityLocateAvailabilities"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetMarginInformation.java b/src/main/java/com/coinbase/examples/financing/GetMarginInformation.java new file mode 100644 index 00000000..2cadb7b8 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetMarginInformation.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetMarginInformation (GET /v1/entities/{entity_id}/margin). + * Replace with a real example using requests from this package. + */ +public class GetMarginInformation { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetMarginInformation"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java b/src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java new file mode 100644 index 00000000..39b8e5c5 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetPortfolioBuyingPower (GET /v1/portfolios/{portfolio_id}/buying_power). + * Replace with a real example using requests from this package. + */ +public class GetPortfolioBuyingPower { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetPortfolioBuyingPower"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java b/src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java new file mode 100644 index 00000000..3709f061 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetPortfolioCreditInformation (GET /v1/portfolios/{portfolio_id}/credit). + * Replace with a real example using requests from this package. + */ +public class GetPortfolioCreditInformation { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetPortfolioCreditInformation"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java b/src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java new file mode 100644 index 00000000..9e267e83 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetPortfolioWithdrawalPower (GET /v1/portfolios/{portfolio_id}/withdrawal_power). + * Replace with a real example using requests from this package. + */ +public class GetPortfolioWithdrawalPower { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetPortfolioWithdrawalPower"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java b/src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java new file mode 100644 index 00000000..872d8fbb --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for GetTradeFinanceTieredPricingFees (GET /v1/entities/{entity_id}/tf_tiered_fees). + * Replace with a real example using requests from this package. + */ +public class GetTradeFinanceTieredPricingFees { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetTradeFinanceTieredPricingFees"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/ListExistingLocates.java b/src/main/java/com/coinbase/examples/financing/ListExistingLocates.java new file mode 100644 index 00000000..01ab14ca --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/ListExistingLocates.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for ListExistingLocates (GET /v1/portfolios/{portfolio_id}/locates). + * Replace with a real example using requests from this package. + */ +public class ListExistingLocates { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListExistingLocates"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java b/src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java new file mode 100644 index 00000000..1af11051 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for ListInterestAccruals (GET /v1/entities/{entity_id}/accruals). + * Replace with a real example using requests from this package. + */ +public class ListInterestAccruals { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListInterestAccruals"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java b/src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java new file mode 100644 index 00000000..48d9beca --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for ListInterestAccrualsForPortfolio (GET /v1/portfolios/{portfolio_id}/accruals). + * Replace with a real example using requests from this package. + */ +public class ListInterestAccrualsForPortfolio { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListInterestAccrualsForPortfolio"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java b/src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java new file mode 100644 index 00000000..56cbc887 --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for ListMarginCallSummaries (GET /v1/entities/{entity_id}/margin_summaries). + * Replace with a real example using requests from this package. + */ +public class ListMarginCallSummaries { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListMarginCallSummaries"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/ListMarginConversions.java b/src/main/java/com/coinbase/examples/financing/ListMarginConversions.java new file mode 100644 index 00000000..0c9e025c --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/ListMarginConversions.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for ListMarginConversions (GET /v1/portfolios/{portfolio_id}/margin_conversions). + * Replace with a real example using requests from this package. + */ +public class ListMarginConversions { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListMarginConversions"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java b/src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java new file mode 100644 index 00000000..37a1abad --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for ListTradeFinanceObligations (GET /v1/entities/{entity_id}/tf_obligations). + * Replace with a real example using requests from this package. + */ +public class ListTradeFinanceObligations { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListTradeFinanceObligations"); + } +} diff --git a/src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java b/src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java new file mode 100644 index 00000000..c136786d --- /dev/null +++ b/src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.financing; + +/** + * Example stub for UpdateFundingSettings (POST /v1/entities/{entity_id}/funding-settings). + * Replace with a real example using requests from this package. + */ +public class UpdateFundingSettings { + public static void main(String[] args) { + System.out.println("TODO: implement example for UpdateFundingSettings"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java b/src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java new file mode 100644 index 00000000..94f77a24 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for CancelEntityFuturesSweep (DELETE /v1/entities/{entity_id}/futures/sweeps). + * Replace with a real example using requests from this package. + */ +public class CancelEntityFuturesSweep { + public static void main(String[] args) { + System.out.println("TODO: implement example for CancelEntityFuturesSweep"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java b/src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java new file mode 100644 index 00000000..77c429d1 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for GetEntityFcmBalance (GET /v1/entities/{entity_id}/futures/balance_summary). + * Replace with a real example using requests from this package. + */ +public class GetEntityFcmBalance { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetEntityFcmBalance"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/GetFcmEquity.java b/src/main/java/com/coinbase/examples/futures/GetFcmEquity.java new file mode 100644 index 00000000..5beea54d --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/GetFcmEquity.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for GetFcmEquity (GET /v1/entities/{entity_id}/futures/equity). + * Replace with a real example using requests from this package. + */ +public class GetFcmEquity { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetFcmEquity"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java b/src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java new file mode 100644 index 00000000..b02987f8 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for GetFcmMarginCallDetails (GET /v1/entities/{entity_id}/futures/margin_call_details). + * Replace with a real example using requests from this package. + */ +public class GetFcmMarginCallDetails { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetFcmMarginCallDetails"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java b/src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java new file mode 100644 index 00000000..9e6d7032 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for GetFcmRiskLimits (GET /v1/entities/{entity_id}/futures/risk_limits). + * Replace with a real example using requests from this package. + */ +public class GetFcmRiskLimits { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetFcmRiskLimits"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/GetPositions.java b/src/main/java/com/coinbase/examples/futures/GetPositions.java new file mode 100644 index 00000000..d0a74a50 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/GetPositions.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for GetPositions (GET /v1/entities/{entity_id}/futures/positions). + * Replace with a real example using requests from this package. + */ +public class GetPositions { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetPositions"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java b/src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java new file mode 100644 index 00000000..67e21ed7 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for ListEntityFuturesSweeps (GET /v1/entities/{entity_id}/futures/sweeps). + * Replace with a real example using requests from this package. + */ +public class ListEntityFuturesSweeps { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListEntityFuturesSweeps"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java b/src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java new file mode 100644 index 00000000..1df1666a --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for ScheduleEntityFuturesSweep (POST /v1/entities/{entity_id}/futures/sweeps). + * Replace with a real example using requests from this package. + */ +public class ScheduleEntityFuturesSweep { + public static void main(String[] args) { + System.out.println("TODO: implement example for ScheduleEntityFuturesSweep"); + } +} diff --git a/src/main/java/com/coinbase/examples/futures/SetAutoSweep.java b/src/main/java/com/coinbase/examples/futures/SetAutoSweep.java new file mode 100644 index 00000000..ef31f210 --- /dev/null +++ b/src/main/java/com/coinbase/examples/futures/SetAutoSweep.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.futures; + +/** + * Example stub for SetAutoSweep (POST /v1/entities/{entity_id}/futures/auto_sweep). + * Replace with a real example using requests from this package. + */ +public class SetAutoSweep { + public static void main(String[] args) { + System.out.println("TODO: implement example for SetAutoSweep"); + } +} diff --git a/src/main/java/com/coinbase/examples/orders/GetOrder.java b/src/main/java/com/coinbase/examples/orders/GetOrder.java new file mode 100644 index 00000000..68e1035c --- /dev/null +++ b/src/main/java/com/coinbase/examples/orders/GetOrder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.orders; + +/** + * Example stub for GetOrder (GET /v1/portfolios/{portfolio_id}/orders/{order_id}). + * Replace with a real example using requests from this package. + */ +public class GetOrder { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetOrder"); + } +} diff --git a/src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java b/src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java new file mode 100644 index 00000000..17ab7e7e --- /dev/null +++ b/src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java @@ -0,0 +1,27 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.orders; + +/** + * Example stub for GetOrderByOrderId (GET /v1/portfolios/{portfolio_id}/orders/{order_id}). + * Replace with a real example using requests from this package. + */ +public class GetOrderByOrderId { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetOrderByOrderId"); + } +} diff --git a/src/main/java/com/coinbase/examples/orders/GetOrderPreview.java b/src/main/java/com/coinbase/examples/orders/GetOrderPreview.java new file mode 100644 index 00000000..bff1a01a --- /dev/null +++ b/src/main/java/com/coinbase/examples/orders/GetOrderPreview.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.orders; + +/** + * Example stub for GetOrderPreview (POST /v1/portfolios/{portfolio_id}/order_preview). + * Replace with a real example using requests from this package. + */ +public class GetOrderPreview { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetOrderPreview"); + } +} diff --git a/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java b/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java index 0176ac33..7499d3f9 100644 --- a/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java +++ b/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,35 +16,13 @@ package com.coinbase.examples.paymentmethods; -import com.coinbase.prime.client.CoinbasePrimeClient; -import com.coinbase.prime.credentials.CoinbasePrimeCredentials; -import com.coinbase.prime.factory.PrimeServiceFactory; -import com.coinbase.prime.paymentmethods.GetPaymentMethodDetailsRequest; -import com.coinbase.prime.paymentmethods.GetPaymentMethodDetailsResponse; -import com.coinbase.prime.paymentmethods.PaymentMethodsService; -import com.coinbase.prime.utils.Utils; - +/** + * Example stub for GetPaymentMethodDetails (GET + * /v1/entities/{entity_id}/payment-methods/{payment_method_id}). + * Replace with a real example using requests from this package. + */ public class GetPaymentMethodDetails { public static void main(String[] args) { - try { - CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials( - System.getenv("COINBASE_PRIME_CREDENTIALS")); - CoinbasePrimeClient client = new CoinbasePrimeClient(credentials); - String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID"); - String paymentMethodId = args[0]; - - System.out.println("Using Entity ID: " + entityId + ", Payment Method ID: " + paymentMethodId); - - PaymentMethodsService service = PrimeServiceFactory.createPaymentMethodsService(client); - GetPaymentMethodDetailsResponse response = service.getPaymentMethodDetails( - new GetPaymentMethodDetailsRequest.Builder() - .entityId(entityId) - .paymentMethodId(paymentMethodId) - .build()); - - System.out.println(Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("TODO: implement example for GetPaymentMethodDetails"); } } diff --git a/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java b/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java index 7fe2133b..63161bf2 100644 --- a/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java +++ b/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,31 +16,12 @@ package com.coinbase.examples.paymentmethods; -import com.coinbase.prime.client.CoinbasePrimeClient; -import com.coinbase.prime.credentials.CoinbasePrimeCredentials; -import com.coinbase.prime.factory.PrimeServiceFactory; -import com.coinbase.prime.paymentmethods.ListPaymentMethodsRequest; -import com.coinbase.prime.paymentmethods.ListPaymentMethodsResponse; -import com.coinbase.prime.paymentmethods.PaymentMethodsService; -import com.coinbase.prime.utils.Utils; - +/** + * Example stub for ListPaymentMethods (GET /v1/entities/{entity_id}/payment-methods). + * Replace with a real example using requests from this package. + */ public class ListPaymentMethods { public static void main(String[] args) { - try { - CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials( - System.getenv("COINBASE_PRIME_CREDENTIALS")); - CoinbasePrimeClient client = new CoinbasePrimeClient(credentials); - String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID"); - - System.out.println("Using Entity ID: " + entityId); - - PaymentMethodsService service = PrimeServiceFactory.createPaymentMethodsService(client); - ListPaymentMethodsResponse response = service.listPaymentMethods( - new ListPaymentMethodsRequest.Builder(entityId).build()); - - System.out.println(Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); - } catch (Exception e) { - e.printStackTrace(); - } + System.out.println("TODO: implement example for ListPaymentMethods"); } } diff --git a/src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java b/src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java new file mode 100644 index 00000000..218d7ae8 --- /dev/null +++ b/src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.positions; + +/** + * Example stub for ListAggregateEntityPositions (GET /v1/entities/{entity_id}/aggregate_positions). + * Replace with a real example using requests from this package. + */ +public class ListAggregateEntityPositions { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListAggregateEntityPositions"); + } +} diff --git a/src/main/java/com/coinbase/examples/positions/ListEntityPositions.java b/src/main/java/com/coinbase/examples/positions/ListEntityPositions.java new file mode 100644 index 00000000..97c92ae1 --- /dev/null +++ b/src/main/java/com/coinbase/examples/positions/ListEntityPositions.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.positions; + +/** + * Example stub for ListEntityPositions (GET /v1/entities/{entity_id}/positions). + * Replace with a real example using requests from this package. + */ +public class ListEntityPositions { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListEntityPositions"); + } +} diff --git a/src/main/java/com/coinbase/examples/products/GetCandles.java b/src/main/java/com/coinbase/examples/products/GetCandles.java new file mode 100644 index 00000000..2765df03 --- /dev/null +++ b/src/main/java/com/coinbase/examples/products/GetCandles.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.products; + +/** + * Example stub for GetCandles (GET /v1/portfolios/{portfolio_id}/candles). + * Replace with a real example using requests from this package. + */ +public class GetCandles { + public static void main(String[] args) { + System.out.println("TODO: implement example for GetCandles"); + } +} diff --git a/src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java b/src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java new file mode 100644 index 00000000..26fad6ae --- /dev/null +++ b/src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.staking; + +/** + * Example stub for ClaimStakingRewards (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/staking/claim_rewards). + * Replace with a real example using requests from this package. + */ +public class ClaimStakingRewards { + public static void main(String[] args) { + System.out.println("TODO: implement example for ClaimStakingRewards"); + } +} diff --git a/src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java b/src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java new file mode 100644 index 00000000..d1e95b6a --- /dev/null +++ b/src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.staking; + +/** + * Example stub for CreatePortfolioStake (POST /v1/portfolios/{portfolio_id}/staking/initiate). + * Replace with a real example using requests from this package. + */ +public class CreatePortfolioStake { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreatePortfolioStake"); + } +} diff --git a/src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java b/src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java new file mode 100644 index 00000000..e988d9a2 --- /dev/null +++ b/src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.staking; + +/** + * Example stub for CreatePortfolioUnstake (POST /v1/portfolios/{portfolio_id}/staking/unstake). + * Replace with a real example using requests from this package. + */ +public class CreatePortfolioUnstake { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreatePortfolioUnstake"); + } +} diff --git a/src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java b/src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java new file mode 100644 index 00000000..92f0fd0c --- /dev/null +++ b/src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.transactions; + +/** + * Example stub for CreateOnchainTransaction (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/onchain_transaction). + * Replace with a real example using requests from this package. + */ +public class CreateOnchainTransaction { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateOnchainTransaction"); + } +} diff --git a/src/main/java/com/coinbase/examples/transactions/CreateTransfer.java b/src/main/java/com/coinbase/examples/transactions/CreateTransfer.java new file mode 100644 index 00000000..479f7e04 --- /dev/null +++ b/src/main/java/com/coinbase/examples/transactions/CreateTransfer.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.transactions; + +/** + * Example stub for CreateTransfer (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transfers). + * Replace with a real example using requests from this package. + */ +public class CreateTransfer { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateTransfer"); + } +} diff --git a/src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java b/src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java new file mode 100644 index 00000000..0cffb326 --- /dev/null +++ b/src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.transactions; + +/** + * Example stub for CreateWithdrawal (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/withdrawals). + * Replace with a real example using requests from this package. + */ +public class CreateWithdrawal { + public static void main(String[] args) { + System.out.println("TODO: implement example for CreateWithdrawal"); + } +} diff --git a/src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java b/src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java new file mode 100644 index 00000000..529e2e07 --- /dev/null +++ b/src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.transactions; + +/** + * Example stub for SubmitDepositTravelRuleData (POST /v1/portfolios/{portfolio_id}/transactions/{transaction_id}/travel_rule/deposit). + * Replace with a real example using requests from this package. + */ +public class SubmitDepositTravelRuleData { + public static void main(String[] args) { + System.out.println("TODO: implement example for SubmitDepositTravelRuleData"); + } +} diff --git a/src/main/java/com/coinbase/examples/users/ListUsers.java b/src/main/java/com/coinbase/examples/users/ListUsers.java new file mode 100644 index 00000000..9cd0e63e --- /dev/null +++ b/src/main/java/com/coinbase/examples/users/ListUsers.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.users; + +/** + * Example stub for ListUsers (GET /v1/entities/{entity_id}/users). + * Replace with a real example using requests from this package. + */ +public class ListUsers { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListUsers"); + } +} diff --git a/src/main/java/com/coinbase/examples/wallets/ListWallets.java b/src/main/java/com/coinbase/examples/wallets/ListWallets.java new file mode 100644 index 00000000..f16b5ea9 --- /dev/null +++ b/src/main/java/com/coinbase/examples/wallets/ListWallets.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.wallets; + +/** + * Example stub for ListWallets (GET /v1/portfolios/{portfolio_id}/wallets). + * Replace with a real example using requests from this package. + */ +public class ListWallets { + public static void main(String[] args) { + System.out.println("TODO: implement example for ListWallets"); + } +} diff --git a/src/main/java/com/coinbase/prime/activities/ActivitiesService.java b/src/main/java/com/coinbase/prime/activities/ActivitiesService.java index 6b3e3717..23548c14 100644 --- a/src/main/java/com/coinbase/prime/activities/ActivitiesService.java +++ b/src/main/java/com/coinbase/prime/activities/ActivitiesService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,12 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface ActivitiesService { - GetActivityResponse getActivity(GetActivityRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListEntityActivitiesResponse listEntityActivities(ListEntityActivitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Activities */ ListPortfolioActivitiesResponse listPortfolioActivities(ListPortfolioActivitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Entity Activities */ + ListEntityActivitiesResponse listEntityActivities(ListEntityActivitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Activity by Activity ID */ + GetActivityResponse getActivity(GetActivityRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Portfolio Activity by Activity ID */ GetPortfolioActivityResponse getPortfolioActivity(GetPortfolioActivityRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java b/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java index 7783257c..b74de654 100644 --- a/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java +++ b/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.coinbase.core.service.CoinbaseServiceImpl; import com.coinbase.prime.client.CoinbasePrimeClient; import com.coinbase.prime.errors.CoinbasePrimeException; -import com.coinbase.prime.utils.Utils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; @@ -31,8 +30,7 @@ public ActivitiesServiceImpl(CoinbasePrimeClient client) { } @Override - public ListPortfolioActivitiesResponse listPortfolioActivities(ListPortfolioActivitiesRequest request) - throws CoinbasePrimeException { + public ListPortfolioActivitiesResponse listPortfolioActivities(ListPortfolioActivitiesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, String.format("/portfolios/%s/activities", request.getPortfolioId()), @@ -42,29 +40,27 @@ public ListPortfolioActivitiesResponse listPortfolioActivities(ListPortfolioActi } @Override - public GetActivityResponse getActivity(GetActivityRequest request) throws CoinbasePrimeException { + public ListEntityActivitiesResponse listEntityActivities(ListEntityActivitiesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/activities/%s", request.getActivityId()), + String.format("/entities/%s/activities", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListEntityActivitiesResponse listEntityActivities(ListEntityActivitiesRequest request) - throws CoinbasePrimeException { + public GetActivityResponse getActivity(GetActivityRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/activities", request.getEntityId()), + String.format("/activities/%s", request.getActivityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetPortfolioActivityResponse getPortfolioActivity(GetPortfolioActivityRequest request) - throws CoinbasePrimeException { + public GetPortfolioActivityResponse getPortfolioActivity(GetPortfolioActivityRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, String.format("/portfolios/%s/activities/%s", request.getPortfolioId(), request.getActivityId()), @@ -72,4 +68,5 @@ public GetPortfolioActivityResponse getPortfolioActivity(GetPortfolioActivityReq List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/activities/GetActivityRequest.java b/src/main/java/com/coinbase/prime/activities/GetActivityRequest.java index 7c82e920..3b161f0e 100644 --- a/src/main/java/com/coinbase/prime/activities/GetActivityRequest.java +++ b/src/main/java/com/coinbase/prime/activities/GetActivityRequest.java @@ -16,9 +16,15 @@ package com.coinbase.prime.activities; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Activity by Activity ID + */ public class GetActivityRequest { @JsonProperty(required = true, value = "activity_id") @JsonIgnore @@ -27,8 +33,8 @@ public class GetActivityRequest { public GetActivityRequest() { } - public GetActivityRequest(String activityId) { - this.activityId = activityId; + public GetActivityRequest(Builder builder) { + this.activityId = builder.activityId; } public String getActivityId() { @@ -38,4 +44,27 @@ public String getActivityId() { public void setActivityId(String activityId) { this.activityId = activityId; } + + public static class Builder { + private String activityId; + + public Builder() { + } + + public Builder activityId(String activityId) { + this.activityId = activityId; + return this; + } + + public GetActivityRequest build() throws CoinbaseClientException { + validate(); + return new GetActivityRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.activityId)) { + throw new CoinbaseClientException("ActivityId is required"); + } + } + } } diff --git a/src/main/java/com/coinbase/prime/activities/GetActivityResponse.java b/src/main/java/com/coinbase/prime/activities/GetActivityResponse.java index 479cc232..d6ec66a0 100644 --- a/src/main/java/com/coinbase/prime/activities/GetActivityResponse.java +++ b/src/main/java/com/coinbase/prime/activities/GetActivityResponse.java @@ -17,14 +17,13 @@ package com.coinbase.prime.activities; import com.coinbase.prime.model.Activity; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving an activity by its activity ID. - * - * This endpoint can retrieve both portfolio and entity activities when passed the appropriate API key. + * Get Activity by Activity ID */ public class GetActivityResponse { - /** The activity details */ + @JsonProperty("activity") private Activity activity; public GetActivityResponse() { diff --git a/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityRequest.java b/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityRequest.java index f09604fd..43e7e58f 100644 --- a/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityRequest.java +++ b/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityRequest.java @@ -16,13 +16,14 @@ package com.coinbase.prime.activities; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.coinbase.core.errors.CoinbaseClientException; + import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * Request for getting a portfolio activity by activity ID. + * Get Portfolio Activity by Activity ID */ public class GetPortfolioActivityRequest { @JsonProperty(required = true, value = "portfolio_id") @@ -36,7 +37,7 @@ public class GetPortfolioActivityRequest { public GetPortfolioActivityRequest() { } - private GetPortfolioActivityRequest(Builder builder) { + public GetPortfolioActivityRequest(Builder builder) { this.portfolioId = builder.portfolioId; this.activityId = builder.activityId; } @@ -57,14 +58,13 @@ public void setActivityId(String activityId) { this.activityId = activityId; } - public String getPath() { - return String.format("/v1/portfolios/%s/activities/%s", this.portfolioId, this.activityId); - } - public static class Builder { private String portfolioId; private String activityId; + public Builder() { + } + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; return this; @@ -75,17 +75,17 @@ public Builder activityId(String activityId) { return this; } - public GetPortfolioActivityRequest build() { - this.validate(); + public GetPortfolioActivityRequest build() throws CoinbaseClientException { + validate(); return new GetPortfolioActivityRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } if (isNullOrEmpty(this.activityId)) { - throw new CoinbaseClientException("ActivityId cannot be null"); + throw new CoinbaseClientException("ActivityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityResponse.java b/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityResponse.java index 66f28cd2..9ffebf76 100644 --- a/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityResponse.java +++ b/src/main/java/com/coinbase/prime/activities/GetPortfolioActivityResponse.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response for getting a portfolio activity by activity ID. + * Get Portfolio Activity by Activity ID */ public class GetPortfolioActivityResponse { @JsonProperty("activity") @@ -36,4 +36,5 @@ public Activity getActivity() { public void setActivity(Activity activity) { this.activity = activity; } -} \ No newline at end of file + +} diff --git a/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesRequest.java b/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesRequest.java index bd2f0fab..8d8f39f2 100644 --- a/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesRequest.java +++ b/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesRequest.java @@ -28,6 +28,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Entity Activities + */ public class ListEntityActivitiesRequest extends PrimeListRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -36,10 +39,13 @@ public class ListEntityActivitiesRequest extends PrimeListRequest { @JsonProperty("activity_level") private ActivityLevel activityLevel; + @JsonProperty("symbols") private String[] symbols; + @JsonProperty("categories") private ActivityCategory[] categories; + @JsonProperty("statuses") private ActivityStatus[] statuses; @JsonProperty("start_time") @@ -48,8 +54,10 @@ public class ListEntityActivitiesRequest extends PrimeListRequest { @JsonProperty("end_time") private String endTime; - public ListEntityActivitiesRequest(String entityId) { - this.entityId = entityId; + @JsonProperty("get_network_unified_activities") + private Boolean getNetworkUnifiedActivities; + + public ListEntityActivitiesRequest() { } public ListEntityActivitiesRequest(Builder builder) { @@ -61,10 +69,11 @@ public ListEntityActivitiesRequest(Builder builder) { this.statuses = builder.statuses; this.startTime = builder.startTime; this.endTime = builder.endTime; + this.getNetworkUnifiedActivities = builder.getNetworkUnifiedActivities; } public String getEntityId() { - return this.entityId; + return entityId; } public void setEntityId(String entityId) { @@ -72,7 +81,7 @@ public void setEntityId(String entityId) { } public ActivityLevel getActivityLevel() { - return this.activityLevel; + return activityLevel; } public void setActivityLevel(ActivityLevel activityLevel) { @@ -80,7 +89,7 @@ public void setActivityLevel(ActivityLevel activityLevel) { } public String[] getSymbols() { - return this.symbols; + return symbols; } public void setSymbols(String[] symbols) { @@ -88,7 +97,7 @@ public void setSymbols(String[] symbols) { } public ActivityCategory[] getCategories() { - return this.categories; + return categories; } public void setCategories(ActivityCategory[] categories) { @@ -96,7 +105,7 @@ public void setCategories(ActivityCategory[] categories) { } public ActivityStatus[] getStatuses() { - return this.statuses; + return statuses; } public void setStatuses(ActivityStatus[] statuses) { @@ -104,7 +113,7 @@ public void setStatuses(ActivityStatus[] statuses) { } public String getStartTime() { - return this.startTime; + return startTime; } public void setStartTime(String startTime) { @@ -112,72 +121,90 @@ public void setStartTime(String startTime) { } public String getEndTime() { - return this.endTime; + return endTime; } public void setEndTime(String endTime) { this.endTime = endTime; } + public Boolean getGetNetworkUnifiedActivities() { + return getNetworkUnifiedActivities; + } + + public void setGetNetworkUnifiedActivities(Boolean getNetworkUnifiedActivities) { + this.getNetworkUnifiedActivities = getNetworkUnifiedActivities; + } + public static class Builder { - private final String entityId; + private String entityId; private ActivityLevel activityLevel; private String[] symbols; private ActivityCategory[] categories; private ActivityStatus[] statuses; private String startTime; private String endTime; + private Boolean getNetworkUnifiedActivities; private String cursor; private SortDirection sortDirection; private Integer limit; - public Builder(String entityId) { + public Builder() { + } + + public Builder entityId(String entityId) { this.entityId = entityId; + return this; } - public ListEntityActivitiesRequest.Builder activityLevel(ActivityLevel activityLevel) { + public Builder activityLevel(ActivityLevel activityLevel) { this.activityLevel = activityLevel; return this; } - public ListEntityActivitiesRequest.Builder symbols(String[] symbols) { + public Builder symbols(String[] symbols) { this.symbols = symbols; return this; } - public ListEntityActivitiesRequest.Builder categories(ActivityCategory[] categories) { + public Builder categories(ActivityCategory[] categories) { this.categories = categories; return this; } - public ListEntityActivitiesRequest.Builder statuses(ActivityStatus[] statuses) { + public Builder statuses(ActivityStatus[] statuses) { this.statuses = statuses; return this; } - public ListEntityActivitiesRequest.Builder startTime(String startTime) { + public Builder startTime(String startTime) { this.startTime = startTime; return this; } - public ListEntityActivitiesRequest.Builder endTime(String endTime) { + public Builder endTime(String endTime) { this.endTime = endTime; return this; } - public ListEntityActivitiesRequest.Builder limit(Integer limit) { + public Builder getNetworkUnifiedActivities(Boolean getNetworkUnifiedActivities) { + this.getNetworkUnifiedActivities = getNetworkUnifiedActivities; + return this; + } + + public Builder limit(Integer limit) { this.limit = limit; return this; } - public ListEntityActivitiesRequest.Builder pagination(Pagination pagination) { + public Builder pagination(Pagination pagination) { this.cursor = pagination.getNextCursor(); this.sortDirection = pagination.getSortDirection(); return this; } public ListEntityActivitiesRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListEntityActivitiesRequest(this); } diff --git a/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesResponse.java b/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesResponse.java index aca152a3..27c6d0cb 100644 --- a/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesResponse.java +++ b/src/main/java/com/coinbase/prime/activities/ListEntityActivitiesResponse.java @@ -18,17 +18,16 @@ import com.coinbase.prime.model.Activity; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all activities associated with a given entity. - * - * Supports filtering by activity level (portfolio, entity, or all) and various criteria. + * List Entity Activities */ public class ListEntityActivitiesResponse { - /** List of activities associated with the entity */ + @JsonProperty("activities") private Activity[] activities; - - /** Pagination information for the response */ + + @JsonProperty("pagination") private Pagination pagination; public ListEntityActivitiesResponse() { diff --git a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java index eed1762e..7add23a8 100644 --- a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java +++ b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,20 +25,34 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Activities + */ public class ListPortfolioActivitiesRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + + @JsonProperty("symbols") private String[] symbols; + + @JsonProperty("categories") private ActivityCategory[] categories; + + @JsonProperty("statuses") private ActivityStatus[] statuses; + @JsonProperty("start_time") private String startTime; + @JsonProperty("end_time") private String endTime; + @JsonProperty("get_network_unified_activities") + private Boolean getNetworkUnifiedActivities; + public ListPortfolioActivitiesRequest() { } @@ -50,6 +64,7 @@ public ListPortfolioActivitiesRequest(Builder builder) { this.statuses = builder.statuses; this.startTime = builder.startTime; this.endTime = builder.endTime; + this.getNetworkUnifiedActivities = builder.getNetworkUnifiedActivities; } public String getPortfolioId() { @@ -100,19 +115,32 @@ public void setEndTime(String endTime) { this.endTime = endTime; } + public Boolean getGetNetworkUnifiedActivities() { + return getNetworkUnifiedActivities; + } + + public void setGetNetworkUnifiedActivities(Boolean getNetworkUnifiedActivities) { + this.getNetworkUnifiedActivities = getNetworkUnifiedActivities; + } + public static class Builder { - private final String portfolioId; + private String portfolioId; private String[] symbols; private ActivityCategory[] categories; private ActivityStatus[] statuses; private String startTime; private String endTime; + private Boolean getNetworkUnifiedActivities; private String cursor; private SortDirection sortDirection; private Integer limit; - public Builder(String portfolioId) { + public Builder() { + } + + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; } public Builder symbols(String[] symbols) { @@ -140,6 +168,11 @@ public Builder endTime(String endTime) { return this; } + public Builder getNetworkUnifiedActivities(Boolean getNetworkUnifiedActivities) { + this.getNetworkUnifiedActivities = getNetworkUnifiedActivities; + return this; + } + public Builder limit(Integer limit) { this.limit = limit; return this; @@ -152,7 +185,7 @@ public Builder pagination(Pagination pagination) { } public ListPortfolioActivitiesRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioActivitiesRequest(this); } diff --git a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java index 56984a4b..e6407baf 100644 --- a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java +++ b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,17 +18,16 @@ import com.coinbase.prime.model.Activity; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all activities associated with a given portfolio. - * - * Supports filtering by currencies, activity categories, activity statuses, and date ranges. + * List Activities */ public class ListPortfolioActivitiesResponse { - /** List of activities associated with the portfolio */ + @JsonProperty("activities") private Activity[] activities; - /** Pagination information for the response */ + @JsonProperty("pagination") private Pagination pagination; public ListPortfolioActivitiesResponse() { diff --git a/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java b/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java index 1664f000..eef39861 100644 --- a/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java +++ b/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AddressBookService { - // Address Book Management - OpenAPI spec compliance + /** Get Address Book */ ListAddressBookResponse listAddressBook(ListAddressBookRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Address Book Entry */ CreateAddressBookEntryResponse createAddressBookEntry(CreateAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java b/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java index 25e4a161..f47343d5 100644 --- a/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java +++ b/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,8 @@ public CreateAddressBookEntryResponse createAddressBookEntry(CreateAddressBookEn HttpMethod.POST, String.format("/portfolios/%s/address_book", request.getPortfolioId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryRequest.java b/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryRequest.java index f8cecfd6..0636300d 100644 --- a/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryRequest.java +++ b/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryRequest.java @@ -20,23 +20,31 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Address Book Entry + */ public class CreateAddressBookEntryRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("address") private String address; @JsonProperty("currency_symbol") private String currencySymbol; + @JsonProperty("name") private String name; @JsonProperty("account_identifier") private String accountIdentifier; + @JsonProperty("chain_ids") + private String[] chainIds; + public CreateAddressBookEntryRequest() { } @@ -46,6 +54,7 @@ public CreateAddressBookEntryRequest(Builder builder) { this.currencySymbol = builder.currencySymbol; this.name = builder.name; this.accountIdentifier = builder.accountIdentifier; + this.chainIds = builder.chainIds; } public String getPortfolioId() { @@ -88,15 +97,28 @@ public void setAccountIdentifier(String accountIdentifier) { this.accountIdentifier = accountIdentifier; } + public String[] getChainIds() { + return chainIds; + } + + public void setChainIds(String[] chainIds) { + this.chainIds = chainIds; + } + public static class Builder { - private final String portfolioId; + private String portfolioId; private String address; private String currencySymbol; private String name; private String accountIdentifier; + private String[] chainIds; + + public Builder() { + } - public Builder(String portfolioId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; } public Builder address(String address) { @@ -119,8 +141,13 @@ public Builder accountIdentifier(String accountIdentifier) { return this; } + public Builder chainIds(String[] chainIds) { + this.chainIds = chainIds; + return this; + } + public CreateAddressBookEntryRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new CreateAddressBookEntryRequest(this); } @@ -128,15 +155,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.address)) { - throw new CoinbaseClientException("Address is required"); - } - if (isNullOrEmpty(this.currencySymbol)) { - throw new CoinbaseClientException("Currency symbol is required"); - } - if (isNullOrEmpty(this.name)) { - throw new CoinbaseClientException("Name is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryResponse.java b/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryResponse.java index ccb75bd1..167b9920 100644 --- a/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryResponse.java +++ b/src/main/java/com/coinbase/prime/addressbook/CreateAddressBookEntryResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.enums.CustodyActivityType; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Create Address Book Entry + */ public class CreateAddressBookEntryResponse { @JsonProperty("activity_type") private CustodyActivityType activityType; diff --git a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java new file mode 100644 index 00000000..5c0b4a27 --- /dev/null +++ b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.addressbook; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.SortDirection; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Address Book + */ +public class ListAddressBookEntriesRequest extends PrimeListRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty("currency_symbol") + private String currencySymbol; + + @JsonProperty("search") + private String search; + + public ListAddressBookEntriesRequest() { + } + + public ListAddressBookEntriesRequest(Builder builder) { + super(builder.cursor, builder.sortDirection, builder.limit); + this.portfolioId = builder.portfolioId; + this.currencySymbol = builder.currencySymbol; + this.search = builder.search; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + + public String getSearch() { + return search; + } + + public void setSearch(String search) { + this.search = search; + } + + public static class Builder { + private String portfolioId; + private String currencySymbol; + private String search; + private String cursor; + private SortDirection sortDirection; + private Integer limit; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + + public Builder search(String search) { + this.search = search; + return this; + } + + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + + public ListAddressBookEntriesRequest build() throws CoinbaseClientException { + validate(); + return new ListAddressBookEntriesRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java new file mode 100644 index 00000000..54f24e7c --- /dev/null +++ b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.addressbook; + +import com.coinbase.prime.model.AddressBookEntry; +import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Get Address Book + */ +public class ListAddressBookEntriesResponse { + @JsonProperty("addresses") + private AddressBookEntry[] addresses; + + @JsonProperty("pagination") + private Pagination pagination; + + public ListAddressBookEntriesResponse() { + } + + public AddressBookEntry[] getAddresses() { + return addresses; + } + + public void setAddresses(AddressBookEntry[] addresses) { + this.addresses = addresses; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + +} diff --git a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookRequest.java b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookRequest.java index 1969dabc..99d4eec7 100644 --- a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookRequest.java +++ b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookRequest.java @@ -23,8 +23,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Address Book + */ public class ListAddressBookRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -33,6 +36,7 @@ public class ListAddressBookRequest extends PrimeListRequest { @JsonProperty("currency_symbol") private String currencySymbol; + @JsonProperty("search") private String search; public ListAddressBookRequest() { @@ -70,15 +74,19 @@ public void setSearch(String search) { } public static class Builder { - private final String portfolioId; + private String portfolioId; private String currencySymbol; private String search; private String cursor; private SortDirection sortDirection; private Integer limit; - public Builder(String portfolioId) { + public Builder() { + } + + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; } public Builder currencySymbol(String currencySymbol) { @@ -103,7 +111,7 @@ public Builder pagination(Pagination pagination) { } public ListAddressBookRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListAddressBookRequest(this); } diff --git a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookResponse.java b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookResponse.java index b0f48927..b1e5543c 100644 --- a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookResponse.java +++ b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookResponse.java @@ -18,10 +18,16 @@ import com.coinbase.prime.model.AddressBookEntry; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Address Book + */ public class ListAddressBookResponse { + @JsonProperty("addresses") private AddressBookEntry[] addresses; + @JsonProperty("pagination") private Pagination pagination; public ListAddressBookResponse() { diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java new file mode 100644 index 00000000..7c4f66e4 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java @@ -0,0 +1,33 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.errors.CoinbasePrimeException; + +public interface AdvancedTransferService { + /** List Advanced Transfers */ + ListAdvancedTransfersResponse listAdvancedTransfers(ListAdvancedTransfersRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Advanced Transfer */ + CreateAdvancedTransferResponse createAdvancedTransfer(CreateAdvancedTransferRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Cancel Advanced Transfer */ + CancelAdvancedTransferResponse cancelAdvancedTransfer(CancelAdvancedTransferRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List transactions associated with an Advanced Transfer */ + ListAdvancedTransferTransactionsResponse listAdvancedTransferTransactions(ListAdvancedTransferTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Portfolio Counterparty ID */ + GetPortfolioCounterpartyIdResponse getPortfolioCounterpartyId(GetPortfolioCounterpartyIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java new file mode 100644 index 00000000..da4e9d18 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java @@ -0,0 +1,82 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.common.HttpMethod; +import com.coinbase.core.service.CoinbaseServiceImpl; +import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.errors.CoinbasePrimeException; +import com.fasterxml.jackson.core.type.TypeReference; + +import java.util.List; + +public class AdvancedTransferServiceImpl extends CoinbaseServiceImpl implements AdvancedTransferService { + public AdvancedTransferServiceImpl(CoinbasePrimeClient client) { + super(client); + } + + @Override + public ListAdvancedTransfersResponse listAdvancedTransfers(ListAdvancedTransfersRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.GET, + String.format("/portfolios/%s/advanced_transfers", request.getPortfolioId()), + request, + List.of(200), + new TypeReference() {}); + } + + @Override + public CreateAdvancedTransferResponse createAdvancedTransfer(CreateAdvancedTransferRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.POST, + String.format("/portfolios/%s/advanced_transfers", request.getPortfolioId()), + request, + List.of(201, 200), + new TypeReference() {}); + } + + @Override + public CancelAdvancedTransferResponse cancelAdvancedTransfer(CancelAdvancedTransferRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.POST, + String.format("/portfolios/%s/advanced_transfers/%s/cancel", request.getPortfolioId(), request.getAdvancedTransferId()), + request, + List.of(200), + new TypeReference() {}); + } + + @Override + public ListAdvancedTransferTransactionsResponse listAdvancedTransferTransactions(ListAdvancedTransferTransactionsRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.GET, + String.format("/portfolios/%s/advanced_transfers/%s/transactions", request.getPortfolioId(), request.getAdvancedTransferId()), + request, + List.of(200), + new TypeReference() {}); + } + + @Override + public GetPortfolioCounterpartyIdResponse getPortfolioCounterpartyId(GetPortfolioCounterpartyIdRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.GET, + String.format("/portfolios/%s/counterparty", request.getPortfolioId()), + request, + List.of(200), + new TypeReference() {}); + } + +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java new file mode 100644 index 00000000..cf401c4e --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Cancel Advanced Transfer + */ +public class CancelAdvancedTransferRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "advanced_transfer_id") + @JsonIgnore + private String advancedTransferId; + + public CancelAdvancedTransferRequest() { + } + + public CancelAdvancedTransferRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.advancedTransferId = builder.advancedTransferId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getAdvancedTransferId() { + return advancedTransferId; + } + + public void setAdvancedTransferId(String advancedTransferId) { + this.advancedTransferId = advancedTransferId; + } + + public static class Builder { + private String portfolioId; + private String advancedTransferId; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder advancedTransferId(String advancedTransferId) { + this.advancedTransferId = advancedTransferId; + return this; + } + + public CancelAdvancedTransferRequest build() throws CoinbaseClientException { + validate(); + return new CancelAdvancedTransferRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.advancedTransferId)) { + throw new CoinbaseClientException("AdvancedTransferId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java new file mode 100644 index 00000000..3ab45c0a --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Cancel Advanced Transfer + */ +public class CancelAdvancedTransferResponse { + @JsonProperty("advanced_transfer_id") + private String advancedTransferId; + + public CancelAdvancedTransferResponse() { + } + + public String getAdvancedTransferId() { + return advancedTransferId; + } + + public void setAdvancedTransferId(String advancedTransferId) { + this.advancedTransferId = advancedTransferId; + } + +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java new file mode 100644 index 00000000..375ed42d --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java @@ -0,0 +1,89 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.AdvancedTransfer; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Create Advanced Transfer + */ +public class CreateAdvancedTransferRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty("advanced_transfer") + private AdvancedTransfer advancedTransfer; + + public CreateAdvancedTransferRequest() { + } + + public CreateAdvancedTransferRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.advancedTransfer = builder.advancedTransfer; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public AdvancedTransfer getAdvancedTransfer() { + return advancedTransfer; + } + + public void setAdvancedTransfer(AdvancedTransfer advancedTransfer) { + this.advancedTransfer = advancedTransfer; + } + + public static class Builder { + private String portfolioId; + private AdvancedTransfer advancedTransfer; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder advancedTransfer(AdvancedTransfer advancedTransfer) { + this.advancedTransfer = advancedTransfer; + return this; + } + + public CreateAdvancedTransferRequest build() throws CoinbaseClientException { + validate(); + return new CreateAdvancedTransferRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java new file mode 100644 index 00000000..a4391ef4 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.prime.model.AdvancedTransfer; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Create Advanced Transfer + */ +public class CreateAdvancedTransferResponse { + @JsonProperty("advanced_transfer") + private AdvancedTransfer advancedTransfer; + + public CreateAdvancedTransferResponse() { + } + + public AdvancedTransfer getAdvancedTransfer() { + return advancedTransfer; + } + + public void setAdvancedTransfer(AdvancedTransfer advancedTransfer) { + this.advancedTransfer = advancedTransfer; + } + +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java new file mode 100644 index 00000000..76203da6 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Portfolio Counterparty ID + */ +public class GetPortfolioCounterpartyIdRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + public GetPortfolioCounterpartyIdRequest() { + } + + public GetPortfolioCounterpartyIdRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public static class Builder { + private String portfolioId; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public GetPortfolioCounterpartyIdRequest build() throws CoinbaseClientException { + validate(); + return new GetPortfolioCounterpartyIdRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java new file mode 100644 index 00000000..1d13ce99 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.prime.model.Counterparty; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Get Portfolio Counterparty ID + */ +public class GetPortfolioCounterpartyIdResponse { + @JsonProperty("counterparty") + private Counterparty counterparty; + + public GetPortfolioCounterpartyIdResponse() { + } + + public Counterparty getCounterparty() { + return counterparty; + } + + public void setCounterparty(Counterparty counterparty) { + this.counterparty = counterparty; + } + +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java new file mode 100644 index 00000000..60980ed2 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Portfolio Counterparty ID + */ +public class GetPortfolioCounterpartyRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + public GetPortfolioCounterpartyRequest() { + } + + public GetPortfolioCounterpartyRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public static class Builder { + private String portfolioId; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public GetPortfolioCounterpartyRequest build() throws CoinbaseClientException { + validate(); + return new GetPortfolioCounterpartyRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java new file mode 100644 index 00000000..46f74ad9 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.prime.model.Counterparty; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Get Portfolio Counterparty ID + */ +public class GetPortfolioCounterpartyResponse { + @JsonProperty("counterparty") + private Counterparty counterparty; + + public GetPortfolioCounterpartyResponse() { + } + + public Counterparty getCounterparty() { + return counterparty; + } + + public void setCounterparty(Counterparty counterparty) { + this.counterparty = counterparty; + } + +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java new file mode 100644 index 00000000..ae7fe7b9 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List transactions associated with an Advanced Transfer + */ +public class ListAdvancedTransferTransactionsRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "advanced_transfer_id") + @JsonIgnore + private String advancedTransferId; + + public ListAdvancedTransferTransactionsRequest() { + } + + public ListAdvancedTransferTransactionsRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.advancedTransferId = builder.advancedTransferId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getAdvancedTransferId() { + return advancedTransferId; + } + + public void setAdvancedTransferId(String advancedTransferId) { + this.advancedTransferId = advancedTransferId; + } + + public static class Builder { + private String portfolioId; + private String advancedTransferId; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder advancedTransferId(String advancedTransferId) { + this.advancedTransferId = advancedTransferId; + return this; + } + + public ListAdvancedTransferTransactionsRequest build() throws CoinbaseClientException { + validate(); + return new ListAdvancedTransferTransactionsRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.advancedTransferId)) { + throw new CoinbaseClientException("AdvancedTransferId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java new file mode 100644 index 00000000..5bd5e4c9 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.prime.model.Transaction; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * List transactions associated with an Advanced Transfer + */ +public class ListAdvancedTransferTransactionsResponse { + @JsonProperty("transactions") + private Transaction[] transactions; + + public ListAdvancedTransferTransactionsResponse() { + } + + public Transaction[] getTransactions() { + return transactions; + } + + public void setTransactions(Transaction[] transactions) { + this.transactions = transactions; + } + +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java new file mode 100644 index 00000000..1b093392 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java @@ -0,0 +1,180 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.AdvancedTransferState; +import com.coinbase.prime.model.enums.AdvancedTransferType; +import com.coinbase.prime.model.enums.SortDirection; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Advanced Transfers + */ +public class ListAdvancedTransfersRequest extends PrimeListRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty("state") + private AdvancedTransferState state; + + @JsonProperty("type") + private AdvancedTransferType type; + + @JsonProperty("start_time") + private String startTime; + + @JsonProperty("end_time") + private String endTime; + + @JsonProperty("reference_id") + private String referenceId; + + public ListAdvancedTransfersRequest() { + } + + public ListAdvancedTransfersRequest(Builder builder) { + super(builder.cursor, builder.sortDirection, builder.limit); + this.portfolioId = builder.portfolioId; + this.state = builder.state; + this.type = builder.type; + this.startTime = builder.startTime; + this.endTime = builder.endTime; + this.referenceId = builder.referenceId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public AdvancedTransferState getState() { + return state; + } + + public void setState(AdvancedTransferState state) { + this.state = state; + } + + public AdvancedTransferType getType() { + return type; + } + + public void setType(AdvancedTransferType type) { + this.type = type; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getReferenceId() { + return referenceId; + } + + public void setReferenceId(String referenceId) { + this.referenceId = referenceId; + } + + public static class Builder { + private String portfolioId; + private AdvancedTransferState state; + private AdvancedTransferType type; + private String startTime; + private String endTime; + private String referenceId; + private String cursor; + private SortDirection sortDirection; + private Integer limit; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder state(AdvancedTransferState state) { + this.state = state; + return this; + } + + public Builder type(AdvancedTransferType type) { + this.type = type; + return this; + } + + public Builder startTime(String startTime) { + this.startTime = startTime; + return this; + } + + public Builder endTime(String endTime) { + this.endTime = endTime; + return this; + } + + public Builder referenceId(String referenceId) { + this.referenceId = referenceId; + return this; + } + + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + + public ListAdvancedTransfersRequest build() throws CoinbaseClientException { + validate(); + return new ListAdvancedTransfersRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java new file mode 100644 index 00000000..5be67b90 --- /dev/null +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfer; + +import com.coinbase.prime.model.AdvancedTransfer; +import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * List Advanced Transfers + */ +public class ListAdvancedTransfersResponse { + @JsonProperty("advanced_transfers") + private AdvancedTransfer[] advancedTransfers; + + @JsonProperty("pagination") + private Pagination pagination; + + public ListAdvancedTransfersResponse() { + } + + public AdvancedTransfer[] getAdvancedTransfers() { + return advancedTransfers; + } + + public void setAdvancedTransfers(AdvancedTransfer[] advancedTransfers) { + this.advancedTransfers = advancedTransfers; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + +} diff --git a/src/main/java/com/coinbase/prime/allocations/AllocationsService.java b/src/main/java/com/coinbase/prime/allocations/AllocationsService.java index ec99c26b..ada4530a 100644 --- a/src/main/java/com/coinbase/prime/allocations/AllocationsService.java +++ b/src/main/java/com/coinbase/prime/allocations/AllocationsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,14 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AllocationsService { - // Allocations + /** Create Portfolio Allocations */ CreateAllocationResponse createAllocation(CreateAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Portfolio Net Allocations */ CreateNetAllocationResponse createNetAllocation(CreateNetAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; - GetAllocationResponse getAllocation(GetAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolio Allocations */ + ListPortfolioAllocationsResponse listPortfolioAllocations(ListPortfolioAllocationsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Net Allocations by Netting ID */ ListAllocationsByNettingIdResponse listAllocationsByNettingId(ListAllocationsByNettingIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListPortfolioAllocationsResponse getPortfolioAllocations(ListPortfolioAllocationsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Allocation by ID */ + GetAllocationResponse getAllocation(GetAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java b/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java index a473ccc3..3d3128c0 100644 --- a/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import java.util.List; public class AllocationsServiceImpl extends CoinbaseServiceImpl implements AllocationsService { - public AllocationsServiceImpl(CoinbasePrimeClient client) { super(client); } @@ -36,7 +35,7 @@ public CreateAllocationResponse createAllocation(CreateAllocationRequest request HttpMethod.POST, "/allocations", request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @@ -46,12 +45,12 @@ public CreateNetAllocationResponse createNetAllocation(CreateNetAllocationReques HttpMethod.POST, "/allocations/net", request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @Override - public ListPortfolioAllocationsResponse getPortfolioAllocations(ListPortfolioAllocationsRequest request) throws CoinbasePrimeException { + public ListPortfolioAllocationsResponse listPortfolioAllocations(ListPortfolioAllocationsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, String.format("/portfolios/%s/allocations", request.getPortfolioId()), @@ -61,22 +60,23 @@ public ListPortfolioAllocationsResponse getPortfolioAllocations(ListPortfolioAll } @Override - public GetAllocationResponse getAllocation(GetAllocationRequest request) throws CoinbasePrimeException { + public ListAllocationsByNettingIdResponse listAllocationsByNettingId(ListAllocationsByNettingIdRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/allocations/%s", request.getPortfolioId(), request.getAllocationId()), - null, + String.format("/portfolios/%s/allocations/net/%s", request.getPortfolioId(), request.getNettingId()), + request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListAllocationsByNettingIdResponse listAllocationsByNettingId(ListAllocationsByNettingIdRequest request) throws CoinbasePrimeException { + public GetAllocationResponse getAllocation(GetAllocationRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/allocations/net/%s", request.getPortfolioId(), request.getNettingId()), + String.format("/portfolios/%s/allocations/%s", request.getPortfolioId(), request.getAllocationId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/allocations/CreateAllocationRequest.java b/src/main/java/com/coinbase/prime/allocations/CreateAllocationRequest.java index cf595837..8ff0353f 100644 --- a/src/main/java/com/coinbase/prime/allocations/CreateAllocationRequest.java +++ b/src/main/java/com/coinbase/prime/allocations/CreateAllocationRequest.java @@ -16,23 +16,36 @@ package com.coinbase.prime.allocations; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.AllocationLeg; import com.coinbase.prime.model.enums.AllocationSizeType; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Create Portfolio Allocations + */ public class CreateAllocationRequest { @JsonProperty("allocation_id") private String allocationId; + @JsonProperty("source_portfolio_id") private String sourcePortfolioId; + @JsonProperty("product_id") private String productId; + @JsonProperty("order_ids") private String[] orderIds; + @JsonProperty("allocation_legs") private AllocationLeg[] allocationLegs; + @JsonProperty("size_type") private AllocationSizeType sizeType; + @JsonProperty("remainder_destination_portfolio") private String remainderDestinationPortfolio; @@ -152,8 +165,12 @@ public Builder remainderDestinationPortfolio(String remainderDestinationPortfoli return this; } - public CreateAllocationRequest build() { + public CreateAllocationRequest build() throws CoinbaseClientException { + validate(); return new CreateAllocationRequest(this); } + + private void validate() throws CoinbaseClientException { + } } } diff --git a/src/main/java/com/coinbase/prime/allocations/CreateAllocationResponse.java b/src/main/java/com/coinbase/prime/allocations/CreateAllocationResponse.java index 5e4cc189..9b15901c 100644 --- a/src/main/java/com/coinbase/prime/allocations/CreateAllocationResponse.java +++ b/src/main/java/com/coinbase/prime/allocations/CreateAllocationResponse.java @@ -16,50 +16,25 @@ package com.coinbase.prime.allocations; +import com.coinbase.prime.model.CreateAllocationResponseBody; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for creating an allocation for a given portfolio. - * - * Contains allocation creation result, including success status and allocation identifiers. + * Create Portfolio Allocations */ public class CreateAllocationResponse { - /** Indicates whether the allocation creation was successful */ - private boolean success; - - /** The unique identifier for the created allocation */ - @JsonProperty("allocation_id") - private String allocationId; - - /** The reason for allocation creation failure, if applicable */ - @JsonProperty("failure_reason") - private String failureReason; + @JsonProperty("body") + private CreateAllocationResponseBody body; public CreateAllocationResponse() { } - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public String getAllocationId() { - return allocationId; - } - - public void setAllocationId(String allocationId) { - this.allocationId = allocationId; - } - - public String getFailureReason() { - return failureReason; + public CreateAllocationResponseBody getBody() { + return body; } - public void setFailureReason(String failureReason) { - this.failureReason = failureReason; + public void setBody(CreateAllocationResponseBody body) { + this.body = body; } } diff --git a/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationRequest.java b/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationRequest.java index 0246add9..509329c3 100644 --- a/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationRequest.java +++ b/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationRequest.java @@ -16,10 +16,17 @@ package com.coinbase.prime.allocations; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.AllocationLeg; import com.coinbase.prime.model.enums.AllocationSizeType; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Create Portfolio Net Allocations + */ public class CreateNetAllocationRequest { @JsonProperty("source_portfolio_id") private String sourcePortfolioId; @@ -45,7 +52,7 @@ public class CreateNetAllocationRequest { public CreateNetAllocationRequest() { } - public CreateNetAllocationRequest(CreateNetAllocationRequest.Builder builder) { + public CreateNetAllocationRequest(Builder builder) { this.sourcePortfolioId = builder.sourcePortfolioId; this.productId = builder.productId; this.orderIds = builder.orderIds; @@ -158,8 +165,12 @@ public Builder nettingId(String nettingId) { return this; } - public CreateNetAllocationRequest build() { + public CreateNetAllocationRequest build() throws CoinbaseClientException { + validate(); return new CreateNetAllocationRequest(this); } + + private void validate() throws CoinbaseClientException { + } } } diff --git a/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationResponse.java b/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationResponse.java index 0ba0eb96..d147f0f2 100644 --- a/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationResponse.java +++ b/src/main/java/com/coinbase/prime/allocations/CreateNetAllocationResponse.java @@ -16,85 +16,25 @@ package com.coinbase.prime.allocations; +import com.coinbase.prime.model.CreateNetAllocationResponseBody; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for creating a net allocation for a given portfolio. - * - * Contains result information for net allocation creation, including success status and allocation identifiers. + * Create Portfolio Net Allocations */ public class CreateNetAllocationResponse { - /** Indicates whether the net allocation creation was successful */ - private boolean success; - - /** The netting identifier for the net allocation */ - @JsonProperty("netting_id") - private String nettingId; - - /** The allocation identifier for the buy side of the net allocation */ - @JsonProperty("buy_allocation_id") - private String buyAllocationId; - - /** The allocation identifier for the sell side of the net allocation */ - @JsonProperty("sell_allocation_id") - private String sellAllocationId; - - /** The reason for net allocation creation failure, if applicable */ - @JsonProperty("failure_reason") - private String failureReason; - - /** The original request that generated this response */ - private CreateNetAllocationRequest request; + @JsonProperty("body") + private CreateNetAllocationResponseBody body; public CreateNetAllocationResponse() { } - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public String getNettingId() { - return nettingId; - } - - public void setNettingId(String nettingId) { - this.nettingId = nettingId; - } - - public String getBuyAllocationId() { - return buyAllocationId; - } - - public void setBuyAllocationId(String buyAllocationId) { - this.buyAllocationId = buyAllocationId; - } - - public String getSellAllocationId() { - return sellAllocationId; - } - - public void setSellAllocationId(String sellAllocationId) { - this.sellAllocationId = sellAllocationId; - } - - public String getFailureReason() { - return failureReason; - } - - public void setFailureReason(String failureReason) { - this.failureReason = failureReason; - } - - public CreateNetAllocationRequest getRequest() { - return request; + public CreateNetAllocationResponseBody getBody() { + return body; } - public void setRequest(CreateNetAllocationRequest request) { - this.request = request; + public void setBody(CreateNetAllocationResponseBody body) { + this.body = body; } } diff --git a/src/main/java/com/coinbase/prime/allocations/GetAllocationRequest.java b/src/main/java/com/coinbase/prime/allocations/GetAllocationRequest.java index 78a18b91..0b49f560 100644 --- a/src/main/java/com/coinbase/prime/allocations/GetAllocationRequest.java +++ b/src/main/java/com/coinbase/prime/allocations/GetAllocationRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Allocation by ID + */ public class GetAllocationRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -56,16 +59,24 @@ public void setAllocationId(String allocationId) { } public static class Builder { - private final String portfolioId; - private final String allocationId; + private String portfolioId; + private String allocationId; + + public Builder() { + } - public Builder(String portfolioId, String allocationId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; + } + + public Builder allocationId(String allocationId) { this.allocationId = allocationId; + return this; } public GetAllocationRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetAllocationRequest(this); } @@ -73,7 +84,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.allocationId)) { throw new CoinbaseClientException("AllocationId is required"); } diff --git a/src/main/java/com/coinbase/prime/allocations/GetAllocationResponse.java b/src/main/java/com/coinbase/prime/allocations/GetAllocationResponse.java index 038b03c9..96be51c8 100644 --- a/src/main/java/com/coinbase/prime/allocations/GetAllocationResponse.java +++ b/src/main/java/com/coinbase/prime/allocations/GetAllocationResponse.java @@ -17,14 +17,13 @@ package com.coinbase.prime.allocations; import com.coinbase.prime.model.Allocation; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving an allocation by allocation ID. - * - * Returns the allocation details for the specified allocation ID within a portfolio. + * Get Allocation by ID */ public class GetAllocationResponse { - /** The allocation details */ + @JsonProperty("allocation") private Allocation allocation; public GetAllocationResponse() { diff --git a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java new file mode 100644 index 00000000..c1c07e6f --- /dev/null +++ b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.allocations; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Net Allocations by Netting ID + */ +public class ListAllocationsByClientNettingIdRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "netting_id") + @JsonIgnore + private String nettingId; + + public ListAllocationsByClientNettingIdRequest() { + } + + public ListAllocationsByClientNettingIdRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.nettingId = builder.nettingId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getNettingId() { + return nettingId; + } + + public void setNettingId(String nettingId) { + this.nettingId = nettingId; + } + + public static class Builder { + private String portfolioId; + private String nettingId; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder nettingId(String nettingId) { + this.nettingId = nettingId; + return this; + } + + public ListAllocationsByClientNettingIdRequest build() throws CoinbaseClientException { + validate(); + return new ListAllocationsByClientNettingIdRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.nettingId)) { + throw new CoinbaseClientException("NettingId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java new file mode 100644 index 00000000..429ba702 --- /dev/null +++ b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.allocations; + +import com.coinbase.prime.model.Allocation; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Get Net Allocations by Netting ID + */ +public class ListAllocationsByClientNettingIdResponse { + @JsonProperty("allocations") + private Allocation[] allocations; + + public ListAllocationsByClientNettingIdResponse() { + } + + public Allocation[] getAllocations() { + return allocations; + } + + public void setAllocations(Allocation[] allocations) { + this.allocations = allocations; + } + +} diff --git a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdRequest.java b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdRequest.java index ce1ed5d8..c74911fc 100644 --- a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdRequest.java +++ b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Net Allocations by Netting ID + */ public class ListAllocationsByNettingIdRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -56,16 +59,24 @@ public void setNettingId(String nettingId) { } public static class Builder { - private final String portfolioId; - private final String nettingId; + private String portfolioId; + private String nettingId; + + public Builder() { + } - public Builder(String portfolioId, String nettingId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; + } + + public Builder nettingId(String nettingId) { this.nettingId = nettingId; + return this; } public ListAllocationsByNettingIdRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListAllocationsByNettingIdRequest(this); } @@ -73,7 +84,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.nettingId)) { throw new CoinbaseClientException("NettingId is required"); } diff --git a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdResponse.java b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdResponse.java index 82f6fc52..14c0630e 100644 --- a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdResponse.java +++ b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByNettingIdResponse.java @@ -17,14 +17,13 @@ package com.coinbase.prime.allocations; import com.coinbase.prime.model.Allocation; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving net allocations by netting ID. - * - * Returns all allocations associated with the specified netting ID within a portfolio. + * Get Net Allocations by Netting ID */ public class ListAllocationsByNettingIdResponse { - /** Array of allocations associated with the netting ID */ + @JsonProperty("allocations") private Allocation[] allocations; public ListAllocationsByNettingIdResponse() { diff --git a/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsRequest.java b/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsRequest.java index a825aa06..76eca31a 100644 --- a/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsRequest.java +++ b/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsRequest.java @@ -24,10 +24,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Date; - -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Allocations + */ public class ListPortfolioAllocationsRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -40,10 +41,10 @@ public class ListPortfolioAllocationsRequest extends PrimeListRequest { private OrderSide orderSide; @JsonProperty("start_date") - private Date startDate; + private String startDate; @JsonProperty("end_date") - private Date endDate; + private String endDate; public ListPortfolioAllocationsRequest() { } @@ -81,19 +82,19 @@ public void setOrderSide(OrderSide orderSide) { this.orderSide = orderSide; } - public Date getStartDate() { + public String getStartDate() { return startDate; } - public void setStartDate(Date startDate) { + public void setStartDate(String startDate) { this.startDate = startDate; } - public Date getEndDate() { + public String getEndDate() { return endDate; } - public void setEndDate(Date endDate) { + public void setEndDate(String endDate) { this.endDate = endDate; } @@ -101,14 +102,13 @@ public static class Builder { private String portfolioId; private String[] productIds; private OrderSide orderSide; - private Date startDate; - private Date endDate; + private String startDate; + private String endDate; private String cursor; private SortDirection sortDirection; private Integer limit; - public Builder(String portfolioId) { - this.portfolioId = portfolioId; + public Builder() { } public Builder portfolioId(String portfolioId) { @@ -126,34 +126,34 @@ public Builder orderSide(OrderSide orderSide) { return this; } - public Builder startDate(Date startDate) { + public Builder startDate(String startDate) { this.startDate = startDate; return this; } - public Builder endDate(Date endDate) { + public Builder endDate(String endDate) { this.endDate = endDate; return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListPortfolioAllocationsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioAllocationsRequest(this); } - public void validate() { - if (isNullOrEmpty(portfolioId)) { + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } } diff --git a/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsResponse.java b/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsResponse.java index 9cff5787..bb26c47e 100644 --- a/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsResponse.java +++ b/src/main/java/com/coinbase/prime/allocations/ListPortfolioAllocationsResponse.java @@ -18,21 +18,17 @@ import com.coinbase.prime.model.Allocation; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing historical allocations for a given portfolio. - * - * Returns paginated list of allocations with optional filtering by products and allocation IDs. + * List Portfolio Allocations */ public class ListPortfolioAllocationsResponse { - /** List of allocations for the portfolio */ + @JsonProperty("allocations") private Allocation[] allocations; - - /** Pagination information for the response */ - private Pagination pagination; - /** The original request that generated this response */ - private ListPortfolioAllocationsRequest request; + @JsonProperty("pagination") + private Pagination pagination; public ListPortfolioAllocationsResponse() { } @@ -53,12 +49,4 @@ public void setPagination(Pagination pagination) { this.pagination = pagination; } - public ListPortfolioAllocationsRequest getRequest() { - return request; - } - - public void setRequest(ListPortfolioAllocationsRequest request) { - this.request = request; - } - } diff --git a/src/main/java/com/coinbase/prime/assets/AssetsService.java b/src/main/java/com/coinbase/prime/assets/AssetsService.java index 326201c3..488beafb 100644 --- a/src/main/java/com/coinbase/prime/assets/AssetsService.java +++ b/src/main/java/com/coinbase/prime/assets/AssetsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AssetsService { - // Assets + /** List Assets */ ListAssetsResponse listAssets(ListAssetsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java b/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java index 08437936..6a9a971c 100644 --- a/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.coinbase.core.service.CoinbaseServiceImpl; import com.coinbase.prime.client.CoinbasePrimeClient; import com.coinbase.prime.errors.CoinbasePrimeException; -import com.coinbase.prime.utils.Utils; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; @@ -39,4 +38,5 @@ public ListAssetsResponse listAssets(ListAssetsRequest request) throws CoinbaseP List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/assets/ListAssetsRequest.java b/src/main/java/com/coinbase/prime/assets/ListAssetsRequest.java index 065b9282..206c9d5c 100644 --- a/src/main/java/com/coinbase/prime/assets/ListAssetsRequest.java +++ b/src/main/java/com/coinbase/prime/assets/ListAssetsRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Assets + */ public class ListAssetsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -43,20 +46,24 @@ public void setEntityId(String entityId) { } public static class Builder { - private final String entityId; + private String entityId; + + public Builder() { + } - public Builder(String entityId) { + public Builder entityId(String entityId) { this.entityId = entityId; + return this; } public ListAssetsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListAssetsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("entityId is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/assets/ListAssetsResponse.java b/src/main/java/com/coinbase/prime/assets/ListAssetsResponse.java index a0a5390a..226ac156 100644 --- a/src/main/java/com/coinbase/prime/assets/ListAssetsResponse.java +++ b/src/main/java/com/coinbase/prime/assets/ListAssetsResponse.java @@ -17,12 +17,13 @@ package com.coinbase.prime.assets; import com.coinbase.prime.model.Asset; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all available assets. + * List Assets */ public class ListAssetsResponse { - /** Array of available asset information */ + @JsonProperty("assets") private Asset[] assets; public ListAssetsResponse() { diff --git a/src/main/java/com/coinbase/prime/balances/BalancesService.java b/src/main/java/com/coinbase/prime/balances/BalancesService.java index f8d4123b..1268fd6a 100644 --- a/src/main/java/com/coinbase/prime/balances/BalancesService.java +++ b/src/main/java/com/coinbase/prime/balances/BalancesService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,9 +20,12 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface BalancesService { - // Balances + /** List Entity Balances */ ListEntityBalancesResponse listEntityBalances(ListEntityBalancesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolio Balances */ ListPortfolioBalancesResponse listPortfolioBalances(ListPortfolioBalancesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Wallet Balance */ GetWalletBalanceResponse getWalletBalance(GetWalletBalanceRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Onchain Wallet Balances */ ListOnchainWalletBalancesResponse listOnchainWalletBalances(ListOnchainWalletBalancesRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java b/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java index a424a0f7..4f545178 100644 --- a/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java +++ b/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public GetWalletBalanceResponse getWalletBalance(GetWalletBalanceRequest request return this.request( HttpMethod.GET, String.format("/portfolios/%s/wallets/%s/balance", request.getPortfolioId(), request.getWalletId()), - null, + request, List.of(200), new TypeReference() {}); } @@ -68,4 +68,5 @@ public ListOnchainWalletBalancesResponse listOnchainWalletBalances(ListOnchainWa List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/balances/GetWalletBalanceRequest.java b/src/main/java/com/coinbase/prime/balances/GetWalletBalanceRequest.java index fa1b240b..84d65127 100644 --- a/src/main/java/com/coinbase/prime/balances/GetWalletBalanceRequest.java +++ b/src/main/java/com/coinbase/prime/balances/GetWalletBalanceRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Wallet Balance + */ public class GetWalletBalanceRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -73,15 +76,14 @@ public Builder walletId(String walletId) { } public GetWalletBalanceRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetWalletBalanceRequest(this); } - public void validate() { + private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.walletId)) { throw new CoinbaseClientException("WalletId is required"); } diff --git a/src/main/java/com/coinbase/prime/balances/GetWalletBalanceResponse.java b/src/main/java/com/coinbase/prime/balances/GetWalletBalanceResponse.java index b4b22c70..34e0d594 100644 --- a/src/main/java/com/coinbase/prime/balances/GetWalletBalanceResponse.java +++ b/src/main/java/com/coinbase/prime/balances/GetWalletBalanceResponse.java @@ -17,12 +17,13 @@ package com.coinbase.prime.balances; import com.coinbase.prime.model.Balance; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for querying balance for a specific wallet. + * Get Wallet Balance */ public class GetWalletBalanceResponse { - /** The wallet balance information */ + @JsonProperty("balance") private Balance balance; public GetWalletBalanceResponse() { diff --git a/src/main/java/com/coinbase/prime/balances/ListEntityBalancesRequest.java b/src/main/java/com/coinbase/prime/balances/ListEntityBalancesRequest.java index 0cda2959..90af3cf1 100644 --- a/src/main/java/com/coinbase/prime/balances/ListEntityBalancesRequest.java +++ b/src/main/java/com/coinbase/prime/balances/ListEntityBalancesRequest.java @@ -16,20 +16,26 @@ package com.coinbase.prime.balances; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.enums.PortfolioBalanceType; +import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.coinbase.core.errors.CoinbaseClientException; + import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Entity Balances + */ public class ListEntityBalancesRequest extends PrimeListRequest { - @JsonProperty("entity_id") + @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; @JsonProperty("symbols") - private String symbols; + private String[] symbols; @JsonProperty("aggregation_type") private PortfolioBalanceType aggregationType; @@ -38,7 +44,7 @@ public ListEntityBalancesRequest() { } public ListEntityBalancesRequest(Builder builder) { - super(builder.cursor, null, builder.limit); + super(builder.cursor, builder.sortDirection, builder.limit); this.entityId = builder.entityId; this.symbols = builder.symbols; this.aggregationType = builder.aggregationType; @@ -52,11 +58,11 @@ public void setEntityId(String entityId) { this.entityId = entityId; } - public String getSymbols() { + public String[] getSymbols() { return symbols; } - public void setSymbols(String symbols) { + public void setSymbols(String[] symbols) { this.symbols = symbols; } @@ -70,10 +76,11 @@ public void setAggregationType(PortfolioBalanceType aggregationType) { public static class Builder { private String entityId; - private String symbols; + private String[] symbols; + private PortfolioBalanceType aggregationType; private String cursor; + private SortDirection sortDirection; private Integer limit; - private PortfolioBalanceType aggregationType; public Builder() { } @@ -83,13 +90,13 @@ public Builder entityId(String entityId) { return this; } - public Builder symbols(String symbols) { + public Builder symbols(String[] symbols) { this.symbols = symbols; return this; } - public Builder cursor(String cursor) { - this.cursor = cursor; + public Builder aggregationType(PortfolioBalanceType aggregationType) { + this.aggregationType = aggregationType; return this; } @@ -98,13 +105,14 @@ public Builder limit(Integer limit) { return this; } - public Builder aggregationType(PortfolioBalanceType aggregationType) { - this.aggregationType = aggregationType; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } - public ListEntityBalancesRequest build() { - this.validate(); + public ListEntityBalancesRequest build() throws CoinbaseClientException { + validate(); return new ListEntityBalancesRequest(this); } diff --git a/src/main/java/com/coinbase/prime/balances/ListEntityBalancesResponse.java b/src/main/java/com/coinbase/prime/balances/ListEntityBalancesResponse.java index 2b400db7..5f8854f3 100644 --- a/src/main/java/com/coinbase/prime/balances/ListEntityBalancesResponse.java +++ b/src/main/java/com/coinbase/prime/balances/ListEntityBalancesResponse.java @@ -18,25 +18,21 @@ import com.coinbase.prime.model.EntityBalance; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all balances for a specific entity. + * List Entity Balances */ public class ListEntityBalancesResponse { - /** Array of entity balance information */ + @JsonProperty("balances") private EntityBalance[] balances; - /** Pagination information for the response */ + @JsonProperty("pagination") private Pagination pagination; public ListEntityBalancesResponse() { } - public ListEntityBalancesResponse(EntityBalance[] balances, Pagination pagination) { - this.balances = balances; - this.pagination = pagination; - } - public EntityBalance[] getBalances() { return balances; } diff --git a/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesRequest.java b/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesRequest.java index 777f7475..47fc1f23 100644 --- a/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesRequest.java +++ b/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesRequest.java @@ -19,13 +19,16 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; import com.coinbase.prime.common.Pagination; -import com.coinbase.prime.model.enums.VisibilityStatus; import com.coinbase.prime.model.enums.SortDirection; +import com.coinbase.prime.model.enums.VisibilityStatus; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Onchain Wallet Balances + */ public class ListOnchainWalletBalancesRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -98,19 +101,19 @@ public Builder visibilityStatuses(VisibilityStatus[] visibilityStatuses) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListOnchainWalletBalancesRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListOnchainWalletBalancesRequest(this); } diff --git a/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesResponse.java b/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesResponse.java index 40a262b0..cff9e008 100644 --- a/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesResponse.java +++ b/src/main/java/com/coinbase/prime/balances/ListOnchainWalletBalancesResponse.java @@ -16,18 +16,24 @@ package com.coinbase.prime.balances; -import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.DefiBalance; import com.coinbase.prime.model.OnchainBalance; +import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing on-chain wallet balances by entity. + * List Onchain Wallet Balances */ public class ListOnchainWalletBalancesResponse { - /** Array of on-chain wallet balance information */ + @JsonProperty("balances") private OnchainBalance[] balances; - /** Pagination information for the response */ + + @JsonProperty("pagination") private Pagination pagination; + @JsonProperty("defi_balances") + private DefiBalance[] defiBalances; + public ListOnchainWalletBalancesResponse() { } @@ -47,4 +53,12 @@ public void setPagination(Pagination pagination) { this.pagination = pagination; } + public DefiBalance[] getDefiBalances() { + return defiBalances; + } + + public void setDefiBalances(DefiBalance[] defiBalances) { + this.defiBalances = defiBalances; + } + } diff --git a/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesRequest.java b/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesRequest.java index 6937fcd6..8a9caff4 100644 --- a/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesRequest.java +++ b/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesRequest.java @@ -17,17 +17,26 @@ package com.coinbase.prime.balances; import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.enums.PortfolioBalanceType; +import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; -public class ListPortfolioBalancesRequest { - @JsonProperty("portfolio_id") +/** + * List Portfolio Balances + */ +public class ListPortfolioBalancesRequest extends PrimeListRequest { + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + + @JsonProperty("symbols") private String[] symbols; + @JsonProperty("balance_type") private PortfolioBalanceType balanceType; @@ -35,6 +44,7 @@ public ListPortfolioBalancesRequest() { } public ListPortfolioBalancesRequest(Builder builder) { + super(builder.cursor, builder.sortDirection, builder.limit); this.portfolioId = builder.portfolioId; this.symbols = builder.symbols; this.balanceType = builder.balanceType; @@ -68,6 +78,12 @@ public static class Builder { private String portfolioId; private String[] symbols; private PortfolioBalanceType balanceType; + private String cursor; + private SortDirection sortDirection; + private Integer limit; + + public Builder() { + } public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; @@ -84,8 +100,19 @@ public Builder balanceType(PortfolioBalanceType balanceType) { return this; } + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + public ListPortfolioBalancesRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioBalancesRequest(this); } diff --git a/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesResponse.java b/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesResponse.java index 4519191c..73fc992c 100644 --- a/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesResponse.java +++ b/src/main/java/com/coinbase/prime/balances/ListPortfolioBalancesResponse.java @@ -16,26 +16,30 @@ package com.coinbase.prime.balances; -import com.coinbase.prime.model.Balance; import com.coinbase.prime.model.AggregatedFiatBalance; +import com.coinbase.prime.model.Balance; import com.coinbase.prime.model.enums.PortfolioBalanceType; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all balances for a specific portfolio. + * List Portfolio Balances */ public class ListPortfolioBalancesResponse { - /** Array of portfolio balance information */ + @JsonProperty("balances") private Balance[] balances; - /** The type of portfolio balance */ + + @JsonProperty("type") private PortfolioBalanceType type; - /** Trading-specific balance summary */ + @JsonProperty("trading_balances") private AggregatedFiatBalance tradingBalances; - /** Vault-specific balance summary */ + @JsonProperty("vault_balances") private AggregatedFiatBalance vaultBalances; + @JsonProperty("prime_custody_balances") + private AggregatedFiatBalance primeCustodyBalances; + public ListPortfolioBalancesResponse() { } @@ -71,4 +75,12 @@ public void setVaultBalances(AggregatedFiatBalance vaultBalances) { this.vaultBalances = vaultBalances; } + public AggregatedFiatBalance getPrimeCustodyBalances() { + return primeCustodyBalances; + } + + public void setPrimeCustodyBalances(AggregatedFiatBalance primeCustodyBalances) { + this.primeCustodyBalances = primeCustodyBalances; + } + } diff --git a/src/main/java/com/coinbase/prime/commission/CommissionService.java b/src/main/java/com/coinbase/prime/commission/CommissionService.java index ff8570b3..83ccf77b 100644 --- a/src/main/java/com/coinbase/prime/commission/CommissionService.java +++ b/src/main/java/com/coinbase/prime/commission/CommissionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface CommissionService { - // Commission + /** Get Portfolio Commission */ GetPortfolioCommissionResponse getPortfolioCommission(GetPortfolioCommissionRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java b/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java index e7430689..326b102d 100644 --- a/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java +++ b/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,4 +38,5 @@ public GetPortfolioCommissionResponse getPortfolioCommission(GetPortfolioCommiss List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionRequest.java b/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionRequest.java index 8c5d79a3..f4d34735 100644 --- a/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionRequest.java +++ b/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionRequest.java @@ -22,11 +22,14 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Portfolio Commission + */ public class GetPortfolioCommissionRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - + @JsonProperty("product_id") private String productId; @@ -72,13 +75,13 @@ public Builder productId(String productId) { } public GetPortfolioCommissionRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetPortfolioCommissionRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("Portfolio ID is required"); + throw new CoinbaseClientException("PortfolioId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionResponse.java b/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionResponse.java index 743f68c4..f8b4e0aa 100644 --- a/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionResponse.java +++ b/src/main/java/com/coinbase/prime/commission/GetPortfolioCommissionResponse.java @@ -17,12 +17,13 @@ package com.coinbase.prime.commission; import com.coinbase.prime.model.Commission; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving commission information for a specific portfolio. + * Get Portfolio Commission */ public class GetPortfolioCommissionResponse { - /** The commission information for the portfolio */ + @JsonProperty("commission") private Commission commission; public GetPortfolioCommissionResponse() { diff --git a/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java b/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java index 0c4ab614..881ad9a9 100644 --- a/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java +++ b/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,17 +18,16 @@ import com.coinbase.prime.activities.ActivitiesService; import com.coinbase.prime.activities.ActivitiesServiceImpl; -import com.coinbase.prime.advancedtransfers.AdvancedTransfersService; -import com.coinbase.prime.advancedtransfers.AdvancedTransfersServiceImpl; import com.coinbase.prime.addressbook.AddressBookService; import com.coinbase.prime.addressbook.AddressBookServiceImpl; +import com.coinbase.prime.advancedtransfer.AdvancedTransferService; +import com.coinbase.prime.advancedtransfer.AdvancedTransferServiceImpl; import com.coinbase.prime.allocations.AllocationsService; import com.coinbase.prime.allocations.AllocationsServiceImpl; import com.coinbase.prime.assets.AssetsService; import com.coinbase.prime.assets.AssetsServiceImpl; import com.coinbase.prime.balances.BalancesService; import com.coinbase.prime.balances.BalancesServiceImpl; -import com.coinbase.prime.client.CoinbasePrimeClient; import com.coinbase.prime.commission.CommissionService; import com.coinbase.prime.commission.CommissionServiceImpl; import com.coinbase.prime.financing.FinancingService; @@ -57,20 +56,21 @@ import com.coinbase.prime.users.UsersServiceImpl; import com.coinbase.prime.wallets.WalletsService; import com.coinbase.prime.wallets.WalletsServiceImpl; +import com.coinbase.prime.client.CoinbasePrimeClient; public class PrimeServiceFactory { public static ActivitiesService createActivitiesService(CoinbasePrimeClient client) { return new ActivitiesServiceImpl(client); } - public static AdvancedTransfersService createAdvancedTransfersService(CoinbasePrimeClient client) { - return new AdvancedTransfersServiceImpl(client); - } - public static AddressBookService createAddressBookService(CoinbasePrimeClient client) { return new AddressBookServiceImpl(client); } + public static AdvancedTransferService createAdvancedTransferService(CoinbasePrimeClient client) { + return new AdvancedTransferServiceImpl(client); + } + public static AllocationsService createAllocationsService(CoinbasePrimeClient client) { return new AllocationsServiceImpl(client); } @@ -138,4 +138,5 @@ public static UsersService createUsersService(CoinbasePrimeClient client) { public static WalletsService createWalletsService(CoinbasePrimeClient client) { return new WalletsServiceImpl(client); } + } diff --git a/src/main/java/com/coinbase/prime/financing/CreateNewLocatesRequest.java b/src/main/java/com/coinbase/prime/financing/CreateNewLocatesRequest.java index f526e71b..c38f6d1b 100644 --- a/src/main/java/com/coinbase/prime/financing/CreateNewLocatesRequest.java +++ b/src/main/java/com/coinbase/prime/financing/CreateNewLocatesRequest.java @@ -16,94 +16,127 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -public class CreateNewLocatesRequest { - @JsonIgnore - @JsonProperty(required = true, value = "portfolio_id") - private String portfolioId; - - private String symbol; - - private String amount; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; - @JsonProperty("locate_date") - private String locateDate; +/** + * Create New Locates + */ +public class CreateNewLocatesRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; - public CreateNewLocatesRequest() { - } + @JsonProperty("symbol") + private String symbol; - public CreateNewLocatesRequest(Builder builder) { - this.portfolioId = builder.portfolioId; - this.symbol = builder.symbol; - this.amount = builder.amount; - this.locateDate = builder.locateDate; - } + @JsonProperty("amount") + private String amount; - public String getPortfolioId() { - return portfolioId; - } + @JsonProperty("conversion_date") + private String conversionDate; - public void setPortfolioId(String portfolioId) { - this.portfolioId = portfolioId; - } + @JsonProperty("locate_date") + private String locateDate; - public String getSymbol() { - return symbol; - } + public CreateNewLocatesRequest() { + } - public void setSymbol(String symbol) { - this.symbol = symbol; - } + public CreateNewLocatesRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.symbol = builder.symbol; + this.amount = builder.amount; + this.conversionDate = builder.conversionDate; + this.locateDate = builder.locateDate; + } - public String getAmount() { - return amount; - } + public String getPortfolioId() { + return portfolioId; + } - public void setAmount(String amount) { - this.amount = amount; - } + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } - public String getLocateDate() { - return locateDate; - } + public String getSymbol() { + return symbol; + } - public void setLocateDate(String locateDate) { - this.locateDate = locateDate; - } + public void setSymbol(String symbol) { + this.symbol = symbol; + } - public static class Builder { - private String portfolioId; - private String symbol; - private String amount; - private String locateDate; + public String getAmount() { + return amount; + } - public Builder() { + public void setAmount(String amount) { + this.amount = amount; } - public Builder portfolioId(String portfolioId) { - this.portfolioId = portfolioId; - return this; + public String getConversionDate() { + return conversionDate; } - public Builder symbol(String symbol) { - this.symbol = symbol; - return this; + public void setConversionDate(String conversionDate) { + this.conversionDate = conversionDate; } - public Builder amount(String amount) { - this.amount = amount; - return this; + public String getLocateDate() { + return locateDate; } - public Builder locateDate(String locateDate) { - this.locateDate = locateDate; - return this; + public void setLocateDate(String locateDate) { + this.locateDate = locateDate; } - public CreateNewLocatesRequest build() { - return new CreateNewLocatesRequest(this); + public static class Builder { + private String portfolioId; + private String symbol; + private String amount; + private String conversionDate; + private String locateDate; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder symbol(String symbol) { + this.symbol = symbol; + return this; + } + + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + public Builder conversionDate(String conversionDate) { + this.conversionDate = conversionDate; + return this; + } + + public Builder locateDate(String locateDate) { + this.locateDate = locateDate; + return this; + } + + public CreateNewLocatesRequest build() throws CoinbaseClientException { + validate(); + return new CreateNewLocatesRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } - } } diff --git a/src/main/java/com/coinbase/prime/financing/CreateNewLocatesResponse.java b/src/main/java/com/coinbase/prime/financing/CreateNewLocatesResponse.java index 86c83bb5..f273bb8b 100644 --- a/src/main/java/com/coinbase/prime/financing/CreateNewLocatesResponse.java +++ b/src/main/java/com/coinbase/prime/financing/CreateNewLocatesResponse.java @@ -18,18 +18,22 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Create New Locates + */ public class CreateNewLocatesResponse { - @JsonProperty("locate_id") - private String locateId; + @JsonProperty("locate_id") + private String locateId; + + public CreateNewLocatesResponse() { + } - public CreateNewLocatesResponse() { - } + public String getLocateId() { + return locateId; + } - public String getLocateId() { - return locateId; - } + public void setLocateId(String locateId) { + this.locateId = locateId; + } - public void setLocateId(String locateId) { - this.locateId = locateId; - } } diff --git a/src/main/java/com/coinbase/prime/financing/FinancingService.java b/src/main/java/com/coinbase/prime/financing/FinancingService.java index ccba737e..30b78e67 100644 --- a/src/main/java/com/coinbase/prime/financing/FinancingService.java +++ b/src/main/java/com/coinbase/prime/financing/FinancingService.java @@ -20,19 +20,36 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface FinancingService { - CreateNewLocatesResponse createNewLocates(CreateNewLocatesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Interest Accruals */ + ListInterestAccrualsResponse listInterestAccruals(ListInterestAccrualsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Cross Margin Overview */ GetCrossMarginOverviewResponse getCrossMarginOverview(GetCrossMarginOverviewRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Entity Locate Availabilities */ GetEntityLocateAvailabilitiesResponse getEntityLocateAvailabilities(GetEntityLocateAvailabilitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Margin Information */ GetMarginInformationResponse getMarginInformation(GetMarginInformationRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Margin Call Summaries */ + ListMarginCallSummariesResponse listMarginCallSummaries(ListMarginCallSummariesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Trade Finance Obligations */ + ListTradeFinanceObligationsResponse listTradeFinanceObligations(ListTradeFinanceObligationsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Trade Finance Tiered Pricing Fees */ + GetTradeFinanceTieredPricingFeesResponse getTradeFinanceTieredPricingFees(GetTradeFinanceTieredPricingFeesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Financing Eligible Assets */ + ListFinancingEligibleAssetsResponse listFinancingEligibleAssets() throws CoinbaseClientException, CoinbasePrimeException; + /** List Interest Accruals For Portfolio */ + ListInterestAccrualsForPortfolioResponse listInterestAccrualsForPortfolio(ListInterestAccrualsForPortfolioRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Portfolio Buying Power */ GetPortfolioBuyingPowerResponse getPortfolioBuyingPower(GetPortfolioBuyingPowerRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Portfolio Credit Information */ GetPortfolioCreditInformationResponse getPortfolioCreditInformation(GetPortfolioCreditInformationRequest request) throws CoinbaseClientException, CoinbasePrimeException; - GetPortfolioWithdrawalPowerResponse getPortfolioWithdrawalPower(GetPortfolioWithdrawalPowerRequest request) throws CoinbaseClientException, CoinbasePrimeException; - GetTradeFinanceTieredPricingFeesResponse getTradeFinanceTieredPricingFees(GetTradeFinanceTieredPricingFeesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Existing Locates */ ListExistingLocatesResponse listExistingLocates(ListExistingLocatesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListInterestAccrualsResponse listInterestAccruals(ListInterestAccrualsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListInterestAccrualsForPortfolioResponse listInterestAccrualsForPortfolio(ListInterestAccrualsForPortfolioRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListMarginCallSummariesResponse listMarginCallSummaries(ListMarginCallSummariesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create New Locates */ + CreateNewLocatesResponse createNewLocates(CreateNewLocatesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Margin Conversions */ ListMarginConversionsResponse listMarginConversions(ListMarginConversionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListTfObligationsResponse listTfObligations(ListTfObligationsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListFinancingEligibleAssetsResponse listFinancingEligibleAssets(ListFinancingEligibleAssetsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Portfolio Withdrawal Power */ + GetPortfolioWithdrawalPowerResponse getPortfolioWithdrawalPower(GetPortfolioWithdrawalPowerRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Update Funding Settings (Beta) */ + UpdateFundingSettingsResponse updateFundingSettings(UpdateFundingSettingsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/financing/FinancingServiceImpl.java b/src/main/java/com/coinbase/prime/financing/FinancingServiceImpl.java index ae761b08..20006d3c 100644 --- a/src/main/java/com/coinbase/prime/financing/FinancingServiceImpl.java +++ b/src/main/java/com/coinbase/prime/financing/FinancingServiceImpl.java @@ -30,13 +30,13 @@ public FinancingServiceImpl(CoinbasePrimeClient client) { } @Override - public CreateNewLocatesResponse createNewLocates(CreateNewLocatesRequest request) throws CoinbasePrimeException { + public ListInterestAccrualsResponse listInterestAccruals(ListInterestAccrualsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, - String.format("/portfolios/%s/locates", request.getPortfolioId()), + HttpMethod.GET, + String.format("/entities/%s/accruals", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override @@ -53,7 +53,7 @@ public GetCrossMarginOverviewResponse getCrossMarginOverview(GetCrossMarginOverv public GetEntityLocateAvailabilitiesResponse getEntityLocateAvailabilities(GetEntityLocateAvailabilitiesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/locates/locates_availability", request.getEntityId()), + String.format("/entities/%s/locates_availability", request.getEntityId()), request, List.of(200), new TypeReference() {}); @@ -70,83 +70,93 @@ public GetMarginInformationResponse getMarginInformation(GetMarginInformationReq } @Override - public GetPortfolioBuyingPowerResponse getPortfolioBuyingPower(GetPortfolioBuyingPowerRequest request) throws CoinbasePrimeException { + public ListMarginCallSummariesResponse listMarginCallSummaries(ListMarginCallSummariesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/buying_power", request.getPortfolioId()), + String.format("/entities/%s/margin_summaries", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetPortfolioCreditInformationResponse getPortfolioCreditInformation(GetPortfolioCreditInformationRequest request) throws CoinbasePrimeException { + public ListTradeFinanceObligationsResponse listTradeFinanceObligations(ListTradeFinanceObligationsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/credit", request.getPortfolioId()), + String.format("/entities/%s/tf_obligations", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetPortfolioWithdrawalPowerResponse getPortfolioWithdrawalPower(GetPortfolioWithdrawalPowerRequest request) throws CoinbasePrimeException { + public GetTradeFinanceTieredPricingFeesResponse getTradeFinanceTieredPricingFees(GetTradeFinanceTieredPricingFeesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/withdrawal_power", request.getPortfolioId()), + String.format("/entities/%s/tf_tiered_fees", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetTradeFinanceTieredPricingFeesResponse getTradeFinanceTieredPricingFees(GetTradeFinanceTieredPricingFeesRequest request) throws CoinbasePrimeException { + public ListFinancingEligibleAssetsResponse listFinancingEligibleAssets() throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/tf_tiered_fees", request.getEntityId()), - request, + "/financing/eligible-assets", + null, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListExistingLocatesResponse listExistingLocates(ListExistingLocatesRequest request) throws CoinbasePrimeException { + public ListInterestAccrualsForPortfolioResponse listInterestAccrualsForPortfolio(ListInterestAccrualsForPortfolioRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/locates", request.getPortfolioId()), + String.format("/portfolios/%s/accruals", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListInterestAccrualsResponse listInterestAccruals(ListInterestAccrualsRequest request) throws CoinbasePrimeException { + public GetPortfolioBuyingPowerResponse getPortfolioBuyingPower(GetPortfolioBuyingPowerRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/accruals", request.getEntityId()), + String.format("/portfolios/%s/buying_power", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListInterestAccrualsForPortfolioResponse listInterestAccrualsForPortfolio(ListInterestAccrualsForPortfolioRequest request) throws CoinbasePrimeException { + public GetPortfolioCreditInformationResponse getPortfolioCreditInformation(GetPortfolioCreditInformationRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/accruals", request.getPortfolioId()), + String.format("/portfolios/%s/credit", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListMarginCallSummariesResponse listMarginCallSummaries(ListMarginCallSummariesRequest request) throws CoinbasePrimeException { + public ListExistingLocatesResponse listExistingLocates(ListExistingLocatesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/margin_summaries", request.getEntityId()), + String.format("/portfolios/%s/locates", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); + } + + @Override + public CreateNewLocatesResponse createNewLocates(CreateNewLocatesRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.POST, + String.format("/portfolios/%s/locates", request.getPortfolioId()), + request, + List.of(201, 200), + new TypeReference() {}); } @Override @@ -160,22 +170,23 @@ public ListMarginConversionsResponse listMarginConversions(ListMarginConversions } @Override - public ListTfObligationsResponse listTfObligations(ListTfObligationsRequest request) throws CoinbasePrimeException { + public GetPortfolioWithdrawalPowerResponse getPortfolioWithdrawalPower(GetPortfolioWithdrawalPowerRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/tf_obligations", request.getEntityId()), + String.format("/portfolios/%s/withdrawal_power", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListFinancingEligibleAssetsResponse listFinancingEligibleAssets(ListFinancingEligibleAssetsRequest request) throws CoinbasePrimeException { + public UpdateFundingSettingsResponse updateFundingSettings(UpdateFundingSettingsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, - "/financing/eligible-assets", + HttpMethod.POST, + String.format("/entities/%s/funding-settings", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewRequest.java b/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewRequest.java index ab3ed60a..7bfef5cc 100644 --- a/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewRequest.java @@ -16,15 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + /** - * Request object for retrieving cross margin overview for an entity. + * Get Cross Margin Overview */ public class GetCrossMarginOverviewRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; public GetCrossMarginOverviewRequest() { @@ -53,9 +56,15 @@ public Builder entityId(String entityId) { return this; } - public GetCrossMarginOverviewRequest build() { + public GetCrossMarginOverviewRequest build() throws CoinbaseClientException { + validate(); return new GetCrossMarginOverviewRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } - diff --git a/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewResponse.java b/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewResponse.java index b42d58c0..08b9b1d4 100644 --- a/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetCrossMarginOverviewResponse.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving cross margin overview for an entity. + * Get Cross Margin Overview */ public class GetCrossMarginOverviewResponse { @JsonProperty("overview") @@ -36,5 +36,5 @@ public CrossMarginOverview getOverview() { public void setOverview(CrossMarginOverview overview) { this.overview = overview; } -} +} diff --git a/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesRequest.java b/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesRequest.java index 1451b1ff..38002be6 100644 --- a/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Entity Locate Availabilities + */ public class GetEntityLocateAvailabilitiesRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; @JsonProperty("conversion_date") @@ -86,8 +92,15 @@ public Builder locateDate(String locateDate) { return this; } - public GetEntityLocateAvailabilitiesRequest build() { + public GetEntityLocateAvailabilitiesRequest build() throws CoinbaseClientException { + validate(); return new GetEntityLocateAvailabilitiesRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesResponse.java b/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesResponse.java index cea8773b..6fa01c89 100644 --- a/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetEntityLocateAvailabilitiesResponse.java @@ -17,8 +17,13 @@ package com.coinbase.prime.financing; import com.coinbase.prime.model.Locate; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Entity Locate Availabilities + */ public class GetEntityLocateAvailabilitiesResponse { + @JsonProperty("locates") private Locate[] locates; public GetEntityLocateAvailabilitiesResponse() { diff --git a/src/main/java/com/coinbase/prime/financing/GetMarginInformationRequest.java b/src/main/java/com/coinbase/prime/financing/GetMarginInformationRequest.java index 7f037803..c26ecbe7 100644 --- a/src/main/java/com/coinbase/prime/financing/GetMarginInformationRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetMarginInformationRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Margin Information + */ public class GetMarginInformationRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; public GetMarginInformationRequest() { @@ -50,8 +56,15 @@ public Builder entityId(String entityId) { return this; } - public GetMarginInformationRequest build() { + public GetMarginInformationRequest build() throws CoinbaseClientException { + validate(); return new GetMarginInformationRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/GetMarginInformationResponse.java b/src/main/java/com/coinbase/prime/financing/GetMarginInformationResponse.java index 2066813f..67d5b268 100644 --- a/src/main/java/com/coinbase/prime/financing/GetMarginInformationResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetMarginInformationResponse.java @@ -20,10 +20,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving margin information for a portfolio. + * Get Margin Information */ public class GetMarginInformationResponse { - /** The margin information for the portfolio */ @JsonProperty("margin_information") private MarginInformation marginInformation; diff --git a/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerRequest.java b/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerRequest.java index dc565a7b..6beb1b2c 100644 --- a/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerRequest.java @@ -16,18 +16,24 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Portfolio Buying Power + */ public class GetPortfolioBuyingPowerRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonProperty(required = true, value = "base_currency") + @JsonProperty("base_currency") private String baseCurrency; - @JsonProperty(required = true, value = "quote_currency") + @JsonProperty("quote_currency") private String quoteCurrency; public GetPortfolioBuyingPowerRequest() { @@ -86,8 +92,15 @@ public Builder quoteCurrency(String quoteCurrency) { return this; } - public GetPortfolioBuyingPowerRequest build() { + public GetPortfolioBuyingPowerRequest build() throws CoinbaseClientException { + validate(); return new GetPortfolioBuyingPowerRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerResponse.java b/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerResponse.java index 41d60309..647cdd36 100644 --- a/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetPortfolioBuyingPowerResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.BuyingPower; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Portfolio Buying Power + */ public class GetPortfolioBuyingPowerResponse { @JsonProperty("buying_power") private BuyingPower buyingPower; diff --git a/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationRequest.java b/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationRequest.java index e0783c94..68e4a7e5 100644 --- a/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Portfolio Credit Information + */ public class GetPortfolioCreditInformationRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -30,10 +33,6 @@ public class GetPortfolioCreditInformationRequest { public GetPortfolioCreditInformationRequest() { } - public GetPortfolioCreditInformationRequest(String portfolioId) { - this.portfolioId = portfolioId; - } - public GetPortfolioCreditInformationRequest(Builder builder) { this.portfolioId = builder.portfolioId; } @@ -58,13 +57,13 @@ public Builder portfolioId(String portfolioId) { } public GetPortfolioCreditInformationRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetPortfolioCreditInformationRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationResponse.java b/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationResponse.java index 9d8bcf18..eb24086c 100644 --- a/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetPortfolioCreditInformationResponse.java @@ -17,8 +17,13 @@ package com.coinbase.prime.financing; import com.coinbase.prime.model.PostTradeCreditInformation; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Portfolio Credit Information + */ public class GetPortfolioCreditInformationResponse { + @JsonProperty("post_trade_credit") private PostTradeCreditInformation postTradeCredit; public GetPortfolioCreditInformationResponse() { @@ -28,7 +33,7 @@ public PostTradeCreditInformation getPostTradeCredit() { return postTradeCredit; } - public void setPortfolioCreditInformation(PostTradeCreditInformation postTradeCredit) { + public void setPostTradeCredit(PostTradeCreditInformation postTradeCredit) { this.postTradeCredit = postTradeCredit; } diff --git a/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerRequest.java b/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerRequest.java index 4c114a85..1a158f41 100644 --- a/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerRequest.java @@ -16,15 +16,21 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Portfolio Withdrawal Power + */ public class GetPortfolioWithdrawalPowerRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonProperty(required = true) + @JsonProperty("symbol") private String symbol; public GetPortfolioWithdrawalPowerRequest() { @@ -68,8 +74,15 @@ public Builder symbol(String symbol) { return this; } - public GetPortfolioWithdrawalPowerRequest build() { + public GetPortfolioWithdrawalPowerRequest build() throws CoinbaseClientException { + validate(); return new GetPortfolioWithdrawalPowerRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerResponse.java b/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerResponse.java index 59d88ef6..60c03e0f 100644 --- a/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetPortfolioWithdrawalPowerResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.WithdrawalPower; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Portfolio Withdrawal Power + */ public class GetPortfolioWithdrawalPowerResponse { @JsonProperty("withdrawal_power") private WithdrawalPower withdrawalPower; @@ -26,10 +29,6 @@ public class GetPortfolioWithdrawalPowerResponse { public GetPortfolioWithdrawalPowerResponse() { } - public GetPortfolioWithdrawalPowerResponse(WithdrawalPower withdrawalPower) { - this.withdrawalPower = withdrawalPower; - } - public WithdrawalPower getWithdrawalPower() { return withdrawalPower; } @@ -37,4 +36,5 @@ public WithdrawalPower getWithdrawalPower() { public void setWithdrawalPower(WithdrawalPower withdrawalPower) { this.withdrawalPower = withdrawalPower; } + } diff --git a/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesRequest.java b/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesRequest.java index 5f96ef83..9cee91ed 100644 --- a/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesRequest.java +++ b/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Trade Finance Tiered Pricing Fees + */ public class GetTradeFinanceTieredPricingFeesRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; @JsonProperty("effective_at") @@ -68,8 +74,15 @@ public Builder effectiveAt(String effectiveAt) { return this; } - public GetTradeFinanceTieredPricingFeesRequest build() { + public GetTradeFinanceTieredPricingFeesRequest build() throws CoinbaseClientException { + validate(); return new GetTradeFinanceTieredPricingFeesRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesResponse.java b/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesResponse.java index fd0f3400..3a1198cd 100644 --- a/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesResponse.java +++ b/src/main/java/com/coinbase/prime/financing/GetTradeFinanceTieredPricingFeesResponse.java @@ -17,8 +17,13 @@ package com.coinbase.prime.financing; import com.coinbase.prime.model.TieredPricingFee; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Trade Finance Tiered Pricing Fees + */ public class GetTradeFinanceTieredPricingFeesResponse { + @JsonProperty("fees") private TieredPricingFee[] fees; public GetTradeFinanceTieredPricingFeesResponse() { diff --git a/src/main/java/com/coinbase/prime/financing/ListExistingLocatesRequest.java b/src/main/java/com/coinbase/prime/financing/ListExistingLocatesRequest.java index ebdd0702..5f85a7cd 100644 --- a/src/main/java/com/coinbase/prime/financing/ListExistingLocatesRequest.java +++ b/src/main/java/com/coinbase/prime/financing/ListExistingLocatesRequest.java @@ -16,31 +16,37 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Existing Locates + */ public class ListExistingLocatesRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; @JsonProperty("locate_ids") private String[] locateIds; - @JsonProperty("locate_date") - private String locateDate; - @JsonProperty("conversion_date") private String conversionDate; + @JsonProperty("locate_date") + private String locateDate; + public ListExistingLocatesRequest() { } public ListExistingLocatesRequest(Builder builder) { this.portfolioId = builder.portfolioId; this.locateIds = builder.locateIds; - this.locateDate = builder.locateDate; this.conversionDate = builder.conversionDate; + this.locateDate = builder.locateDate; } public String getPortfolioId() { @@ -59,14 +65,6 @@ public void setLocateIds(String[] locateIds) { this.locateIds = locateIds; } - public String getLocateDate() { - return locateDate; - } - - public void setLocateDate(String locateDate) { - this.locateDate = locateDate; - } - public String getConversionDate() { return conversionDate; } @@ -75,11 +73,19 @@ public void setConversionDate(String conversionDate) { this.conversionDate = conversionDate; } + public String getLocateDate() { + return locateDate; + } + + public void setLocateDate(String locateDate) { + this.locateDate = locateDate; + } + public static class Builder { private String portfolioId; private String[] locateIds; - private String locateDate; private String conversionDate; + private String locateDate; public Builder() { } @@ -94,18 +100,25 @@ public Builder locateIds(String[] locateIds) { return this; } - public Builder locateDate(String locateDate) { - this.locateDate = locateDate; + public Builder conversionDate(String conversionDate) { + this.conversionDate = conversionDate; return this; } - public Builder conversionDate(String conversionDate) { - this.conversionDate = conversionDate; + public Builder locateDate(String locateDate) { + this.locateDate = locateDate; return this; } - public ListExistingLocatesRequest build() { + public ListExistingLocatesRequest build() throws CoinbaseClientException { + validate(); return new ListExistingLocatesRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/ListExistingLocatesResponse.java b/src/main/java/com/coinbase/prime/financing/ListExistingLocatesResponse.java index 05d0f89e..099e768d 100644 --- a/src/main/java/com/coinbase/prime/financing/ListExistingLocatesResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListExistingLocatesResponse.java @@ -16,19 +16,24 @@ package com.coinbase.prime.financing; -import com.coinbase.prime.model.Locate; +import com.coinbase.prime.model.ExistingLocate; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Existing Locates + */ public class ListExistingLocatesResponse { - private Locate[] locates; + @JsonProperty("locates") + private ExistingLocate[] locates; public ListExistingLocatesResponse() { } - public Locate[] getLocates() { + public ExistingLocate[] getLocates() { return locates; } - public void setLocates(Locate[] locates) { + public void setLocates(ExistingLocate[] locates) { this.locates = locates; } diff --git a/src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsResponse.java b/src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsResponse.java index ba3de91e..df75286b 100644 --- a/src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsResponse.java @@ -19,20 +19,22 @@ import com.coinbase.prime.model.TfAsset; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - +/** + * List Financing Eligible Assets + */ public class ListFinancingEligibleAssetsResponse { @JsonProperty("assets") - private List assets; + private TfAsset[] assets; public ListFinancingEligibleAssetsResponse() { } - public List getAssets() { + public TfAsset[] getAssets() { return assets; } - public void setAssets(List assets) { + public void setAssets(TfAsset[] assets) { this.assets = assets; } + } diff --git a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioRequest.java b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioRequest.java index b9f663e6..37912330 100644 --- a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioRequest.java +++ b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Interest Accruals For Portfolio + */ public class ListInterestAccrualsForPortfolioRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; @JsonProperty("start_date") @@ -71,7 +77,7 @@ public static class Builder { public Builder() { } - public Builder prtfolioId(String portfolioId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; return this; } @@ -86,6 +92,15 @@ public Builder endDate(String endDate) { return this; } + public ListInterestAccrualsForPortfolioRequest build() throws CoinbaseClientException { + validate(); + return new ListInterestAccrualsForPortfolioRequest(this); + } + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioResponse.java b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioResponse.java index fd898198..1f7c0232 100644 --- a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsForPortfolioResponse.java @@ -19,10 +19,14 @@ import com.coinbase.prime.model.Accrual; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Interest Accruals For Portfolio + */ public class ListInterestAccrualsForPortfolioResponse { @JsonProperty("total_notional_accrual") private String totalNotionalAccrual; + @JsonProperty("accruals") private Accrual[] accruals; public ListInterestAccrualsForPortfolioResponse() { diff --git a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsRequest.java b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsRequest.java index 975c0468..4f9cf72a 100644 --- a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsRequest.java +++ b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Interest Accruals + */ public class ListInterestAccrualsRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; @JsonProperty("portfolio_id") @@ -104,8 +110,15 @@ public Builder endDate(String endDate) { return this; } - public ListInterestAccrualsRequest build() { + public ListInterestAccrualsRequest build() throws CoinbaseClientException { + validate(); return new ListInterestAccrualsRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsResponse.java b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsResponse.java index 84119361..25a90000 100644 --- a/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListInterestAccrualsResponse.java @@ -19,10 +19,14 @@ import com.coinbase.prime.model.Accrual; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Interest Accruals + */ public class ListInterestAccrualsResponse { @JsonProperty("total_notional_accrual") private String totalNotionalAccrual; + @JsonProperty("accruals") private Accrual[] accruals; public ListInterestAccrualsResponse() { diff --git a/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesRequest.java b/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesRequest.java index c05dae8a..28b760fe 100644 --- a/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesRequest.java +++ b/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Margin Call Summaries + */ public class ListMarginCallSummariesRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; @JsonProperty("start_date") @@ -86,8 +92,15 @@ public Builder endDate(String endDate) { return this; } - public ListMarginCallSummariesRequest build() { + public ListMarginCallSummariesRequest build() throws CoinbaseClientException { + validate(); return new ListMarginCallSummariesRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesResponse.java b/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesResponse.java index 37620981..b1edff4b 100644 --- a/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListMarginCallSummariesResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.MarginSummaryHistorical; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Margin Call Summaries + */ public class ListMarginCallSummariesResponse { @JsonProperty("margin_summaries") private MarginSummaryHistorical[] marginSummaries; diff --git a/src/main/java/com/coinbase/prime/financing/ListMarginConversionsRequest.java b/src/main/java/com/coinbase/prime/financing/ListMarginConversionsRequest.java index 42566e39..bd6d728d 100644 --- a/src/main/java/com/coinbase/prime/financing/ListMarginConversionsRequest.java +++ b/src/main/java/com/coinbase/prime/financing/ListMarginConversionsRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.financing; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Margin Conversions + */ public class ListMarginConversionsRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; @JsonProperty("start_date") @@ -86,8 +92,15 @@ public Builder endDate(String endDate) { return this; } - public ListMarginConversionsRequest build() { + public ListMarginConversionsRequest build() throws CoinbaseClientException { + validate(); return new ListMarginConversionsRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/financing/ListMarginConversionsResponse.java b/src/main/java/com/coinbase/prime/financing/ListMarginConversionsResponse.java index 8ddbbbe9..a92e0ef5 100644 --- a/src/main/java/com/coinbase/prime/financing/ListMarginConversionsResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListMarginConversionsResponse.java @@ -17,8 +17,13 @@ package com.coinbase.prime.financing; import com.coinbase.prime.model.Conversion; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Margin Conversions + */ public class ListMarginConversionsResponse { + @JsonProperty("conversions") private Conversion[] conversions; public ListMarginConversionsResponse() { diff --git a/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java new file mode 100644 index 00000000..3ed0a27a --- /dev/null +++ b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.financing; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Trade Finance Obligations + */ +public class ListTradeFinanceObligationsRequest { + @JsonProperty(required = true, value = "entity_id") + @JsonIgnore + private String entityId; + + public ListTradeFinanceObligationsRequest() { + } + + public ListTradeFinanceObligationsRequest(Builder builder) { + this.entityId = builder.entityId; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public static class Builder { + private String entityId; + + public Builder() { + } + + public Builder entityId(String entityId) { + this.entityId = entityId; + return this; + } + + public ListTradeFinanceObligationsRequest build() throws CoinbaseClientException { + validate(); + return new ListTradeFinanceObligationsRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java new file mode 100644 index 00000000..f03c7e98 --- /dev/null +++ b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.financing; + +import com.coinbase.prime.model.TfObligation; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * List Trade Finance Obligations + */ +public class ListTradeFinanceObligationsResponse { + @JsonProperty("obligations") + private TfObligation[] obligations; + + public ListTradeFinanceObligationsResponse() { + } + + public TfObligation[] getObligations() { + return obligations; + } + + public void setObligations(TfObligation[] obligations) { + this.obligations = obligations; + } + +} diff --git a/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java new file mode 100644 index 00000000..71c1e914 --- /dev/null +++ b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java @@ -0,0 +1,160 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.financing; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Update Funding Settings (Beta) + */ +public class UpdateFundingSettingsRequest { + @JsonProperty(required = true, value = "entity_id") + @JsonIgnore + private String entityId; + + @JsonProperty("designated_funding_portfolio_id") + private String designatedFundingPortfolioId; + + @JsonProperty("automatic_conversion_enabled") + private Boolean automaticConversionEnabled; + + @JsonProperty("automatic_loan_enabled") + private Boolean automaticLoanEnabled; + + @JsonProperty("automatic_excess_return_enabled") + private Boolean automaticExcessReturnEnabled; + + @JsonProperty("excess_funds_target_amount") + private String excessFundsTargetAmount; + + public UpdateFundingSettingsRequest() { + } + + public UpdateFundingSettingsRequest(Builder builder) { + this.entityId = builder.entityId; + this.designatedFundingPortfolioId = builder.designatedFundingPortfolioId; + this.automaticConversionEnabled = builder.automaticConversionEnabled; + this.automaticLoanEnabled = builder.automaticLoanEnabled; + this.automaticExcessReturnEnabled = builder.automaticExcessReturnEnabled; + this.excessFundsTargetAmount = builder.excessFundsTargetAmount; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public String getDesignatedFundingPortfolioId() { + return designatedFundingPortfolioId; + } + + public void setDesignatedFundingPortfolioId(String designatedFundingPortfolioId) { + this.designatedFundingPortfolioId = designatedFundingPortfolioId; + } + + public Boolean getAutomaticConversionEnabled() { + return automaticConversionEnabled; + } + + public void setAutomaticConversionEnabled(Boolean automaticConversionEnabled) { + this.automaticConversionEnabled = automaticConversionEnabled; + } + + public Boolean getAutomaticLoanEnabled() { + return automaticLoanEnabled; + } + + public void setAutomaticLoanEnabled(Boolean automaticLoanEnabled) { + this.automaticLoanEnabled = automaticLoanEnabled; + } + + public Boolean getAutomaticExcessReturnEnabled() { + return automaticExcessReturnEnabled; + } + + public void setAutomaticExcessReturnEnabled(Boolean automaticExcessReturnEnabled) { + this.automaticExcessReturnEnabled = automaticExcessReturnEnabled; + } + + public String getExcessFundsTargetAmount() { + return excessFundsTargetAmount; + } + + public void setExcessFundsTargetAmount(String excessFundsTargetAmount) { + this.excessFundsTargetAmount = excessFundsTargetAmount; + } + + public static class Builder { + private String entityId; + private String designatedFundingPortfolioId; + private Boolean automaticConversionEnabled; + private Boolean automaticLoanEnabled; + private Boolean automaticExcessReturnEnabled; + private String excessFundsTargetAmount; + + public Builder() { + } + + public Builder entityId(String entityId) { + this.entityId = entityId; + return this; + } + + public Builder designatedFundingPortfolioId(String designatedFundingPortfolioId) { + this.designatedFundingPortfolioId = designatedFundingPortfolioId; + return this; + } + + public Builder automaticConversionEnabled(Boolean automaticConversionEnabled) { + this.automaticConversionEnabled = automaticConversionEnabled; + return this; + } + + public Builder automaticLoanEnabled(Boolean automaticLoanEnabled) { + this.automaticLoanEnabled = automaticLoanEnabled; + return this; + } + + public Builder automaticExcessReturnEnabled(Boolean automaticExcessReturnEnabled) { + this.automaticExcessReturnEnabled = automaticExcessReturnEnabled; + return this; + } + + public Builder excessFundsTargetAmount(String excessFundsTargetAmount) { + this.excessFundsTargetAmount = excessFundsTargetAmount; + return this; + } + + public UpdateFundingSettingsRequest build() throws CoinbaseClientException { + validate(); + return new UpdateFundingSettingsRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java new file mode 100644 index 00000000..5e4bfa96 --- /dev/null +++ b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java @@ -0,0 +1,61 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.financing; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Update Funding Settings (Beta) + */ +public class UpdateFundingSettingsResponse { + @JsonProperty("activity_id") + private String activityId; + + @JsonProperty("activity_type") + private String activityType; + + @JsonProperty("num_approvals_remaining") + private Integer numApprovalsRemaining; + + public UpdateFundingSettingsResponse() { + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + public String getActivityType() { + return activityType; + } + + public void setActivityType(String activityType) { + this.activityType = activityType; + } + + public Integer getNumApprovalsRemaining() { + return numApprovalsRemaining; + } + + public void setNumApprovalsRemaining(Integer numApprovalsRemaining) { + this.numApprovalsRemaining = numApprovalsRemaining; + } + +} diff --git a/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepRequest.java b/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepRequest.java index 947885ca..78abe4e2 100644 --- a/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepRequest.java +++ b/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Cancel Entity Futures Sweep + */ public class CancelEntityFuturesSweepRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -54,13 +57,13 @@ public Builder entityId(String entityId) { } public CancelEntityFuturesSweepRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new CancelEntityFuturesSweepRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepResponse.java b/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepResponse.java index 2b4e9b61..7a4d9439 100644 --- a/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepResponse.java +++ b/src/main/java/com/coinbase/prime/futures/CancelEntityFuturesSweepResponse.java @@ -18,8 +18,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Cancel Entity Futures Sweep + */ public class CancelEntityFuturesSweepResponse { - private boolean success; + @JsonProperty("success") + private Boolean success; @JsonProperty("request_id") private String requestId; @@ -27,11 +31,11 @@ public class CancelEntityFuturesSweepResponse { public CancelEntityFuturesSweepResponse() { } - public boolean getSuccess() { + public Boolean getSuccess() { return success; } - public void setSuccess(boolean success) { + public void setSuccess(Boolean success) { this.success = success; } diff --git a/src/main/java/com/coinbase/prime/futures/FuturesService.java b/src/main/java/com/coinbase/prime/futures/FuturesService.java index 6faae0c0..f619f365 100644 --- a/src/main/java/com/coinbase/prime/futures/FuturesService.java +++ b/src/main/java/com/coinbase/prime/futures/FuturesService.java @@ -20,16 +20,26 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface FuturesService { - // Futures + /** Set Auto Sweep */ SetAutoSweepResponse setAutoSweep(SetAutoSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Entity FCM Balance */ GetEntityFcmBalanceResponse getEntityFcmBalance(GetEntityFcmBalanceRequest request) throws CoinbaseClientException, CoinbasePrimeException; - GetPositionsResponse getPositions(GetPositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListEntityFuturesSweepsResponse listEntityFuturesSweeps(ListEntityFuturesSweepsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - CancelEntityFuturesSweepResponse cancelEntityFuturesSweep(CancelEntityFuturesSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ScheduleEntityFuturesSweepResponse scheduleEntityFuturesSweep(ScheduleEntityFuturesSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get FCM Margin Call Details */ GetFcmMarginCallDetailsResponse getFcmMarginCallDetails(GetFcmMarginCallDetailsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Entity Positions */ + GetPositionsResponse getPositions(GetPositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get FCM Risk Limits */ GetFcmRiskLimitsResponse getFcmRiskLimits(GetFcmRiskLimitsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get FCM Settings */ GetFcmSettingsResponse getFcmSettings(GetFcmSettingsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Set FCM Settings */ SetFcmSettingsResponse setFcmSettings(SetFcmSettingsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Entity Futures Sweeps */ + ListEntityFuturesSweepsResponse listEntityFuturesSweeps(ListEntityFuturesSweepsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Schedule Entity Futures Sweep */ + ScheduleEntityFuturesSweepResponse scheduleEntityFuturesSweep(ScheduleEntityFuturesSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Cancel Entity Futures Sweep */ + CancelEntityFuturesSweepResponse cancelEntityFuturesSweep(CancelEntityFuturesSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get FCM Equity */ GetFcmEquityResponse getFcmEquity(GetFcmEquityRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/futures/FuturesServiceImpl.java b/src/main/java/com/coinbase/prime/futures/FuturesServiceImpl.java index 0acf83fa..991c3a25 100644 --- a/src/main/java/com/coinbase/prime/futures/FuturesServiceImpl.java +++ b/src/main/java/com/coinbase/prime/futures/FuturesServiceImpl.java @@ -49,85 +49,84 @@ public GetEntityFcmBalanceResponse getEntityFcmBalance(GetEntityFcmBalanceReques new TypeReference() {}); } - @Override - public ListEntityFuturesSweepsResponse listEntityFuturesSweeps(ListEntityFuturesSweepsRequest request) throws CoinbasePrimeException { + public GetFcmMarginCallDetailsResponse getFcmMarginCallDetails(GetFcmMarginCallDetailsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/futures/sweeps", request.getEntityId()), + String.format("/entities/%s/futures/margin_call_details", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public CancelEntityFuturesSweepResponse cancelEntityFuturesSweep(CancelEntityFuturesSweepRequest request) throws CoinbasePrimeException { + public GetPositionsResponse getPositions(GetPositionsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.DELETE, - String.format("/entities/%s/futures/sweeps", request.getEntityId()), + HttpMethod.GET, + String.format("/entities/%s/futures/positions", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ScheduleEntityFuturesSweepResponse scheduleEntityFuturesSweep(ScheduleEntityFuturesSweepRequest request) throws CoinbasePrimeException { + public GetFcmRiskLimitsResponse getFcmRiskLimits(GetFcmRiskLimitsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, - String.format("/entities/%s/futures/sweeps", request.getEntityId()), + HttpMethod.GET, + String.format("/entities/%s/futures/risk_limits", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetFcmMarginCallDetailsResponse getFcmMarginCallDetails(GetFcmMarginCallDetailsRequest request) throws CoinbasePrimeException { + public GetFcmSettingsResponse getFcmSettings(GetFcmSettingsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/futures/margin_call_details", request.getEntityId()), + String.format("/entities/%s/futures/settings", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetFcmRiskLimitsResponse getFcmRiskLimits(GetFcmRiskLimitsRequest request) throws CoinbasePrimeException { + public SetFcmSettingsResponse setFcmSettings(SetFcmSettingsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, - String.format("/entities/%s/futures/risk_limits", request.getEntityId()), + HttpMethod.POST, + String.format("/entities/%s/futures/settings", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetPositionsResponse getPositions(GetPositionsRequest request) throws CoinbasePrimeException { + public ListEntityFuturesSweepsResponse listEntityFuturesSweeps(ListEntityFuturesSweepsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/futures/positions", request.getEntityId()), + String.format("/entities/%s/futures/sweeps", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetFcmSettingsResponse getFcmSettings(GetFcmSettingsRequest request) throws CoinbasePrimeException { + public ScheduleEntityFuturesSweepResponse scheduleEntityFuturesSweep(ScheduleEntityFuturesSweepRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, - String.format("/entities/%s/futures/settings", request.getEntityId()), + HttpMethod.POST, + String.format("/entities/%s/futures/sweeps", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public SetFcmSettingsResponse setFcmSettings(SetFcmSettingsRequest request) throws CoinbasePrimeException { + public CancelEntityFuturesSweepResponse cancelEntityFuturesSweep(CancelEntityFuturesSweepRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, - String.format("/entities/%s/futures/settings", request.getEntityId()), + HttpMethod.DELETE, + String.format("/entities/%s/futures/sweeps", request.getEntityId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override @@ -139,4 +138,5 @@ public GetFcmEquityResponse getFcmEquity(GetFcmEquityRequest request) throws Coi List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceRequest.java b/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceRequest.java index e98ced5b..bb7193f7 100644 --- a/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Entity FCM Balance + */ public class GetEntityFcmBalanceRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -54,13 +57,13 @@ public Builder entityId(String entityId) { } public GetEntityFcmBalanceRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetEntityFcmBalanceRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceResponse.java b/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceResponse.java index 009eb616..afb2f32b 100644 --- a/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetEntityFcmBalanceResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Entity FCM Balance + */ public class GetEntityFcmBalanceResponse { @JsonProperty("portfolio_id") private String portfolioId; @@ -131,4 +134,5 @@ public String getCfmUnsettledAccruedFundingPnl() { public void setCfmUnsettledAccruedFundingPnl(String cfmUnsettledAccruedFundingPnl) { this.cfmUnsettledAccruedFundingPnl = cfmUnsettledAccruedFundingPnl; } + } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java b/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java index bc4621d9..1291bb8b 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,18 @@ package com.coinbase.prime.futures; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get FCM Equity + */ public class GetFcmEquityRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; public GetFcmEquityRequest() { @@ -50,8 +56,15 @@ public Builder entityId(String entityId) { return this; } - public GetFcmEquityRequest build() { + public GetFcmEquityRequest build() throws CoinbaseClientException { + validate(); return new GetFcmEquityRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java b/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java index 4abecae7..5a48e715 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,36 +18,23 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get FCM Equity + */ public class GetFcmEquityResponse { - @JsonProperty("available_to_sweep") - private String availableToSweep; - - @JsonProperty("current_excess_deficit") - private String currentExcessDeficit; - @JsonProperty("eod_account_equity") private String eodAccountEquity; @JsonProperty("eod_unrealized_pnl") private String eodUnrealizedPnl; - public GetFcmEquityResponse() { - } - - public String getAvailableToSweep() { - return availableToSweep; - } - - public void setAvailableToSweep(String availableToSweep) { - this.availableToSweep = availableToSweep; - } + @JsonProperty("current_excess_deficit") + private String currentExcessDeficit; - public String getCurrentExcessDeficit() { - return currentExcessDeficit; - } + @JsonProperty("available_to_sweep") + private String availableToSweep; - public void setCurrentExcessDeficit(String currentExcessDeficit) { - this.currentExcessDeficit = currentExcessDeficit; + public GetFcmEquityResponse() { } public String getEodAccountEquity() { @@ -65,4 +52,21 @@ public String getEodUnrealizedPnl() { public void setEodUnrealizedPnl(String eodUnrealizedPnl) { this.eodUnrealizedPnl = eodUnrealizedPnl; } + + public String getCurrentExcessDeficit() { + return currentExcessDeficit; + } + + public void setCurrentExcessDeficit(String currentExcessDeficit) { + this.currentExcessDeficit = currentExcessDeficit; + } + + public String getAvailableToSweep() { + return availableToSweep; + } + + public void setAvailableToSweep(String availableToSweep) { + this.availableToSweep = availableToSweep; + } + } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsRequest.java b/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsRequest.java index 7bb1f35f..e35e4514 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get FCM Margin Call Details + */ public class GetFcmMarginCallDetailsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -54,13 +57,13 @@ public Builder entityId(String entityId) { } public GetFcmMarginCallDetailsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetFcmMarginCallDetailsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsResponse.java b/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsResponse.java index 8bd3586c..5b43d3ea 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmMarginCallDetailsResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.FcmMarginCall; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get FCM Margin Call Details + */ public class GetFcmMarginCallDetailsResponse { @JsonProperty("margin_calls") private FcmMarginCall[] marginCalls; @@ -33,4 +36,5 @@ public FcmMarginCall[] getMarginCalls() { public void setMarginCalls(FcmMarginCall[] marginCalls) { this.marginCalls = marginCalls; } + } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsRequest.java b/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsRequest.java index 0f13ba38..d2f8ab62 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get FCM Risk Limits + */ public class GetFcmRiskLimitsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -54,13 +57,13 @@ public Builder entityId(String entityId) { } public GetFcmRiskLimitsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetFcmRiskLimitsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsResponse.java b/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsResponse.java index 9815b4c5..faab88ba 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmRiskLimitsResponse.java @@ -16,33 +16,37 @@ package com.coinbase.prime.futures; +import com.coinbase.prime.model.enums.FcmMarginHealthState; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get FCM Risk Limits + */ public class GetFcmRiskLimitsResponse { - /** Risk Limit set for a client */ @JsonProperty("cfm_risk_limit") private String cfmRiskLimit; - /** Limit utilization calculated based on total margin and PnLs */ @JsonProperty("cfm_risk_limit_utilization") private String cfmRiskLimitUtilization; - /** The total margin required for both positions and open orders */ @JsonProperty("cfm_total_margin") private String cfmTotalMargin; - /** Open Trade Equity accrued during the current trading session */ @JsonProperty("cfm_delta_ote") private String cfmDeltaOte; - /** Unsettled realized PNL for positions closed intraday */ @JsonProperty("cfm_unsettled_realized_pnl") private String cfmUnsettledRealizedPnl; - /** Unsettled accrued funding PNL from the last settlement */ @JsonProperty("cfm_unsettled_accrued_funding_pnl") private String cfmUnsettledAccruedFundingPnl; + @JsonProperty("margin_utilization_percent") + private String marginUtilizationPercent; + + @JsonProperty("margin_health_state") + private FcmMarginHealthState marginHealthState; + public GetFcmRiskLimitsResponse() { } @@ -93,4 +97,21 @@ public String getCfmUnsettledAccruedFundingPnl() { public void setCfmUnsettledAccruedFundingPnl(String cfmUnsettledAccruedFundingPnl) { this.cfmUnsettledAccruedFundingPnl = cfmUnsettledAccruedFundingPnl; } + + public String getMarginUtilizationPercent() { + return marginUtilizationPercent; + } + + public void setMarginUtilizationPercent(String marginUtilizationPercent) { + this.marginUtilizationPercent = marginUtilizationPercent; + } + + public FcmMarginHealthState getMarginHealthState() { + return marginHealthState; + } + + public void setMarginHealthState(FcmMarginHealthState marginHealthState) { + this.marginHealthState = marginHealthState; + } + } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmSettingsRequest.java b/src/main/java/com/coinbase/prime/futures/GetFcmSettingsRequest.java index 3512535c..931509cb 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmSettingsRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmSettingsRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.futures; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get FCM Settings + */ public class GetFcmSettingsRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; public GetFcmSettingsRequest() { @@ -50,8 +56,15 @@ public Builder entityId(String entityId) { return this; } - public GetFcmSettingsRequest build() { + public GetFcmSettingsRequest build() throws CoinbaseClientException { + validate(); return new GetFcmSettingsRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmSettingsResponse.java b/src/main/java/com/coinbase/prime/futures/GetFcmSettingsResponse.java index b617d096..b9d366e5 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmSettingsResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmSettingsResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get FCM Settings + */ public class GetFcmSettingsResponse { @JsonProperty("target_derivatives_excess") private String targetDerivativesExcess; @@ -32,4 +35,5 @@ public String getTargetDerivativesExcess() { public void setTargetDerivativesExcess(String targetDerivativesExcess) { this.targetDerivativesExcess = targetDerivativesExcess; } + } diff --git a/src/main/java/com/coinbase/prime/futures/GetPositionsRequest.java b/src/main/java/com/coinbase/prime/futures/GetPositionsRequest.java index 97504edb..5a53de79 100644 --- a/src/main/java/com/coinbase/prime/futures/GetPositionsRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetPositionsRequest.java @@ -23,12 +23,13 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * Retrieve all active FCM positions for a given entity. + * Get Entity Positions */ public class GetPositionsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; + @JsonProperty("product_id") private String productId; @@ -74,14 +75,14 @@ public Builder productId(String productId) { } public GetPositionsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetPositionsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/futures/GetPositionsResponse.java b/src/main/java/com/coinbase/prime/futures/GetPositionsResponse.java index e3e21a33..2f11fed7 100644 --- a/src/main/java/com/coinbase/prime/futures/GetPositionsResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetPositionsResponse.java @@ -16,14 +16,15 @@ package com.coinbase.prime.futures; -import com.coinbase.prime.model.Position; +import com.coinbase.prime.model.FcmPosition; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response containing positions for an entity. + * Get Entity Positions */ public class GetPositionsResponse { - private Position[] positions; + @JsonProperty("positions") + private FcmPosition[] positions; @JsonProperty("clearing_account_id") private String clearingAccountId; @@ -31,11 +32,11 @@ public class GetPositionsResponse { public GetPositionsResponse() { } - public Position[] getPositions() { + public FcmPosition[] getPositions() { return positions; } - public void setPositions(Position[] positions) { + public void setPositions(FcmPosition[] positions) { this.positions = positions; } diff --git a/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsRequest.java b/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsRequest.java index c305eec2..16a020d6 100644 --- a/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsRequest.java +++ b/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Entity Futures Sweeps + */ public class ListEntityFuturesSweepsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -40,10 +43,11 @@ public String getEntityId() { public void setEntityId(String entityId) { this.entityId = entityId; - } + } public static class Builder { private String entityId; + public Builder() { } @@ -53,13 +57,13 @@ public Builder entityId(String entityId) { } public ListEntityFuturesSweepsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListEntityFuturesSweepsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsResponse.java b/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsResponse.java index 4e6e1a0c..5dd7654f 100644 --- a/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsResponse.java +++ b/src/main/java/com/coinbase/prime/futures/ListEntityFuturesSweepsResponse.java @@ -19,11 +19,15 @@ import com.coinbase.prime.model.FuturesSweep; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Entity Futures Sweeps + */ public class ListEntityFuturesSweepsResponse { + @JsonProperty("sweeps") private FuturesSweep[] sweeps; @JsonProperty("auto_sweep") - private boolean autoSweep; + private Boolean autoSweep; public ListEntityFuturesSweepsResponse() { } @@ -36,11 +40,12 @@ public void setSweeps(FuturesSweep[] sweeps) { this.sweeps = sweeps; } - public boolean getAutoSweep() { + public Boolean getAutoSweep() { return autoSweep; } - public void setAutoSweep(boolean autoSweep) { + public void setAutoSweep(Boolean autoSweep) { this.autoSweep = autoSweep; } + } diff --git a/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepRequest.java b/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepRequest.java index 3ed2948a..3dcd30bb 100644 --- a/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepRequest.java +++ b/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepRequest.java @@ -22,14 +22,18 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Schedule Entity Futures Sweep + */ public class ScheduleEntityFuturesSweepRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; + @JsonProperty("amount") private String amount; - @JsonProperty(required = true) + @JsonProperty("currency") private String currency; public ScheduleEntityFuturesSweepRequest() { @@ -78,17 +82,24 @@ public Builder entityId(String entityId) { return this; } + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + public Builder currency(String currency) { + this.currency = currency; + return this; + } + public ScheduleEntityFuturesSweepRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ScheduleEntityFuturesSweepRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); - } - if (isNullOrEmpty(this.currency)) { - throw new CoinbaseClientException("Currency is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepResponse.java b/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepResponse.java index 743a33bd..700efea8 100644 --- a/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepResponse.java +++ b/src/main/java/com/coinbase/prime/futures/ScheduleEntityFuturesSweepResponse.java @@ -18,8 +18,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Schedule Entity Futures Sweep + */ public class ScheduleEntityFuturesSweepResponse { - private boolean success; + @JsonProperty("success") + private Boolean success; @JsonProperty("request_id") private String requestId; @@ -27,11 +31,11 @@ public class ScheduleEntityFuturesSweepResponse { public ScheduleEntityFuturesSweepResponse() { } - public boolean getSuccess() { + public Boolean getSuccess() { return success; } - public void setSuccess(boolean success) { + public void setSuccess(Boolean success) { this.success = success; } diff --git a/src/main/java/com/coinbase/prime/futures/SetAutoSweepRequest.java b/src/main/java/com/coinbase/prime/futures/SetAutoSweepRequest.java index 4078afe9..a1986f9d 100644 --- a/src/main/java/com/coinbase/prime/futures/SetAutoSweepRequest.java +++ b/src/main/java/com/coinbase/prime/futures/SetAutoSweepRequest.java @@ -22,13 +22,16 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Set Auto Sweep + */ public class SetAutoSweepRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; @JsonProperty("auto_sweep") - private boolean autoSweep; + private Boolean autoSweep; public SetAutoSweepRequest() { } @@ -46,17 +49,17 @@ public void setEntityId(String entityId) { this.entityId = entityId; } - public boolean getAutoSweep() { + public Boolean getAutoSweep() { return autoSweep; } - public void setAutoSweep(boolean autoSweep) { + public void setAutoSweep(Boolean autoSweep) { this.autoSweep = autoSweep; } public static class Builder { private String entityId; - private boolean autoSweep; + private Boolean autoSweep; public Builder() { } @@ -66,19 +69,19 @@ public Builder entityId(String entityId) { return this; } - public Builder autoSweep(boolean autoSweep) { + public Builder autoSweep(Boolean autoSweep) { this.autoSweep = autoSweep; return this; } public SetAutoSweepRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new SetAutoSweepRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("Entity ID is required"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/futures/SetAutoSweepResponse.java b/src/main/java/com/coinbase/prime/futures/SetAutoSweepResponse.java index acfdfa68..7b00e935 100644 --- a/src/main/java/com/coinbase/prime/futures/SetAutoSweepResponse.java +++ b/src/main/java/com/coinbase/prime/futures/SetAutoSweepResponse.java @@ -16,17 +16,23 @@ package com.coinbase.prime.futures; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Set Auto Sweep + */ public class SetAutoSweepResponse { - private boolean success; + @JsonProperty("success") + private Boolean success; public SetAutoSweepResponse() { } - public boolean getSuccess() { + public Boolean getSuccess() { return success; } - public void setSuccess(boolean success) { + public void setSuccess(Boolean success) { this.success = success; } diff --git a/src/main/java/com/coinbase/prime/futures/SetFcmSettingsRequest.java b/src/main/java/com/coinbase/prime/futures/SetFcmSettingsRequest.java index 96bc826d..ac69098a 100644 --- a/src/main/java/com/coinbase/prime/futures/SetFcmSettingsRequest.java +++ b/src/main/java/com/coinbase/prime/futures/SetFcmSettingsRequest.java @@ -16,12 +16,18 @@ package com.coinbase.prime.futures; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Set FCM Settings + */ public class SetFcmSettingsRequest { - @JsonIgnore @JsonProperty(required = true, value = "entity_id") + @JsonIgnore private String entityId; @JsonProperty("target_derivatives_excess") @@ -68,8 +74,15 @@ public Builder targetDerivativesExcess(String targetDerivativesExcess) { return this; } - public SetFcmSettingsRequest build() { + public SetFcmSettingsRequest build() throws CoinbaseClientException { + validate(); return new SetFcmSettingsRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/futures/SetFcmSettingsResponse.java b/src/main/java/com/coinbase/prime/futures/SetFcmSettingsResponse.java index b15cca75..69df0ba4 100644 --- a/src/main/java/com/coinbase/prime/futures/SetFcmSettingsResponse.java +++ b/src/main/java/com/coinbase/prime/futures/SetFcmSettingsResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Set FCM Settings + */ public class SetFcmSettingsResponse { @JsonProperty("success") private Boolean success; @@ -32,4 +35,5 @@ public Boolean getSuccess() { public void setSuccess(Boolean success) { this.success = success; } + } diff --git a/src/main/java/com/coinbase/prime/invoice/InvoiceService.java b/src/main/java/com/coinbase/prime/invoice/InvoiceService.java index eb68c229..f721655c 100644 --- a/src/main/java/com/coinbase/prime/invoice/InvoiceService.java +++ b/src/main/java/com/coinbase/prime/invoice/InvoiceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface InvoiceService { - // Invoice + /** List Invoices */ ListInvoicesResponse listInvoices(ListInvoicesRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java b/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java index 1644cb83..b7a53829 100644 --- a/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java +++ b/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,4 +38,5 @@ public ListInvoicesResponse listInvoices(ListInvoicesRequest request) throws Coi List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/invoice/ListInvoicesRequest.java b/src/main/java/com/coinbase/prime/invoice/ListInvoicesRequest.java index 48364558..294e76c7 100644 --- a/src/main/java/com/coinbase/prime/invoice/ListInvoicesRequest.java +++ b/src/main/java/com/coinbase/prime/invoice/ListInvoicesRequest.java @@ -18,23 +18,31 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.enums.InvoiceState; import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Invoices + */ public class ListInvoicesRequest extends PrimeListRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; + + @JsonProperty("states") private InvoiceState[] states; - @JsonProperty("billing_month") - private Integer billingMonth; + @JsonProperty("billing_year") private Integer billingYear; + @JsonProperty("billing_month") + private Integer billingMonth; + public ListInvoicesRequest() { } @@ -42,8 +50,8 @@ public ListInvoicesRequest(Builder builder) { super(builder.cursor, builder.sortDirection, builder.limit); this.entityId = builder.entityId; this.states = builder.states; - this.billingMonth = builder.billingMonth; this.billingYear = builder.billingYear; + this.billingMonth = builder.billingMonth; } public String getEntityId() { @@ -62,14 +70,6 @@ public void setStates(InvoiceState[] states) { this.states = states; } - public Integer getBillingMonth() { - return billingMonth; - } - - public void setBillingMonth(Integer billingMonth) { - this.billingMonth = billingMonth; - } - public Integer getBillingYear() { return billingYear; } @@ -78,26 +78,33 @@ public void setBillingYear(Integer billingYear) { this.billingYear = billingYear; } + public Integer getBillingMonth() { + return billingMonth; + } + + public void setBillingMonth(Integer billingMonth) { + this.billingMonth = billingMonth; + } + public static class Builder { - private final String entityId; + private String entityId; private InvoiceState[] states; - private Integer billingMonth; private Integer billingYear; + private Integer billingMonth; private String cursor; - private Integer limit; private SortDirection sortDirection; + private Integer limit; - public Builder(String entityId) { - this.entityId = entityId; + public Builder() { } - public Builder states(InvoiceState[] states) { - this.states = states; + public Builder entityId(String entityId) { + this.entityId = entityId; return this; } - public Builder billingMonth(Integer billingMonth) { - this.billingMonth = billingMonth; + public Builder states(InvoiceState[] states) { + this.states = states; return this; } @@ -106,8 +113,8 @@ public Builder billingYear(Integer billingYear) { return this; } - public Builder cursor(String cursor) { - this.cursor = cursor; + public Builder billingMonth(Integer billingMonth) { + this.billingMonth = billingMonth; return this; } @@ -116,13 +123,14 @@ public Builder limit(Integer limit) { return this; } - public Builder sortDirection(SortDirection sortDirection) { - this.sortDirection = sortDirection; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListInvoicesRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListInvoicesRequest(this); } diff --git a/src/main/java/com/coinbase/prime/invoice/ListInvoicesResponse.java b/src/main/java/com/coinbase/prime/invoice/ListInvoicesResponse.java index 24283ab3..014f2fc4 100644 --- a/src/main/java/com/coinbase/prime/invoice/ListInvoicesResponse.java +++ b/src/main/java/com/coinbase/prime/invoice/ListInvoicesResponse.java @@ -17,8 +17,13 @@ package com.coinbase.prime.invoice; import com.coinbase.prime.model.Invoice; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Invoices + */ public class ListInvoicesResponse { + @JsonProperty("invoices") private Invoice[] invoices; public ListInvoicesResponse() { diff --git a/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java b/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java index b5dfd6f2..c911675b 100644 --- a/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java +++ b/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java b/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java index 4f1ad4f5..51e8a5dd 100644 --- a/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java +++ b/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java b/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java index 4479727c..2d1d394f 100644 --- a/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java +++ b/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java b/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java index 08257da5..2f54dc6e 100644 --- a/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java +++ b/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java b/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java index 1e15f799..4cfa62bb 100644 --- a/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java +++ b/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java b/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java index 0e7f0ef1..1621024e 100644 --- a/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java +++ b/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FundMovement.java b/src/main/java/com/coinbase/prime/model/FundMovement.java index 39de3afd..0157ea1b 100644 --- a/src/main/java/com/coinbase/prime/model/FundMovement.java +++ b/src/main/java/com/coinbase/prime/model/FundMovement.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FutureProductDetails.java b/src/main/java/com/coinbase/prime/model/FutureProductDetails.java index 7ccfc60d..202b3fdd 100644 --- a/src/main/java/com/coinbase/prime/model/FutureProductDetails.java +++ b/src/main/java/com/coinbase/prime/model/FutureProductDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java b/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java index ead345a0..310577a5 100644 --- a/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java +++ b/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java b/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java index 713ee0c8..8cabeb4e 100644 --- a/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java +++ b/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/StakingStatus.java b/src/main/java/com/coinbase/prime/model/StakingStatus.java index da906c63..f944c64d 100644 --- a/src/main/java/com/coinbase/prime/model/StakingStatus.java +++ b/src/main/java/com/coinbase/prime/model/StakingStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/TravelRuleData.java b/src/main/java/com/coinbase/prime/model/TravelRuleData.java index 29ffceef..4718874c 100644 --- a/src/main/java/com/coinbase/prime/model/TravelRuleData.java +++ b/src/main/java/com/coinbase/prime/model/TravelRuleData.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java b/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java index 2a7fd881..5107ca52 100644 --- a/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java +++ b/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java b/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java index 8c2fc0c7..2cc3254a 100644 --- a/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java +++ b/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java b/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java index 5e9d9b1a..eadcd9b6 100644 --- a/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java +++ b/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java index 161e54af..9bf2adc5 100644 --- a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java +++ b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java index a0fbf47b..22660dd0 100644 --- a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java +++ b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java b/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java index 1eaf6cc1..c8166c83 100644 --- a/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java +++ b/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java b/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java index 6866fd8b..3a980ca0 100644 --- a/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java +++ b/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java b/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java index 7cb75093..5834673c 100644 --- a/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java +++ b/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java index 33d2d64d..9c8f2733 100644 --- a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java +++ b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java index ec40172e..8d547f86 100644 --- a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java +++ b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/ProductType.java b/src/main/java/com/coinbase/prime/model/enums/ProductType.java index b38f342c..b89fd0a8 100644 --- a/src/main/java/com/coinbase/prime/model/enums/ProductType.java +++ b/src/main/java/com/coinbase/prime/model/enums/ProductType.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java b/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java index bc6c7ec5..318afec4 100644 --- a/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java +++ b/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java b/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java index a4d1f872..a3301021 100644 --- a/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java +++ b/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/StakeType.java b/src/main/java/com/coinbase/prime/model/enums/StakeType.java index 5cf323e6..cc3b6c13 100644 --- a/src/main/java/com/coinbase/prime/model/enums/StakeType.java +++ b/src/main/java/com/coinbase/prime/model/enums/StakeType.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java b/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java index e185f4ac..3ded3fa7 100644 --- a/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java +++ b/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryRequest.java b/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryRequest.java index c39b3cd2..5a4e0ed2 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryRequest.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryRequest.java @@ -16,10 +16,16 @@ package com.coinbase.prime.onchainaddressbook; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.AddressGroup; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Create Onchain Address Book Entry + */ public class CreateOnchainAddressBookEntryRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -69,8 +75,15 @@ public Builder addressGroup(AddressGroup addressGroup) { return this; } - public CreateOnchainAddressBookEntryRequest build() { + public CreateOnchainAddressBookEntryRequest build() throws CoinbaseClientException { + validate(); return new CreateOnchainAddressBookEntryRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryResponse.java b/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryResponse.java index 93a7aa1e..20d638ae 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryResponse.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/CreateOnchainAddressBookEntryResponse.java @@ -19,12 +19,15 @@ import com.coinbase.prime.model.enums.CustodyActivityType; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Create Onchain Address Book Entry + */ public class CreateOnchainAddressBookEntryResponse { @JsonProperty("activity_type") private CustodyActivityType activityType; @JsonProperty("num_approvals_remaining") - private int numApprovalsRemaining; + private Integer numApprovalsRemaining; @JsonProperty("activity_id") private String activityId; @@ -40,11 +43,11 @@ public void setActivityType(CustodyActivityType activityType) { this.activityType = activityType; } - public int getNumApprovalsRemaining() { + public Integer getNumApprovalsRemaining() { return numApprovalsRemaining; } - public void setNumApprovalsRemaining(int numApprovalsRemaining) { + public void setNumApprovalsRemaining(Integer numApprovalsRemaining) { this.numApprovalsRemaining = numApprovalsRemaining; } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupRequest.java b/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupRequest.java index e3aab531..eb5f5bf6 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupRequest.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupRequest.java @@ -16,13 +16,20 @@ package com.coinbase.prime.onchainaddressbook; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Delete Onchain Address Group + */ public class DeleteOnchainAddressGroupRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "address_group_id") @JsonIgnore private String addressGroupId; @@ -68,8 +75,18 @@ public Builder addressGroupId(String addressGroupId) { return this; } - public DeleteOnchainAddressGroupRequest build() { + public DeleteOnchainAddressGroupRequest build() throws CoinbaseClientException { + validate(); return new DeleteOnchainAddressGroupRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.addressGroupId)) { + throw new CoinbaseClientException("AddressGroupId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupResponse.java b/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupResponse.java index 712a3a9f..62c3b17b 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupResponse.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/DeleteOnchainAddressGroupResponse.java @@ -19,12 +19,15 @@ import com.coinbase.prime.model.enums.CustodyActivityType; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Delete Onchain Address Group + */ public class DeleteOnchainAddressGroupResponse { @JsonProperty("activity_type") private CustodyActivityType activityType; @JsonProperty("num_approvals_remaining") - private int numApprovalsRemaining; + private Integer numApprovalsRemaining; @JsonProperty("activity_id") private String activityId; @@ -40,11 +43,11 @@ public void setActivityType(CustodyActivityType activityType) { this.activityType = activityType; } - public int getNumApprovalsRemaining() { + public Integer getNumApprovalsRemaining() { return numApprovalsRemaining; } - public void setNumApprovalsRemaining(int numApprovalsRemaining) { + public void setNumApprovalsRemaining(Integer numApprovalsRemaining) { this.numApprovalsRemaining = numApprovalsRemaining; } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsRequest.java b/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsRequest.java index 1eee7468..20c716d6 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsRequest.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsRequest.java @@ -16,22 +16,24 @@ package com.coinbase.prime.onchainaddressbook; -import com.coinbase.prime.common.PrimeListRequest; -import com.coinbase.prime.model.enums.SortDirection; import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * Request for listing onchain address groups for a portfolio. + * List Onchain Address Groups */ -public class ListOnchainAddressGroupsRequest extends PrimeListRequest { +public class ListOnchainAddressGroupsRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; public ListOnchainAddressGroupsRequest() { } - private ListOnchainAddressGroupsRequest(Builder builder) { - super(builder.cursor, builder.sortDirection, builder.limit); + public ListOnchainAddressGroupsRequest(Builder builder) { this.portfolioId = builder.portfolioId; } @@ -43,42 +45,26 @@ public void setPortfolioId(String portfolioId) { this.portfolioId = portfolioId; } - public String getPath() { - return String.format("/v1/portfolios/%s/onchain_address_groups", this.portfolioId); - } - public static class Builder { private String portfolioId; - private String cursor; - private SortDirection sortDirection; - private Integer limit; - public Builder portfolioId(String portfolioId) { - this.portfolioId = portfolioId; - return this; + public Builder() { } - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - public Builder sortDirection(SortDirection sortDirection) { - this.sortDirection = sortDirection; + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; return this; } - public Builder limit(Integer limit) { - this.limit = limit; - return this; + public ListOnchainAddressGroupsRequest build() throws CoinbaseClientException { + validate(); + return new ListOnchainAddressGroupsRequest(this); } - public ListOnchainAddressGroupsRequest build() { + private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } - return new ListOnchainAddressGroupsRequest(this); } } } - diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsResponse.java b/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsResponse.java index 104391e1..d508a270 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsResponse.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/ListOnchainAddressGroupsResponse.java @@ -19,24 +19,22 @@ import com.coinbase.prime.model.AddressGroup; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - /** - * Response for listing onchain address groups. + * List Onchain Address Groups */ public class ListOnchainAddressGroupsResponse { @JsonProperty("address_groups") - private List addressGroups; + private AddressGroup[] addressGroups; public ListOnchainAddressGroupsResponse() { } - public List getAddressGroups() { + public AddressGroup[] getAddressGroups() { return addressGroups; } - public void setAddressGroups(List addressGroups) { + public void setAddressGroups(AddressGroup[] addressGroups) { this.addressGroups = addressGroups; } -} +} diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java b/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java index fa0deeaf..9fef83cb 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java @@ -20,8 +20,12 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface OnchainAddressBookService { + /** Update Onchain Address Book Entry */ + UpdateOnchainAddressBookEntryResponse updateOnchainAddressBookEntry(UpdateOnchainAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Onchain Address Book Entry */ CreateOnchainAddressBookEntryResponse createOnchainAddressBookEntry(CreateOnchainAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Delete Onchain Address Group */ DeleteOnchainAddressGroupResponse deleteOnchainAddressGroup(DeleteOnchainAddressGroupRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Onchain Address Groups */ ListOnchainAddressGroupsResponse listOnchainAddressGroups(ListOnchainAddressGroupsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - UpdateOnchainAddressBookEntryResponse updateOnchainAddressBookEntry(UpdateOnchainAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceImpl.java b/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceImpl.java index a78647cd..e946e374 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceImpl.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceImpl.java @@ -19,6 +19,7 @@ import com.coinbase.core.common.HttpMethod; import com.coinbase.core.service.CoinbaseServiceImpl; import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.errors.CoinbasePrimeException; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; @@ -28,25 +29,28 @@ public OnchainAddressBookServiceImpl(CoinbasePrimeClient client) { super(client); } - public CreateOnchainAddressBookEntryResponse createOnchainAddressBookEntry(CreateOnchainAddressBookEntryRequest request) { + @Override + public UpdateOnchainAddressBookEntryResponse updateOnchainAddressBookEntry(UpdateOnchainAddressBookEntryRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, + HttpMethod.PUT, String.format("/portfolios/%s/onchain_address_group", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } - public UpdateOnchainAddressBookEntryResponse updateOnchainAddressBookEntry(UpdateOnchainAddressBookEntryRequest request) { + @Override + public CreateOnchainAddressBookEntryResponse createOnchainAddressBookEntry(CreateOnchainAddressBookEntryRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.PUT, + HttpMethod.POST, String.format("/portfolios/%s/onchain_address_group", request.getPortfolioId()), request, - List.of(200), - new TypeReference() {}); + List.of(201, 200), + new TypeReference() {}); } - public DeleteOnchainAddressGroupResponse deleteOnchainAddressGroup(DeleteOnchainAddressGroupRequest request) { + @Override + public DeleteOnchainAddressGroupResponse deleteOnchainAddressGroup(DeleteOnchainAddressGroupRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.DELETE, String.format("/portfolios/%s/onchain_address_group/%s", request.getPortfolioId(), request.getAddressGroupId()), @@ -55,7 +59,8 @@ public DeleteOnchainAddressGroupResponse deleteOnchainAddressGroup(DeleteOnchain new TypeReference() {}); } - public ListOnchainAddressGroupsResponse listOnchainAddressGroups(ListOnchainAddressGroupsRequest request) { + @Override + public ListOnchainAddressGroupsResponse listOnchainAddressGroups(ListOnchainAddressGroupsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, String.format("/portfolios/%s/onchain_address_groups", request.getPortfolioId()), @@ -63,4 +68,5 @@ public ListOnchainAddressGroupsResponse listOnchainAddressGroups(ListOnchainAddr List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryRequest.java b/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryRequest.java index 15899eb7..baba8e17 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryRequest.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryRequest.java @@ -16,10 +16,16 @@ package com.coinbase.prime.onchainaddressbook; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.AddressGroup; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Update Onchain Address Book Entry + */ public class UpdateOnchainAddressBookEntryRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -44,11 +50,11 @@ public void setPortfolioId(String portfolioId) { this.portfolioId = portfolioId; } - public AddressGroup getAddressGroupId() { + public AddressGroup getAddressGroup() { return addressGroup; } - public void setAddressGroupId(AddressGroup addressGroup) { + public void setAddressGroup(AddressGroup addressGroup) { this.addressGroup = addressGroup; } @@ -69,8 +75,15 @@ public Builder addressGroup(AddressGroup addressGroup) { return this; } - public UpdateOnchainAddressBookEntryRequest build() { + public UpdateOnchainAddressBookEntryRequest build() throws CoinbaseClientException { + validate(); return new UpdateOnchainAddressBookEntryRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryResponse.java b/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryResponse.java index 87cac7b1..75fe2dc0 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryResponse.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/UpdateOnchainAddressBookEntryResponse.java @@ -19,12 +19,15 @@ import com.coinbase.prime.model.enums.CustodyActivityType; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Update Onchain Address Book Entry + */ public class UpdateOnchainAddressBookEntryResponse { @JsonProperty("activity_type") private CustodyActivityType activityType; @JsonProperty("num_approvals_remaining") - private int numApprovalsRemaining; + private Integer numApprovalsRemaining; @JsonProperty("activity_id") private String activityId; @@ -40,11 +43,11 @@ public void setActivityType(CustodyActivityType activityType) { this.activityType = activityType; } - public int getNumApprovalsRemaining() { + public Integer getNumApprovalsRemaining() { return numApprovalsRemaining; } - public void setNumApprovalsRemaining(int numApprovalsRemaining) { + public void setNumApprovalsRemaining(Integer numApprovalsRemaining) { this.numApprovalsRemaining = numApprovalsRemaining; } diff --git a/src/main/java/com/coinbase/prime/orders/AcceptQuoteRequest.java b/src/main/java/com/coinbase/prime/orders/AcceptQuoteRequest.java index 0b6a5005..728d7f72 100644 --- a/src/main/java/com/coinbase/prime/orders/AcceptQuoteRequest.java +++ b/src/main/java/com/coinbase/prime/orders/AcceptQuoteRequest.java @@ -23,126 +23,139 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Accept Quote + */ public class AcceptQuoteRequest { - @JsonProperty(required = true, value = "portfolio_id") - @JsonIgnore - private String portfolioId; - @JsonProperty(required = true, value = "product_id") - private String productId; - @JsonProperty(required = true, value = "side") - private OrderSide side; - @JsonProperty(required = true, value = "client_order_id") - private String clientOrderId; - @JsonProperty(required = true, value = "quote_id") - private String quoteId; - - public AcceptQuoteRequest() { - } - - public AcceptQuoteRequest(Builder builder) { - this.portfolioId = builder.portfolioId; - this.productId = builder.productId; - this.side = builder.side; - this.clientOrderId = builder.clientOrderId; - this.quoteId = builder.quoteId; - } - - public String getPortfolioId() { - return portfolioId; - } - - public void setPortfolioId(String portfolioId) { - this.portfolioId = portfolioId; - } - - public String getProductId() { - return productId; - } - - public void setProductId(String productId) { - this.productId = productId; - } - - public OrderSide getSide() { - return side; - } - - public void setSide(OrderSide side) { - this.side = side; - } - - public String getClientOrderId() { - return clientOrderId; - } - - public void setClientOrderId(String clientOrderId) { - this.clientOrderId = clientOrderId; - } - - public String getQuoteId() { - return quoteId; - } - - public void setQuoteId(String quoteId) { - this.quoteId = quoteId; - } - - public static class Builder { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; + + @JsonProperty("product_id") private String productId; + + @JsonProperty("side") private OrderSide side; + + @JsonProperty("client_order_id") private String clientOrderId; + + @JsonProperty("quote_id") private String quoteId; - public Builder() { + @JsonProperty("settl_currency") + private String settlCurrency; + + public AcceptQuoteRequest() { + } + + public AcceptQuoteRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.productId = builder.productId; + this.side = builder.side; + this.clientOrderId = builder.clientOrderId; + this.quoteId = builder.quoteId; + this.settlCurrency = builder.settlCurrency; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public OrderSide getSide() { + return side; + } + + public void setSide(OrderSide side) { + this.side = side; } - public Builder portfolioId(String portfolioId) { - this.portfolioId = portfolioId; - return this; + public String getClientOrderId() { + return clientOrderId; } - public Builder productId(String productId) { - this.productId = productId; - return this; + public void setClientOrderId(String clientOrderId) { + this.clientOrderId = clientOrderId; } - public Builder side(OrderSide side) { - this.side = side; - return this; + public String getQuoteId() { + return quoteId; } - public Builder clientOrderId(String clientOrderId) { - this.clientOrderId = clientOrderId; - return this; + public void setQuoteId(String quoteId) { + this.quoteId = quoteId; } - public Builder quoteId(String quoteId) { - this.quoteId = quoteId; - return this; + public String getSettlCurrency() { + return settlCurrency; } - public AcceptQuoteRequest build() throws CoinbaseClientException { - this.validate(); - return new AcceptQuoteRequest(this); + public void setSettlCurrency(String settlCurrency) { + this.settlCurrency = settlCurrency; } - private void validate() throws CoinbaseClientException { - if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId is required"); - } - if (isNullOrEmpty(this.productId)) { - throw new CoinbaseClientException("ProductId is required"); - } - if (this.side == null) { - throw new CoinbaseClientException("Side is required"); - } - if (isNullOrEmpty(this.clientOrderId)) { - throw new CoinbaseClientException("ClientOrderId is required"); - } - if (isNullOrEmpty(this.quoteId)) { - throw new CoinbaseClientException("QuoteId is required"); - } + public static class Builder { + private String portfolioId; + private String productId; + private OrderSide side; + private String clientOrderId; + private String quoteId; + private String settlCurrency; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder productId(String productId) { + this.productId = productId; + return this; + } + + public Builder side(OrderSide side) { + this.side = side; + return this; + } + + public Builder clientOrderId(String clientOrderId) { + this.clientOrderId = clientOrderId; + return this; + } + + public Builder quoteId(String quoteId) { + this.quoteId = quoteId; + return this; + } + + public Builder settlCurrency(String settlCurrency) { + this.settlCurrency = settlCurrency; + return this; + } + + public AcceptQuoteRequest build() throws CoinbaseClientException { + validate(); + return new AcceptQuoteRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } - } } diff --git a/src/main/java/com/coinbase/prime/orders/AcceptQuoteResponse.java b/src/main/java/com/coinbase/prime/orders/AcceptQuoteResponse.java index 59a9f0d8..80aea1b3 100644 --- a/src/main/java/com/coinbase/prime/orders/AcceptQuoteResponse.java +++ b/src/main/java/com/coinbase/prime/orders/AcceptQuoteResponse.java @@ -19,24 +19,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for accepting a quote and creating an order. - * - * Accepts the quote received by the quote request and creates an order with the provided quote ID. - * Always required: portfolio_id, product_id, side, quote_id, client_quote_id. + * Accept Quote */ public class AcceptQuoteResponse { - /** The order ID generated by Coinbase */ - @JsonProperty("order_id") - private String orderId; + @JsonProperty("order_id") + private String orderId; - public AcceptQuoteResponse() { - } + public AcceptQuoteResponse() { + } - public String getOrderId() { - return orderId; - } + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } - public void setOrderId(String orderId) { - this.orderId = orderId; - } } diff --git a/src/main/java/com/coinbase/prime/orders/CancelOrderRequest.java b/src/main/java/com/coinbase/prime/orders/CancelOrderRequest.java index 84f5a3fa..8249112d 100644 --- a/src/main/java/com/coinbase/prime/orders/CancelOrderRequest.java +++ b/src/main/java/com/coinbase/prime/orders/CancelOrderRequest.java @@ -22,11 +22,15 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Cancel Order + */ public class CancelOrderRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - @JsonProperty("order_id") + + @JsonProperty(required = true, value = "order_id") @JsonIgnore private String orderId; @@ -71,7 +75,7 @@ public Builder orderId(String orderId) { return this; } - public CancelOrderRequest build() { + public CancelOrderRequest build() throws CoinbaseClientException { validate(); return new CancelOrderRequest(this); } @@ -80,7 +84,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.orderId)) { throw new CoinbaseClientException("OrderId is required"); } diff --git a/src/main/java/com/coinbase/prime/orders/CancelOrderResponse.java b/src/main/java/com/coinbase/prime/orders/CancelOrderResponse.java index eee5f407..1b5eb5a3 100644 --- a/src/main/java/com/coinbase/prime/orders/CancelOrderResponse.java +++ b/src/main/java/com/coinbase/prime/orders/CancelOrderResponse.java @@ -19,13 +19,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for canceling an order. - * - * Cancel an order. (Filled orders cannot be canceled.) + * Cancel Order */ public class CancelOrderResponse { - /** The ID of the canceled order */ - @JsonProperty("order_id") + @JsonProperty("id") private String id; public CancelOrderResponse() { diff --git a/src/main/java/com/coinbase/prime/orders/CreateOrderRequest.java b/src/main/java/com/coinbase/prime/orders/CreateOrderRequest.java index 118c44ec..b4195df7 100644 --- a/src/main/java/com/coinbase/prime/orders/CreateOrderRequest.java +++ b/src/main/java/com/coinbase/prime/orders/CreateOrderRequest.java @@ -19,55 +19,81 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.enums.OrderSide; import com.coinbase.prime.model.enums.OrderType; +import com.coinbase.prime.model.enums.PegOffsetType; import com.coinbase.prime.model.enums.TimeInForceType; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.UUID; - import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Order + */ public class CreateOrderRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("product_id") private String productId; + + @JsonProperty("side") private OrderSide side; + @JsonProperty("client_order_id") private String clientOrderId; + + @JsonProperty("type") private OrderType type; + @JsonProperty("base_quantity") private String baseQuantity; + @JsonProperty("quote_value") private String quoteValue; + @JsonProperty("limit_price") private String limitPrice; - @JsonProperty("stop_price") - private String stopPrice; - @JsonProperty("time_in_force") - private TimeInForceType timeInForce; + @JsonProperty("start_time") private String startTime; + @JsonProperty("expiry_time") private String expiryTime; + + @JsonProperty("time_in_force") + private TimeInForceType timeInForce; + @JsonProperty("stp_id") private String stpId; + @JsonProperty("display_quote_size") private String displayQuoteSize; + @JsonProperty("display_base_size") private String displayBaseSize; + @JsonProperty("is_raise_exact") - private boolean isRaiseExact; + private Boolean isRaiseExact; + @JsonProperty("historical_pov") private String historicalPov; + + @JsonProperty("stop_price") + private String stopPrice; + @JsonProperty("settl_currency") private String settlCurrency; + @JsonProperty("post_only") private Boolean postOnly; + @JsonProperty("peg_offset_type") - private String pegOffsetType; + private PegOffsetType pegOffsetType; + + @JsonProperty("offset") private String offset; + @JsonProperty("wig_level") private String wigLevel; @@ -83,15 +109,15 @@ public CreateOrderRequest(Builder builder) { this.baseQuantity = builder.baseQuantity; this.quoteValue = builder.quoteValue; this.limitPrice = builder.limitPrice; - this.stopPrice = builder.stopPrice; - this.timeInForce = builder.timeInForce; this.startTime = builder.startTime; this.expiryTime = builder.expiryTime; + this.timeInForce = builder.timeInForce; this.stpId = builder.stpId; this.displayQuoteSize = builder.displayQuoteSize; this.displayBaseSize = builder.displayBaseSize; this.isRaiseExact = builder.isRaiseExact; this.historicalPov = builder.historicalPov; + this.stopPrice = builder.stopPrice; this.settlCurrency = builder.settlCurrency; this.postOnly = builder.postOnly; this.pegOffsetType = builder.pegOffsetType; @@ -163,22 +189,6 @@ public void setLimitPrice(String limitPrice) { this.limitPrice = limitPrice; } - public String getStopPrice() { - return stopPrice; - } - - public void setStopPrice(String stopPrice) { - this.stopPrice = stopPrice; - } - - public TimeInForceType getTimeInForce() { - return timeInForce; - } - - public void setTimeInForce(TimeInForceType timeInForce) { - this.timeInForce = timeInForce; - } - public String getStartTime() { return startTime; } @@ -195,6 +205,14 @@ public void setExpiryTime(String expiryTime) { this.expiryTime = expiryTime; } + public TimeInForceType getTimeInForce() { + return timeInForce; + } + + public void setTimeInForce(TimeInForceType timeInForce) { + this.timeInForce = timeInForce; + } + public String getStpId() { return stpId; } @@ -219,11 +237,11 @@ public void setDisplayBaseSize(String displayBaseSize) { this.displayBaseSize = displayBaseSize; } - public boolean isRaiseExact() { + public Boolean getIsRaiseExact() { return isRaiseExact; } - public void setRaiseExact(boolean isRaiseExact) { + public void setIsRaiseExact(Boolean isRaiseExact) { this.isRaiseExact = isRaiseExact; } @@ -235,6 +253,14 @@ public void setHistoricalPov(String historicalPov) { this.historicalPov = historicalPov; } + public String getStopPrice() { + return stopPrice; + } + + public void setStopPrice(String stopPrice) { + this.stopPrice = stopPrice; + } + public String getSettlCurrency() { return settlCurrency; } @@ -251,11 +277,11 @@ public void setPostOnly(Boolean postOnly) { this.postOnly = postOnly; } - public String getPegOffsetType() { + public PegOffsetType getPegOffsetType() { return pegOffsetType; } - public void setPegOffsetType(String pegOffsetType) { + public void setPegOffsetType(PegOffsetType pegOffsetType) { this.pegOffsetType = pegOffsetType; } @@ -284,18 +310,18 @@ public static class Builder { private String baseQuantity; private String quoteValue; private String limitPrice; - private String stopPrice; - private TimeInForceType timeInForce; private String startTime; private String expiryTime; + private TimeInForceType timeInForce; private String stpId; private String displayQuoteSize; private String displayBaseSize; - private boolean isRaiseExact; + private Boolean isRaiseExact; private String historicalPov; + private String stopPrice; private String settlCurrency; private Boolean postOnly; - private String pegOffsetType; + private PegOffsetType pegOffsetType; private String offset; private String wigLevel; @@ -342,16 +368,6 @@ public Builder limitPrice(String limitPrice) { return this; } - public Builder stopPrice(String stopPrice) { - this.stopPrice = stopPrice; - return this; - } - - public Builder timeInForce(TimeInForceType timeInForce) { - this.timeInForce = timeInForce; - return this; - } - public Builder startTime(String startTime) { this.startTime = startTime; return this; @@ -362,6 +378,11 @@ public Builder expiryTime(String expiryTime) { return this; } + public Builder timeInForce(TimeInForceType timeInForce) { + this.timeInForce = timeInForce; + return this; + } + public Builder stpId(String stpId) { this.stpId = stpId; return this; @@ -377,7 +398,7 @@ public Builder displayBaseSize(String displayBaseSize) { return this; } - public Builder isRaiseExact(boolean isRaiseExact) { + public Builder isRaiseExact(Boolean isRaiseExact) { this.isRaiseExact = isRaiseExact; return this; } @@ -387,6 +408,11 @@ public Builder historicalPov(String historicalPov) { return this; } + public Builder stopPrice(String stopPrice) { + this.stopPrice = stopPrice; + return this; + } + public Builder settlCurrency(String settlCurrency) { this.settlCurrency = settlCurrency; return this; @@ -397,7 +423,7 @@ public Builder postOnly(Boolean postOnly) { return this; } - public Builder pegOffsetType(String pegOffsetType) { + public Builder pegOffsetType(PegOffsetType pegOffsetType) { this.pegOffsetType = pegOffsetType; return this; } @@ -413,10 +439,7 @@ public Builder wigLevel(String wigLevel) { } public CreateOrderRequest build() throws CoinbaseClientException { - this.validate(); - if (isNullOrEmpty(this.clientOrderId)) { - this.clientOrderId(UUID.randomUUID().toString()); - } + validate(); return new CreateOrderRequest(this); } @@ -424,18 +447,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.productId)) { - throw new CoinbaseClientException("ProductId is required"); - } - if (this.side == null) { - throw new CoinbaseClientException("Side is required"); - } - if (this.type == null) { - throw new CoinbaseClientException("Type is required"); - } - if (isNullOrEmpty(this.baseQuantity) && isNullOrEmpty(this.quoteValue)) { - throw new CoinbaseClientException("BaseQuantity or QuoteValue is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/orders/CreateOrderResponse.java b/src/main/java/com/coinbase/prime/orders/CreateOrderResponse.java index f2b8594c..4661cbbf 100644 --- a/src/main/java/com/coinbase/prime/orders/CreateOrderResponse.java +++ b/src/main/java/com/coinbase/prime/orders/CreateOrderResponse.java @@ -19,12 +19,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for creating an order. - * - * Create an order. + * Create Order */ public class CreateOrderResponse { - /** The order ID generated by Coinbase */ @JsonProperty("order_id") private String orderId; diff --git a/src/main/java/com/coinbase/prime/orders/CreateQuoteRequest.java b/src/main/java/com/coinbase/prime/orders/CreateQuoteRequest.java index 42e515f9..7400eb31 100644 --- a/src/main/java/com/coinbase/prime/orders/CreateQuoteRequest.java +++ b/src/main/java/com/coinbase/prime/orders/CreateQuoteRequest.java @@ -23,163 +23,175 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Quote Request + */ public class CreateQuoteRequest { - @JsonProperty(required = true, value = "portfolio_id") - @JsonIgnore - private String portfolioId; - @JsonProperty(required = true, value = "product_id") - private String productId; - @JsonProperty(required = true, value = "side") - private OrderSide side; - @JsonProperty(required = true, value = "client_quote_id") - private String clientQuoteId; - @JsonProperty("base_quantity") - private String baseQuantity; - @JsonProperty("quote_value") - private String quoteValue; - @JsonProperty(required = true, value = "limit_price") - private String limitPrice; - - public CreateQuoteRequest() { - } - - public CreateQuoteRequest(Builder builder) { - this.portfolioId = builder.portfolioId; - this.productId = builder.productId; - this.side = builder.side; - this.clientQuoteId = builder.clientQuoteId; - this.baseQuantity = builder.baseQuantity; - this.quoteValue = builder.quoteValue; - this.limitPrice = builder.limitPrice; - } - - public String getPortfolioId() { - return portfolioId; - } - - public void setPortfolioId(String portfolioId) { - this.portfolioId = portfolioId; - } - - public String getProductId() { - return productId; - } - - public void setProductId(String productId) { - this.productId = productId; - } - - public OrderSide getSide() { - return side; - } - - public void setSide(OrderSide side) { - this.side = side; - } - - public String getClientQuoteId() { - return clientQuoteId; - } - - public void setClientQuoteId(String clientQuoteId) { - this.clientQuoteId = clientQuoteId; - } - - public String getBaseQuantity() { - return baseQuantity; - } - - public void setBaseQuantity(String baseQuantity) { - this.baseQuantity = baseQuantity; - } - - public String getQuoteValue() { - return quoteValue; - } - - public void setQuoteValue(String quoteValue) { - this.quoteValue = quoteValue; - } - - public String getLimitPrice() { - return limitPrice; - } - - public void setLimitPrice(String limitPrice) { - this.limitPrice = limitPrice; - } - - public static class Builder { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; + + @JsonProperty("product_id") private String productId; + + @JsonProperty("side") private OrderSide side; + + @JsonProperty("client_quote_id") private String clientQuoteId; + + @JsonProperty("base_quantity") private String baseQuantity; + + @JsonProperty("quote_value") private String quoteValue; + + @JsonProperty("limit_price") private String limitPrice; - public Builder() { + @JsonProperty("settl_currency") + private String settlCurrency; + + public CreateQuoteRequest() { + } + + public CreateQuoteRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.productId = builder.productId; + this.side = builder.side; + this.clientQuoteId = builder.clientQuoteId; + this.baseQuantity = builder.baseQuantity; + this.quoteValue = builder.quoteValue; + this.limitPrice = builder.limitPrice; + this.settlCurrency = builder.settlCurrency; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public OrderSide getSide() { + return side; + } + + public void setSide(OrderSide side) { + this.side = side; + } + + public String getClientQuoteId() { + return clientQuoteId; + } + + public void setClientQuoteId(String clientQuoteId) { + this.clientQuoteId = clientQuoteId; } - public Builder portfolioId(String portfolioId) { - this.portfolioId = portfolioId; - return this; + public String getBaseQuantity() { + return baseQuantity; } - public Builder productId(String productId) { - this.productId = productId; - return this; + public void setBaseQuantity(String baseQuantity) { + this.baseQuantity = baseQuantity; } - public Builder side(OrderSide side) { - this.side = side; - return this; + public String getQuoteValue() { + return quoteValue; } - public Builder clientQuoteId(String clientQuoteId) { - this.clientQuoteId = clientQuoteId; - return this; + public void setQuoteValue(String quoteValue) { + this.quoteValue = quoteValue; } - public Builder baseQuantity(String baseQuantity) { - this.baseQuantity = baseQuantity; - return this; + public String getLimitPrice() { + return limitPrice; } - public Builder quoteValue(String quoteValue) { - this.quoteValue = quoteValue; - return this; + public void setLimitPrice(String limitPrice) { + this.limitPrice = limitPrice; } - public Builder limitPrice(String limitPrice) { - this.limitPrice = limitPrice; - return this; + public String getSettlCurrency() { + return settlCurrency; } - public CreateQuoteRequest build() throws CoinbaseClientException { - this.validate(); - return new CreateQuoteRequest(this); + public void setSettlCurrency(String settlCurrency) { + this.settlCurrency = settlCurrency; } - private void validate() throws CoinbaseClientException { - if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId is required"); - } - if (isNullOrEmpty(this.productId)) { - throw new CoinbaseClientException("ProductId is required"); - } - if (this.side == null) { - throw new CoinbaseClientException("Side is required"); - } - if (isNullOrEmpty(this.clientQuoteId)) { - throw new CoinbaseClientException("ClientQuoteId is required"); - } - if (isNullOrEmpty(this.limitPrice)) { - throw new CoinbaseClientException("LimitPrice is required"); - } - if (isNullOrEmpty(this.baseQuantity) && isNullOrEmpty(this.quoteValue)) { - throw new CoinbaseClientException("BaseQuantity or QuoteValue is required"); - } + public static class Builder { + private String portfolioId; + private String productId; + private OrderSide side; + private String clientQuoteId; + private String baseQuantity; + private String quoteValue; + private String limitPrice; + private String settlCurrency; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder productId(String productId) { + this.productId = productId; + return this; + } + + public Builder side(OrderSide side) { + this.side = side; + return this; + } + + public Builder clientQuoteId(String clientQuoteId) { + this.clientQuoteId = clientQuoteId; + return this; + } + + public Builder baseQuantity(String baseQuantity) { + this.baseQuantity = baseQuantity; + return this; + } + + public Builder quoteValue(String quoteValue) { + this.quoteValue = quoteValue; + return this; + } + + public Builder limitPrice(String limitPrice) { + this.limitPrice = limitPrice; + return this; + } + + public Builder settlCurrency(String settlCurrency) { + this.settlCurrency = settlCurrency; + return this; + } + + public CreateQuoteRequest build() throws CoinbaseClientException { + validate(); + return new CreateQuoteRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } - } } diff --git a/src/main/java/com/coinbase/prime/orders/CreateQuoteResponse.java b/src/main/java/com/coinbase/prime/orders/CreateQuoteResponse.java index cf5e7e95..7abca49d 100644 --- a/src/main/java/com/coinbase/prime/orders/CreateQuoteResponse.java +++ b/src/main/java/com/coinbase/prime/orders/CreateQuoteResponse.java @@ -19,72 +19,65 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for creating a quote request. - * - * A Quote Request is the start of the RFQ process. Coinbase Prime sends a Quote Request to - * Liquidity Providers (LPs) on behalf of a customer looking to participate in an RFQ trade. + * Create Quote Request */ public class CreateQuoteResponse { - /** Unique identifier for the quote */ - @JsonProperty("quote_id") - private String quoteId; + @JsonProperty("quote_id") + private String quoteId; - /** Time when the quote expires */ - @JsonProperty("expiration_time") - private String expirationTime; + @JsonProperty("expiration_time") + private String expirationTime; - /** Best available price for the quote */ - @JsonProperty("best_price") - private String bestPrice; + @JsonProperty("best_price") + private String bestPrice; - /** Total quote amount for previewing */ - @JsonProperty("order_total") - private String orderTotal; + @JsonProperty("order_total") + private String orderTotal; - /** Price inclusive of all fees */ - @JsonProperty("price_inclusive_of_fees") - private String priceInclusiveOfFees; + @JsonProperty("price_inclusive_of_fees") + private String priceInclusiveOfFees; - public CreateQuoteResponse() { - } + public CreateQuoteResponse() { + } - public String getQuoteId() { - return quoteId; - } + public String getQuoteId() { + return quoteId; + } - public void setQuoteId(String quoteId) { - this.quoteId = quoteId; - } + public void setQuoteId(String quoteId) { + this.quoteId = quoteId; + } - public String getExpirationTime() { - return expirationTime; - } + public String getExpirationTime() { + return expirationTime; + } - public void setExpirationTime(String expirationTime) { - this.expirationTime = expirationTime; - } + public void setExpirationTime(String expirationTime) { + this.expirationTime = expirationTime; + } - public String getBestPrice() { - return bestPrice; - } + public String getBestPrice() { + return bestPrice; + } - public void setBestPrice(String bestPrice) { - this.bestPrice = bestPrice; - } + public void setBestPrice(String bestPrice) { + this.bestPrice = bestPrice; + } - public String getOrderTotal() { - return orderTotal; - } + public String getOrderTotal() { + return orderTotal; + } - public void setOrderTotal(String orderTotal) { - this.orderTotal = orderTotal; - } + public void setOrderTotal(String orderTotal) { + this.orderTotal = orderTotal; + } - public String getPriceInclusiveOfFees() { - return priceInclusiveOfFees; - } + public String getPriceInclusiveOfFees() { + return priceInclusiveOfFees; + } + + public void setPriceInclusiveOfFees(String priceInclusiveOfFees) { + this.priceInclusiveOfFees = priceInclusiveOfFees; + } - public void setPriceInclusiveOfFees(String priceInclusiveOfFees) { - this.priceInclusiveOfFees = priceInclusiveOfFees; - } } diff --git a/src/main/java/com/coinbase/prime/orders/EditOrderRequest.java b/src/main/java/com/coinbase/prime/orders/EditOrderRequest.java index 50217197..b4dfdd11 100644 --- a/src/main/java/com/coinbase/prime/orders/EditOrderRequest.java +++ b/src/main/java/com/coinbase/prime/orders/EditOrderRequest.java @@ -23,56 +23,44 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * This feature is in beta. Please reach out to your Coinbase Prime account manager for more information. + * Edit Order (Beta) */ public class EditOrderRequest { - /** The ID of the portfolio that owns the order */ @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - - /** The ID of the order being edited */ + @JsonProperty(required = true, value = "order_id") @JsonIgnore private String orderId; - - /** Deprecated: The product ID of the order being edited */ + @JsonProperty("product_id") private String productId; - - /** The client order ID of the order being edited */ + @JsonProperty("orig_client_order_id") private String origClientOrderId; - - /** The updated version of the client order ID */ + @JsonProperty("client_order_id") private String clientOrderId; - - /** Order size in base asset units (either base_quantity or quote_value is required) */ + @JsonProperty("base_quantity") private String baseQuantity; - - /** Order size in quote asset units, i.e. the amount the user wants to spend (when buying) or receive (when selling); the quantity in base units will be determined based on the market */ + @JsonProperty("quote_value") private String quoteValue; - - /** Order limit price (buy orders are placed at or below this price; sell orders are placed at or above this price) */ + @JsonProperty("limit_price") private String limitPrice; - - /** The expiry time of the order */ + @JsonProperty("expiry_time") private String expiryTime; - - /** The maximum order size that will show up on venue order books (iceberg orders) */ + @JsonProperty("display_quote_size") private String displayQuoteSize; - - /** The maximum order size that will show up on venue order books (iceberg orders) */ + @JsonProperty("display_base_size") private String displayBaseSize; - - /** Specifies the stop price at which the order activates */ + @JsonProperty("stop_price") private String stopPrice; @@ -268,7 +256,7 @@ public Builder stopPrice(String stopPrice) { } public EditOrderRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new EditOrderRequest(this); } @@ -279,12 +267,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.orderId)) { throw new CoinbaseClientException("OrderId is required"); } - if (isNullOrEmpty(this.origClientOrderId)) { - throw new CoinbaseClientException("OrigClientOrderId is required"); - } - if (isNullOrEmpty(this.clientOrderId)) { - throw new CoinbaseClientException("ClientOrderId is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/orders/EditOrderResponse.java b/src/main/java/com/coinbase/prime/orders/EditOrderResponse.java index b29a6523..3a10420e 100644 --- a/src/main/java/com/coinbase/prime/orders/EditOrderResponse.java +++ b/src/main/java/com/coinbase/prime/orders/EditOrderResponse.java @@ -19,10 +19,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Edit an open order. This feature is in beta please reach out to your Coinbase Prime account manager for more information. + * Edit Order (Beta) */ public class EditOrderResponse { - /** The ID of the order being edited */ @JsonProperty("order_id") private String orderId; diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdRequest.java b/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdRequest.java index a7dc6d06..dfe5bfa6 100644 --- a/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdRequest.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdRequest.java @@ -22,28 +22,24 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Order by Order ID + */ public class GetOrderByOrderIdRequest { - @JsonProperty("order_id") - @JsonIgnore - private String orderId; - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "order_id") + @JsonIgnore + private String orderId; + public GetOrderByOrderIdRequest() { } public GetOrderByOrderIdRequest(Builder builder) { - this.orderId = builder.orderId; this.portfolioId = builder.portfolioId; - } - - public String getOrderId() { - return orderId; - } - - public void setOrderId(String orderId) { - this.orderId = orderId; + this.orderId = builder.orderId; } public String getPortfolioId() { @@ -54,35 +50,43 @@ public void setPortfolioId(String portfolioId) { this.portfolioId = portfolioId; } + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + public static class Builder { - private String orderId; private String portfolioId; + private String orderId; public Builder() { } - public Builder orderId(String orderId) { - this.orderId = orderId; + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; return this; } - public Builder portfolioId(String portfolioId) { - this.portfolioId = portfolioId; + public Builder orderId(String orderId) { + this.orderId = orderId; return this; } - public GetOrderByOrderIdRequest build() { - this.validate(); + public GetOrderByOrderIdRequest build() throws CoinbaseClientException { + validate(); return new GetOrderByOrderIdRequest(this); } private void validate() throws CoinbaseClientException { - if (isNullOrEmpty(this.orderId)) { - throw new CoinbaseClientException("OrderId is required"); - } if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } + if (isNullOrEmpty(this.orderId)) { + throw new CoinbaseClientException("OrderId is required"); + } } } } diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdResponse.java b/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdResponse.java index a91e2e2c..64ad22e8 100644 --- a/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdResponse.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderByOrderIdResponse.java @@ -17,14 +17,13 @@ package com.coinbase.prime.orders; import com.coinbase.prime.model.Order; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving an order by order ID. - * - * Retrieve an order by order ID. + * Get Order by Order ID */ public class GetOrderByOrderIdResponse { - /** The order details */ + @JsonProperty("order") private Order order; public GetOrderByOrderIdResponse() { diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderPreviewRequest.java b/src/main/java/com/coinbase/prime/orders/GetOrderPreviewRequest.java index 488d4217..737e83af 100644 --- a/src/main/java/com/coinbase/prime/orders/GetOrderPreviewRequest.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderPreviewRequest.java @@ -19,49 +19,75 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.enums.OrderSide; import com.coinbase.prime.model.enums.OrderType; +import com.coinbase.prime.model.enums.PegOffsetType; import com.coinbase.prime.model.enums.TimeInForceType; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Order Preview + */ public class GetOrderPreviewRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("product_id") private String productId; + + @JsonProperty("side") private OrderSide side; + + @JsonProperty("type") private OrderType type; + @JsonProperty("base_quantity") private String baseQuantity; + @JsonProperty("quote_value") private String quoteValue; + @JsonProperty("limit_price") private String limitPrice; - @JsonProperty("stop_price") - private String stopPrice; - @JsonProperty("time_in_force") - private TimeInForceType timeInForce; + @JsonProperty("start_time") private String startTime; + @JsonProperty("expiry_time") private String expiryTime; + + @JsonProperty("time_in_force") + private TimeInForceType timeInForce; + @JsonProperty("is_raise_exact") - private boolean isRaiseExact; + private Boolean isRaiseExact; + @JsonProperty("historical_pov") private String historicalPov; + + @JsonProperty("stop_price") + private String stopPrice; + @JsonProperty("settl_currency") private String settlCurrency; + @JsonProperty("postOnly") private Boolean postOnly; + @JsonProperty("display_quote_size") private String displayQuoteSize; + @JsonProperty("display_base_size") private String displayBaseSize; + @JsonProperty("peg_offset_type") - private String pegOffsetType; + private PegOffsetType pegOffsetType; + + @JsonProperty("offset") private String offset; + @JsonProperty("wig_level") private String wigLevel; @@ -76,12 +102,12 @@ public GetOrderPreviewRequest(Builder builder) { this.baseQuantity = builder.baseQuantity; this.quoteValue = builder.quoteValue; this.limitPrice = builder.limitPrice; - this.stopPrice = builder.stopPrice; - this.timeInForce = builder.timeInForce; this.startTime = builder.startTime; this.expiryTime = builder.expiryTime; + this.timeInForce = builder.timeInForce; this.isRaiseExact = builder.isRaiseExact; this.historicalPov = builder.historicalPov; + this.stopPrice = builder.stopPrice; this.settlCurrency = builder.settlCurrency; this.postOnly = builder.postOnly; this.displayQuoteSize = builder.displayQuoteSize; @@ -147,22 +173,6 @@ public void setLimitPrice(String limitPrice) { this.limitPrice = limitPrice; } - public String getStopPrice() { - return stopPrice; - } - - public void setStopPrice(String stopPrice) { - this.stopPrice = stopPrice; - } - - public TimeInForceType getTimeInForce() { - return timeInForce; - } - - public void setTimeInForce(TimeInForceType timeInForce) { - this.timeInForce = timeInForce; - } - public String getStartTime() { return startTime; } @@ -179,12 +189,20 @@ public void setExpiryTime(String expiryTime) { this.expiryTime = expiryTime; } - public boolean isRaiseExact() { + public TimeInForceType getTimeInForce() { + return timeInForce; + } + + public void setTimeInForce(TimeInForceType timeInForce) { + this.timeInForce = timeInForce; + } + + public Boolean getIsRaiseExact() { return isRaiseExact; } - public void setRaiseExact(boolean raiseExact) { - isRaiseExact = raiseExact; + public void setIsRaiseExact(Boolean isRaiseExact) { + this.isRaiseExact = isRaiseExact; } public String getHistoricalPov() { @@ -195,6 +213,14 @@ public void setHistoricalPov(String historicalPov) { this.historicalPov = historicalPov; } + public String getStopPrice() { + return stopPrice; + } + + public void setStopPrice(String stopPrice) { + this.stopPrice = stopPrice; + } + public String getSettlCurrency() { return settlCurrency; } @@ -227,11 +253,11 @@ public void setDisplayBaseSize(String displayBaseSize) { this.displayBaseSize = displayBaseSize; } - public String getPegOffsetType() { + public PegOffsetType getPegOffsetType() { return pegOffsetType; } - public void setPegOffsetType(String pegOffsetType) { + public void setPegOffsetType(PegOffsetType pegOffsetType) { this.pegOffsetType = pegOffsetType; } @@ -259,17 +285,17 @@ public static class Builder { private String baseQuantity; private String quoteValue; private String limitPrice; - private String stopPrice; - private TimeInForceType timeInForce; private String startTime; private String expiryTime; - private boolean isRaiseExact; + private TimeInForceType timeInForce; + private Boolean isRaiseExact; private String historicalPov; + private String stopPrice; private String settlCurrency; private Boolean postOnly; private String displayQuoteSize; private String displayBaseSize; - private String pegOffsetType; + private PegOffsetType pegOffsetType; private String offset; private String wigLevel; @@ -311,16 +337,6 @@ public Builder limitPrice(String limitPrice) { return this; } - public Builder stopPrice(String stopPrice) { - this.stopPrice = stopPrice; - return this; - } - - public Builder timeInForce(TimeInForceType timeInForce) { - this.timeInForce = timeInForce; - return this; - } - public Builder startTime(String startTime) { this.startTime = startTime; return this; @@ -331,7 +347,12 @@ public Builder expiryTime(String expiryTime) { return this; } - public Builder isRaiseExact(boolean isRaiseExact) { + public Builder timeInForce(TimeInForceType timeInForce) { + this.timeInForce = timeInForce; + return this; + } + + public Builder isRaiseExact(Boolean isRaiseExact) { this.isRaiseExact = isRaiseExact; return this; } @@ -341,6 +362,11 @@ public Builder historicalPov(String historicalPov) { return this; } + public Builder stopPrice(String stopPrice) { + this.stopPrice = stopPrice; + return this; + } + public Builder settlCurrency(String settlCurrency) { this.settlCurrency = settlCurrency; return this; @@ -361,7 +387,7 @@ public Builder displayBaseSize(String displayBaseSize) { return this; } - public Builder pegOffsetType(String pegOffsetType) { + public Builder pegOffsetType(PegOffsetType pegOffsetType) { this.pegOffsetType = pegOffsetType; return this; } @@ -377,7 +403,7 @@ public Builder wigLevel(String wigLevel) { } public GetOrderPreviewRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetOrderPreviewRequest(this); } @@ -385,18 +411,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.productId)) { - throw new CoinbaseClientException("ProductId is required"); - } - if (this.side == null) { - throw new CoinbaseClientException("Side is required"); - } - if (this.type == null) { - throw new CoinbaseClientException("Type is required"); - } - if (isNullOrEmpty(this.baseQuantity) && isNullOrEmpty(this.quoteValue)) { - throw new CoinbaseClientException("BaseQuantity or QuoteValue is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderPreviewResponse.java b/src/main/java/com/coinbase/prime/orders/GetOrderPreviewResponse.java index cd96575a..c17ec562 100644 --- a/src/main/java/com/coinbase/prime/orders/GetOrderPreviewResponse.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderPreviewResponse.java @@ -21,45 +21,73 @@ import com.coinbase.prime.model.enums.TimeInForceType; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Order Preview + */ public class GetOrderPreviewResponse { @JsonProperty("portfolio_id") private String portfolioId; + @JsonProperty("product_id") private String productId; + + @JsonProperty("side") private OrderSide side; + + @JsonProperty("type") private OrderType type; + @JsonProperty("base_quantity") private String baseQuantity; + @JsonProperty("quote_value") private String quoteValue; + @JsonProperty("limit_price") private String limitPrice; + @JsonProperty("start_time") private String startTime; + @JsonProperty("expiry_time") private String expiryTime; + @JsonProperty("time_in_force") private TimeInForceType timeInForce; + + @JsonProperty("commission") private String commission; + + @JsonProperty("slippage") private String slippage; + @JsonProperty("best_bid") private String bestBid; + @JsonProperty("best_ask") private String bestAsk; + @JsonProperty("average_filled_price") private String averageFilledPrice; + @JsonProperty("order_total") private String orderTotal; + @JsonProperty("historical_pov") private String historicalPov; + @JsonProperty("is_raise_exact") private Boolean isRaiseExact; + @JsonProperty("stop_price") private String stopPrice; + @JsonProperty("display_size") private String displaySize; + @JsonProperty("display_quote_size") private String displayQuoteSize; + @JsonProperty("display_base_size") private String displayBaseSize; diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java b/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java new file mode 100644 index 00000000..6974354c --- /dev/null +++ b/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java @@ -0,0 +1,92 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.orders; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Order by Order ID + */ +public class GetOrderRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "order_id") + @JsonIgnore + private String orderId; + + public GetOrderRequest() { + } + + public GetOrderRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.orderId = builder.orderId; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public static class Builder { + private String portfolioId; + private String orderId; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder orderId(String orderId) { + this.orderId = orderId; + return this; + } + + public GetOrderRequest build() throws CoinbaseClientException { + validate(); + return new GetOrderRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.orderId)) { + throw new CoinbaseClientException("OrderId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsRequest.java b/src/main/java/com/coinbase/prime/orders/GetOrderResponse.java similarity index 61% rename from src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsRequest.java rename to src/main/java/com/coinbase/prime/orders/GetOrderResponse.java index 5c245b76..7383ea36 100644 --- a/src/main/java/com/coinbase/prime/financing/ListFinancingEligibleAssetsRequest.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderResponse.java @@ -14,21 +14,27 @@ * limitations under the License. */ -package com.coinbase.prime.financing; +package com.coinbase.prime.orders; -public class ListFinancingEligibleAssetsRequest { - public ListFinancingEligibleAssetsRequest() { - } +import com.coinbase.prime.model.Order; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Get Order by Order ID + */ +public class GetOrderResponse { + @JsonProperty("order") + private Order order; - public ListFinancingEligibleAssetsRequest(Builder builder) { + public GetOrderResponse() { } - public static class Builder { - public Builder() { - } + public Order getOrder() { + return order; + } - public ListFinancingEligibleAssetsRequest build() { - return new ListFinancingEligibleAssetsRequest(this); - } + public void setOrder(Order order) { + this.order = order; } + } diff --git a/src/main/java/com/coinbase/prime/orders/ListOpenOrdersRequest.java b/src/main/java/com/coinbase/prime/orders/ListOpenOrdersRequest.java index 4b779214..fbb3122e 100644 --- a/src/main/java/com/coinbase/prime/orders/ListOpenOrdersRequest.java +++ b/src/main/java/com/coinbase/prime/orders/ListOpenOrdersRequest.java @@ -25,24 +25,30 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Date; - -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Open Orders + */ public class ListOpenOrdersRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("product_ids") private String[] productIds; + @JsonProperty("order_type") private OrderType orderType; + @JsonProperty("start_date") - private Date startDate; + private String startDate; + @JsonProperty("order_side") private OrderSide orderSide; + @JsonProperty("end_date") - private Date endDate; + private String endDate; public ListOpenOrdersRequest() { } @@ -81,11 +87,11 @@ public void setOrderType(OrderType orderType) { this.orderType = orderType; } - public Date getStartDate() { + public String getStartDate() { return startDate; } - public void setStartDate(Date startDate) { + public void setStartDate(String startDate) { this.startDate = startDate; } @@ -97,11 +103,11 @@ public void setOrderSide(OrderSide orderSide) { this.orderSide = orderSide; } - public Date getEndDate() { + public String getEndDate() { return endDate; } - public void setEndDate(Date endDate) { + public void setEndDate(String endDate) { this.endDate = endDate; } @@ -109,9 +115,9 @@ public static class Builder { private String portfolioId; private String[] productIds; private OrderType orderType; - private Date startDate; + private String startDate; private OrderSide orderSide; - private Date endDate; + private String endDate; private String cursor; private SortDirection sortDirection; private Integer limit; @@ -134,7 +140,7 @@ public Builder orderType(OrderType orderType) { return this; } - public Builder startDate(Date startDate) { + public Builder startDate(String startDate) { this.startDate = startDate; return this; } @@ -144,24 +150,24 @@ public Builder orderSide(OrderSide orderSide) { return this; } - public Builder endDate(Date endDate) { + public Builder endDate(String endDate) { this.endDate = endDate; return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListOpenOrdersRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListOpenOrdersRequest(this); } diff --git a/src/main/java/com/coinbase/prime/orders/ListOpenOrdersResponse.java b/src/main/java/com/coinbase/prime/orders/ListOpenOrdersResponse.java index 04e70ad2..52262d55 100644 --- a/src/main/java/com/coinbase/prime/orders/ListOpenOrdersResponse.java +++ b/src/main/java/com/coinbase/prime/orders/ListOpenOrdersResponse.java @@ -18,18 +18,16 @@ import com.coinbase.prime.model.Order; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all open orders. - * - * List all open orders. - * Caution: The maximum number of orders returned is 1000. If a client has more than 1000 open orders, - * an error is returned prompting the user to use Websocket API, or FIX API to stream open orders. + * List Open Orders */ public class ListOpenOrdersResponse { - /** Array of open orders */ + @JsonProperty("orders") private Order[] orders; - /** Pagination information for the response */ + + @JsonProperty("pagination") private Pagination pagination; public ListOpenOrdersResponse() { diff --git a/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryRequest.java b/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryRequest.java index a54edb01..ef6c9ffe 100644 --- a/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryRequest.java +++ b/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryRequest.java @@ -22,11 +22,15 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Order Edit History + */ public class ListOrderEditHistoryRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - @JsonProperty("order_id") + + @JsonProperty(required = true, value = "order_id") @JsonIgnore private String orderId; @@ -72,17 +76,17 @@ public Builder orderId(String orderId) { } public ListOrderEditHistoryRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListOrderEditHistoryRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("Portfolio ID is required"); + throw new CoinbaseClientException("PortfolioId is required"); } if (isNullOrEmpty(this.orderId)) { - throw new CoinbaseClientException("Order ID is required"); + throw new CoinbaseClientException("OrderId is required"); } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryResponse.java b/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryResponse.java index 98aeab19..d4f13a9b 100644 --- a/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryResponse.java +++ b/src/main/java/com/coinbase/prime/orders/ListOrderEditHistoryResponse.java @@ -19,17 +19,19 @@ import com.coinbase.prime.model.LimitOrderEdit; import com.coinbase.prime.model.OrderEdit; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; +/** + * List Order Edit History + */ public class ListOrderEditHistoryResponse { @JsonProperty("order_id") private String orderId; @JsonProperty("order_edit_history") - private List orderEditHistory; + private LimitOrderEdit[] orderEditHistory; @JsonProperty("edit_history") - private List editHistory; + private OrderEdit[] editHistory; public ListOrderEditHistoryResponse() { } @@ -42,19 +44,20 @@ public void setOrderId(String orderId) { this.orderId = orderId; } - public List getOrderEditHistory() { + public LimitOrderEdit[] getOrderEditHistory() { return orderEditHistory; } - public void setOrderEditHistory(List orderEditHistory) { + public void setOrderEditHistory(LimitOrderEdit[] orderEditHistory) { this.orderEditHistory = orderEditHistory; } - public List getEditHistory() { + public OrderEdit[] getEditHistory() { return editHistory; } - public void setEditHistory(List editHistory) { + public void setEditHistory(OrderEdit[] editHistory) { this.editHistory = editHistory; } -} \ No newline at end of file + +} diff --git a/src/main/java/com/coinbase/prime/orders/ListOrderFillsRequest.java b/src/main/java/com/coinbase/prime/orders/ListOrderFillsRequest.java index 25deaa48..b8deafa4 100644 --- a/src/main/java/com/coinbase/prime/orders/ListOrderFillsRequest.java +++ b/src/main/java/com/coinbase/prime/orders/ListOrderFillsRequest.java @@ -25,11 +25,15 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Order Fills + */ public class ListOrderFillsRequest extends PrimeListRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - @JsonProperty("order_id") + + @JsonProperty(required = true, value = "order_id") @JsonIgnore private String orderId; @@ -78,27 +82,26 @@ public Builder orderId(String orderId) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListOrderFillsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListOrderFillsRequest(this); } - public void validate() { + private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.orderId)) { throw new CoinbaseClientException("OrderId is required"); } diff --git a/src/main/java/com/coinbase/prime/orders/ListOrderFillsResponse.java b/src/main/java/com/coinbase/prime/orders/ListOrderFillsResponse.java index 12979359..f5f9ac6c 100644 --- a/src/main/java/com/coinbase/prime/orders/ListOrderFillsResponse.java +++ b/src/main/java/com/coinbase/prime/orders/ListOrderFillsResponse.java @@ -18,9 +18,16 @@ import com.coinbase.prime.model.Fill; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Order Fills + */ public class ListOrderFillsResponse { + @JsonProperty("fills") private Fill[] fills; + + @JsonProperty("pagination") private Pagination pagination; public ListOrderFillsResponse() { diff --git a/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsRequest.java b/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsRequest.java index 2550bd16..0a9b7dd6 100644 --- a/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsRequest.java +++ b/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsRequest.java @@ -25,8 +25,11 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Fills + */ public class ListPortfolioFillsRequest extends PrimeListRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; @@ -96,30 +99,26 @@ public Builder endDate(String endDate) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListPortfolioFillsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioFillsRequest(this); } - public void validate() { + private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.startDate)) { - throw new CoinbaseClientException("StartDate is required"); - } - } } } diff --git a/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsResponse.java b/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsResponse.java index 0267e7c7..e0ac27d4 100644 --- a/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsResponse.java +++ b/src/main/java/com/coinbase/prime/orders/ListPortfolioFillsResponse.java @@ -18,9 +18,16 @@ import com.coinbase.prime.model.Fill; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Portfolio Fills + */ public class ListPortfolioFillsResponse { + @JsonProperty("fills") private Fill[] fills; + + @JsonProperty("pagination") private Pagination pagination; public ListPortfolioFillsResponse() { diff --git a/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersRequest.java b/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersRequest.java index 604b937a..10d214e2 100644 --- a/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersRequest.java +++ b/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersRequest.java @@ -26,22 +26,31 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Orders + */ public class ListPortfolioOrdersRequest extends PrimeListRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("order_statuses") private OrderStatus[] orderStatuses; + @JsonProperty("product_ids") private String[] productIds; + @JsonProperty("order_type") private OrderType orderType; + @JsonProperty("order_side") private OrderSide orderSide; + @JsonProperty("start_date") private String startDate; + @JsonProperty("end_date") private String endDate; @@ -165,19 +174,19 @@ public Builder endDate(String endDate) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListPortfolioOrdersRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioOrdersRequest(this); } diff --git a/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersResponse.java b/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersResponse.java index c4cd17dc..8e099f4a 100644 --- a/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersResponse.java +++ b/src/main/java/com/coinbase/prime/orders/ListPortfolioOrdersResponse.java @@ -18,9 +18,16 @@ import com.coinbase.prime.model.Order; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Portfolio Orders + */ public class ListPortfolioOrdersResponse { + @JsonProperty("orders") private Order[] orders; + + @JsonProperty("pagination") private Pagination pagination; public ListPortfolioOrdersResponse() { diff --git a/src/main/java/com/coinbase/prime/orders/OrdersService.java b/src/main/java/com/coinbase/prime/orders/OrdersService.java index aade2a1a..ad7552b4 100644 --- a/src/main/java/com/coinbase/prime/orders/OrdersService.java +++ b/src/main/java/com/coinbase/prime/orders/OrdersService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,28 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface OrdersService { - // Orders - OpenAPI spec compliance + /** Accept Quote */ AcceptQuoteResponse acceptQuote(AcceptQuoteRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolio Fills */ + ListPortfolioFillsResponse listPortfolioFills(ListPortfolioFillsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Open Orders */ ListOpenOrdersResponse listOpenOrders(ListOpenOrdersRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Order */ CreateOrderResponse createOrder(CreateOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Order Preview */ GetOrderPreviewResponse getOrderPreview(GetOrderPreviewRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolio Orders */ ListPortfolioOrdersResponse listPortfolioOrders(ListPortfolioOrdersRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Order by Order ID */ GetOrderByOrderIdResponse getOrderByOrderId(GetOrderByOrderIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Cancel Order */ CancelOrderResponse cancelOrder(CancelOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Edit Order (Beta) */ + EditOrderResponse editOrder(EditOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Order Edit History */ ListOrderEditHistoryResponse listOrderEditHistory(ListOrderEditHistoryRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Order Fills */ ListOrderFillsResponse listOrderFills(ListOrderFillsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListPortfolioFillsResponse listPortfolioFills(ListPortfolioFillsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Quote Request */ CreateQuoteResponse createQuote(CreateQuoteRequest request) throws CoinbaseClientException, CoinbasePrimeException; - EditOrderResponse editOrder(EditOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java b/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java index 93d3d299..8b92176f 100644 --- a/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java +++ b/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,26 @@ public OrdersServiceImpl(CoinbasePrimeClient client) { super(client); } + @Override + public AcceptQuoteResponse acceptQuote(AcceptQuoteRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.POST, + String.format("/portfolios/%s/accept_quote", request.getPortfolioId()), + request, + List.of(200), + new TypeReference() {}); + } + + @Override + public ListPortfolioFillsResponse listPortfolioFills(ListPortfolioFillsRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.GET, + String.format("/portfolios/%s/fills", request.getPortfolioId()), + request, + List.of(200), + new TypeReference() {}); + } + @Override public ListOpenOrdersResponse listOpenOrders(ListOpenOrdersRequest request) throws CoinbasePrimeException { return this.request( @@ -45,7 +65,7 @@ public CreateOrderResponse createOrder(CreateOrderRequest request) throws Coinba HttpMethod.POST, String.format("/portfolios/%s/order", request.getPortfolioId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @@ -60,8 +80,7 @@ public GetOrderPreviewResponse getOrderPreview(GetOrderPreviewRequest request) t } @Override - public ListPortfolioOrdersResponse listPortfolioOrders(ListPortfolioOrdersRequest request) - throws CoinbasePrimeException { + public ListPortfolioOrdersResponse listPortfolioOrders(ListPortfolioOrdersRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, String.format("/portfolios/%s/orders", request.getPortfolioId()), @@ -91,64 +110,43 @@ public CancelOrderResponse cancelOrder(CancelOrderRequest request) throws Coinba } @Override - public ListOrderFillsResponse listOrderFills(ListOrderFillsRequest request) throws CoinbasePrimeException { + public EditOrderResponse editOrder(EditOrderRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, - String.format("/portfolios/%s/orders/%s/fills", request.getPortfolioId(), request.getOrderId()), + HttpMethod.PUT, + String.format("/portfolios/%s/orders/%s/edit", request.getPortfolioId(), request.getOrderId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListPortfolioFillsResponse listPortfolioFills(ListPortfolioFillsRequest request) - throws CoinbasePrimeException { + public ListOrderEditHistoryResponse listOrderEditHistory(ListOrderEditHistoryRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/fills", request.getPortfolioId()), + String.format("/portfolios/%s/orders/%s/edit_history", request.getPortfolioId(), request.getOrderId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public CreateQuoteResponse createQuote(CreateQuoteRequest request) throws CoinbasePrimeException { + public ListOrderFillsResponse listOrderFills(ListOrderFillsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, - String.format("/portfolios/%s/rfq", request.getPortfolioId()), + HttpMethod.GET, + String.format("/portfolios/%s/orders/%s/fills", request.getPortfolioId(), request.getOrderId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public AcceptQuoteResponse acceptQuote(AcceptQuoteRequest request) throws CoinbasePrimeException { + public CreateQuoteResponse createQuote(CreateQuoteRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, - String.format("/portfolios/%s/accept_quote", request.getPortfolioId()), - request, - List.of(200), - new TypeReference() {}); - } - - @Override - public ListOrderEditHistoryResponse listOrderEditHistory(ListOrderEditHistoryRequest request) - throws CoinbasePrimeException { - return this.request( - HttpMethod.GET, - String.format("/portfolios/%s/orders/%s/edit_history", request.getPortfolioId(), request.getOrderId()), + String.format("/portfolios/%s/rfq", request.getPortfolioId()), request, - List.of(200), - new TypeReference() {}); + List.of(201, 200), + new TypeReference() {}); } - @Override - public EditOrderResponse editOrder(EditOrderRequest request) throws CoinbasePrimeException { - return this.request( - HttpMethod.PUT, - String.format("/portfolios/%s/orders/%s/edit", request.getPortfolioId(), request.getOrderId()), - request, - List.of(200), - new TypeReference() {}); - } } diff --git a/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsRequest.java b/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsRequest.java index 396d53c3..2fdbc075 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsRequest.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsRequest.java @@ -22,10 +22,14 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Entity Payment Method + */ public class GetPaymentMethodDetailsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; + @JsonProperty(required = true, value = "payment_method_id") @JsonIgnore private String paymentMethodId; @@ -58,6 +62,9 @@ public static class Builder { private String entityId; private String paymentMethodId; + public Builder() { + } + public Builder entityId(String entityId) { this.entityId = entityId; return this; @@ -69,7 +76,7 @@ public Builder paymentMethodId(String paymentMethodId) { } public GetPaymentMethodDetailsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetPaymentMethodDetailsRequest(this); } diff --git a/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsResponse.java b/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsResponse.java index c97ba202..b6aac0e4 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsResponse.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/GetPaymentMethodDetailsResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.PaymentMethodDetails; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Entity Payment Method + */ public class GetPaymentMethodDetailsResponse { @JsonProperty("details") private PaymentMethodDetails details; diff --git a/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsRequest.java b/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsRequest.java index 549baa7b..98b2bc56 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsRequest.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsRequest.java @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Entity Payment Methods + */ public class ListPaymentMethodsRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -43,20 +46,24 @@ public void setEntityId(String entityId) { } public static class Builder { - private final String entityId; + private String entityId; + + public Builder() { + } - public Builder (String entityId) { + public Builder entityId(String entityId) { this.entityId = entityId; + return this; } public ListPaymentMethodsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPaymentMethodsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.entityId)) { - throw new CoinbaseClientException("EntityId cannot be null"); + throw new CoinbaseClientException("EntityId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsResponse.java b/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsResponse.java index 9a778194..0bc75be5 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsResponse.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/ListPaymentMethodsResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.PaymentMethodSummary; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Entity Payment Methods + */ public class ListPaymentMethodsResponse { @JsonProperty("payment_methods") private PaymentMethodSummary[] paymentMethods; diff --git a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java index d37100e6..475cf3e9 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,10 +16,12 @@ package com.coinbase.prime.paymentmethods; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.errors.CoinbasePrimeException; public interface PaymentMethodsService { - // Payment Methods - ListPaymentMethodsResponse listPaymentMethods(ListPaymentMethodsRequest request) throws CoinbasePrimeException; - GetPaymentMethodDetailsResponse getPaymentMethodDetails(GetPaymentMethodDetailsRequest request) throws CoinbasePrimeException; + /** List Entity Payment Methods */ + ListPaymentMethodsResponse listPaymentMethods(ListPaymentMethodsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Entity Payment Method */ + GetPaymentMethodDetailsResponse getPaymentMethodDetails(GetPaymentMethodDetailsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java index 8450dedf..05a3c164 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,8 +44,9 @@ public GetPaymentMethodDetailsResponse getPaymentMethodDetails(GetPaymentMethodD return this.request( HttpMethod.GET, String.format("/entities/%s/payment-methods/%s", request.getEntityId(), request.getPaymentMethodId()), - null, + request, List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/portfolios/GetPortfolioRequest.java b/src/main/java/com/coinbase/prime/portfolios/GetPortfolioRequest.java index 2b839db9..09e08435 100644 --- a/src/main/java/com/coinbase/prime/portfolios/GetPortfolioRequest.java +++ b/src/main/java/com/coinbase/prime/portfolios/GetPortfolioRequest.java @@ -20,8 +20,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Portfolio by Portfolio ID + */ public class GetPortfolioRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -43,14 +46,18 @@ public void setPortfolioId(String portfolioId) { } public static class Builder { - private final String portfolioId; + private String portfolioId; + + public Builder() { + } - public Builder(String portfolioId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; } public GetPortfolioRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetPortfolioRequest(this); } diff --git a/src/main/java/com/coinbase/prime/portfolios/GetPortfolioResponse.java b/src/main/java/com/coinbase/prime/portfolios/GetPortfolioResponse.java index 8ed5fa46..8a3f2f42 100644 --- a/src/main/java/com/coinbase/prime/portfolios/GetPortfolioResponse.java +++ b/src/main/java/com/coinbase/prime/portfolios/GetPortfolioResponse.java @@ -17,8 +17,13 @@ package com.coinbase.prime.portfolios; import com.coinbase.prime.model.Portfolio; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Portfolio by Portfolio ID + */ public class GetPortfolioResponse { + @JsonProperty("portfolio") private Portfolio portfolio; public GetPortfolioResponse() { diff --git a/src/main/java/com/coinbase/prime/portfolios/ListPortfoliosResponse.java b/src/main/java/com/coinbase/prime/portfolios/ListPortfoliosResponse.java index 6034ea89..7b23404e 100644 --- a/src/main/java/com/coinbase/prime/portfolios/ListPortfoliosResponse.java +++ b/src/main/java/com/coinbase/prime/portfolios/ListPortfoliosResponse.java @@ -17,16 +17,18 @@ package com.coinbase.prime.portfolios; import com.coinbase.prime.model.Portfolio; +import com.fasterxml.jackson.annotation.JsonProperty; -public class ListPortfoliosResponse{ +/** + * List Portfolios + */ +public class ListPortfoliosResponse { + @JsonProperty("portfolios") private Portfolio[] portfolios; - public ListPortfoliosResponse(Portfolio[] portfolios) { - this.portfolios = portfolios; + public ListPortfoliosResponse() { } - public ListPortfoliosResponse() {} - public Portfolio[] getPortfolios() { return portfolios; } @@ -34,4 +36,5 @@ public Portfolio[] getPortfolios() { public void setPortfolios(Portfolio[] portfolios) { this.portfolios = portfolios; } -} \ No newline at end of file + +} diff --git a/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java b/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java index c435ceaa..e816c61e 100644 --- a/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java +++ b/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface PortfoliosService { - // Portfolios - OpenAPI spec compliance - ListPortfoliosResponse listPortfolios(ListPortfoliosRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolios */ + ListPortfoliosResponse listPortfolios() throws CoinbaseClientException, CoinbasePrimeException; + /** Get Portfolio by Portfolio ID */ GetPortfolioResponse getPortfolio(GetPortfolioRequest request) throws CoinbaseClientException, CoinbasePrimeException; - GetPortfolioCounterpartyIdResponse getPortfolioCounterpartyId(GetPortfolioCounterpartyIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java b/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java index e6bfd70b..9369fa5b 100644 --- a/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java +++ b/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,11 +30,11 @@ public PortfoliosServiceImpl(CoinbasePrimeClient client) { } @Override - public ListPortfoliosResponse listPortfolios(ListPortfoliosRequest request) throws CoinbasePrimeException { + public ListPortfoliosResponse listPortfolios() throws CoinbasePrimeException { return this.request( HttpMethod.GET, "/portfolios", - request, + null, List.of(200), new TypeReference() {}); } @@ -44,20 +44,9 @@ public GetPortfolioResponse getPortfolio(GetPortfolioRequest request) throws Coi return this.request( HttpMethod.GET, String.format("/portfolios/%s", request.getPortfolioId()), - null, + request, List.of(200), new TypeReference() {}); } - @Override - public GetPortfolioCounterpartyIdResponse getPortfolioCounterpartyId(GetPortfolioCounterpartyIdRequest request) - throws CoinbasePrimeException { - return this.request( - HttpMethod.GET, - String.format("/portfolios/%s/counterparty", request.getPortfolioId()), - null, - List.of(200), - new TypeReference() {}); - } - } diff --git a/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java new file mode 100644 index 00000000..0de9b32c --- /dev/null +++ b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.positions; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.SortDirection; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Aggregate Entity Positions + */ +public class ListAggregateEntityPositionsRequest extends PrimeListRequest { + @JsonProperty(required = true, value = "entity_id") + @JsonIgnore + private String entityId; + + public ListAggregateEntityPositionsRequest() { + } + + public ListAggregateEntityPositionsRequest(Builder builder) { + super(builder.cursor, builder.sortDirection, builder.limit); + this.entityId = builder.entityId; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public static class Builder { + private String entityId; + private String cursor; + private SortDirection sortDirection; + private Integer limit; + + public Builder() { + } + + public Builder entityId(String entityId) { + this.entityId = entityId; + return this; + } + + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + + public ListAggregateEntityPositionsRequest build() throws CoinbaseClientException { + validate(); + return new ListAggregateEntityPositionsRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java new file mode 100644 index 00000000..88dfbaca --- /dev/null +++ b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.positions; + +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.Position; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * List Aggregate Entity Positions + */ +public class ListAggregateEntityPositionsResponse { + @JsonProperty("positions") + private Position[] positions; + + @JsonProperty("pagination") + private Pagination pagination; + + public ListAggregateEntityPositionsResponse() { + } + + public Position[] getPositions() { + return positions; + } + + public void setPositions(Position[] positions) { + this.positions = positions; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + +} diff --git a/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsRequest.java b/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsRequest.java index a6e39b32..8a8376a7 100644 --- a/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsRequest.java +++ b/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsRequest.java @@ -16,15 +16,20 @@ package com.coinbase.prime.positions; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.coinbase.core.errors.CoinbaseClientException; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Aggregate Entity Positions + */ public class ListAggregatePositionsRequest extends PrimeListRequest { - @JsonProperty("entity_id") + @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; @@ -32,40 +37,45 @@ public ListAggregatePositionsRequest() { } public ListAggregatePositionsRequest(Builder builder) { - super(builder.cursor, null, builder.limit); + super(builder.cursor, builder.sortDirection, builder.limit); this.entityId = builder.entityId; } - public String getId() { + public String getEntityId() { return entityId; } - public void setId(String entityId) { + public void setEntityId(String entityId) { this.entityId = entityId; } public static class Builder { private String entityId; private String cursor; + private SortDirection sortDirection; private Integer limit; + public Builder() { + } + public Builder entityId(String entityId) { this.entityId = entityId; return this; } - public Builder cursor(String cursor) { - this.cursor = cursor; + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } - public ListAggregatePositionsRequest build() { - this.validate(); + public ListAggregatePositionsRequest build() throws CoinbaseClientException { + validate(); return new ListAggregatePositionsRequest(this); } diff --git a/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsResponse.java b/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsResponse.java index 84f3bf80..b26107e2 100644 --- a/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsResponse.java +++ b/src/main/java/com/coinbase/prime/positions/ListAggregatePositionsResponse.java @@ -18,20 +18,21 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.Position; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Aggregate Entity Positions + */ public class ListAggregatePositionsResponse { + @JsonProperty("positions") private Position[] positions; + @JsonProperty("pagination") private Pagination pagination; public ListAggregatePositionsResponse() { } - public ListAggregatePositionsResponse(Position[] positions, Pagination pagination) { - this.positions = positions; - this.pagination = pagination; - } - public Position[] getPositions() { return positions; } diff --git a/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java new file mode 100644 index 00000000..4419b7e1 --- /dev/null +++ b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.positions; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.SortDirection; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Entity Positions + */ +public class ListEntityPositionsRequest extends PrimeListRequest { + @JsonProperty(required = true, value = "entity_id") + @JsonIgnore + private String entityId; + + public ListEntityPositionsRequest() { + } + + public ListEntityPositionsRequest(Builder builder) { + super(builder.cursor, builder.sortDirection, builder.limit); + this.entityId = builder.entityId; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public static class Builder { + private String entityId; + private String cursor; + private SortDirection sortDirection; + private Integer limit; + + public Builder() { + } + + public Builder entityId(String entityId) { + this.entityId = entityId; + return this; + } + + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + + public ListEntityPositionsRequest build() throws CoinbaseClientException { + validate(); + return new ListEntityPositionsRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java new file mode 100644 index 00000000..c07886a0 --- /dev/null +++ b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.positions; + +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.Position; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * List Entity Positions + */ +public class ListEntityPositionsResponse { + @JsonProperty("positions") + private Position[] positions; + + @JsonProperty("pagination") + private Pagination pagination; + + public ListEntityPositionsResponse() { + } + + public Position[] getPositions() { + return positions; + } + + public void setPositions(Position[] positions) { + this.positions = positions; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + +} diff --git a/src/main/java/com/coinbase/prime/positions/ListPositionsRequest.java b/src/main/java/com/coinbase/prime/positions/ListPositionsRequest.java index f647fdd7..8a515da2 100644 --- a/src/main/java/com/coinbase/prime/positions/ListPositionsRequest.java +++ b/src/main/java/com/coinbase/prime/positions/ListPositionsRequest.java @@ -16,16 +16,20 @@ package com.coinbase.prime.positions; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.coinbase.core.errors.CoinbaseClientException; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Entity Positions + */ public class ListPositionsRequest extends PrimeListRequest { - @JsonProperty("entity_id") + @JsonProperty(required = true, value = "entity_id") @JsonIgnore private String entityId; @@ -37,27 +41,25 @@ public ListPositionsRequest(Builder builder) { this.entityId = builder.entityId; } - public String getId() { + public String getEntityId() { return entityId; } - public void setId(String entityId) { + public void setEntityId(String entityId) { this.entityId = entityId; } public static class Builder { private String entityId; private String cursor; - private Integer limit; private SortDirection sortDirection; + private Integer limit; - public Builder entityId(String entityId) { - this.entityId = entityId; - return this; + public Builder() { } - public Builder cursor(String cursor) { - this.cursor = cursor; + public Builder entityId(String entityId) { + this.entityId = entityId; return this; } @@ -66,13 +68,14 @@ public Builder limit(Integer limit) { return this; } - public Builder sortDirection(SortDirection sortDirection) { - this.sortDirection = sortDirection; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } - public ListPositionsRequest build() { - this.validate(); + public ListPositionsRequest build() throws CoinbaseClientException { + validate(); return new ListPositionsRequest(this); } diff --git a/src/main/java/com/coinbase/prime/positions/ListPositionsResponse.java b/src/main/java/com/coinbase/prime/positions/ListPositionsResponse.java index bdf9fb34..aea8c585 100644 --- a/src/main/java/com/coinbase/prime/positions/ListPositionsResponse.java +++ b/src/main/java/com/coinbase/prime/positions/ListPositionsResponse.java @@ -18,25 +18,21 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.Position; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing positions for a specific entity. + * List Entity Positions */ public class ListPositionsResponse { - /** Array of position information for the entity */ + @JsonProperty("positions") private Position[] positions; - /** Pagination information for the response */ + @JsonProperty("pagination") private Pagination pagination; public ListPositionsResponse() { } - public ListPositionsResponse(Position[] positions, Pagination pagination) { - this.positions = positions; - this.pagination = pagination; - } - public Position[] getPositions() { return positions; } diff --git a/src/main/java/com/coinbase/prime/positions/PositionsService.java b/src/main/java/com/coinbase/prime/positions/PositionsService.java index 634bfba8..2c25c58a 100644 --- a/src/main/java/com/coinbase/prime/positions/PositionsService.java +++ b/src/main/java/com/coinbase/prime/positions/PositionsService.java @@ -20,6 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface PositionsService { + /** List Aggregate Entity Positions */ ListAggregatePositionsResponse listAggregatePositions(ListAggregatePositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Entity Positions */ ListPositionsResponse listPositions(ListPositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/positions/PositionsServiceImpl.java b/src/main/java/com/coinbase/prime/positions/PositionsServiceImpl.java index 31431820..9f54d47f 100644 --- a/src/main/java/com/coinbase/prime/positions/PositionsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/positions/PositionsServiceImpl.java @@ -19,6 +19,7 @@ import com.coinbase.core.common.HttpMethod; import com.coinbase.core.service.CoinbaseServiceImpl; import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.errors.CoinbasePrimeException; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; @@ -29,22 +30,23 @@ public PositionsServiceImpl(CoinbasePrimeClient client) { } @Override - public ListAggregatePositionsResponse listAggregatePositions(ListAggregatePositionsRequest request) { + public ListAggregatePositionsResponse listAggregatePositions(ListAggregatePositionsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/aggregate_positions", request.getId()), + String.format("/entities/%s/aggregate_positions", request.getEntityId()), request, List.of(200), new TypeReference() {}); } @Override - public ListPositionsResponse listPositions(ListPositionsRequest request) { + public ListPositionsResponse listPositions(ListPositionsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/entities/%s/positions", request.getId()), + String.format("/entities/%s/positions", request.getEntityId()), request, List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java b/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java new file mode 100644 index 00000000..7792b92f --- /dev/null +++ b/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java @@ -0,0 +1,143 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.products; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.enums.CandlesGranularity; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Public Product Candles (Beta) + */ +public class GetCandlesRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty("product_id") + private String productId; + + @JsonProperty("start_time") + private String startTime; + + @JsonProperty("end_time") + private String endTime; + + @JsonProperty("granularity") + private CandlesGranularity granularity; + + public GetCandlesRequest() { + } + + public GetCandlesRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.productId = builder.productId; + this.startTime = builder.startTime; + this.endTime = builder.endTime; + this.granularity = builder.granularity; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public CandlesGranularity getGranularity() { + return granularity; + } + + public void setGranularity(CandlesGranularity granularity) { + this.granularity = granularity; + } + + public static class Builder { + private String portfolioId; + private String productId; + private String startTime; + private String endTime; + private CandlesGranularity granularity; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder productId(String productId) { + this.productId = productId; + return this; + } + + public Builder startTime(String startTime) { + this.startTime = startTime; + return this; + } + + public Builder endTime(String endTime) { + this.endTime = endTime; + return this; + } + + public Builder granularity(CandlesGranularity granularity) { + this.granularity = granularity; + return this; + } + + public GetCandlesRequest build() throws CoinbaseClientException { + validate(); + return new GetCandlesRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/portfolios/ListPortfoliosRequest.java b/src/main/java/com/coinbase/prime/products/GetCandlesResponse.java similarity index 56% rename from src/main/java/com/coinbase/prime/portfolios/ListPortfoliosRequest.java rename to src/main/java/com/coinbase/prime/products/GetCandlesResponse.java index 5b851ea0..6a7889ee 100644 --- a/src/main/java/com/coinbase/prime/portfolios/ListPortfoliosRequest.java +++ b/src/main/java/com/coinbase/prime/products/GetCandlesResponse.java @@ -14,25 +14,27 @@ * limitations under the License. */ -package com.coinbase.prime.portfolios; +package com.coinbase.prime.products; + +import com.coinbase.prime.model.Candle; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * List all portfolios associated with a given entity. + * Get Public Product Candles (Beta) */ -public class ListPortfoliosRequest { - // No parameters required for listing all portfolios - // This is a simple GET request to /v1/portfolios with no path or query parameters +public class GetCandlesResponse { + @JsonProperty("candles") + private Candle[] candles; - public ListPortfoliosRequest() { + public GetCandlesResponse() { } - public static class Builder { - - public Builder() { - } + public Candle[] getCandles() { + return candles; + } - public ListPortfoliosRequest build() { - return new ListPortfoliosRequest(); - } + public void setCandles(Candle[] candles) { + this.candles = candles; } + } diff --git a/src/main/java/com/coinbase/prime/products/ListPortfolioProductsRequest.java b/src/main/java/com/coinbase/prime/products/ListPortfolioProductsRequest.java index 6dd155f6..b7a95706 100644 --- a/src/main/java/com/coinbase/prime/products/ListPortfolioProductsRequest.java +++ b/src/main/java/com/coinbase/prime/products/ListPortfolioProductsRequest.java @@ -19,23 +19,41 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.ContractExpiryType; +import com.coinbase.prime.model.enums.ExpiringContractStatus; +import com.coinbase.prime.model.enums.ProductType; import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Products + */ public class ListPortfolioProductsRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("product_type") + private ProductType productType; + + @JsonProperty("contract_expiry_type") + private ContractExpiryType contractExpiryType; + + @JsonProperty("expiring_contract_status") + private ExpiringContractStatus expiringContractStatus; + public ListPortfolioProductsRequest() { } public ListPortfolioProductsRequest(Builder builder) { super(builder.cursor, builder.sortDirection, builder.limit); this.portfolioId = builder.portfolioId; + this.productType = builder.productType; + this.contractExpiryType = builder.contractExpiryType; + this.expiringContractStatus = builder.expiringContractStatus; } public String getPortfolioId() { @@ -46,8 +64,35 @@ public void setPortfolioId(String portfolioId) { this.portfolioId = portfolioId; } + public ProductType getProductType() { + return productType; + } + + public void setProductType(ProductType productType) { + this.productType = productType; + } + + public ContractExpiryType getContractExpiryType() { + return contractExpiryType; + } + + public void setContractExpiryType(ContractExpiryType contractExpiryType) { + this.contractExpiryType = contractExpiryType; + } + + public ExpiringContractStatus getExpiringContractStatus() { + return expiringContractStatus; + } + + public void setExpiringContractStatus(ExpiringContractStatus expiringContractStatus) { + this.expiringContractStatus = expiringContractStatus; + } + public static class Builder { private String portfolioId; + private ProductType productType; + private ContractExpiryType contractExpiryType; + private ExpiringContractStatus expiringContractStatus; private String cursor; private SortDirection sortDirection; private Integer limit; @@ -60,9 +105,18 @@ public Builder portfolioId(String portfolioId) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder productType(ProductType productType) { + this.productType = productType; + return this; + } + + public Builder contractExpiryType(ContractExpiryType contractExpiryType) { + this.contractExpiryType = contractExpiryType; + return this; + } + + public Builder expiringContractStatus(ExpiringContractStatus expiringContractStatus) { + this.expiringContractStatus = expiringContractStatus; return this; } @@ -71,14 +125,20 @@ public Builder limit(Integer limit) { return this; } + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + public ListPortfolioProductsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioProductsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/products/ListPortfolioProductsResponse.java b/src/main/java/com/coinbase/prime/products/ListPortfolioProductsResponse.java index c496e8e1..7b63ab52 100644 --- a/src/main/java/com/coinbase/prime/products/ListPortfolioProductsResponse.java +++ b/src/main/java/com/coinbase/prime/products/ListPortfolioProductsResponse.java @@ -18,16 +18,16 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.Product; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing tradable products for a given portfolio. - * - * List tradable products for a given portfolio. + * List Portfolio Products */ public class ListPortfolioProductsResponse { - /** Array of tradable products for the portfolio */ + @JsonProperty("products") private Product[] products; - /** Pagination information for the response */ + + @JsonProperty("pagination") private Pagination pagination; public ListPortfolioProductsResponse() { diff --git a/src/main/java/com/coinbase/prime/products/ProductsService.java b/src/main/java/com/coinbase/prime/products/ProductsService.java index a898c548..ba6b6941 100644 --- a/src/main/java/com/coinbase/prime/products/ProductsService.java +++ b/src/main/java/com/coinbase/prime/products/ProductsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface ProductsService { - // Products - ListCandlesResponse listCandles(ListCandlesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolio Products */ ListPortfolioProductsResponse listPortfolioProducts(ListPortfolioProductsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Public Product Candles (Beta) */ + GetCandlesResponse getCandles(GetCandlesRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java b/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java index 06aa253a..db9d514e 100644 --- a/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,22 +30,23 @@ public ProductsServiceImpl(CoinbasePrimeClient client) { } @Override - public ListCandlesResponse listCandles(ListCandlesRequest request) throws CoinbasePrimeException { + public ListPortfolioProductsResponse listPortfolioProducts(ListPortfolioProductsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/candles", request.getPortfolioId()), + String.format("/portfolios/%s/products", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListPortfolioProductsResponse listPortfolioProducts(ListPortfolioProductsRequest request) throws CoinbasePrimeException { + public GetCandlesResponse getCandles(GetCandlesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/products", request.getPortfolioId()), + String.format("/portfolios/%s/candles", request.getPortfolioId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/staking/ClaimRewardsRequest.java b/src/main/java/com/coinbase/prime/staking/ClaimRewardsRequest.java index f6363786..1b0694aa 100644 --- a/src/main/java/com/coinbase/prime/staking/ClaimRewardsRequest.java +++ b/src/main/java/com/coinbase/prime/staking/ClaimRewardsRequest.java @@ -16,32 +16,28 @@ package com.coinbase.prime.staking; -import com.coinbase.prime.model.WalletClaimRewardsInputs; import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.WalletClaimRewardsInputs; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * Creates a request to claim the pending staking rewards from the specified wallet. + * Claim Wallet Staking Rewards (Alpha) */ public class ClaimRewardsRequest { - /** The portfolio ID */ - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - /** The wallet ID */ - @JsonIgnore @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore private String walletId; - /** The client generated idempotency key for requested execution. Any subsequent requests with the same key will return the original response */ @JsonProperty("idempotency_key") private String idempotencyKey; - /** Custom inputs for claim rewards operations on a wallet. Requirements and supported fields vary by asset type. */ @JsonProperty("inputs") private WalletClaimRewardsInputs inputs; @@ -117,7 +113,7 @@ public Builder inputs(WalletClaimRewardsInputs inputs) { } public ClaimRewardsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ClaimRewardsRequest(this); } @@ -128,9 +124,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.walletId)) { throw new CoinbaseClientException("WalletId is required"); } - if (isNullOrEmpty(this.idempotencyKey)) { - throw new CoinbaseClientException("IdempotencyKey is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/staking/ClaimRewardsResponse.java b/src/main/java/com/coinbase/prime/staking/ClaimRewardsResponse.java index f7d27691..af6df54c 100644 --- a/src/main/java/com/coinbase/prime/staking/ClaimRewardsResponse.java +++ b/src/main/java/com/coinbase/prime/staking/ClaimRewardsResponse.java @@ -18,16 +18,16 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Claim Wallet Staking Rewards (Alpha) + */ public class ClaimRewardsResponse { - /** The wallet ID */ @JsonProperty("wallet_id") private String walletId; - - /** ID of the newly created transaction, can be used to fetch details of the current state of execution */ + @JsonProperty("transaction_id") private String transactionId; - - /** The ID for the activity generated for this request */ + @JsonProperty("activity_id") private String activityId; diff --git a/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java new file mode 100644 index 00000000..57ab9acc --- /dev/null +++ b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java @@ -0,0 +1,129 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.WalletClaimRewardsInputs; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Claim Wallet Staking Rewards (Alpha) + */ +public class ClaimStakingRewardsRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore + private String walletId; + + @JsonProperty("idempotency_key") + private String idempotencyKey; + + @JsonProperty("inputs") + private WalletClaimRewardsInputs inputs; + + public ClaimStakingRewardsRequest() { + } + + public ClaimStakingRewardsRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.walletId = builder.walletId; + this.idempotencyKey = builder.idempotencyKey; + this.inputs = builder.inputs; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getWalletId() { + return walletId; + } + + public void setWalletId(String walletId) { + this.walletId = walletId; + } + + public String getIdempotencyKey() { + return idempotencyKey; + } + + public void setIdempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + } + + public WalletClaimRewardsInputs getInputs() { + return inputs; + } + + public void setInputs(WalletClaimRewardsInputs inputs) { + this.inputs = inputs; + } + + public static class Builder { + private String portfolioId; + private String walletId; + private String idempotencyKey; + private WalletClaimRewardsInputs inputs; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder walletId(String walletId) { + this.walletId = walletId; + return this; + } + + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + + public Builder inputs(WalletClaimRewardsInputs inputs) { + this.inputs = inputs; + return this; + } + + public ClaimStakingRewardsRequest build() throws CoinbaseClientException { + validate(); + return new ClaimStakingRewardsRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java new file mode 100644 index 00000000..003829ce --- /dev/null +++ b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java @@ -0,0 +1,61 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Claim Wallet Staking Rewards (Alpha) + */ +public class ClaimStakingRewardsResponse { + @JsonProperty("wallet_id") + private String walletId; + + @JsonProperty("transaction_id") + private String transactionId; + + @JsonProperty("activity_id") + private String activityId; + + public ClaimStakingRewardsResponse() { + } + + public String getWalletId() { + return walletId; + } + + public void setWalletId(String walletId) { + this.walletId = walletId; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + +} diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java new file mode 100644 index 00000000..ba8b4081 --- /dev/null +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java @@ -0,0 +1,143 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.PortfolioStakingMetadata; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Request to stake currency in a portfolio + */ +public class CreatePortfolioStakeRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty("idempotency_key") + private String idempotencyKey; + + @JsonProperty("currency_symbol") + private String currencySymbol; + + @JsonProperty("amount") + private String amount; + + @JsonProperty("metadata") + private PortfolioStakingMetadata metadata; + + public CreatePortfolioStakeRequest() { + } + + public CreatePortfolioStakeRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.idempotencyKey = builder.idempotencyKey; + this.currencySymbol = builder.currencySymbol; + this.amount = builder.amount; + this.metadata = builder.metadata; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getIdempotencyKey() { + return idempotencyKey; + } + + public void setIdempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + } + + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public PortfolioStakingMetadata getMetadata() { + return metadata; + } + + public void setMetadata(PortfolioStakingMetadata metadata) { + this.metadata = metadata; + } + + public static class Builder { + private String portfolioId; + private String idempotencyKey; + private String currencySymbol; + private String amount; + private PortfolioStakingMetadata metadata; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + public Builder metadata(PortfolioStakingMetadata metadata) { + this.metadata = metadata; + return this; + } + + public CreatePortfolioStakeRequest build() throws CoinbaseClientException { + validate(); + return new CreatePortfolioStakeRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java new file mode 100644 index 00000000..a975cc08 --- /dev/null +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request to stake currency in a portfolio + */ +public class CreatePortfolioStakeResponse { + @JsonProperty("activity_id") + private String activityId; + + @JsonProperty("transaction_id") + private String transactionId; + + public CreatePortfolioStakeResponse() { + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + +} diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java new file mode 100644 index 00000000..271ff9a8 --- /dev/null +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java @@ -0,0 +1,143 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.PortfolioStakingMetadata; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Request to unstake currency across a portfolio + */ +public class CreatePortfolioUnstakeRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty("idempotency_key") + private String idempotencyKey; + + @JsonProperty("currency_symbol") + private String currencySymbol; + + @JsonProperty("amount") + private String amount; + + @JsonProperty("metadata") + private PortfolioStakingMetadata metadata; + + public CreatePortfolioUnstakeRequest() { + } + + public CreatePortfolioUnstakeRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.idempotencyKey = builder.idempotencyKey; + this.currencySymbol = builder.currencySymbol; + this.amount = builder.amount; + this.metadata = builder.metadata; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getIdempotencyKey() { + return idempotencyKey; + } + + public void setIdempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + } + + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public PortfolioStakingMetadata getMetadata() { + return metadata; + } + + public void setMetadata(PortfolioStakingMetadata metadata) { + this.metadata = metadata; + } + + public static class Builder { + private String portfolioId; + private String idempotencyKey; + private String currencySymbol; + private String amount; + private PortfolioStakingMetadata metadata; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + public Builder metadata(PortfolioStakingMetadata metadata) { + this.metadata = metadata; + return this; + } + + public CreatePortfolioUnstakeRequest build() throws CoinbaseClientException { + validate(); + return new CreatePortfolioUnstakeRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java new file mode 100644 index 00000000..7a8aeaf7 --- /dev/null +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java @@ -0,0 +1,50 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request to unstake currency across a portfolio + */ +public class CreatePortfolioUnstakeResponse { + @JsonProperty("activity_id") + private String activityId; + + @JsonProperty("transaction_id") + private String transactionId; + + public CreatePortfolioUnstakeResponse() { + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + +} diff --git a/src/main/java/com/coinbase/prime/staking/CreateStakeRequest.java b/src/main/java/com/coinbase/prime/staking/CreateStakeRequest.java index 50d6c0c9..13554bc1 100644 --- a/src/main/java/com/coinbase/prime/staking/CreateStakeRequest.java +++ b/src/main/java/com/coinbase/prime/staking/CreateStakeRequest.java @@ -16,22 +16,29 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.WalletStakeInputs; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Request to stake or delegate a wallet + */ public class CreateStakeRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonIgnore @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore private String walletId; @JsonProperty("idempotency_key") private String idempotencyKey; + @JsonProperty("inputs") private WalletStakeInputs inputs; public CreateStakeRequest() { @@ -105,8 +112,18 @@ public Builder inputs(WalletStakeInputs inputs) { return this; } - public CreateStakeRequest build() { + public CreateStakeRequest build() throws CoinbaseClientException { + validate(); return new CreateStakeRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/staking/CreateStakeResponse.java b/src/main/java/com/coinbase/prime/staking/CreateStakeResponse.java index 02ac8b10..6cf169c2 100644 --- a/src/main/java/com/coinbase/prime/staking/CreateStakeResponse.java +++ b/src/main/java/com/coinbase/prime/staking/CreateStakeResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Request to stake or delegate a wallet + */ public class CreateStakeResponse { @JsonProperty("wallet_id") private String walletId; diff --git a/src/main/java/com/coinbase/prime/staking/CreateUnstakeRequest.java b/src/main/java/com/coinbase/prime/staking/CreateUnstakeRequest.java index 082ed8a9..36d37f08 100644 --- a/src/main/java/com/coinbase/prime/staking/CreateUnstakeRequest.java +++ b/src/main/java/com/coinbase/prime/staking/CreateUnstakeRequest.java @@ -16,28 +16,35 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.WalletUnstakeInputs; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Request to unstake a wallet + */ public class CreateUnstakeRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonIgnore @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore private String walletId; @JsonProperty("idempotency_key") private String idempotencyKey; + @JsonProperty("inputs") private WalletUnstakeInputs inputs; public CreateUnstakeRequest() { } - public CreateUnstakeRequest(CreateUnstakeRequest.Builder builder) { + public CreateUnstakeRequest(Builder builder) { this.portfolioId = builder.portfolioId; this.walletId = builder.walletId; this.idempotencyKey = builder.idempotencyKey; @@ -85,28 +92,38 @@ public static class Builder { public Builder() { } - public CreateUnstakeRequest.Builder portfolioId(String portfolioId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; return this; } - public CreateUnstakeRequest.Builder walletId(String walletId) { + public Builder walletId(String walletId) { this.walletId = walletId; return this; } - public CreateUnstakeRequest.Builder idempotencyKey(String idempotencyKey) { + public Builder idempotencyKey(String idempotencyKey) { this.idempotencyKey = idempotencyKey; return this; } - public CreateUnstakeRequest.Builder inputs(WalletUnstakeInputs inputs) { + public Builder inputs(WalletUnstakeInputs inputs) { this.inputs = inputs; return this; } - public CreateUnstakeRequest build() { + public CreateUnstakeRequest build() throws CoinbaseClientException { + validate(); return new CreateUnstakeRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/staking/CreateUnstakeResponse.java b/src/main/java/com/coinbase/prime/staking/CreateUnstakeResponse.java index 03a312a0..515e2bfd 100644 --- a/src/main/java/com/coinbase/prime/staking/CreateUnstakeResponse.java +++ b/src/main/java/com/coinbase/prime/staking/CreateUnstakeResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Request to unstake a wallet + */ public class CreateUnstakeResponse { @JsonProperty("wallet_id") private String walletId; diff --git a/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java b/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java index cd673386..38ead00e 100644 --- a/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java +++ b/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,22 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Staking Status + */ public class GetStakingStatusRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonIgnore @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore private String walletId; public GetStakingStatusRequest() { @@ -69,8 +75,18 @@ public Builder walletId(String walletId) { return this; } - public GetStakingStatusRequest build() { + public GetStakingStatusRequest build() throws CoinbaseClientException { + validate(); return new GetStakingStatusRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java b/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java index df31ee38..ba05e5f7 100644 --- a/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java +++ b/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,9 @@ import com.coinbase.prime.model.ValidatorStakingInfo; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - +/** + * Get Staking Status + */ public class GetStakingStatusResponse { @JsonProperty("portfolio_id") private String portfolioId; @@ -35,7 +36,7 @@ public class GetStakingStatusResponse { private String currentTimestamp; @JsonProperty("validators") - private List validators; + private ValidatorStakingInfo[] validators; public GetStakingStatusResponse() { } @@ -72,11 +73,12 @@ public void setCurrentTimestamp(String currentTimestamp) { this.currentTimestamp = currentTimestamp; } - public List getValidators() { + public ValidatorStakingInfo[] getValidators() { return validators; } - public void setValidators(List validators) { + public void setValidators(ValidatorStakingInfo[] validators) { this.validators = validators; } + } diff --git a/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusRequest.java b/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusRequest.java index d24f5e92..16627772 100644 --- a/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusRequest.java +++ b/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusRequest.java @@ -16,16 +16,22 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Get Unstaking Status + */ public class GetUnstakingStatusRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonIgnore @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore private String walletId; public GetUnstakingStatusRequest() { @@ -69,8 +75,18 @@ public Builder walletId(String walletId) { return this; } - public GetUnstakingStatusRequest build() { + public GetUnstakingStatusRequest build() throws CoinbaseClientException { + validate(); return new GetUnstakingStatusRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusResponse.java b/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusResponse.java index 4c0857b8..92558892 100644 --- a/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusResponse.java +++ b/src/main/java/com/coinbase/prime/staking/GetUnstakingStatusResponse.java @@ -19,8 +19,9 @@ import com.coinbase.prime.model.ValidatorUnstakingInfo; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - +/** + * Get Unstaking Status + */ public class GetUnstakingStatusResponse { @JsonProperty("portfolio_id") private String portfolioId; @@ -35,7 +36,7 @@ public class GetUnstakingStatusResponse { private String currentTimestamp; @JsonProperty("validators") - private List validators; + private ValidatorUnstakingInfo[] validators; public GetUnstakingStatusResponse() { } @@ -72,11 +73,12 @@ public void setCurrentTimestamp(String currentTimestamp) { this.currentTimestamp = currentTimestamp; } - public List getValidators() { + public ValidatorUnstakingInfo[] getValidators() { return validators; } - public void setValidators(List validators) { + public void setValidators(ValidatorUnstakingInfo[] validators) { this.validators = validators; } + } diff --git a/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsRequest.java b/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsRequest.java index 2ee05288..d26c1775 100644 --- a/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsRequest.java +++ b/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsRequest.java @@ -16,30 +16,42 @@ package com.coinbase.prime.staking; -import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * Request object for listing transaction validators. + * List Transaction Validators */ -public class ListTransactionValidatorsRequest extends PrimeListRequest { - @JsonIgnore +public class ListTransactionValidatorsRequest { @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonProperty(required = true, value = "transaction_ids") - private List transactionIds; + @JsonProperty("transaction_ids") + private String[] transactionIds; + + @JsonProperty("cursor") + private String cursor; + + @JsonProperty("limit") + private Integer limit; + + @JsonProperty("sort_direction") + private SortDirection sortDirection; public ListTransactionValidatorsRequest() { } public ListTransactionValidatorsRequest(Builder builder) { - super(builder.cursor, builder.sortDirection, builder.limit); this.portfolioId = builder.portfolioId; this.transactionIds = builder.transactionIds; + this.cursor = builder.cursor; + this.limit = builder.limit; + this.sortDirection = builder.sortDirection; } public String getPortfolioId() { @@ -50,17 +62,41 @@ public void setPortfolioId(String portfolioId) { this.portfolioId = portfolioId; } - public List getTransactionIds() { + public String[] getTransactionIds() { return transactionIds; } - public void setTransactionIds(List transactionIds) { + public void setTransactionIds(String[] transactionIds) { this.transactionIds = transactionIds; } + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public SortDirection getSortDirection() { + return sortDirection; + } + + public void setSortDirection(SortDirection sortDirection) { + this.sortDirection = sortDirection; + } + public static class Builder { private String portfolioId; - private List transactionIds; + private String[] transactionIds; private String cursor; private Integer limit; private SortDirection sortDirection; @@ -73,7 +109,7 @@ public Builder portfolioId(String portfolioId) { return this; } - public Builder transactionIds(List transactionIds) { + public Builder transactionIds(String[] transactionIds) { this.transactionIds = transactionIds; return this; } @@ -93,9 +129,15 @@ public Builder sortDirection(SortDirection sortDirection) { return this; } - public ListTransactionValidatorsRequest build() { + public ListTransactionValidatorsRequest build() throws CoinbaseClientException { + validate(); return new ListTransactionValidatorsRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } } - diff --git a/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsResponse.java b/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsResponse.java index 3f867ccb..4bdf1b4b 100644 --- a/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsResponse.java +++ b/src/main/java/com/coinbase/prime/staking/ListTransactionValidatorsResponse.java @@ -19,14 +19,13 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.TransactionValidator; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; /** - * Response object for listing transaction validators. + * List Transaction Validators */ public class ListTransactionValidatorsResponse { @JsonProperty("transaction_validators") - private List transactionValidators; + private TransactionValidator[] transactionValidators; @JsonProperty("pagination") private Pagination pagination; @@ -34,11 +33,11 @@ public class ListTransactionValidatorsResponse { public ListTransactionValidatorsResponse() { } - public List getTransactionValidators() { + public TransactionValidator[] getTransactionValidators() { return transactionValidators; } - public void setTransactionValidators(List transactionValidators) { + public void setTransactionValidators(TransactionValidator[] transactionValidators) { this.transactionValidators = transactionValidators; } @@ -49,5 +48,5 @@ public Pagination getPagination() { public void setPagination(Pagination pagination) { this.pagination = pagination; } -} +} diff --git a/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateRequest.java b/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateRequest.java index 1bebeca2..877f28f7 100644 --- a/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateRequest.java +++ b/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateRequest.java @@ -16,13 +16,19 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.PortfolioStakingMetadata; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Request to stake currency in a portfolio + */ public class PortfolioStakingInitiateRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; @JsonProperty("idempotency_key") @@ -123,8 +129,15 @@ public Builder metadata(PortfolioStakingMetadata metadata) { return this; } - public PortfolioStakingInitiateRequest build() { + public PortfolioStakingInitiateRequest build() throws CoinbaseClientException { + validate(); return new PortfolioStakingInitiateRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateResponse.java b/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateResponse.java index a83289fc..1e202965 100644 --- a/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateResponse.java +++ b/src/main/java/com/coinbase/prime/staking/PortfolioStakingInitiateResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Request to stake currency in a portfolio + */ public class PortfolioStakingInitiateResponse { @JsonProperty("activity_id") private String activityId; diff --git a/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeRequest.java b/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeRequest.java index fd0a6564..67bda460 100644 --- a/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeRequest.java +++ b/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeRequest.java @@ -16,13 +16,19 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.PortfolioStakingMetadata; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Request to unstake currency across a portfolio + */ public class PortfolioStakingUnstakeRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; @JsonProperty("idempotency_key") @@ -123,8 +129,15 @@ public Builder metadata(PortfolioStakingMetadata metadata) { return this; } - public PortfolioStakingUnstakeRequest build() { + public PortfolioStakingUnstakeRequest build() throws CoinbaseClientException { + validate(); return new PortfolioStakingUnstakeRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeResponse.java b/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeResponse.java index 28914e47..4bf3a226 100644 --- a/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeResponse.java +++ b/src/main/java/com/coinbase/prime/staking/PortfolioStakingUnstakeResponse.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Request to unstake currency across a portfolio + */ public class PortfolioStakingUnstakeResponse { @JsonProperty("activity_id") private String activityId; diff --git a/src/main/java/com/coinbase/prime/staking/PreviewUnstakeRequest.java b/src/main/java/com/coinbase/prime/staking/PreviewUnstakeRequest.java index 990e4d5f..ea707c3b 100644 --- a/src/main/java/com/coinbase/prime/staking/PreviewUnstakeRequest.java +++ b/src/main/java/com/coinbase/prime/staking/PreviewUnstakeRequest.java @@ -16,16 +16,22 @@ package com.coinbase.prime.staking; +import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Preview Unstake + */ public class PreviewUnstakeRequest { - @JsonIgnore @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore private String portfolioId; - @JsonIgnore @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore private String walletId; @JsonProperty("amount") @@ -87,8 +93,18 @@ public Builder amount(String amount) { return this; } - public PreviewUnstakeRequest build() { + public PreviewUnstakeRequest build() throws CoinbaseClientException { + validate(); return new PreviewUnstakeRequest(this); } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } } } diff --git a/src/main/java/com/coinbase/prime/staking/PreviewUnstakeResponse.java b/src/main/java/com/coinbase/prime/staking/PreviewUnstakeResponse.java index ba1ae30a..33750a9d 100644 --- a/src/main/java/com/coinbase/prime/staking/PreviewUnstakeResponse.java +++ b/src/main/java/com/coinbase/prime/staking/PreviewUnstakeResponse.java @@ -16,12 +16,28 @@ package com.coinbase.prime.staking; +import com.coinbase.prime.model.ValidatorUnstakePreview; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Preview Unstake + */ public class PreviewUnstakeResponse { @JsonProperty("estimated_amount") private String estimatedAmount; + @JsonProperty("wallet_id") + private String walletId; + + @JsonProperty("wallet_address") + private String walletAddress; + + @JsonProperty("current_timestamp") + private String currentTimestamp; + + @JsonProperty("validators") + private ValidatorUnstakePreview[] validators; + public PreviewUnstakeResponse() { } @@ -32,4 +48,37 @@ public String getEstimatedAmount() { public void setEstimatedAmount(String estimatedAmount) { this.estimatedAmount = estimatedAmount; } + + public String getWalletId() { + return walletId; + } + + public void setWalletId(String walletId) { + this.walletId = walletId; + } + + public String getWalletAddress() { + return walletAddress; + } + + public void setWalletAddress(String walletAddress) { + this.walletAddress = walletAddress; + } + + public String getCurrentTimestamp() { + return currentTimestamp; + } + + public void setCurrentTimestamp(String currentTimestamp) { + this.currentTimestamp = currentTimestamp; + } + + public ValidatorUnstakePreview[] getValidators() { + return validators; + } + + public void setValidators(ValidatorUnstakePreview[] validators) { + this.validators = validators; + } + } diff --git a/src/main/java/com/coinbase/prime/staking/StakingService.java b/src/main/java/com/coinbase/prime/staking/StakingService.java index 64d32d22..f28d2d22 100644 --- a/src/main/java/com/coinbase/prime/staking/StakingService.java +++ b/src/main/java/com/coinbase/prime/staking/StakingService.java @@ -20,13 +20,22 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface StakingService { + /** Claim Wallet Staking Rewards (Alpha) */ ClaimRewardsResponse claimRewards(ClaimRewardsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Request to stake or delegate a wallet */ CreateStakeResponse createStake(CreateStakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Request to unstake a wallet */ CreateUnstakeResponse createUnstake(CreateUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Transaction Validators */ ListTransactionValidatorsResponse listTransactionValidators(ListTransactionValidatorsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Request to stake currency in a portfolio */ PortfolioStakingInitiateResponse portfolioStakingInitiate(PortfolioStakingInitiateRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Request to unstake currency across a portfolio */ PortfolioStakingUnstakeResponse portfolioStakingUnstake(PortfolioStakingUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; - PreviewUnstakeResponse previewUnstake(PreviewUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; - GetUnstakingStatusResponse getUnstakingStatus(GetUnstakingStatusRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Staking Status */ GetStakingStatusResponse getStakingStatus(GetStakingStatusRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Unstaking Status */ + GetUnstakingStatusResponse getUnstakingStatus(GetUnstakingStatusRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Preview Unstake */ + PreviewUnstakeResponse previewUnstake(PreviewUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/staking/StakingServiceImpl.java b/src/main/java/com/coinbase/prime/staking/StakingServiceImpl.java index cc68578e..774ea729 100644 --- a/src/main/java/com/coinbase/prime/staking/StakingServiceImpl.java +++ b/src/main/java/com/coinbase/prime/staking/StakingServiceImpl.java @@ -19,6 +19,7 @@ import com.coinbase.core.common.HttpMethod; import com.coinbase.core.service.CoinbaseServiceImpl; import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.errors.CoinbasePrimeException; import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; @@ -29,27 +30,37 @@ public StakingServiceImpl(CoinbasePrimeClient client) { } @Override - public CreateStakeResponse createStake(CreateStakeRequest request) { + public ClaimRewardsResponse claimRewards(ClaimRewardsRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.POST, + String.format("/portfolios/%s/wallets/%s/staking/claim_rewards", request.getPortfolioId(), request.getWalletId()), + request, + List.of(201, 200), + new TypeReference() {}); + } + + @Override + public CreateStakeResponse createStake(CreateStakeRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/wallets/%s/staking/initiate", request.getPortfolioId(), request.getWalletId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @Override - public CreateUnstakeResponse createUnstake(CreateUnstakeRequest request) { + public CreateUnstakeResponse createUnstake(CreateUnstakeRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/wallets/%s/staking/unstake", request.getPortfolioId(), request.getWalletId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @Override - public ListTransactionValidatorsResponse listTransactionValidators(ListTransactionValidatorsRequest request) { + public ListTransactionValidatorsResponse listTransactionValidators(ListTransactionValidatorsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/staking/transaction-validators/query", request.getPortfolioId()), @@ -59,47 +70,37 @@ public ListTransactionValidatorsResponse listTransactionValidators(ListTransacti } @Override - public PortfolioStakingInitiateResponse portfolioStakingInitiate(PortfolioStakingInitiateRequest request) { + public PortfolioStakingInitiateResponse portfolioStakingInitiate(PortfolioStakingInitiateRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/staking/initiate", request.getPortfolioId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @Override - public PortfolioStakingUnstakeResponse portfolioStakingUnstake(PortfolioStakingUnstakeRequest request) { + public PortfolioStakingUnstakeResponse portfolioStakingUnstake(PortfolioStakingUnstakeRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/staking/unstake", request.getPortfolioId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @Override - public ClaimRewardsResponse claimRewards(ClaimRewardsRequest request) { + public GetStakingStatusResponse getStakingStatus(GetStakingStatusRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, - String.format("/portfolios/%s/wallets/%s/staking/claim_rewards", request.getPortfolioId(), request.getWalletId()), - request, - List.of(200), - new TypeReference() {}); - } - - @Override - public PreviewUnstakeResponse previewUnstake(PreviewUnstakeRequest request) { - return this.request( - HttpMethod.POST, - String.format("/portfolios/%s/wallets/%s/staking/unstake/preview", request.getPortfolioId(), request.getWalletId()), + HttpMethod.GET, + String.format("/portfolios/%s/wallets/%s/staking/status", request.getPortfolioId(), request.getWalletId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public GetUnstakingStatusResponse getUnstakingStatus(GetUnstakingStatusRequest request) { + public GetUnstakingStatusResponse getUnstakingStatus(GetUnstakingStatusRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, String.format("/portfolios/%s/wallets/%s/staking/unstake/status", request.getPortfolioId(), request.getWalletId()), @@ -109,12 +110,13 @@ public GetUnstakingStatusResponse getUnstakingStatus(GetUnstakingStatusRequest r } @Override - public GetStakingStatusResponse getStakingStatus(GetStakingStatusRequest request) { + public PreviewUnstakeResponse previewUnstake(PreviewUnstakeRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, - String.format("/portfolios/%s/wallets/%s/staking/status", request.getPortfolioId(), request.getWalletId()), + HttpMethod.POST, + String.format("/portfolios/%s/wallets/%s/staking/unstake/preview", request.getPortfolioId(), request.getWalletId()), request, - List.of(200), - new TypeReference() {}); + List.of(201, 200), + new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateConversionRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateConversionRequest.java index af2fa1cc..14af896f 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateConversionRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateConversionRequest.java @@ -20,23 +20,32 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.UUID; - import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Conversion + */ public class CreateConversionRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; + + @JsonProperty("amount") private String amount; + + @JsonProperty("destination") private String destination; + @JsonProperty("idempotency_key") private String idempotencyKey; + @JsonProperty("source_symbol") private String sourceSymbol; + @JsonProperty("destination_symbol") private String destinationSymbol; @@ -157,26 +166,16 @@ public Builder destinationSymbol(String destinationSymbol) { } public CreateConversionRequest build() throws CoinbaseClientException { - this.validate(); - if (isNullOrEmpty(this.idempotencyKey)) { - this.idempotencyKey(UUID.randomUUID().toString()); - } + validate(); return new CreateConversionRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.walletId)) { - throw new CoinbaseClientException("WalletId cannot be null"); - } - if (isNullOrEmpty(this.amount)) { - throw new CoinbaseClientException("Amount cannot be null"); - } - if (isNullOrEmpty(this.destination)) { - throw new CoinbaseClientException("Destination cannot be null"); + throw new CoinbaseClientException("WalletId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateConversionResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateConversionResponse.java index a2d11301..9d091398 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateConversionResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateConversionResponse.java @@ -18,16 +18,28 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Create Conversion + */ public class CreateConversionResponse { @JsonProperty("activity_id") private String activityId; + @JsonProperty("source_symbol") private String sourceSymbol; + @JsonProperty("destination_symbol") private String destinationSymbol; + + @JsonProperty("amount") private String amount; + + @JsonProperty("destination") private String destination; + + @JsonProperty("source") private String source; + @JsonProperty("transaction_id") private String transactionId; diff --git a/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionRequest.java index fea915a1..f9ff5eba 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionRequest.java @@ -16,14 +16,17 @@ package com.coinbase.prime.transactions; +import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.EvmParams; import com.coinbase.prime.model.RpcConfig; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.coinbase.core.errors.CoinbaseClientException; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Onchain Transaction + */ public class CreateOnchainTransactionRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -36,6 +39,7 @@ public class CreateOnchainTransactionRequest { @JsonProperty("raw_unsigned_txn") private String rawUnsignedTxn; + @JsonProperty("rpc") private RpcConfig rpc; @JsonProperty("evm_params") @@ -127,24 +131,17 @@ public Builder evmParams(EvmParams evmParams) { return this; } - public CreateOnchainTransactionRequest build() { - this.validate(); + public CreateOnchainTransactionRequest build() throws CoinbaseClientException { + validate(); return new CreateOnchainTransactionRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } if (isNullOrEmpty(this.walletId)) { - throw new CoinbaseClientException("WalletId cannot be null"); - } - - if (isNullOrEmpty(this.rawUnsignedTxn)) { - throw new CoinbaseClientException("RawUnsignedTxn cannot be null"); - } - if (this.rpc == null) { - throw new CoinbaseClientException("Rpc cannot be null"); + throw new CoinbaseClientException("WalletId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionResponse.java index c6ac74d9..ef96b4e3 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateOnchainTransactionResponse.java @@ -19,12 +19,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for creating an on-chain transaction. - * - * Contains the transaction ID for the newly created on-chain transaction. + * Create Onchain Transaction */ public class CreateOnchainTransactionResponse { - /** Unique identifier for the created transaction */ @JsonProperty("transaction_id") private String transactionId; diff --git a/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java new file mode 100644 index 00000000..edc02967 --- /dev/null +++ b/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java @@ -0,0 +1,164 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.transactions; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Create Transfer + */ +public class CreateTransferRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore + private String walletId; + + @JsonProperty("amount") + private String amount; + + @JsonProperty("destination") + private String destination; + + @JsonProperty("idempotency_key") + private String idempotencyKey; + + @JsonProperty("currency_symbol") + private String currencySymbol; + + public CreateTransferRequest() { + } + + public CreateTransferRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.walletId = builder.walletId; + this.amount = builder.amount; + this.destination = builder.destination; + this.idempotencyKey = builder.idempotencyKey; + this.currencySymbol = builder.currencySymbol; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getWalletId() { + return walletId; + } + + public void setWalletId(String walletId) { + this.walletId = walletId; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public String getDestination() { + return destination; + } + + public void setDestination(String destination) { + this.destination = destination; + } + + public String getIdempotencyKey() { + return idempotencyKey; + } + + public void setIdempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + } + + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + + public static class Builder { + private String portfolioId; + private String walletId; + private String amount; + private String destination; + private String idempotencyKey; + private String currencySymbol; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder walletId(String walletId) { + this.walletId = walletId; + return this; + } + + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + public Builder destination(String destination) { + this.destination = destination; + return this; + } + + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + + public CreateTransferRequest build() throws CoinbaseClientException { + validate(); + return new CreateTransferRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java new file mode 100644 index 00000000..9b612b0d --- /dev/null +++ b/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java @@ -0,0 +1,138 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.transactions; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Create Transfer + */ +public class CreateTransferResponse { + @JsonProperty("activity_id") + private String activityId; + + @JsonProperty("approval_url") + private String approvalUrl; + + @JsonProperty("symbol") + private String symbol; + + @JsonProperty("amount") + private String amount; + + @JsonProperty("fee") + private String fee; + + @JsonProperty("destination_address") + private String destinationAddress; + + @JsonProperty("destination_type") + private String destinationType; + + @JsonProperty("source_address") + private String sourceAddress; + + @JsonProperty("source_type") + private String sourceType; + + @JsonProperty("transaction_id") + private String transactionId; + + public CreateTransferResponse() { + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + public String getApprovalUrl() { + return approvalUrl; + } + + public void setApprovalUrl(String approvalUrl) { + this.approvalUrl = approvalUrl; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public String getFee() { + return fee; + } + + public void setFee(String fee) { + this.fee = fee; + } + + public String getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + } + + public String getDestinationType() { + return destinationType; + } + + public void setDestinationType(String destinationType) { + this.destinationType = destinationType; + } + + public String getSourceAddress() { + return sourceAddress; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + +} diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferRequest.java index a357991d..a376f21b 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferRequest.java @@ -20,23 +20,32 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; -import java.util.UUID; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Transfer + */ public class CreateWalletTransferRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; + + @JsonProperty("amount") private String amount; - @JsonProperty("currency_symbol") - private String currencySymbol; + + @JsonProperty("destination") private String destination; + @JsonProperty("idempotency_key") private String idempotencyKey; + @JsonProperty("currency_symbol") + private String currencySymbol; + public CreateWalletTransferRequest() { } @@ -44,9 +53,9 @@ public CreateWalletTransferRequest(Builder builder) { this.portfolioId = builder.portfolioId; this.walletId = builder.walletId; this.amount = builder.amount; - this.currencySymbol = builder.currencySymbol; this.destination = builder.destination; this.idempotencyKey = builder.idempotencyKey; + this.currencySymbol = builder.currencySymbol; } public String getPortfolioId() { @@ -73,14 +82,6 @@ public void setAmount(String amount) { this.amount = amount; } - public String getCurrencySymbol() { - return currencySymbol; - } - - public void setCurrencySymbol(String currencySymbol) { - this.currencySymbol = currencySymbol; - } - public String getDestination() { return destination; } @@ -97,26 +98,37 @@ public void setIdempotencyKey(String idempotencyKey) { this.idempotencyKey = idempotencyKey; } + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + public static class Builder { - private final String portfolioId; - private final String walletId; + private String portfolioId; + private String walletId; private String amount; - private String currencySymbol; private String destination; private String idempotencyKey; + private String currencySymbol; + + public Builder() { + } - public Builder(String portfolioId, String walletId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; - this.walletId = walletId; + return this; } - public Builder amount(String amount) { - this.amount = amount; + public Builder walletId(String walletId) { + this.walletId = walletId; return this; } - public Builder currencySymbol(String currencySymbol) { - this.currencySymbol = currencySymbol; + public Builder amount(String amount) { + this.amount = amount; return this; } @@ -130,11 +142,13 @@ public Builder idempotencyKey(String idempotencyKey) { return this; } + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + public CreateWalletTransferRequest build() throws CoinbaseClientException { - this.validate(); - if (isNullOrEmpty(this.idempotencyKey)) { - this.idempotencyKey(UUID.randomUUID().toString()); - } + validate(); return new CreateWalletTransferRequest(this); } @@ -145,15 +159,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.walletId)) { throw new CoinbaseClientException("WalletId is required"); } - if (isNullOrEmpty(this.amount)) { - throw new CoinbaseClientException("Amount is required"); - } - if (isNullOrEmpty(this.currencySymbol)) { - throw new CoinbaseClientException("Currency symbol is required"); - } - if (isNullOrEmpty(this.destination)) { - throw new CoinbaseClientException("Destination is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferResponse.java index e864ce50..431b6a10 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateWalletTransferResponse.java @@ -16,41 +16,39 @@ package com.coinbase.prime.transactions; -import com.coinbase.prime.model.enums.DestinationType; import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for creating a wallet transfer. - * - * Contains the details of the transfer request including activity ID, approval URL, - * transfer amounts, addresses, and transaction information. + * Create Transfer */ public class CreateWalletTransferResponse { - /** The activity ID for the transfer */ @JsonProperty("activity_id") private String activityId; - /** A URL to the activity associated with this transfer for approval */ + @JsonProperty("approval_url") private String approvalUrl; - /** The symbol of the transferred asset */ + + @JsonProperty("symbol") private String symbol; - /** The amount being transferred */ + + @JsonProperty("amount") private String amount; - /** The fee associated with the transfer */ + + @JsonProperty("fee") private String fee; - /** The destination address for the transfer */ + @JsonProperty("destination_address") private String destinationAddress; - /** The type of the destination (e.g., WALLET, EXCHANGE) */ + @JsonProperty("destination_type") - private DestinationType destinationType; - /** The source address for the transfer */ + private String destinationType; + @JsonProperty("source_address") private String sourceAddress; - /** The type of the source (e.g., WALLET, EXCHANGE) */ + @JsonProperty("source_type") - private DestinationType sourceType; - /** The unique identifier for the transfer transaction */ + private String sourceType; + @JsonProperty("transaction_id") private String transactionId; @@ -105,11 +103,11 @@ public void setDestinationAddress(String destinationAddress) { this.destinationAddress = destinationAddress; } - public DestinationType getDestinationType() { + public String getDestinationType() { return destinationType; } - public void setDestinationType(DestinationType destinationType) { + public void setDestinationType(String destinationType) { this.destinationType = destinationType; } @@ -121,11 +119,11 @@ public void setSourceAddress(String sourceAddress) { this.sourceAddress = sourceAddress; } - public DestinationType getSourceType() { + public String getSourceType() { return sourceType; } - public void setSourceType(DestinationType sourceType) { + public void setSourceType(String sourceType) { this.sourceType = sourceType; } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalRequest.java index c9232b3d..0510366b 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalRequest.java @@ -25,28 +25,41 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; -import java.util.UUID; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Withdrawal + */ public class CreateWalletWithdrawalRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; + + @JsonProperty("amount") private String amount; - @JsonProperty("currency_symbol") - private String currencySymbol; + @JsonProperty("destination_type") private DestinationType destinationType; + @JsonProperty("idempotency_key") private String idempotencyKey; + + @JsonProperty("currency_symbol") + private String currencySymbol; + @JsonProperty("payment_method") private PaymentMethodDestination paymentMethod; + @JsonProperty("blockchain_address") private BlockchainAddress blockchainAddress; + + @JsonProperty("counterparty") private CounterpartyDestination counterparty; + @JsonProperty("travel_rule_data") private TravelRuleData travelRuleData; @@ -57,9 +70,9 @@ public CreateWalletWithdrawalRequest(Builder builder) { this.portfolioId = builder.portfolioId; this.walletId = builder.walletId; this.amount = builder.amount; - this.currencySymbol = builder.currencySymbol; this.destinationType = builder.destinationType; this.idempotencyKey = builder.idempotencyKey; + this.currencySymbol = builder.currencySymbol; this.paymentMethod = builder.paymentMethod; this.blockchainAddress = builder.blockchainAddress; this.counterparty = builder.counterparty; @@ -90,14 +103,6 @@ public void setAmount(String amount) { this.amount = amount; } - public String getCurrencySymbol() { - return currencySymbol; - } - - public void setCurrencySymbol(String currencySymbol) { - this.currencySymbol = currencySymbol; - } - public DestinationType getDestinationType() { return destinationType; } @@ -114,6 +119,14 @@ public void setIdempotencyKey(String idempotencyKey) { this.idempotencyKey = idempotencyKey; } + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + public PaymentMethodDestination getPaymentMethod() { return paymentMethod; } @@ -147,29 +160,32 @@ public void setTravelRuleData(TravelRuleData travelRuleData) { } public static class Builder { - private final String portfolioId; - private final String walletId; + private String portfolioId; + private String walletId; private String amount; - private String currencySymbol; private DestinationType destinationType; private String idempotencyKey; + private String currencySymbol; private PaymentMethodDestination paymentMethod; private BlockchainAddress blockchainAddress; private CounterpartyDestination counterparty; private TravelRuleData travelRuleData; - public Builder(String portfolioId, String walletId) { + public Builder() { + } + + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; - this.walletId = walletId; + return this; } - public Builder amount(String amount) { - this.amount = amount; + public Builder walletId(String walletId) { + this.walletId = walletId; return this; } - public Builder currencySymbol(String currencySymbol) { - this.currencySymbol = currencySymbol; + public Builder amount(String amount) { + this.amount = amount; return this; } @@ -183,6 +199,11 @@ public Builder idempotencyKey(String idempotencyKey) { return this; } + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + public Builder paymentMethod(PaymentMethodDestination paymentMethod) { this.paymentMethod = paymentMethod; return this; @@ -204,10 +225,7 @@ public Builder travelRuleData(TravelRuleData travelRuleData) { } public CreateWalletWithdrawalRequest build() throws CoinbaseClientException { - this.validate(); - if (isNullOrEmpty(this.idempotencyKey)) { - this.idempotencyKey(UUID.randomUUID().toString()); - } + validate(); return new CreateWalletWithdrawalRequest(this); } @@ -218,15 +236,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.walletId)) { throw new CoinbaseClientException("WalletId is required"); } - if (isNullOrEmpty(this.amount)) { - throw new CoinbaseClientException("Amount is required"); - } - if (isNullOrEmpty(this.currencySymbol)) { - throw new CoinbaseClientException("Currency symbol is required"); - } - if (this.destinationType == null) { - throw new CoinbaseClientException("Destination type is required"); - } } } } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalResponse.java index 90d8539a..f2d4ba94 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateWalletWithdrawalResponse.java @@ -18,27 +18,42 @@ import com.coinbase.prime.model.BlockchainAddress; import com.coinbase.prime.model.CounterpartyDestination; -import com.coinbase.prime.model.enums.DestinationType; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Create Withdrawal + */ public class CreateWalletWithdrawalResponse { @JsonProperty("activity_id") private String activityId; + @JsonProperty("approval_url") private String approvalUrl; + + @JsonProperty("symbol") private String symbol; + + @JsonProperty("amount") private String amount; + + @JsonProperty("fee") private String fee; + @JsonProperty("destination_type") - private DestinationType destinationType; + private String destinationType; + @JsonProperty("source_type") - private DestinationType sourceType; + private String sourceType; + @JsonProperty("blockchain_destination") private BlockchainAddress blockchainDestination; + @JsonProperty("counterparty_destination") private CounterpartyDestination counterpartyDestination; + @JsonProperty("blockchain_source") private BlockchainAddress blockchainSource; + @JsonProperty("transaction_id") private String transactionId; @@ -85,19 +100,19 @@ public void setFee(String fee) { this.fee = fee; } - public DestinationType getDestinationType() { + public String getDestinationType() { return destinationType; } - public void setDestinationType(DestinationType destinationType) { + public void setDestinationType(String destinationType) { this.destinationType = destinationType; } - public DestinationType getSourceType() { + public String getSourceType() { return sourceType; } - public void setSourceType(DestinationType sourceType) { + public void setSourceType(String sourceType) { this.sourceType = sourceType; } diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java new file mode 100644 index 00000000..825ed385 --- /dev/null +++ b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java @@ -0,0 +1,241 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.transactions; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.BlockchainAddress; +import com.coinbase.prime.model.CounterpartyDestination; +import com.coinbase.prime.model.PaymentMethodDestination; +import com.coinbase.prime.model.TravelRuleData; +import com.coinbase.prime.model.enums.DestinationType; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * Create Withdrawal + */ +public class CreateWithdrawalRequest { + @JsonProperty(required = true, value = "portfolio_id") + @JsonIgnore + private String portfolioId; + + @JsonProperty(required = true, value = "wallet_id") + @JsonIgnore + private String walletId; + + @JsonProperty("amount") + private String amount; + + @JsonProperty("destination_type") + private DestinationType destinationType; + + @JsonProperty("idempotency_key") + private String idempotencyKey; + + @JsonProperty("currency_symbol") + private String currencySymbol; + + @JsonProperty("payment_method") + private PaymentMethodDestination paymentMethod; + + @JsonProperty("blockchain_address") + private BlockchainAddress blockchainAddress; + + @JsonProperty("counterparty") + private CounterpartyDestination counterparty; + + @JsonProperty("travel_rule_data") + private TravelRuleData travelRuleData; + + public CreateWithdrawalRequest() { + } + + public CreateWithdrawalRequest(Builder builder) { + this.portfolioId = builder.portfolioId; + this.walletId = builder.walletId; + this.amount = builder.amount; + this.destinationType = builder.destinationType; + this.idempotencyKey = builder.idempotencyKey; + this.currencySymbol = builder.currencySymbol; + this.paymentMethod = builder.paymentMethod; + this.blockchainAddress = builder.blockchainAddress; + this.counterparty = builder.counterparty; + this.travelRuleData = builder.travelRuleData; + } + + public String getPortfolioId() { + return portfolioId; + } + + public void setPortfolioId(String portfolioId) { + this.portfolioId = portfolioId; + } + + public String getWalletId() { + return walletId; + } + + public void setWalletId(String walletId) { + this.walletId = walletId; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public DestinationType getDestinationType() { + return destinationType; + } + + public void setDestinationType(DestinationType destinationType) { + this.destinationType = destinationType; + } + + public String getIdempotencyKey() { + return idempotencyKey; + } + + public void setIdempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + } + + public String getCurrencySymbol() { + return currencySymbol; + } + + public void setCurrencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + } + + public PaymentMethodDestination getPaymentMethod() { + return paymentMethod; + } + + public void setPaymentMethod(PaymentMethodDestination paymentMethod) { + this.paymentMethod = paymentMethod; + } + + public BlockchainAddress getBlockchainAddress() { + return blockchainAddress; + } + + public void setBlockchainAddress(BlockchainAddress blockchainAddress) { + this.blockchainAddress = blockchainAddress; + } + + public CounterpartyDestination getCounterparty() { + return counterparty; + } + + public void setCounterparty(CounterpartyDestination counterparty) { + this.counterparty = counterparty; + } + + public TravelRuleData getTravelRuleData() { + return travelRuleData; + } + + public void setTravelRuleData(TravelRuleData travelRuleData) { + this.travelRuleData = travelRuleData; + } + + public static class Builder { + private String portfolioId; + private String walletId; + private String amount; + private DestinationType destinationType; + private String idempotencyKey; + private String currencySymbol; + private PaymentMethodDestination paymentMethod; + private BlockchainAddress blockchainAddress; + private CounterpartyDestination counterparty; + private TravelRuleData travelRuleData; + + public Builder() { + } + + public Builder portfolioId(String portfolioId) { + this.portfolioId = portfolioId; + return this; + } + + public Builder walletId(String walletId) { + this.walletId = walletId; + return this; + } + + public Builder amount(String amount) { + this.amount = amount; + return this; + } + + public Builder destinationType(DestinationType destinationType) { + this.destinationType = destinationType; + return this; + } + + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + + public Builder currencySymbol(String currencySymbol) { + this.currencySymbol = currencySymbol; + return this; + } + + public Builder paymentMethod(PaymentMethodDestination paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + public Builder blockchainAddress(BlockchainAddress blockchainAddress) { + this.blockchainAddress = blockchainAddress; + return this; + } + + public Builder counterparty(CounterpartyDestination counterparty) { + this.counterparty = counterparty; + return this; + } + + public Builder travelRuleData(TravelRuleData travelRuleData) { + this.travelRuleData = travelRuleData; + return this; + } + + public CreateWithdrawalRequest build() throws CoinbaseClientException { + validate(); + return new CreateWithdrawalRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.portfolioId)) { + throw new CoinbaseClientException("PortfolioId is required"); + } + if (isNullOrEmpty(this.walletId)) { + throw new CoinbaseClientException("WalletId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java new file mode 100644 index 00000000..3d41b24d --- /dev/null +++ b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java @@ -0,0 +1,151 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.transactions; + +import com.coinbase.prime.model.BlockchainAddress; +import com.coinbase.prime.model.CounterpartyDestination; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Create Withdrawal + */ +public class CreateWithdrawalResponse { + @JsonProperty("activity_id") + private String activityId; + + @JsonProperty("approval_url") + private String approvalUrl; + + @JsonProperty("symbol") + private String symbol; + + @JsonProperty("amount") + private String amount; + + @JsonProperty("fee") + private String fee; + + @JsonProperty("destination_type") + private String destinationType; + + @JsonProperty("source_type") + private String sourceType; + + @JsonProperty("blockchain_destination") + private BlockchainAddress blockchainDestination; + + @JsonProperty("counterparty_destination") + private CounterpartyDestination counterpartyDestination; + + @JsonProperty("blockchain_source") + private BlockchainAddress blockchainSource; + + @JsonProperty("transaction_id") + private String transactionId; + + public CreateWithdrawalResponse() { + } + + public String getActivityId() { + return activityId; + } + + public void setActivityId(String activityId) { + this.activityId = activityId; + } + + public String getApprovalUrl() { + return approvalUrl; + } + + public void setApprovalUrl(String approvalUrl) { + this.approvalUrl = approvalUrl; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public String getFee() { + return fee; + } + + public void setFee(String fee) { + this.fee = fee; + } + + public String getDestinationType() { + return destinationType; + } + + public void setDestinationType(String destinationType) { + this.destinationType = destinationType; + } + + public String getSourceType() { + return sourceType; + } + + public void setSourceType(String sourceType) { + this.sourceType = sourceType; + } + + public BlockchainAddress getBlockchainDestination() { + return blockchainDestination; + } + + public void setBlockchainDestination(BlockchainAddress blockchainDestination) { + this.blockchainDestination = blockchainDestination; + } + + public CounterpartyDestination getCounterpartyDestination() { + return counterpartyDestination; + } + + public void setCounterpartyDestination(CounterpartyDestination counterpartyDestination) { + this.counterpartyDestination = counterpartyDestination; + } + + public BlockchainAddress getBlockchainSource() { + return blockchainSource; + } + + public void setBlockchainSource(BlockchainAddress blockchainSource) { + this.blockchainSource = blockchainSource; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + +} diff --git a/src/main/java/com/coinbase/prime/transactions/GetTransactionRequest.java b/src/main/java/com/coinbase/prime/transactions/GetTransactionRequest.java index f9ff6ae1..9513fc5c 100644 --- a/src/main/java/com/coinbase/prime/transactions/GetTransactionRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/GetTransactionRequest.java @@ -20,12 +20,16 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Transaction by Transaction ID + */ public class GetTransactionRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "transaction_id") @JsonIgnore private String transactionId; @@ -55,16 +59,24 @@ public void setTransactionId(String transactionId) { } public static class Builder { - private final String portfolioId; - private final String transactionId; + private String portfolioId; + private String transactionId; + + public Builder() { + } - public Builder(String portfolioId, String transactionId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; + } + + public Builder transactionId(String transactionId) { this.transactionId = transactionId; + return this; } public GetTransactionRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetTransactionRequest(this); } diff --git a/src/main/java/com/coinbase/prime/transactions/GetTransactionResponse.java b/src/main/java/com/coinbase/prime/transactions/GetTransactionResponse.java index bf9f8e2d..1fbb992e 100644 --- a/src/main/java/com/coinbase/prime/transactions/GetTransactionResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/GetTransactionResponse.java @@ -17,15 +17,13 @@ package com.coinbase.prime.transactions; import com.coinbase.prime.model.Transaction; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving a specific transaction by transaction ID. - * - * Contains the transaction information for the requested transaction ID. - * Only transactions that affect balances are accessible. + * Get Transaction by Transaction ID */ public class GetTransactionResponse { - /** The transaction information */ + @JsonProperty("transaction") private Transaction transaction; public GetTransactionResponse() { diff --git a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java index 48efda4f..b867d79f 100644 --- a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Transaction Travel Rule Data + */ public class GetTransactionTravelRuleDataRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore diff --git a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java index e04703fc..6360cdb1 100644 --- a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +19,27 @@ import com.coinbase.prime.model.TravelRuleParty; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Get Transaction Travel Rule Data + */ public class GetTransactionTravelRuleDataResponse { - private String amount; + @JsonProperty("fulfilled") + private Boolean fulfilled; - @JsonProperty("amount_currency") - private String amountCurrency; + @JsonProperty("is_self") + private Boolean isSelf; + + @JsonProperty("originator") + private TravelRuleParty originator; + @JsonProperty("beneficiary") private TravelRuleParty beneficiary; - @JsonProperty("blockchain_network") - private String blockchainNetwork; + @JsonProperty("amount") + private String amount; + + @JsonProperty("amount_currency") + private String amountCurrency; @JsonProperty("fiat_amount") private String fiatAmount; @@ -36,30 +47,34 @@ public class GetTransactionTravelRuleDataResponse { @JsonProperty("fiat_amount_currency") private String fiatAmountCurrency; - private Boolean fulfilled; + @JsonProperty("blockchain_network") + private String blockchainNetwork; - @JsonProperty("is_self") - private Boolean isSelf; + public GetTransactionTravelRuleDataResponse() { + } - private TravelRuleParty originator; + public Boolean getFulfilled() { + return fulfilled; + } - public GetTransactionTravelRuleDataResponse() { + public void setFulfilled(Boolean fulfilled) { + this.fulfilled = fulfilled; } - public String getAmount() { - return amount; + public Boolean getIsSelf() { + return isSelf; } - public void setAmount(String amount) { - this.amount = amount; + public void setIsSelf(Boolean isSelf) { + this.isSelf = isSelf; } - public String getAmountCurrency() { - return amountCurrency; + public TravelRuleParty getOriginator() { + return originator; } - public void setAmountCurrency(String amountCurrency) { - this.amountCurrency = amountCurrency; + public void setOriginator(TravelRuleParty originator) { + this.originator = originator; } public TravelRuleParty getBeneficiary() { @@ -70,12 +85,20 @@ public void setBeneficiary(TravelRuleParty beneficiary) { this.beneficiary = beneficiary; } - public String getBlockchainNetwork() { - return blockchainNetwork; + public String getAmount() { + return amount; } - public void setBlockchainNetwork(String blockchainNetwork) { - this.blockchainNetwork = blockchainNetwork; + public void setAmount(String amount) { + this.amount = amount; + } + + public String getAmountCurrency() { + return amountCurrency; + } + + public void setAmountCurrency(String amountCurrency) { + this.amountCurrency = amountCurrency; } public String getFiatAmount() { @@ -94,27 +117,12 @@ public void setFiatAmountCurrency(String fiatAmountCurrency) { this.fiatAmountCurrency = fiatAmountCurrency; } - public Boolean getFulfilled() { - return fulfilled; - } - - public void setFulfilled(Boolean fulfilled) { - this.fulfilled = fulfilled; - } - - public Boolean getIsSelf() { - return isSelf; - } - - public void setIsSelf(Boolean isSelf) { - this.isSelf = isSelf; + public String getBlockchainNetwork() { + return blockchainNetwork; } - public TravelRuleParty getOriginator() { - return originator; + public void setBlockchainNetwork(String blockchainNetwork) { + this.blockchainNetwork = blockchainNetwork; } - public void setOriginator(TravelRuleParty originator) { - this.originator = originator; - } } diff --git a/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsRequest.java b/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsRequest.java index edce5763..3ff3bcac 100644 --- a/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsRequest.java @@ -19,24 +19,40 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; import com.coinbase.prime.common.Pagination; -import com.coinbase.prime.model.enums.TransactionType; import com.coinbase.prime.model.enums.SortDirection; +import com.coinbase.prime.model.enums.TransactionType; +import com.coinbase.prime.model.enums.TravelRuleStatus; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Transactions + */ public class ListPortfolioTransactionsRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + + @JsonProperty("symbols") private String[] symbols; + + @JsonProperty("types") private TransactionType[] types; + @JsonProperty("start_time") private String startTime; + @JsonProperty("end_time") private String endTime; + @JsonProperty("get_network_unified_transactions") + private Boolean getNetworkUnifiedTransactions; + + @JsonProperty("travel_rule_status") + private TravelRuleStatus[] travelRuleStatus; + public ListPortfolioTransactionsRequest() { } @@ -47,6 +63,8 @@ public ListPortfolioTransactionsRequest(Builder builder) { this.types = builder.types; this.startTime = builder.startTime; this.endTime = builder.endTime; + this.getNetworkUnifiedTransactions = builder.getNetworkUnifiedTransactions; + this.travelRuleStatus = builder.travelRuleStatus; } public String getPortfolioId() { @@ -89,12 +107,30 @@ public void setEndTime(String endTime) { this.endTime = endTime; } + public Boolean getGetNetworkUnifiedTransactions() { + return getNetworkUnifiedTransactions; + } + + public void setGetNetworkUnifiedTransactions(Boolean getNetworkUnifiedTransactions) { + this.getNetworkUnifiedTransactions = getNetworkUnifiedTransactions; + } + + public TravelRuleStatus[] getTravelRuleStatus() { + return travelRuleStatus; + } + + public void setTravelRuleStatus(TravelRuleStatus[] travelRuleStatus) { + this.travelRuleStatus = travelRuleStatus; + } + public static class Builder { private String portfolioId; private String[] symbols; private TransactionType[] types; private String startTime; private String endTime; + private Boolean getNetworkUnifiedTransactions; + private TravelRuleStatus[] travelRuleStatus; private String cursor; private SortDirection sortDirection; private Integer limit; @@ -127,9 +163,13 @@ public Builder endTime(String endTime) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder getNetworkUnifiedTransactions(Boolean getNetworkUnifiedTransactions) { + this.getNetworkUnifiedTransactions = getNetworkUnifiedTransactions; + return this; + } + + public Builder travelRuleStatus(TravelRuleStatus[] travelRuleStatus) { + this.travelRuleStatus = travelRuleStatus; return this; } @@ -138,8 +178,14 @@ public Builder limit(Integer limit) { return this; } + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + public ListPortfolioTransactionsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioTransactionsRequest(this); } diff --git a/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsResponse.java b/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsResponse.java index 6ce3a7f6..56266fb4 100644 --- a/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/ListPortfolioTransactionsResponse.java @@ -18,17 +18,16 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.Transaction; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing transactions for a given portfolio. - * - * Contains an array of transactions and pagination information. Only transactions - * that affect balances are accessible. + * List Portfolio Transactions */ public class ListPortfolioTransactionsResponse { - /** Array of transactions for the portfolio */ + @JsonProperty("transactions") private Transaction[] transactions; - /** Pagination information for the transaction listing */ + + @JsonProperty("pagination") private Pagination pagination; public ListPortfolioTransactionsResponse() { diff --git a/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsRequest.java b/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsRequest.java index 48c7a0dc..6cc35888 100644 --- a/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsRequest.java @@ -19,23 +19,31 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; import com.coinbase.prime.common.Pagination; -import com.coinbase.prime.model.enums.TransactionType; import com.coinbase.prime.model.enums.SortDirection; +import com.coinbase.prime.model.enums.TransactionType; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Wallet Transactions + */ public class ListWalletTransactionsRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; + + @JsonProperty("types") private TransactionType[] types; + @JsonProperty("start_time") private String startTime; + @JsonProperty("end_time") private String endTime; @@ -129,19 +137,19 @@ public Builder endTime(String endTime) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListWalletTransactionsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListWalletTransactionsRequest(this); } @@ -149,7 +157,6 @@ private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.walletId)) { throw new CoinbaseClientException("WalletId is required"); } diff --git a/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsResponse.java b/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsResponse.java index 30b676a5..f1c78f49 100644 --- a/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/ListWalletTransactionsResponse.java @@ -18,11 +18,17 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.Transaction; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Wallet Transactions + */ public class ListWalletTransactionsResponse { + @JsonProperty("transactions") private Transaction[] transactions; + + @JsonProperty("pagination") private Pagination pagination; - private ListWalletTransactionsRequest request; public ListWalletTransactionsResponse() { } @@ -43,12 +49,4 @@ public void setPagination(Pagination pagination) { this.pagination = pagination; } - public ListWalletTransactionsRequest getRequest() { - return request; - } - - public void setRequest(ListWalletTransactionsRequest request) { - this.request = request; - } - } diff --git a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java index 3bb0c479..14322a26 100644 --- a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,7 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; /** - * Request to submit travel rule data for an existing deposit transaction. - *

- * Beta: This endpoint is in Beta. Contact your account manager for more information. + * Submit Deposit Travel Rule Data */ public class SubmitDepositTravelRuleDataRequest { @JsonProperty(required = true, value = "portfolio_id") @@ -46,9 +44,6 @@ public class SubmitDepositTravelRuleDataRequest { @JsonProperty("is_self") private Boolean isSelf; - @JsonProperty("is_intermediary") - private Boolean isIntermediary; - @JsonProperty("opt_out_of_ownership_verification") private Boolean optOutOfOwnershipVerification; @@ -61,7 +56,6 @@ public SubmitDepositTravelRuleDataRequest(Builder builder) { this.originator = builder.originator; this.beneficiary = builder.beneficiary; this.isSelf = builder.isSelf; - this.isIntermediary = builder.isIntermediary; this.optOutOfOwnershipVerification = builder.optOutOfOwnershipVerification; } @@ -105,14 +99,6 @@ public void setIsSelf(Boolean isSelf) { this.isSelf = isSelf; } - public Boolean getIsIntermediary() { - return isIntermediary; - } - - public void setIsIntermediary(Boolean isIntermediary) { - this.isIntermediary = isIntermediary; - } - public Boolean getOptOutOfOwnershipVerification() { return optOutOfOwnershipVerification; } @@ -127,7 +113,6 @@ public static class Builder { private TravelRuleParty originator; private TravelRuleParty beneficiary; private Boolean isSelf; - private Boolean isIntermediary; private Boolean optOutOfOwnershipVerification; public Builder() { @@ -158,27 +143,22 @@ public Builder isSelf(Boolean isSelf) { return this; } - public Builder isIntermediary(Boolean isIntermediary) { - this.isIntermediary = isIntermediary; - return this; - } - public Builder optOutOfOwnershipVerification(Boolean optOutOfOwnershipVerification) { this.optOutOfOwnershipVerification = optOutOfOwnershipVerification; return this; } public SubmitDepositTravelRuleDataRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new SubmitDepositTravelRuleDataRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } if (isNullOrEmpty(this.transactionId)) { - throw new CoinbaseClientException("TransactionId cannot be null"); + throw new CoinbaseClientException("TransactionId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java index 58f96886..5b8086bf 100644 --- a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2026-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response after submitting travel rule data for a deposit. - *

- * Beta: This endpoint is in Beta. Contact your account manager for more information. + * Submit Deposit Travel Rule Data */ public class SubmitDepositTravelRuleDataResponse { @JsonProperty("ownership_verification_required") @@ -37,4 +35,5 @@ public Boolean getOwnershipVerificationRequired() { public void setOwnershipVerificationRequired(Boolean ownershipVerificationRequired) { this.ownershipVerificationRequired = ownershipVerificationRequired; } + } diff --git a/src/main/java/com/coinbase/prime/transactions/TransactionsService.java b/src/main/java/com/coinbase/prime/transactions/TransactionsService.java index 65514b79..1de91902 100644 --- a/src/main/java/com/coinbase/prime/transactions/TransactionsService.java +++ b/src/main/java/com/coinbase/prime/transactions/TransactionsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,26 +20,22 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface TransactionsService { - // Transactions - OpenAPI spec compliance + /** List Portfolio Transactions */ ListPortfolioTransactionsResponse listPortfolioTransactions(ListPortfolioTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Transaction by Transaction ID */ GetTransactionResponse getTransaction(GetTransactionRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Conversion */ CreateConversionResponse createConversion(CreateConversionRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Onchain Transaction */ CreateOnchainTransactionResponse createOnchainTransaction(CreateOnchainTransactionRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Wallet Transactions */ ListWalletTransactionsResponse listWalletTransactions(ListWalletTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Transfer */ CreateWalletTransferResponse createWalletTransfer(CreateWalletTransferRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Withdrawal */ CreateWalletWithdrawalResponse createWalletWithdrawal(CreateWalletWithdrawalRequest request) throws CoinbaseClientException, CoinbasePrimeException; - ListAdvancedTransferTransactionsResponse listAdvancedTransferTransactions(ListAdvancedTransferTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - - /** - * Submit travel rule data for an existing deposit transaction. - *

- * Beta: This endpoint is in Beta. Contact your account manager for more information. - * - * @param request The request containing portfolio ID, transaction ID, and travel rule data - * @return Response indicating whether ownership verification is required - * @throws CoinbaseClientException if there is a client-side error - * @throws CoinbasePrimeException if there is a server-side error - */ - SubmitDepositTravelRuleDataResponse submitDepositTravelRuleData(SubmitDepositTravelRuleDataRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Transaction Travel Rule Data */ GetTransactionTravelRuleDataResponse getTransactionTravelRuleData(GetTransactionTravelRuleDataRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Submit Deposit Travel Rule Data */ + SubmitDepositTravelRuleDataResponse submitDepositTravelRuleData(SubmitDepositTravelRuleDataRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java b/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java index cc089c0d..ccdb5574 100644 --- a/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,16 @@ public TransactionsServiceImpl(CoinbasePrimeClient client) { super(client); } + @Override + public ListPortfolioTransactionsResponse listPortfolioTransactions(ListPortfolioTransactionsRequest request) throws CoinbasePrimeException { + return this.request( + HttpMethod.GET, + String.format("/portfolios/%s/transactions", request.getPortfolioId()), + request, + List.of(200), + new TypeReference() {}); + } + @Override public GetTransactionResponse getTransaction(GetTransactionRequest request) throws CoinbasePrimeException { return this.request( @@ -45,36 +55,32 @@ public CreateConversionResponse createConversion(CreateConversionRequest request HttpMethod.POST, String.format("/portfolios/%s/wallets/%s/conversion", request.getPortfolioId(), request.getWalletId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @Override - public ListPortfolioTransactionsResponse listPortfolioTransactions(ListPortfolioTransactionsRequest request) - throws CoinbasePrimeException { + public CreateOnchainTransactionResponse createOnchainTransaction(CreateOnchainTransactionRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, - String.format("/portfolios/%s/transactions", request.getPortfolioId()), + HttpMethod.POST, + String.format("/portfolios/%s/wallets/%s/onchain_transaction", request.getPortfolioId(), request.getWalletId()), request, - List.of(200), - new TypeReference() {}); + List.of(201, 200), + new TypeReference() {}); } @Override - public ListWalletTransactionsResponse listWalletTransactions(ListWalletTransactionsRequest request) - throws CoinbasePrimeException { + public ListWalletTransactionsResponse listWalletTransactions(ListWalletTransactionsRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/wallets/%s/transactions", request.getPortfolioId(), - request.getWalletId()), + String.format("/portfolios/%s/wallets/%s/transactions", request.getPortfolioId(), request.getWalletId()), request, List.of(200), new TypeReference() {}); } @Override - public CreateWalletTransferResponse createWalletTransfer(CreateWalletTransferRequest request) - throws CoinbasePrimeException { + public CreateWalletTransferResponse createWalletTransfer(CreateWalletTransferRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/wallets/%s/transfers", request.getPortfolioId(), request.getWalletId()), @@ -84,8 +90,7 @@ public CreateWalletTransferResponse createWalletTransfer(CreateWalletTransferReq } @Override - public CreateWalletWithdrawalResponse createWalletWithdrawal(CreateWalletWithdrawalRequest request) - throws CoinbasePrimeException { + public CreateWalletWithdrawalResponse createWalletWithdrawal(CreateWalletWithdrawalRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, String.format("/portfolios/%s/wallets/%s/withdrawals", request.getPortfolioId(), request.getWalletId()), @@ -95,55 +100,23 @@ public CreateWalletWithdrawalResponse createWalletWithdrawal(CreateWalletWithdra } @Override - public CreateOnchainTransactionResponse createOnchainTransaction(CreateOnchainTransactionRequest request) - throws CoinbasePrimeException { - return this.request( - HttpMethod.POST, - String.format("/portfolios/%s/wallets/%s/onchain_transaction", request.getPortfolioId(), - request.getWalletId()), - request, - List.of(200), - new TypeReference() {}); - } - - @Override - public ListAdvancedTransferTransactionsResponse listAdvancedTransferTransactions(ListAdvancedTransferTransactionsRequest request) - throws CoinbasePrimeException { + public GetTransactionTravelRuleDataResponse getTransactionTravelRuleData(GetTransactionTravelRuleDataRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/advanced_transfers/%s/transactions", request.getPortfolioId(), - request.getAdvancedTransferId()), + String.format("/portfolios/%s/transactions/%s/travel_rule", request.getPortfolioId(), request.getTransactionId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } - /** - * Submit travel rule data for an existing deposit transaction. - *

- * Beta: This endpoint is in Beta. Contact your account manager for more information. - */ @Override - public SubmitDepositTravelRuleDataResponse submitDepositTravelRuleData(SubmitDepositTravelRuleDataRequest request) - throws CoinbasePrimeException { + public SubmitDepositTravelRuleDataResponse submitDepositTravelRuleData(SubmitDepositTravelRuleDataRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.POST, - String.format("/portfolios/%s/transactions/%s/travel_rule/deposit", request.getPortfolioId(), - request.getTransactionId()), + String.format("/portfolios/%s/transactions/%s/travel_rule/deposit", request.getPortfolioId(), request.getTransactionId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } - @Override - public GetTransactionTravelRuleDataResponse getTransactionTravelRuleData(GetTransactionTravelRuleDataRequest request) - throws CoinbasePrimeException { - return this.request( - HttpMethod.GET, - String.format("/portfolios/%s/transactions/%s/travel_rule", request.getPortfolioId(), - request.getTransactionId()), - request, - List.of(200), - new TypeReference() {}); - } } diff --git a/src/main/java/com/coinbase/prime/users/ListEntityUsersRequest.java b/src/main/java/com/coinbase/prime/users/ListEntityUsersRequest.java index 581aff22..7b9834c0 100644 --- a/src/main/java/com/coinbase/prime/users/ListEntityUsersRequest.java +++ b/src/main/java/com/coinbase/prime/users/ListEntityUsersRequest.java @@ -25,6 +25,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Users + */ public class ListEntityUsersRequest extends PrimeListRequest { @JsonProperty(required = true, value = "entity_id") @JsonIgnore @@ -47,18 +50,16 @@ public void setEntityId(String entityId) { } public static class Builder { - private final String entityId; + private String entityId; private String cursor; private SortDirection sortDirection; private Integer limit; - public Builder(String entityId) { - this.entityId = entityId; + public Builder() { } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder entityId(String entityId) { + this.entityId = entityId; return this; } @@ -67,8 +68,14 @@ public Builder limit(Integer limit) { return this; } + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + public ListEntityUsersRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListEntityUsersRequest(this); } @@ -78,4 +85,4 @@ private void validate() throws CoinbaseClientException { } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/users/ListEntityUsersResponse.java b/src/main/java/com/coinbase/prime/users/ListEntityUsersResponse.java index bc9b5ea1..d949b7a5 100644 --- a/src/main/java/com/coinbase/prime/users/ListEntityUsersResponse.java +++ b/src/main/java/com/coinbase/prime/users/ListEntityUsersResponse.java @@ -18,14 +18,16 @@ import com.coinbase.prime.model.EntityUser; import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all users associated with a specific entity. + * List Users */ public class ListEntityUsersResponse { - /** Array of entity user information */ + @JsonProperty("users") private EntityUser[] users; - /** Pagination information for the response */ + + @JsonProperty("pagination") private Pagination pagination; public ListEntityUsersResponse() { diff --git a/src/main/java/com/coinbase/prime/users/ListPortfolioUsersRequest.java b/src/main/java/com/coinbase/prime/users/ListPortfolioUsersRequest.java index 4b22ec3d..f1e6480e 100644 --- a/src/main/java/com/coinbase/prime/users/ListPortfolioUsersRequest.java +++ b/src/main/java/com/coinbase/prime/users/ListPortfolioUsersRequest.java @@ -25,6 +25,9 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Users + */ public class ListPortfolioUsersRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -52,30 +55,33 @@ public static class Builder { private SortDirection sortDirection; private Integer limit; + public Builder() { + } + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder limit(Integer limit) { - this.limit = limit; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListPortfolioUsersRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListPortfolioUsersRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/users/ListPortfolioUsersResponse.java b/src/main/java/com/coinbase/prime/users/ListPortfolioUsersResponse.java index b594111a..f5ff17b3 100644 --- a/src/main/java/com/coinbase/prime/users/ListPortfolioUsersResponse.java +++ b/src/main/java/com/coinbase/prime/users/ListPortfolioUsersResponse.java @@ -16,21 +16,28 @@ package com.coinbase.prime.users; -import com.coinbase.prime.model.EntityUser; import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.PortfolioUser; +import com.fasterxml.jackson.annotation.JsonProperty; +/** + * List Portfolio Users + */ public class ListPortfolioUsersResponse { - private EntityUser[] users; + @JsonProperty("users") + private PortfolioUser[] users; + + @JsonProperty("pagination") private Pagination pagination; public ListPortfolioUsersResponse() { } - public EntityUser[] getUsers() { + public PortfolioUser[] getUsers() { return users; } - public void setUsers(EntityUser[] users) { + public void setUsers(PortfolioUser[] users) { this.users = users; } diff --git a/src/main/java/com/coinbase/prime/users/ListUsersRequest.java b/src/main/java/com/coinbase/prime/users/ListUsersRequest.java new file mode 100644 index 00000000..f236dbdc --- /dev/null +++ b/src/main/java/com/coinbase/prime/users/ListUsersRequest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.users; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; +import com.coinbase.prime.model.enums.SortDirection; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import static com.coinbase.core.utils.Utils.isNullOrEmpty; + +/** + * List Users + */ +public class ListUsersRequest extends PrimeListRequest { + @JsonProperty(required = true, value = "entity_id") + @JsonIgnore + private String entityId; + + public ListUsersRequest() { + } + + public ListUsersRequest(Builder builder) { + super(builder.cursor, builder.sortDirection, builder.limit); + this.entityId = builder.entityId; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public static class Builder { + private String entityId; + private String cursor; + private SortDirection sortDirection; + private Integer limit; + + public Builder() { + } + + public Builder entityId(String entityId) { + this.entityId = entityId; + return this; + } + + public Builder limit(Integer limit) { + this.limit = limit; + return this; + } + + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + + public ListUsersRequest build() throws CoinbaseClientException { + validate(); + return new ListUsersRequest(this); + } + + private void validate() throws CoinbaseClientException { + if (isNullOrEmpty(this.entityId)) { + throw new CoinbaseClientException("EntityId is required"); + } + } + } +} diff --git a/src/main/java/com/coinbase/prime/users/ListUsersResponse.java b/src/main/java/com/coinbase/prime/users/ListUsersResponse.java new file mode 100644 index 00000000..885e6629 --- /dev/null +++ b/src/main/java/com/coinbase/prime/users/ListUsersResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.users; + +import com.coinbase.prime.model.EntityUser; +import com.coinbase.prime.common.Pagination; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * List Users + */ +public class ListUsersResponse { + @JsonProperty("users") + private EntityUser[] users; + + @JsonProperty("pagination") + private Pagination pagination; + + public ListUsersResponse() { + } + + public EntityUser[] getUsers() { + return users; + } + + public void setUsers(EntityUser[] users) { + this.users = users; + } + + public Pagination getPagination() { + return pagination; + } + + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + +} diff --git a/src/main/java/com/coinbase/prime/users/UsersService.java b/src/main/java/com/coinbase/prime/users/UsersService.java index 91d35676..ed43ec6a 100644 --- a/src/main/java/com/coinbase/prime/users/UsersService.java +++ b/src/main/java/com/coinbase/prime/users/UsersService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface UsersService { - // Users - OpenAPI spec compliance + /** List Users */ ListEntityUsersResponse listEntityUsers(ListEntityUsersRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Portfolio Users */ ListPortfolioUsersResponse listPortfolioUsers(ListPortfolioUsersRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java b/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java index 2f81cb78..90612e33 100644 --- a/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java +++ b/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,4 +48,5 @@ public ListPortfolioUsersResponse listPortfolioUsers(ListPortfolioUsersRequest r List.of(200), new TypeReference() {}); } + } diff --git a/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressRequest.java b/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressRequest.java index c2ae66e2..0eba9ba3 100644 --- a/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressRequest.java +++ b/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressRequest.java @@ -22,13 +22,18 @@ import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Wallet Deposit Address + */ public class CreateWalletDepositAddressRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - @JsonProperty("wallet_id") + + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; + @JsonProperty("network_id") private String networkId; @@ -89,20 +94,17 @@ public Builder networkId(String networkId) { } public CreateWalletDepositAddressRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new CreateWalletDepositAddressRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("Portfolio ID is required"); + throw new CoinbaseClientException("PortfolioId is required"); } if (isNullOrEmpty(this.walletId)) { - throw new CoinbaseClientException("Wallet ID is required"); - } - if (isNullOrEmpty(this.networkId)) { - throw new CoinbaseClientException("Network ID is required"); + throw new CoinbaseClientException("WalletId is required"); } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressResponse.java b/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressResponse.java index 8f5be147..bc75dcfa 100644 --- a/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressResponse.java +++ b/src/main/java/com/coinbase/prime/wallets/CreateWalletDepositAddressResponse.java @@ -19,6 +19,9 @@ import com.coinbase.prime.model.Network; import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Create Wallet Deposit Address + */ public class CreateWalletDepositAddressResponse { @JsonProperty("address") private String address; @@ -55,4 +58,5 @@ public Network getNetwork() { public void setNetwork(Network network) { this.network = network; } -} \ No newline at end of file + +} diff --git a/src/main/java/com/coinbase/prime/wallets/CreateWalletRequest.java b/src/main/java/com/coinbase/prime/wallets/CreateWalletRequest.java index 561e2426..b3ee0369 100644 --- a/src/main/java/com/coinbase/prime/wallets/CreateWalletRequest.java +++ b/src/main/java/com/coinbase/prime/wallets/CreateWalletRequest.java @@ -17,23 +17,39 @@ package com.coinbase.prime.wallets; import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.Network; +import com.coinbase.prime.model.enums.NetworkFamily; import com.coinbase.prime.model.enums.WalletType; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Create Wallet + */ public class CreateWalletRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("name") private String name; + @JsonProperty("symbol") private String symbol; @JsonProperty("wallet_type") - private WalletType type; + private WalletType walletType; + + @JsonProperty("idempotency_key") + private String idempotencyKey; + + @JsonProperty("network_family") + private NetworkFamily networkFamily; + + @JsonProperty("network") + private Network network; public CreateWalletRequest() { } @@ -42,7 +58,10 @@ public CreateWalletRequest(Builder builder) { this.portfolioId = builder.portfolioId; this.name = builder.name; this.symbol = builder.symbol; - this.type = builder.type; + this.walletType = builder.walletType; + this.idempotencyKey = builder.idempotencyKey; + this.networkFamily = builder.networkFamily; + this.network = builder.network; } public String getPortfolioId() { @@ -69,19 +88,46 @@ public void setSymbol(String symbol) { this.symbol = symbol; } - public WalletType getType() { - return type; + public WalletType getWalletType() { + return walletType; + } + + public void setWalletType(WalletType walletType) { + this.walletType = walletType; + } + + public String getIdempotencyKey() { + return idempotencyKey; + } + + public void setIdempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + } + + public NetworkFamily getNetworkFamily() { + return networkFamily; + } + + public void setNetworkFamily(NetworkFamily networkFamily) { + this.networkFamily = networkFamily; } - public void setType(WalletType type) { - this.type = type; + public Network getNetwork() { + return network; + } + + public void setNetwork(Network network) { + this.network = network; } public static class Builder { private String portfolioId; private String name; private String symbol; - private WalletType type; + private WalletType walletType; + private String idempotencyKey; + private NetworkFamily networkFamily; + private Network network; public Builder() { } @@ -101,28 +147,34 @@ public Builder symbol(String symbol) { return this; } - public Builder type(WalletType type) { - this.type = type; + public Builder walletType(WalletType walletType) { + this.walletType = walletType; + return this; + } + + public Builder idempotencyKey(String idempotencyKey) { + this.idempotencyKey = idempotencyKey; + return this; + } + + public Builder networkFamily(NetworkFamily networkFamily) { + this.networkFamily = networkFamily; + return this; + } + + public Builder network(Network network) { + this.network = network; return this; } public CreateWalletRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new CreateWalletRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("Portfolio ID is required"); - } - if (isNullOrEmpty(this.name)) { - throw new CoinbaseClientException("Name is required"); - } - if (isNullOrEmpty(this.symbol)) { - throw new CoinbaseClientException("Symbol is required"); - } - if (this.type == null) { - throw new CoinbaseClientException("Type is required"); + throw new CoinbaseClientException("PortfolioId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/wallets/CreateWalletResponse.java b/src/main/java/com/coinbase/prime/wallets/CreateWalletResponse.java index f9af59ca..40447c8a 100644 --- a/src/main/java/com/coinbase/prime/wallets/CreateWalletResponse.java +++ b/src/main/java/com/coinbase/prime/wallets/CreateWalletResponse.java @@ -21,27 +21,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for the create wallet operation. - * - * Creates a new wallet for the specified portfolio. Note that the first ONCHAIN wallet - * for each network family must be created through the Prime UI. + * Create Wallet */ public class CreateWalletResponse { - /** The ID of the activity associated with the wallet creation */ @JsonProperty("activity_id") private String activityId; - /** The name of the wallet */ + @JsonProperty("name") private String name; - /** The asset symbol stored in the wallet */ + @JsonProperty("symbol") private String symbol; - /** The wallet type (VAULT, TRADING, or WALLET_TYPE_OTHER) */ @JsonProperty("wallet_type") - private WalletType type; + private WalletType walletType; - /** The network family for the wallet */ @JsonProperty("network_family") private NetworkFamily networkFamily; @@ -72,12 +66,12 @@ public void setSymbol(String symbol) { this.symbol = symbol; } - public WalletType getType() { - return type; + public WalletType getWalletType() { + return walletType; } - public void setType(WalletType type) { - this.type = type; + public void setWalletType(WalletType walletType) { + this.walletType = walletType; } public NetworkFamily getNetworkFamily() { @@ -87,4 +81,5 @@ public NetworkFamily getNetworkFamily() { public void setNetworkFamily(NetworkFamily networkFamily) { this.networkFamily = networkFamily; } + } diff --git a/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsRequest.java b/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsRequest.java index ade61318..70979fe6 100644 --- a/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsRequest.java +++ b/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsRequest.java @@ -18,12 +18,14 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.model.enums.WalletDepositInstructionType; -import com.coinbase.prime.model.enums.NetworkType; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Wallet Deposit Instructions + */ public class GetWalletDepositInstructionsRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore @@ -33,14 +35,14 @@ public class GetWalletDepositInstructionsRequest { @JsonIgnore private String walletId; - @JsonProperty(required = true, value = "deposit_type") + @JsonProperty("deposit_type") private WalletDepositInstructionType depositType; @JsonProperty("network.id") private String networkId; @JsonProperty("network.type") - private NetworkType networkType; + private String networkType; public GetWalletDepositInstructionsRequest() { } @@ -85,11 +87,11 @@ public void setNetworkId(String networkId) { this.networkId = networkId; } - public NetworkType getNetworkType() { + public String getNetworkType() { return networkType; } - public void setNetworkType(NetworkType networkType) { + public void setNetworkType(String networkType) { this.networkType = networkType; } @@ -98,52 +100,47 @@ public static class Builder { private String walletId; private WalletDepositInstructionType depositType; private String networkId; - private NetworkType networkType; + private String networkType; public Builder() { } - public GetWalletDepositInstructionsRequest.Builder portfolioId(String portfolioId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; return this; } - public GetWalletDepositInstructionsRequest.Builder walletId(String walletId) { + public Builder walletId(String walletId) { this.walletId = walletId; return this; } - public GetWalletDepositInstructionsRequest.Builder depositType(WalletDepositInstructionType depositType) { + public Builder depositType(WalletDepositInstructionType depositType) { this.depositType = depositType; return this; } - public GetWalletDepositInstructionsRequest.Builder networkId(String networkId) { + public Builder networkId(String networkId) { this.networkId = networkId; return this; } - public GetWalletDepositInstructionsRequest.Builder networkType(NetworkType networkType) { + public Builder networkType(String networkType) { this.networkType = networkType; return this; } public GetWalletDepositInstructionsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetWalletDepositInstructionsRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("PortfolioId cannot be null"); + throw new CoinbaseClientException("PortfolioId is required"); } - if (isNullOrEmpty(this.walletId)) { - throw new CoinbaseClientException("WalletId cannot be null"); - } - - if (this.depositType == null) { - throw new CoinbaseClientException("DepositType cannot be null"); + throw new CoinbaseClientException("WalletId is required"); } } } diff --git a/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsResponse.java b/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsResponse.java index 85da4e88..10594c4c 100644 --- a/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsResponse.java +++ b/src/main/java/com/coinbase/prime/wallets/GetWalletDepositInstructionsResponse.java @@ -21,36 +21,32 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving wallet deposit instructions. - * - * Contains both crypto and fiat deposit instructions for the specified wallet, - * providing the necessary information for users to deposit funds. + * Get Wallet Deposit Instructions */ public class GetWalletDepositInstructionsResponse { - /** Cryptocurrency deposit instructions for the wallet */ @JsonProperty("crypto_instructions") - WalletCryptoDepositInstructions cryptoDepositInstructions; - /** Fiat currency deposit instructions for the wallet */ + private WalletCryptoDepositInstructions cryptoInstructions; + @JsonProperty("fiat_instructions") - WalletFiatDepositInstructions fiatDepositInstructions; + private WalletFiatDepositInstructions fiatInstructions; public GetWalletDepositInstructionsResponse() { } - public WalletCryptoDepositInstructions getCryptoDepositInstructions() { - return cryptoDepositInstructions; + public WalletCryptoDepositInstructions getCryptoInstructions() { + return cryptoInstructions; } - public void setCryptoDepositInstructions(WalletCryptoDepositInstructions cryptoDepositInstructions) { - this.cryptoDepositInstructions = cryptoDepositInstructions; + public void setCryptoInstructions(WalletCryptoDepositInstructions cryptoInstructions) { + this.cryptoInstructions = cryptoInstructions; } - public WalletFiatDepositInstructions getFiatDepositInstructions() { - return fiatDepositInstructions; + public WalletFiatDepositInstructions getFiatInstructions() { + return fiatInstructions; } - public void setFiatDepositInstructions(WalletFiatDepositInstructions fiatDepositInstructions) { - this.fiatDepositInstructions = fiatDepositInstructions; + public void setFiatInstructions(WalletFiatDepositInstructions fiatInstructions) { + this.fiatInstructions = fiatInstructions; } } diff --git a/src/main/java/com/coinbase/prime/wallets/GetWalletRequest.java b/src/main/java/com/coinbase/prime/wallets/GetWalletRequest.java index 75aacce4..e36aeeea 100644 --- a/src/main/java/com/coinbase/prime/wallets/GetWalletRequest.java +++ b/src/main/java/com/coinbase/prime/wallets/GetWalletRequest.java @@ -20,12 +20,16 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * Get Wallet by Wallet ID + */ public class GetWalletRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; @@ -55,16 +59,24 @@ public void setWalletId(String walletId) { } public static class Builder { - private final String portfolioId; - private final String walletId; + private String portfolioId; + private String walletId; + + public Builder() { + } - public Builder(String portfolioId, String walletId) { + public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; + return this; + } + + public Builder walletId(String walletId) { this.walletId = walletId; + return this; } public GetWalletRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new GetWalletRequest(this); } diff --git a/src/main/java/com/coinbase/prime/wallets/GetWalletResponse.java b/src/main/java/com/coinbase/prime/wallets/GetWalletResponse.java index b75bf849..dca74c31 100644 --- a/src/main/java/com/coinbase/prime/wallets/GetWalletResponse.java +++ b/src/main/java/com/coinbase/prime/wallets/GetWalletResponse.java @@ -17,14 +17,13 @@ package com.coinbase.prime.wallets; import com.coinbase.prime.model.Wallet; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for retrieving a specific wallet by Wallet ID. - * - * Contains the wallet information for the requested wallet. + * Get Wallet by Wallet ID */ public class GetWalletResponse { - /** The wallet information */ + @JsonProperty("wallet") private Wallet wallet; public GetWalletResponse() { diff --git a/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesRequest.java b/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesRequest.java index 317693f0..80cc6100 100644 --- a/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesRequest.java +++ b/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesRequest.java @@ -18,19 +18,25 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; +import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.enums.SortDirection; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Wallet Addresses + */ public class ListWalletAddressesRequest extends PrimeListRequest { - @JsonProperty("portfolio_id") + @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; - @JsonProperty("wallet_id") + + @JsonProperty(required = true, value = "wallet_id") @JsonIgnore private String walletId; + @JsonProperty("network_id") private String networkId; @@ -68,14 +74,13 @@ public void setNetworkId(String networkId) { this.networkId = networkId; } - public static class Builder { private String portfolioId; private String walletId; private String networkId; private String cursor; - private Integer limit; private SortDirection sortDirection; + private Integer limit; public Builder() { } @@ -95,32 +100,29 @@ public Builder networkId(String networkId) { return this; } - - public Builder cursor(String cursor) { - this.cursor = cursor; + public Builder limit(Integer limit) { + this.limit = limit; return this; } - public Builder sortDirection(SortDirection sortDirection) { - this.sortDirection = sortDirection; + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); return this; } public ListWalletAddressesRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListWalletAddressesRequest(this); } private void validate() throws CoinbaseClientException { if (isNullOrEmpty(this.portfolioId)) { - throw new CoinbaseClientException("Portfolio ID is required"); + throw new CoinbaseClientException("PortfolioId is required"); } if (isNullOrEmpty(this.walletId)) { - throw new CoinbaseClientException("Wallet ID is required"); - } - if (isNullOrEmpty(this.networkId)) { - throw new CoinbaseClientException("Network ID is required"); + throw new CoinbaseClientException("WalletId is required"); } } } -} \ No newline at end of file +} diff --git a/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesResponse.java b/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesResponse.java index 54688d67..3622b5d2 100644 --- a/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesResponse.java +++ b/src/main/java/com/coinbase/prime/wallets/ListWalletAddressesResponse.java @@ -19,28 +19,25 @@ import com.coinbase.prime.model.BlockchainAddress; import com.coinbase.prime.common.Pagination; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; /** - * Response object for listing all deposit addresses associated with a wallet. - * - * Returns all deposit addresses for the specified wallet along with pagination information. + * List Wallet Addresses */ public class ListWalletAddressesResponse { - /** List of deposit addresses associated with the wallet */ @JsonProperty("addresses") - private List addresses; - /** Pagination information for the address listing */ + private BlockchainAddress[] addresses; + + @JsonProperty("pagination") private Pagination pagination; public ListWalletAddressesResponse() { } - public List getAddresses() { + public BlockchainAddress[] getAddresses() { return addresses; } - public void setAddresses(List addresses) { + public void setAddresses(BlockchainAddress[] addresses) { this.addresses = addresses; } @@ -51,4 +48,5 @@ public Pagination getPagination() { public void setPagination(Pagination pagination) { this.pagination = pagination; } -} \ No newline at end of file + +} diff --git a/src/main/java/com/coinbase/prime/wallets/ListWalletsRequest.java b/src/main/java/com/coinbase/prime/wallets/ListWalletsRequest.java index 85635288..65ea2e5c 100644 --- a/src/main/java/com/coinbase/prime/wallets/ListWalletsRequest.java +++ b/src/main/java/com/coinbase/prime/wallets/ListWalletsRequest.java @@ -19,29 +19,39 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.coinbase.prime.common.PrimeListRequest; import com.coinbase.prime.common.Pagination; -import com.coinbase.prime.model.enums.WalletType; import com.coinbase.prime.model.enums.SortDirection; +import com.coinbase.prime.model.enums.WalletType; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import static com.coinbase.core.utils.Utils.*; +import static com.coinbase.core.utils.Utils.isNullOrEmpty; +/** + * List Portfolio Wallets + */ public class ListWalletsRequest extends PrimeListRequest { @JsonProperty(required = true, value = "portfolio_id") @JsonIgnore private String portfolioId; + @JsonProperty("type") private WalletType type; + @JsonProperty("symbols") private String[] symbols; - public ListWalletsRequest() {} + @JsonProperty("get_network_unified_wallets") + private Boolean getNetworkUnifiedWallets; + + public ListWalletsRequest() { + } public ListWalletsRequest(Builder builder) { super(builder.cursor, builder.sortDirection, builder.limit); this.portfolioId = builder.portfolioId; this.type = builder.type; this.symbols = builder.symbols; + this.getNetworkUnifiedWallets = builder.getNetworkUnifiedWallets; } public String getPortfolioId() { @@ -68,15 +78,25 @@ public void setSymbols(String[] symbols) { this.symbols = symbols; } + public Boolean getGetNetworkUnifiedWallets() { + return getNetworkUnifiedWallets; + } + + public void setGetNetworkUnifiedWallets(Boolean getNetworkUnifiedWallets) { + this.getNetworkUnifiedWallets = getNetworkUnifiedWallets; + } + public static class Builder { private String portfolioId; private WalletType type; private String[] symbols; + private Boolean getNetworkUnifiedWallets; private String cursor; private SortDirection sortDirection; private Integer limit; - public Builder() {} + public Builder() { + } public Builder portfolioId(String portfolioId) { this.portfolioId = portfolioId; @@ -93,9 +113,8 @@ public Builder symbols(String[] symbols) { return this; } - public Builder pagination(Pagination pagination) { - this.cursor = pagination.getNextCursor(); - this.sortDirection = pagination.getSortDirection(); + public Builder getNetworkUnifiedWallets(Boolean getNetworkUnifiedWallets) { + this.getNetworkUnifiedWallets = getNetworkUnifiedWallets; return this; } @@ -104,8 +123,14 @@ public Builder limit(Integer limit) { return this; } + public Builder pagination(Pagination pagination) { + this.cursor = pagination.getNextCursor(); + this.sortDirection = pagination.getSortDirection(); + return this; + } + public ListWalletsRequest build() throws CoinbaseClientException { - this.validate(); + validate(); return new ListWalletsRequest(this); } diff --git a/src/main/java/com/coinbase/prime/wallets/ListWalletsResponse.java b/src/main/java/com/coinbase/prime/wallets/ListWalletsResponse.java index 5b8d87b9..f9263209 100644 --- a/src/main/java/com/coinbase/prime/wallets/ListWalletsResponse.java +++ b/src/main/java/com/coinbase/prime/wallets/ListWalletsResponse.java @@ -18,19 +18,20 @@ import com.coinbase.prime.common.Pagination; import com.coinbase.prime.model.Wallet; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Response object for listing all wallets associated with a portfolio. - * - * Contains an array of wallets and pagination information for the wallet listing. + * List Portfolio Wallets */ public class ListWalletsResponse { - /** Array of wallets associated with the portfolio */ + @JsonProperty("wallets") private Wallet[] wallets; - /** Pagination information for the wallet listing */ + + @JsonProperty("pagination") private Pagination pagination; - public ListWalletsResponse() {} + public ListWalletsResponse() { + } public Wallet[] getWallets() { return wallets; @@ -47,4 +48,5 @@ public Pagination getPagination() { public void setPagination(Pagination pagination) { this.pagination = pagination; } + } diff --git a/src/main/java/com/coinbase/prime/wallets/WalletsService.java b/src/main/java/com/coinbase/prime/wallets/WalletsService.java index c221b2bd..62470605 100644 --- a/src/main/java/com/coinbase/prime/wallets/WalletsService.java +++ b/src/main/java/com/coinbase/prime/wallets/WalletsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,16 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface WalletsService { - // Wallets - OpenAPI spec compliance + /** List Portfolio Wallets */ ListWalletsResponse listWallets(ListWalletsRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Wallet */ CreateWalletResponse createWallet(CreateWalletRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Wallet by Wallet ID */ GetWalletResponse getWallet(GetWalletRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** List Wallet Addresses */ ListWalletAddressesResponse listWalletAddresses(ListWalletAddressesRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Create Wallet Deposit Address */ CreateWalletDepositAddressResponse createWalletDepositAddress(CreateWalletDepositAddressRequest request) throws CoinbaseClientException, CoinbasePrimeException; + /** Get Wallet Deposit Instructions */ GetWalletDepositInstructionsResponse getWalletDepositInstructions(GetWalletDepositInstructionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java b/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java index f543ffa3..b17cc9f1 100644 --- a/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2024-present Coinbase Global, Inc. + * Copyright 2025-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public CreateWalletResponse createWallet(CreateWalletRequest request) throws Coi HttpMethod.POST, String.format("/portfolios/%s/wallets", request.getPortfolioId()), request, - List.of(200), + List.of(201, 200), new TypeReference() {}); } @@ -60,36 +60,33 @@ public GetWalletResponse getWallet(GetWalletRequest request) throws CoinbasePrim } @Override - public GetWalletDepositInstructionsResponse getWalletDepositInstructions( - GetWalletDepositInstructionsRequest request) throws CoinbasePrimeException { + public ListWalletAddressesResponse listWalletAddresses(ListWalletAddressesRequest request) throws CoinbasePrimeException { return this.request( HttpMethod.GET, - String.format("/portfolios/%s/wallets/%s/deposit_instructions", request.getPortfolioId(), - request.getWalletId()), + String.format("/portfolios/%s/wallets/%s/addresses", request.getPortfolioId(), request.getWalletId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } @Override - public ListWalletAddressesResponse listWalletAddresses(ListWalletAddressesRequest request) - throws CoinbasePrimeException { + public CreateWalletDepositAddressResponse createWalletDepositAddress(CreateWalletDepositAddressRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.GET, + HttpMethod.POST, String.format("/portfolios/%s/wallets/%s/addresses", request.getPortfolioId(), request.getWalletId()), request, - List.of(200), - new TypeReference() {}); + List.of(201, 200), + new TypeReference() {}); } @Override - public CreateWalletDepositAddressResponse createWalletDepositAddress(CreateWalletDepositAddressRequest request) - throws CoinbasePrimeException { + public GetWalletDepositInstructionsResponse getWalletDepositInstructions(GetWalletDepositInstructionsRequest request) throws CoinbasePrimeException { return this.request( - HttpMethod.POST, - String.format("/portfolios/%s/wallets/%s/addresses", request.getPortfolioId(), request.getWalletId()), + HttpMethod.GET, + String.format("/portfolios/%s/wallets/%s/deposit_instructions", request.getPortfolioId(), request.getWalletId()), request, List.of(200), - new TypeReference() {}); + new TypeReference() {}); } + } diff --git a/src/test/java/com/coinbase/prime/activities/ListEntityActivitiesRequestTest.java b/src/test/java/com/coinbase/prime/activities/ListEntityActivitiesRequestTest.java index 0a5e21fc..28224c52 100644 --- a/src/test/java/com/coinbase/prime/activities/ListEntityActivitiesRequestTest.java +++ b/src/test/java/com/coinbase/prime/activities/ListEntityActivitiesRequestTest.java @@ -32,7 +32,8 @@ public class ListEntityActivitiesRequestTest { @Test public void testBuilderWithEnums() throws CoinbaseClientException { // Test that the builder accepts enum types - ListEntityActivitiesRequest request = new ListEntityActivitiesRequest.Builder("entity-123") + ListEntityActivitiesRequest request = new ListEntityActivitiesRequest.Builder() + .entityId("entity-123") .activityLevel(ActivityLevel.ACTIVITY_LEVEL_ALL) .categories(new ActivityCategory[]{ ActivityCategory.ACTIVITY_CATEGORY_ORDER, @@ -65,7 +66,8 @@ public void testBuilderWithEnums() throws CoinbaseClientException { @Test public void testSettersWithEnums() { - ListEntityActivitiesRequest request = new ListEntityActivitiesRequest("entity-456"); + ListEntityActivitiesRequest request = new ListEntityActivitiesRequest(); + request.setEntityId("entity-456"); // Test that setters accept enum types request.setActivityLevel(ActivityLevel.ACTIVITY_LEVEL_PORTFOLIO); @@ -81,7 +83,8 @@ public void testSettersWithEnums() { @Test public void testJsonSerialization() throws Exception { // Test that enums serialize correctly to JSON - ListEntityActivitiesRequest request = new ListEntityActivitiesRequest.Builder("entity-789") + ListEntityActivitiesRequest request = new ListEntityActivitiesRequest.Builder() + .entityId("entity-789") .activityLevel(ActivityLevel.ACTIVITY_LEVEL_ENTITY) .categories(new ActivityCategory[]{ActivityCategory.ACTIVITY_CATEGORY_LENDING}) .statuses(new ActivityStatus[]{ActivityStatus.ACTIVITY_STATUS_CANCELLED}) @@ -99,11 +102,11 @@ public void testJsonSerialization() throws Exception { public void testBuilderRequiresEntityId() { // Test that validation works assertThrows(CoinbaseClientException.class, () -> { - new ListEntityActivitiesRequest.Builder(null).build(); + new ListEntityActivitiesRequest.Builder().entityId(null).build(); }); assertThrows(CoinbaseClientException.class, () -> { - new ListEntityActivitiesRequest.Builder("").build(); + new ListEntityActivitiesRequest.Builder().entityId("").build(); }); } } diff --git a/src/test/java/com/coinbase/prime/orders/OrdersServiceSerializationTest.java b/src/test/java/com/coinbase/prime/orders/OrdersServiceSerializationTest.java index 8d17503f..c36e6439 100644 --- a/src/test/java/com/coinbase/prime/orders/OrdersServiceSerializationTest.java +++ b/src/test/java/com/coinbase/prime/orders/OrdersServiceSerializationTest.java @@ -261,7 +261,7 @@ public void testCancelOrderRequestCreation() throws CoinbaseClientException { @Test public void testCancelOrderResponseDeserialization() throws JsonProcessingException { - String json = "{\"order_id\":\"order-789\"}"; + String json = "{\"id\":\"order-789\"}"; CancelOrderResponse response = objectMapper.readValue(json, CancelOrderResponse.class); @@ -468,7 +468,7 @@ public void testListOrderEditHistoryResponseDeserialization() throws JsonProcess assertNotNull(response); assertEquals("order-456", response.getOrderId()); assertNotNull(response.getEditHistory()); - assertEquals(2, response.getEditHistory().size()); + assertEquals(2, response.getEditHistory().length); } // ==================== Builder Validation Tests ==================== diff --git a/src/test/java/com/coinbase/prime/serialization/RequestSerializationTest.java b/src/test/java/com/coinbase/prime/serialization/RequestSerializationTest.java index e2aa0af2..1e251dc9 100644 --- a/src/test/java/com/coinbase/prime/serialization/RequestSerializationTest.java +++ b/src/test/java/com/coinbase/prime/serialization/RequestSerializationTest.java @@ -32,7 +32,6 @@ import com.coinbase.prime.paymentmethods.GetPaymentMethodDetailsRequest; import com.coinbase.prime.paymentmethods.ListPaymentMethodsRequest; import com.coinbase.prime.portfolios.GetPortfolioRequest; -import com.coinbase.prime.portfolios.ListPortfoliosRequest; import com.coinbase.prime.transactions.GetTransactionRequest; import com.coinbase.prime.transactions.ListPortfolioTransactionsRequest; import com.coinbase.prime.wallets.GetWalletRequest; @@ -50,197 +49,199 @@ public class RequestSerializationTest { @Test public void testListPortfolioActivitiesRequestConstruction() { - ListPortfolioActivitiesRequest request = new ListPortfolioActivitiesRequest.Builder("portfolio-123") - .build(); + ListPortfolioActivitiesRequest request = + new ListPortfolioActivitiesRequest.Builder().portfolioId("portfolio-123").build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetActivityRequestConstruction() { - GetActivityRequest request = new GetActivityRequest("activity-456"); + public void testGetActivityRequestConstruction() throws Exception { + GetActivityRequest request = + new GetActivityRequest.Builder().activityId("activity-456").build(); assertNotNull(request); assertEquals("activity-456", request.getActivityId()); } @Test - public void testListPortfolioAllocationsRequestConstruction() { - ListPortfolioAllocationsRequest request = new ListPortfolioAllocationsRequest.Builder("portfolio-789") - .build(); + public void testListPortfolioAllocationsRequestConstruction() throws Exception { + ListPortfolioAllocationsRequest request = + new ListPortfolioAllocationsRequest.Builder().portfolioId("portfolio-789").build(); assertNotNull(request); assertEquals("portfolio-789", request.getPortfolioId()); } @Test - public void testGetAllocationRequestConstruction() { - GetAllocationRequest request = new GetAllocationRequest.Builder("portfolio-123", "allocation-456") - .build(); + public void testGetAllocationRequestConstruction() throws Exception { + GetAllocationRequest request = + new GetAllocationRequest.Builder() + .portfolioId("portfolio-123") + .allocationId("allocation-456") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); assertEquals("allocation-456", request.getAllocationId()); } @Test - public void testListAssetsRequestConstruction() { - ListAssetsRequest request = new ListAssetsRequest.Builder("entity-123") - .build(); + public void testListAssetsRequestConstruction() throws Exception { + ListAssetsRequest request = new ListAssetsRequest.Builder().entityId("entity-123").build(); assertNotNull(request); assertEquals("entity-123", request.getEntityId()); } @Test - public void testListPortfolioBalancesRequestConstruction() { - ListPortfolioBalancesRequest request = new ListPortfolioBalancesRequest.Builder() - .portfolioId("portfolio-123") - .build(); + public void testListPortfolioBalancesRequestConstruction() throws Exception { + ListPortfolioBalancesRequest request = + new ListPortfolioBalancesRequest.Builder() + .portfolioId("portfolio-123") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetWalletBalanceRequestConstruction() { - GetWalletBalanceRequest request = new GetWalletBalanceRequest.Builder() - .portfolioId("portfolio-123") - .walletId("wallet-456") - .build(); + public void testGetWalletBalanceRequestConstruction() throws Exception { + GetWalletBalanceRequest request = + new GetWalletBalanceRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); assertEquals("wallet-456", request.getWalletId()); } @Test - public void testGetPortfolioCommissionRequestConstruction() { - GetPortfolioCommissionRequest request = new GetPortfolioCommissionRequest.Builder() - .portfolioId("portfolio-123") - .build(); + public void testGetPortfolioCommissionRequestConstruction() throws Exception { + GetPortfolioCommissionRequest request = + new GetPortfolioCommissionRequest.Builder() + .portfolioId("portfolio-123") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetMarginInformationRequestConstruction() { - GetMarginInformationRequest request = new GetMarginInformationRequest.Builder() - .entityId("entity-123") - .build(); + public void testGetMarginInformationRequestConstruction() throws Exception { + GetMarginInformationRequest request = + new GetMarginInformationRequest.Builder().entityId("entity-123").build(); assertNotNull(request); assertEquals("entity-123", request.getEntityId()); } @Test - public void testListExistingLocatesRequestConstruction() { - ListExistingLocatesRequest request = new ListExistingLocatesRequest.Builder() - .portfolioId("portfolio-123") - .build(); + public void testListExistingLocatesRequestConstruction() throws Exception { + ListExistingLocatesRequest request = + new ListExistingLocatesRequest.Builder().portfolioId("portfolio-123").build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetEntityFcmBalanceRequestConstruction() { - GetEntityFcmBalanceRequest request = new GetEntityFcmBalanceRequest.Builder() - .entityId("entity-123") - .build(); + public void testGetEntityFcmBalanceRequestConstruction() throws Exception { + GetEntityFcmBalanceRequest request = + new GetEntityFcmBalanceRequest.Builder().entityId("entity-123").build(); assertNotNull(request); assertEquals("entity-123", request.getEntityId()); } @Test - public void testListOpenOrdersRequestConstruction() { - ListOpenOrdersRequest request = new ListOpenOrdersRequest.Builder() - .portfolioId("portfolio-123") - .build(); + public void testListOpenOrdersRequestConstruction() throws Exception { + ListOpenOrdersRequest request = + new ListOpenOrdersRequest.Builder().portfolioId("portfolio-123").build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetOrderByOrderIdRequestConstruction() { - GetOrderByOrderIdRequest request = new GetOrderByOrderIdRequest.Builder() - .portfolioId("portfolio-123") - .orderId("order-456") - .build(); + public void testGetOrderByOrderIdRequestConstruction() throws Exception { + GetOrderByOrderIdRequest request = + new GetOrderByOrderIdRequest.Builder() + .portfolioId("portfolio-123") + .orderId("order-456") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); assertEquals("order-456", request.getOrderId()); } @Test - public void testListPaymentMethodsRequestConstruction() { - ListPaymentMethodsRequest request = new ListPaymentMethodsRequest.Builder("entity-123") - .build(); + public void testListPaymentMethodsRequestConstruction() throws Exception { + ListPaymentMethodsRequest request = + new ListPaymentMethodsRequest.Builder().entityId("entity-123").build(); assertNotNull(request); assertEquals("entity-123", request.getEntityId()); } @Test - public void testGetPaymentMethodDetailsRequestConstruction() { - GetPaymentMethodDetailsRequest request = new GetPaymentMethodDetailsRequest.Builder() - .entityId("entity-123") - .paymentMethodId("payment-456") - .build(); + public void testGetPaymentMethodDetailsRequestConstruction() throws Exception { + GetPaymentMethodDetailsRequest request = + new GetPaymentMethodDetailsRequest.Builder() + .entityId("entity-123") + .paymentMethodId("payment-456") + .build(); assertNotNull(request); assertEquals("entity-123", request.getEntityId()); assertEquals("payment-456", request.getPaymentMethodId()); } @Test - public void testListPortfoliosRequestConstruction() { - ListPortfoliosRequest request = new ListPortfoliosRequest.Builder().build(); - assertNotNull(request); - } - - @Test - public void testGetPortfolioRequestConstruction() { - GetPortfolioRequest request = new GetPortfolioRequest.Builder("portfolio-123") - .build(); + public void testGetPortfolioRequestConstruction() throws Exception { + GetPortfolioRequest request = + new GetPortfolioRequest.Builder().portfolioId("portfolio-123").build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetTransactionRequestConstruction() { - GetTransactionRequest request = new GetTransactionRequest.Builder("portfolio-123", "txn-456") - .build(); + public void testGetTransactionRequestConstruction() throws Exception { + GetTransactionRequest request = + new GetTransactionRequest.Builder() + .portfolioId("portfolio-123") + .transactionId("txn-456") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); assertEquals("txn-456", request.getTransactionId()); } @Test - public void testListPortfolioTransactionsRequestConstruction() { - ListPortfolioTransactionsRequest request = new ListPortfolioTransactionsRequest.Builder() - .portfolioId("portfolio-123") - .build(); + public void testListPortfolioTransactionsRequestConstruction() throws Exception { + ListPortfolioTransactionsRequest request = + new ListPortfolioTransactionsRequest.Builder() + .portfolioId("portfolio-123") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testListWalletsRequestConstruction() { - ListWalletsRequest request = new ListWalletsRequest.Builder() - .portfolioId("portfolio-123") - .build(); + public void testListWalletsRequestConstruction() throws Exception { + ListWalletsRequest request = + new ListWalletsRequest.Builder().portfolioId("portfolio-123").build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); } @Test - public void testGetWalletRequestConstruction() { - GetWalletRequest request = new GetWalletRequest.Builder("portfolio-123", "wallet-456") - .build(); + public void testGetWalletRequestConstruction() throws Exception { + GetWalletRequest request = + new GetWalletRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); assertEquals("wallet-456", request.getWalletId()); } @Test - public void testRequestWithOptionalFieldsBuildsSuccessfully() { - // Verify requests can be built without setting optional fields - ListPortfolioActivitiesRequest request = new ListPortfolioActivitiesRequest.Builder("portfolio-123") - .build(); + public void testRequestWithOptionalFieldsBuildsSuccessfully() throws Exception { + ListPortfolioActivitiesRequest request = + new ListPortfolioActivitiesRequest.Builder().portfolioId("portfolio-123").build(); assertNotNull(request); assertEquals("portfolio-123", request.getPortfolioId()); - // Optional fields are null or have default values, which is expected } } diff --git a/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java index 05a706ec..f55a87c5 100644 --- a/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java +++ b/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java @@ -99,15 +99,6 @@ public void testCreateWalletDepositAddressResponseWithNullAccountIdentifier() th @Test public void testCreateWalletDepositAddressRequestBuilderValidation() { - // Missing required fields should throw - assertThrows(CoinbaseClientException.class, () -> { - new CreateWalletDepositAddressRequest.Builder() - .portfolioId("portfolio-123") - .walletId("wallet-123") - // missing networkId - .build(); - }); - assertThrows(CoinbaseClientException.class, () -> { new CreateWalletDepositAddressRequest.Builder() .portfolioId("portfolio-123") @@ -141,8 +132,8 @@ public void testListWalletAddressesResponseDeserialization() throws JsonProcessi assertNotNull(response); assertNotNull(response.getAddresses()); - assertEquals(2, response.getAddresses().size()); - assertEquals("0xabc123", response.getAddresses().get(0).getAddress()); - assertEquals("0xdef456", response.getAddresses().get(1).getAddress()); + assertEquals(2, response.getAddresses().length); + assertEquals("0xabc123", response.getAddresses()[0].getAddress()); + assertEquals("0xdef456", response.getAddresses()[1].getAddress()); } } diff --git a/tools/model-generator/README.md b/tools/model-generator/README.md index 5e4e90ef..7c7f046a 100644 --- a/tools/model-generator/README.md +++ b/tools/model-generator/README.md @@ -1,94 +1,65 @@ -# Model Generator +# Prime Java SDK generator -Generates Java model classes and enums from the OpenAPI specification. +Generates the majority of the Prime Java SDK from the published OpenAPI spec, aligned with `prime-sdk-dotnet` (shared JSON config in `config/`). -## Purpose +## What it generates -Generates domain models (`com.coinbase.prime.model`) and enums (`com.coinbase.prime.model.enums`) from the OpenAPI spec. Request/Response classes are excluded and maintained separately in service packages. +1. **Models & enums** — OpenAPI Generator (`OpenApiGenerator`) → `PostProcessor` → `com.coinbase.prime.model` / `model.enums` +2. **Client surface** — `SdkGeneratorMain` / `ClientSurfacePhase`: per-operation `*Request`, `*Response`, `*Service`, `*ServiceImpl` under `com.coinbase.prime./` +3. **Factory** — `com.coinbase.prime.factory.PrimeServiceFactory` +4. **Examples** — If `com.coinbase.examples//.java` does not exist, a minimal stub is created (existing files are never overwritten) -## Architecture - -The generator implements a three-stage pipeline: +## Configuration -1. **OpenAPI Generator** (`OpenApiGenerator.java`) - Generates raw POJOs from the OpenAPI spec using the OpenAPI Generator library -2. **Post-Processor** (`PostProcessor.java`) - Applies transformations (Web3→Onchain renaming, schema filtering, file routing) -3. **Model Transformer** (`ModelTransformer.java`) - Uses JavaPoet to generate final models with builder pattern, license headers, and proper annotations +| File | Purpose | +|------|---------| +| `config/generator-config.json` | `specUrl`, renames, acronym mappings, `tagToFolderOverrides`, `serviceMethodOrderOverrides`, `statusCodeOverrides` (HTTP names: `OK`, `CREATED`, …) | +| `config/operations-overrides.json` | Per-`operationId` overrides: `sdkMethod`, `service`, `omitRequest`, `forcePaginated`, `paramTypeOverrides` (Java types) | +| [`../.openapi-generator-ignore`](.openapi-generator-ignore) | OpenAPI Generator ignore patterns for the **model** pass (under `model/`) | ## Usage -### Prerequisites - -- Java 11+ -- Maven 3.6+ -- Network access to fetch the OpenAPI spec from `https://api.prime.coinbase.com/v1/openapi.yaml` - -### Build - ```bash cd tools/model-generator -mvn clean package +mvn -q -Pgenerate +# optional: +mvn -q compile exec:java@generate-models -Dgenerator.args=--dry-run +mvn -q compile exec:java@generate-models -Dgenerator.args=--diff ``` -### Generate Models +Or from the **repository root**: ```bash mvn -Pgenerate +mvn -Pgenerate -Dgenerator.args=--diff ``` -Or using the JAR directly: - -```bash -java -jar target/model-generator-1.0.0.jar -``` - -## Generated Code - -Models: -- Apache 2.0 license headers -- Jackson `@JsonProperty` annotations -- Builder pattern -- Standard getters/setters (`is` prefix for booleans) -- No-arg and builder constructors - -Enums: `UPPERCASE_WITH_UNDERSCORES` naming. - -## Configuration - -### Input -- OpenAPI spec: Fetched automatically from `https://api.prime.coinbase.com/v1/openapi.yaml` during generation +The root profile runs `mvn` in this module with `-Pgenerate` and forwards `generator.args`. -### Output -- Models: `src/main/java/com/coinbase/prime/model/` -- Enums: `src/main/java/com/coinbase/prime/model/enums/` +**Wrapper:** `./tools/model-generator/generate.sh` (builds then runs the generator entrypoint). -### Filtering +## Entry points -The `.openapi-generator-ignore` file excludes: -- `*Request.java` - service-specific requests -- `*Response.java` - service-specific responses -- `Google*.java` - infrastructure types -- `RFQ.java` - inline schemas -- `*AllOf*.java` - composition artifacts +- **`com.coinbase.tools.sdkgenerator.SdkGeneratorMain`** — default `main` for the shaded JAR and `exec-maven-plugin` +- **`com.coinbase.tools.modelgenerator.Main`** — delegates to `SdkGeneratorMain` (legacy) -## Technical Details +## Phases (conceptual) -### Dependencies -- OpenAPI Generator 7.x -- Palantir JavaPoet (code generation) -- Jackson (JSON annotations) -- SnakeYAML (spec parsing) +1. Download spec to `../generated/openapi.yaml` +2. Parse YAML to `JsonNode` (`SpecParser`); build operation bindings (`OperationBindingGenerator` + `operations-overrides.json`) +3. Run model/enum generation unless `--dry-run` / `--diff` +4. Emit request/response/service and write files (`ClientSurfacePhase`) +5. Emit missing example stubs (`ExamplePhase`) +6. Regenerate `PrimeServiceFactory` (`FactoryPhase`) -### Transformations +## Tests -The post-processor applies: -- **Web3→Onchain**: Renames classes/fields containing "Web3" to "Onchain" while preserving `@JsonProperty` mappings -- **Schema filtering**: Skips schemas matching ignore patterns -- **Package routing**: Places enums in `model/enums/`, models in `model/` -- **Full regeneration**: Processes all models from the OpenAPI spec, updating existing files and creating new ones as needed +```bash +mvn test +``` -## Workflow +## Dependencies -1. Run generator: `mvn -Pgenerate` -2. Review generated files -3. Compile: `mvn clean install` -4. Commit changes +- OpenAPI Generator 7.x (models) +- Jackson (YAML + JSON for config and spec) +- JUnit 5 (tests) diff --git a/tools/model-generator/config/generator-config.json b/tools/model-generator/config/generator-config.json new file mode 100644 index 00000000..264a8ba4 --- /dev/null +++ b/tools/model-generator/config/generator-config.json @@ -0,0 +1,98 @@ +{ + "specUrl": "https://api.prime.coinbase.com/v1/openapi.yaml", + "filePathReplacements": { + "CoinbaseCustodyApiActivityType": "CustodyActivityType", + "CoinbasePublicRestApiActivityType": "PrimeActivityType", + "rFQ": "RFQ", + "FcmFuturesSweep": "FuturesSweep" + }, + "contentReplacements": { + "coinbaseCustodyApiActivityType": "CustodyActivityType", + "coinbasePublicRestApiActivityType": "PrimeActivityType", + "CoinbaseCustodyApiActivityType": "CustodyActivityType", + "CoinbasePublicRestApiActivityType": "PrimeActivityType", + "CoinbasePublicRestApi": "", + "coinbasePublicRestApi": "", + "PrimeRESTAPI": "", + "primeRESTAPI": "", + "CoinbaseCustodyApi": "", + "coinbaseCustodyApi": "", + "CoinbaseBrokerageProxyEventsMaterializedApi": "", + "coinbaseBrokerageProxyEventsMaterializedApi": "", + "publicRestApi": "", + "PublicRestApi": "", + "CreateOnchainTransactionRequestEvmParams": "EvmParams", + "FcmFuturesSweepRequestAmount": "SweepAmount", + "FcmFuturesSweep": "FuturesSweep", + "EvmParam ": "EvmParams ", + "EvmParam?": "EvmParams?", + "EvmParam>": "EvmParams>", + "RPC ": "RpcConfig ", + "RPC?": "RpcConfig?", + "RPC>": "RpcConfig>", + "PaginatedResponse": "Pagination", + "GoogleTypeDate": "DateOfBirth" + }, + "acronymMappings": [ + { "acronym": "TF", "normalized": "Tf" }, + { "acronym": "FCM", "normalized": "Fcm" }, + { "acronym": "XML", "normalized": "Xml" }, + { "acronym": "XM", "normalized": "Xm" }, + { "acronym": "PM", "normalized": "Pm" }, + { "acronym": "RFQ", "normalized": "Rfq" }, + { "acronym": "NFT", "normalized": "Nft" }, + { "acronym": "EVM", "normalized": "Evm" }, + { "acronym": "VASP", "normalized": "Vasp" } + ], + "enumNameMappings": { + "ActivityType": "PrimeActivityType" + }, + "tagToFolderOverrides": { + "Travel Rule": "transactions" + }, + "serviceMethodOrderOverrides": { + "activities": [ "ListPortfolioActivities", "ListEntityActivities", "GetActivity", "GetPortfolioActivity" ], + "addressbook": [ "ListAddressBook", "CreateAddressBookEntry" ], + "advancedtransfer": [ "ListAdvancedTransfers", "CreateAdvancedTransfer", "CancelAdvancedTransfer", "ListAdvancedTransferTransactions" ], + "allocations": [ "CreateAllocation", "CreateNetAllocation", "ListPortfolioAllocations", "ListAllocationsByNettingId", "GetAllocation" ], + "assets": [ "ListAssets" ], + "balances": [ "ListEntityBalances", "ListPortfolioBalances", "GetWalletBalance", "ListOnchainWalletBalances" ], + "commission": [ "GetPortfolioCommission" ], + "financing": [ "ListInterestAccruals", "GetCrossMarginOverview", "GetEntityLocateAvailabilities", "GetMarginInformation", "ListMarginCallSummaries", "ListTradeFinanceObligations", "GetTradeFinanceTieredPricingFees", "ListFinancingEligibleAssets", "ListInterestAccrualsForPortfolio", "GetPortfolioBuyingPower", "GetPortfolioCreditInformation", "ListExistingLocates", "CreateNewLocates", "ListMarginConversions", "GetPortfolioWithdrawalPower" ], + "futures": [ "SetAutoSweep", "GetEntityFcmBalance", "GetFcmMarginCallDetails", "GetPositions", "GetFcmRiskLimits", "GetFcmSettings", "SetFcmSettings", "ListEntityFuturesSweeps", "ScheduleEntityFuturesSweep", "CancelEntityFuturesSweep", "GetFcmEquity" ], + "invoice": [ "ListInvoices" ], + "onchainaddressbook": [ "UpdateOnchainAddressBookEntry", "CreateOnchainAddressBookEntry", "DeleteOnchainAddressGroup", "ListOnchainAddressGroups" ], + "orders": [ "AcceptQuote", "ListPortfolioFills", "ListOpenOrders", "CreateOrder", "GetOrderPreview", "ListPortfolioOrders", "GetOrderByOrderId", "CancelOrder", "EditOrder", "ListOrderEditHistory", "ListOrderFills", "CreateQuote" ], + "paymentmethods": [ "ListPaymentMethods", "GetPaymentMethodDetails" ], + "portfolios": [ "ListPortfolios", "GetPortfolio", "GetPortfolioCounterpartyId" ], + "positions": [ "ListAggregatePositions", "ListPositions" ], + "products": [ "ListPortfolioProducts", "GetCandles" ], + "staking": [ "ClaimRewards", "CreateStake", "CreateUnstake", "ListTransactionValidators", "PortfolioStakingInitiate", "PortfolioStakingUnstake", "GetStakingStatus", "GetUnstakingStatus", "PreviewUnstake" ], + "transactions": [ "ListPortfolioTransactions", "GetTransaction", "CreateConversion", "CreateOnchainTransaction", "ListWalletTransactions", "CreateWalletTransfer", "CreateWalletWithdrawal", "GetTransactionTravelRuleData", "SubmitDepositTravelRuleData" ], + "users": [ "ListEntityUsers", "ListPortfolioUsers" ], + "wallets": [ "ListWallets", "CreateWallet", "GetWallet", "ListWalletAddresses", "CreateWalletDepositAddress", "GetWalletDepositInstructions" ] + }, + "statusCodeOverrides": { + "CreateOrder": [ "CREATED", "OK" ], + "CreateQuote": [ "CREATED", "OK" ], + "CreateWallet": [ "CREATED", "OK" ], + "CreateWalletDepositAddress": [ "CREATED", "OK" ], + "CreateConversion": [ "CREATED", "OK" ], + "CreateTransfer": [ "CREATED", "OK" ], + "CreateWithdrawal": [ "CREATED", "OK" ], + "CreateOnchainTransaction": [ "CREATED", "OK" ], + "PreviewUnstake": [ "CREATED", "OK" ], + "SubmitDepositTravelRuleData": [ "CREATED", "OK" ], + "CreateAllocation": [ "CREATED", "OK" ], + "CreateNetAllocation": [ "CREATED", "OK" ], + "CreateAddressBookEntry": [ "CREATED", "OK" ], + "CreateAdvancedTransfer": [ "CREATED", "OK" ], + "CreateNewLocates": [ "CREATED", "OK" ], + "PortfolioStakingInitiate": [ "CREATED", "OK" ], + "PortfolioStakingUnstake": [ "CREATED", "OK" ], + "CreateStake": [ "CREATED", "OK" ], + "CreateUnstake": [ "CREATED", "OK" ], + "ClaimRewards": [ "CREATED", "OK" ], + "CreateOnchainAddressBookEntry": [ "CREATED", "OK" ] + } +} diff --git a/tools/model-generator/config/operations-overrides.json b/tools/model-generator/config/operations-overrides.json new file mode 100644 index 00000000..c621ac2d --- /dev/null +++ b/tools/model-generator/config/operations-overrides.json @@ -0,0 +1,166 @@ +[ + { + "operationId": "PrimeRESTAPI_CancelFuturesSweep", + "sdkMethod": "CancelEntityFuturesSweep" + }, + { + "operationId": "PrimeRESTAPI_CreateOnchainAddressGroup", + "sdkMethod": "CreateOnchainAddressBookEntry" + }, + { + "operationId": "PrimeRESTAPI_CreatePortfolioAddressBookEntry", + "sdkMethod": "CreateAddressBookEntry" + }, + { + "operationId": "PrimeRESTAPI_CreateQuoteRequest", + "sdkMethod": "CreateQuote" + }, + { + "operationId": "PrimeRESTAPI_GetAllocationsByClientNettingId", + "sdkMethod": "ListAllocationsByNettingId" + }, + { + "operationId": "PrimeRESTAPI_GetEntityActivities", + "paramTypeOverrides": { + "categories": "ActivityCategory[]", + "statuses": "ActivityStatus[]", + "activity_level": "ActivityLevel" + } + }, + { + "operationId": "PrimeRESTAPI_GetEntityAssets", + "sdkMethod": "ListAssets" + }, + { + "operationId": "PrimeRESTAPI_GetEntityPaymentMethodDetails", + "sdkMethod": "GetPaymentMethodDetails" + }, + { + "operationId": "PrimeRESTAPI_GetEntityPaymentMethods", + "sdkMethod": "ListPaymentMethods" + }, + { + "operationId": "PrimeRESTAPI_GetFcmBalance", + "sdkMethod": "GetEntityFcmBalance" + }, + { + "operationId": "PrimeRESTAPI_GetFuturesSweeps", + "sdkMethod": "ListEntityFuturesSweeps" + }, + { + "operationId": "PrimeRESTAPI_GetLocateAvailabilities", + "sdkMethod": "GetEntityLocateAvailabilities" + }, + { + "operationId": "PrimeRESTAPI_GetMarginSummaries", + "sdkMethod": "ListMarginCallSummaries" + }, + { + "operationId": "PrimeRESTAPI_GetOpenOrders", + "paramTypeOverrides": { + "order_type": "OrderType", + "order_side": "OrderSide" + } + }, + { + "operationId": "PrimeRESTAPI_GetOrders", + "sdkMethod": "ListPortfolioOrders", + "paramTypeOverrides": { + "order_type": "OrderType", + "order_side": "OrderSide" + } + }, + { + "operationId": "PrimeRESTAPI_GetOrder", + "sdkMethod": "GetOrderByOrderId" + }, + { + "operationId": "PrimeRESTAPI_GetPortfolioActivities", + "paramTypeOverrides": { + "categories": "ActivityCategory[]", + "statuses": "ActivityStatus[]" + } + }, + { + "operationId": "PrimeRESTAPI_GetPortfolioAddressBook", + "sdkMethod": "ListAddressBook" + }, + { + "operationId": "PrimeRESTAPI_GetPortfolioAllocations", + "paramTypeOverrides": { + "order_side": "OrderSide" + } + }, + { + "operationId": "PrimeRESTAPI_GetPortfolioBalances", + "forcePaginated": true, + "paramTypeOverrides": { + "balance_type": "PortfolioBalanceType", + "symbols": "String[]" + } + }, + { + "operationId": "PrimeRESTAPI_GetPortfolioCounterpartyID", + "sdkMethod": "GetPortfolioCounterpartyId" + }, + { + "operationId": "PrimeRESTAPI_GetPortfolioInterestAccruals", + "sdkMethod": "ListInterestAccrualsForPortfolio" + }, + { + "operationId": "PrimeRESTAPI_GetPostTradeCredit", + "sdkMethod": "GetPortfolioCreditInformation" + }, + { + "operationId": "PrimeRESTAPI_GetTFTieredPricingFees", + "sdkMethod": "GetTradeFinanceTieredPricingFees" + }, + { + "operationId": "PrimeRESTAPI_ListAdvancedTransferTransactions", + "service": "advancedtransfer" + }, + { + "operationId": "PrimeRESTAPI_ListAggregateEntityPositions", + "sdkMethod": "ListAggregatePositions" + }, + { + "operationId": "PrimeRESTAPI_ListEntityPositions", + "sdkMethod": "ListPositions" + }, + { + "operationId": "PrimeRESTAPI_ListTFObligations", + "sdkMethod": "ListTradeFinanceObligations" + }, + { + "operationId": "PrimeRESTAPI_OrderPreview", + "sdkMethod": "GetOrderPreview" + }, + { + "operationId": "PrimeRESTAPI_PortfolioStakingInitiate", + "sdkMethod": "PortfolioStakingInitiate" + }, + { + "operationId": "PrimeRESTAPI_PortfolioStakingUnstake", + "sdkMethod": "PortfolioStakingUnstake" + }, + { + "operationId": "PrimeRESTAPI_ScheduleFuturesSweep", + "sdkMethod": "ScheduleEntityFuturesSweep" + }, + { + "operationId": "PrimeRESTAPI_StakingClaimRewards", + "sdkMethod": "ClaimRewards" + }, + { + "operationId": "PrimeRESTAPI_StakingInitiate", + "sdkMethod": "CreateStake" + }, + { + "operationId": "PrimeRESTAPI_StakingUnstake", + "sdkMethod": "CreateUnstake" + }, + { + "operationId": "PrimeRESTAPI_UpdateOnchainAddressGroup", + "sdkMethod": "UpdateOnchainAddressBookEntry" + } +] diff --git a/tools/model-generator/generate.sh b/tools/model-generator/generate.sh new file mode 100644 index 00000000..7ae2d20f --- /dev/null +++ b/tools/model-generator/generate.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +cd "$ROOT/tools/model-generator" +mvn -q -DskipTests package +mvn -q -DskipTests exec:java@generate-models diff --git a/tools/model-generator/pom.xml b/tools/model-generator/pom.xml index d0630c32..6d7d31cb 100644 --- a/tools/model-generator/pom.xml +++ b/tools/model-generator/pom.xml @@ -21,6 +21,7 @@ 2.16.1 1.13.0 2.2 + @@ -49,6 +50,11 @@ jackson-dataformat-yaml ${jackson.version} + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson.version} + @@ -75,6 +81,12 @@ slf4j-simple 2.0.9 + + org.junit.jupiter + junit-jupiter + 5.10.0 + test + @@ -88,6 +100,11 @@ 11 + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + org.apache.maven.plugins maven-shade-plugin @@ -101,7 +118,7 @@ - com.coinbase.tools.modelgenerator.Main + com.coinbase.tools.sdkgenerator.SdkGeneratorMain @@ -120,7 +137,8 @@ java - com.coinbase.tools.modelgenerator.Main + com.coinbase.tools.sdkgenerator.SdkGeneratorMain + ${generator.args} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/Main.java b/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/Main.java index 4b86e3b2..a7226302 100644 --- a/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/Main.java +++ b/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/Main.java @@ -16,75 +16,14 @@ package com.coinbase.tools.modelgenerator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.nio.file.Path; -import java.nio.file.Paths; +import com.coinbase.tools.sdkgenerator.SdkGeneratorMain; +/** + * @deprecated Use {@link SdkGeneratorMain}. Kept for compatibility with older scripts. + */ public class Main { - private static final Logger logger = LoggerFactory.getLogger(Main.class); - - public static void main(String[] args) { - try { - logger.info("Coinbase Prime Java SDK Model Generator"); - logger.info("========================================"); - logger.info("Mode: FULL GENERATION (regenerates all models from OpenAPI spec)"); - logger.info(""); - - // Find project root - Path projectRoot = findProjectRoot(); - String specUrl = args.length > 0 ? args[0] : "https://api.prime.coinbase.com/v1/openapi.yaml"; - Path outputDir = projectRoot.resolve("src/main/java/com/coinbase/prime/model"); - Path enumsDir = outputDir.resolve("enums"); - Path tempDir = projectRoot.resolve("generated"); - - logger.info("Project Root: {}", projectRoot); - logger.info("OpenAPI Spec: {}", specUrl); - logger.info("Output Directory: {}", outputDir); - logger.info("Enums Directory: {}", enumsDir); - logger.info("Temp Directory: {}", tempDir); - - // Phase 1: Generate raw models using OpenAPI Generator - logger.info("\nPhase 1: Generating raw models with OpenAPI Generator..."); - OpenApiGenerator generator = new OpenApiGenerator(specUrl, tempDir); - generator.generateModels(); - - // Phase 2: Post-process models to match existing patterns - logger.info("\nPhase 2: Post-processing models..."); - PostProcessor postProcessor = new PostProcessor(tempDir, outputDir, enumsDir); - postProcessor.processModels(); - - logger.info("\nModel generation completed successfully!"); - logger.info("\nGenerated models are in: {}", outputDir); - logger.info("Generated enums are in: {}", enumsDir); - logger.info("\nNext steps:"); - logger.info("1. Review the generated models"); - logger.info("2. Run tests to ensure everything works"); - logger.info("3. Build the project: mvn clean install"); - - } catch (Exception e) { - logger.error("Error during model generation", e); - System.exit(1); - } - } - private static Path findProjectRoot() { - Path current = Paths.get(System.getProperty("user.dir")); - while (current != null) { - if (current.resolve("pom.xml").toFile().exists() && - current.resolve("src/main/java/com/coinbase/prime").toFile().exists()) { - return current; - } - current = current.getParent(); - } - - // If we can't find it, check if we're in the tools directory - Path toolsPath = Paths.get(System.getProperty("user.dir")); - if (toolsPath.toString().contains("tools/model-generator")) { - return toolsPath.getParent().getParent(); - } - - throw new RuntimeException("Could not find project root (looking for pom.xml and src/main/java/com/coinbase/prime)"); + public static void main(String[] args) throws Exception { + SdkGeneratorMain.main(args); } -} \ No newline at end of file +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java new file mode 100644 index 00000000..4139b119 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java @@ -0,0 +1,43 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.tools.sdkgenerator; + +public final class CopyrightHelper { + public static final int DEFAULT_YEAR = 2025; + + private CopyrightHelper() {} + + public static String javaFileHeader() { + return "/*\n" + + " * Copyright " + + DEFAULT_YEAR + + "-present Coinbase Global, Inc.\n" + + " *\n" + + " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" + + " * you may not use this file except in compliance with the License.\n" + + " * You may obtain a copy of the License at\n" + + " *\n" + + " * http://www.apache.org/licenses/LICENSE-2.0\n" + + " *\n" + + " * Unless required by applicable law or agreed to in writing, software\n" + + " * distributed under the License is distributed on an \"AS IS\" BASIS,\n" + + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + + " * See the License for the specific language governing permissions and\n" + + " * limitations under the License.\n" + + " */\n\n"; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/GeneratorPaths.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/GeneratorPaths.java new file mode 100644 index 00000000..6051e3ad --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/GeneratorPaths.java @@ -0,0 +1,53 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.tools.sdkgenerator; + +import java.nio.file.Path; + +public final class GeneratorPaths { + + private GeneratorPaths() {} + + public static Path findProjectRoot() { + Path current = Path.of(System.getProperty("user.dir")); + for (int i = 0; i < 20; i++) { + if (current.resolve("pom.xml").toFile().exists() + && current.resolve("src/main/java/com/coinbase/prime").toFile().exists()) { + return current; + } + Path parent = current.getParent(); + if (parent == null) { + break; + } + current = parent; + } + String env = System.getProperty("user.dir", ""); + if (env.contains("tools/model-generator")) { + return Path.of(env).getParent().getParent(); + } + throw new IllegalStateException( + "Could not find project root (pom.xml and src/main/java/com/coinbase/prime)."); + } + + public static Path configDirectory(Path projectRoot) { + return projectRoot.resolve("tools/model-generator/config"); + } + + public static Path toolDirectory(Path projectRoot) { + return projectRoot.resolve("tools/model-generator"); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java new file mode 100644 index 00000000..2e02ba1d --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java @@ -0,0 +1,112 @@ +package com.coinbase.tools.sdkgenerator; + +import com.coinbase.tools.sdkgenerator.phases.ClientSurfacePhase; +import com.coinbase.tools.sdkgenerator.phases.ExamplePhase; +import com.coinbase.tools.sdkgenerator.phases.FactoryPhase; +import com.coinbase.tools.sdkgenerator.phases.ModelEnumPhase; +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.OperationBindingValidator; +import com.coinbase.tools.sdkgenerator.processing.SharedTransforms; +import com.coinbase.tools.sdkgenerator.processing.SpecAnalyzer; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import com.coinbase.tools.sdkgenerator.spec.SpecParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +/** + * Holistic Prime Java SDK generator: models, enums, client surface, factory, examples. + */ +public final class SdkGeneratorMain { + + private static final Logger log = LoggerFactory.getLogger(SdkGeneratorMain.class); + + private SdkGeneratorMain() {} + + public static void main(String[] args) throws Exception { + boolean dryRun = java.util.Arrays.asList(args).contains("--dry-run"); + boolean diffMode = java.util.Arrays.asList(args).contains("--diff"); + + log.info("Coinbase Prime Java SDK Generator"); + log.info("=================================="); + if (dryRun) { + log.info("Mode: DRY-RUN (no files written)"); + } else if (diffMode) { + log.info("Mode: DIFF (compare to existing files)"); + } else { + log.info("Mode: WRITE (full generation)"); + } + + Path projectRoot = GeneratorPaths.findProjectRoot(); + GeneratorConfiguration cfg = GeneratorConfiguration.load(projectRoot); + SharedTransforms transforms = new SharedTransforms(cfg); + + Path specPath = projectRoot.resolve("generated").resolve("openapi.yaml"); + Files.createDirectories(specPath.getParent()); + log.info("Downloading OpenAPI spec from {} to {}...", cfg.getSpecUrl(), specPath); + HttpClient http = HttpClient.newHttpClient(); + HttpRequest req = + HttpRequest.newBuilder(URI.create(cfg.getSpecUrl())) + .GET() + .build(); + HttpResponse res = http.send(req, HttpResponse.BodyHandlers.ofString()); + Files.writeString(specPath, res.body()); + + log.info("Parsing OpenAPI YAML for client surface..."); + ParsedOpenApiDocument document = SpecParser.load(specPath); + SpecAnalyzer.apply(document, cfg, log); + + if (!dryRun && !diffMode) { + ModelEnumPhase.run(log, projectRoot, specPath.toString()); + } else { + log.info("Skipping model/enum CLI phase (--dry-run or --diff)."); + } + + GeneratorConfiguration.OperationBindingMergeResult merge = + GeneratorConfiguration.mergeOperationBindings(document, cfg, projectRoot); + OperationBindingValidator.validateOperationBindings(log, document, merge); + List operations = merge.getMerged(); + + Path primeRoot = projectRoot.resolve("src/main/java/com/coinbase/prime"); + ClientSurfacePhase client = + new ClientSurfacePhase(log, document, cfg, transforms, primeRoot); + client.run(operations, dryRun, diffMode); + + Path examplesRoot = projectRoot.resolve("src/main/java/com/coinbase/examples"); + ExamplePhase examples = new ExamplePhase(log, document, cfg, examplesRoot); + examples.run(operations, dryRun, diffMode); + + String factory = FactoryPhase.emit(cfg); + Path factoryPath = + projectRoot.resolve("src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java"); + if (diffMode) { + if (!Files.exists(factoryPath)) { + log.info("DIFF missing factory would be created: {}", factoryPath); + } else { + String existing = Files.readString(factoryPath).replace("\r\n", "\n"); + if (!existing.equals(factory.replace("\r\n", "\n"))) { + log.warn("DIFF differs: {}", factoryPath); + } + } + } else if (dryRun) { + log.info("DRY-RUN would write {} ({} chars)", factoryPath, factory.length()); + } else { + Files.createDirectories(factoryPath.getParent()); + Files.writeString(factoryPath, factory); + } + + log.info(""); + log.info("Holistic generation finished."); + if (!dryRun && !diffMode) { + log.info("Next: mvn clean install (from repository root)"); + } + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java new file mode 100644 index 00000000..74938bf5 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java @@ -0,0 +1,179 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.NamingResolver; +import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; +import com.coinbase.tools.sdkgenerator.processing.SharedTransforms; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import org.slf4j.Logger; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +public final class ClientSurfacePhase { + + private final Logger log; + private final ParsedOpenApiDocument doc; + private final GeneratorConfiguration cfg; + private final SharedTransforms transforms; + private final Path primeSrcRoot; + + public ClientSurfacePhase( + Logger log, + ParsedOpenApiDocument doc, + GeneratorConfiguration cfg, + SharedTransforms transforms, + Path primeSrcRoot) { + this.log = log; + this.doc = doc; + this.cfg = cfg; + this.transforms = transforms; + this.primeSrcRoot = primeSrcRoot; + } + + public void run( + List bindings, boolean dryRun, boolean diffMode) throws IOException { + Map> byService = new LinkedHashMap<>(); + for (SdkOperationBinding b : bindings) { + ParsedOperation op = doc.getOperationsById().get(b.getOperationId()); + if (op == null) { + log.warn("OpenAPI spec missing operationId {}; skipping.", b.getOperationId()); + continue; + } + byService.computeIfAbsent(b.getService(), k -> new ArrayList<>()) + .add(new ServicePhase.SdkOpPair(b, op)); + } + for (String key : new ArrayList<>(byService.keySet())) { + byService.put(key, sortOperationsForService(key, byService.get(key))); + } + + for (Map.Entry> e : + byService.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toList())) { + String serviceKey = e.getKey(); + List ops = e.getValue(); + ServiceDefinition svc = NamingResolver.requireService(cfg, serviceKey); + Path folder = primeSrcRoot.resolve(svc.getFolder()); + for (ServicePhase.SdkOpPair pair : ops) { + SdkOperationBinding b = pair.binding; + if (!b.isOmitRequest()) { + String req = RequestPhase.emitRequest(doc, cfg, transforms, b, pair.op); + writeOrDiff( + folder.resolve(b.getSdkMethod() + "Request.java"), req, dryRun, diffMode); + } else { + Path stale = folder.resolve(b.getSdkMethod() + "Request.java"); + if (Files.exists(stale) && !dryRun && !diffMode) { + Files.delete(stale); + log.info("REQUEST deleted stale (omitRequest): {}", stale); + } else if (Files.exists(stale) && (dryRun || diffMode)) { + log.info("REQUEST stale (omitRequest) would delete: {}", stale); + } + } + String resp = + ResponsePhase.emitResponse( + doc, cfg, transforms, b, pair.op); + writeOrDiff( + folder.resolve(b.getSdkMethod() + "Response.java"), resp, dryRun, diffMode); + } + } + + for (Map.Entry> e : + byService.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .collect(Collectors.toList())) { + ServiceDefinition svc = NamingResolver.requireService(cfg, e.getKey()); + Path folder = primeSrcRoot.resolve(svc.getFolder()); + String iface = ServicePhase.emitInterface(svc, e.getValue()); + String impl = ServicePhase.emitServiceImpl(cfg, svc, e.getValue()); + writeOrDiff(folder.resolve(svc.getJavaInterfaceName() + ".java"), iface, dryRun, diffMode); + writeOrDiff( + folder.resolve(svc.getJavaServiceImplName() + ".java"), impl, dryRun, diffMode); + } + } + + private void writeOrDiff(Path path, String content, boolean dryRun, boolean diffMode) + throws IOException { + content = content.replace("\r\n", "\n"); + if (diffMode) { + if (!Files.exists(path)) { + log.info("DIFF missing file would be created: {}", path); + return; + } + String existing = Files.readString(path).replace("\r\n", "\n"); + if (!existing.equals(content)) { + log.warn("DIFF differs: {}", path); + } + return; + } + if (dryRun) { + log.info("DRY-RUN would write {} ({} chars)", path, content.length()); + return; + } + Files.createDirectories(path.getParent()); + Files.writeString(path, content); + } + + private static int httpVerbRank(String m) { + switch (m.toUpperCase(Locale.ROOT)) { + case "GET": + return 0; + case "POST": + return 1; + case "PUT": + return 2; + case "PATCH": + return 3; + case "DELETE": + return 4; + default: + return 5; + } + } + + private static int pathDepth(String path) { + if (path == null) { + return 0; + } + return (int) path.chars().filter(c -> c == '/').count(); + } + + private List sortOperationsForService( + String serviceKey, List ops) { + List order = cfg.getServiceMethodOrderOverrides().get(serviceKey); + if (order != null && !order.isEmpty()) { + Map rank = new LinkedHashMap<>(); + for (int i = 0; i < order.size(); i++) { + rank.put(order.get(i), i); + } + return ops.stream() + .sorted( + Comparator.comparing( + (ServicePhase.SdkOpPair x) -> + rank.getOrDefault( + x.binding.getSdkMethod(), + Integer.MAX_VALUE)) + .thenComparing(x -> x.binding.getSdkMethod())) + .collect(Collectors.toList()); + } + return ops.stream() + .sorted( + Comparator.comparingInt( + (ServicePhase.SdkOpPair x) -> httpVerbRank(x.op.getHttpMethod())) + .thenComparingInt( + (ServicePhase.SdkOpPair x) -> pathDepth(x.op.getPath())) + .thenComparing((ServicePhase.SdkOpPair x) -> x.op.getPath()) + .thenComparing((ServicePhase.SdkOpPair x) -> x.binding.getSdkMethod())) + .collect(Collectors.toList()); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java new file mode 100644 index 00000000..f20082ba --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java @@ -0,0 +1,89 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.sdkgenerator.CopyrightHelper; +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.NamingResolver; +import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import org.slf4j.Logger; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +/** + * Creates minimal example .java under {@code com.coinbase.examples} when missing. + */ +public final class ExamplePhase { + + private final Logger log; + private final ParsedOpenApiDocument doc; + @SuppressWarnings("unused") + private final GeneratorConfiguration cfg; + private final Path examplesRoot; + + public ExamplePhase( + Logger log, ParsedOpenApiDocument doc, GeneratorConfiguration cfg, Path examplesRoot) { + this.log = log; + this.doc = doc; + this.cfg = cfg; + this.examplesRoot = examplesRoot; + } + + public void run(List bindings, boolean dryRun, boolean diffMode) + throws IOException { + for (SdkOperationBinding b : bindings) { + ParsedOperation op = doc.getOperationsById().get(b.getOperationId()); + if (op == null) { + continue; + } + ServiceDefinition svc = NamingResolver.requireService(cfg, b.getService()); + Path p = + examplesRoot + .resolve(svc.getFolder()) + .resolve(b.getSdkMethod() + ".java"); + if (Files.exists(p)) { + if (!diffMode) { + log.info("EXAMPLE skip (exists): {}", p); + } + continue; + } + String content = emitStub(b, op, svc); + if (dryRun) { + log.info("EXAMPLE DRY-RUN would create {} ({} chars)", p, content.length()); + continue; + } + if (diffMode) { + log.info("EXAMPLE DIFF missing: {}", p); + continue; + } + Files.createDirectories(p.getParent()); + Files.writeString(p, content); + log.info("EXAMPLE created: {}", p); + } + } + + private static String emitStub( + SdkOperationBinding b, ParsedOperation op, ServiceDefinition svc) { + String name = b.getSdkMethod(); + StringBuilder s = new StringBuilder(); + s.append(CopyrightHelper.javaFileHeader()); + s.append("package com.coinbase.examples.").append(svc.getFolder()).append(";\n\n"); + s.append("/**\n * Example stub for ") + .append(name) + .append(" (") + .append(op.getHttpMethod()) + .append(" ") + .append(op.getPath()) + .append(").\n * Replace with a real example using requests from this package.\n */\n"); + s.append("public class ").append(name).append(" {\n"); + s.append(" public static void main(String[] args) {\n"); + s.append(" System.out.println(\"TODO: implement example for ").append(name).append("\");\n"); + s.append(" }\n"); + s.append("}\n"); + return s.toString(); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/FactoryPhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/FactoryPhase.java new file mode 100644 index 00000000..6951a36a --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/FactoryPhase.java @@ -0,0 +1,47 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.sdkgenerator.CopyrightHelper; +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; + +/** Emits {@code com.coinbase.prime.factory.PrimeServiceFactory}. */ +public final class FactoryPhase { + + private FactoryPhase() {} + + public static String emit(GeneratorConfiguration cfg) { + List defs = + cfg.getServices().values().stream() + .sorted(Comparator.comparing(ServiceDefinition::getFolder)) + .collect(Collectors.toCollection(ArrayList::new)); + StringBuilder s = new StringBuilder(); + s.append(CopyrightHelper.javaFileHeader()); + s.append("package com.coinbase.prime.factory;\n\n"); + for (ServiceDefinition d : defs) { + s.append("import com.coinbase.prime.").append(d.getFolder()).append(".").append(d.getJavaInterfaceName()).append(";\n"); + s.append("import com.coinbase.prime.").append(d.getFolder()).append(".").append(d.getJavaServiceImplName()).append(";\n"); + } + s.append("import com.coinbase.prime.client.CoinbasePrimeClient;\n\n"); + s.append("public class PrimeServiceFactory {\n"); + for (ServiceDefinition d : defs) { + String method = "create" + d.getPascalName() + "Service"; + s.append(" public static ") + .append(d.getJavaInterfaceName()) + .append(" ") + .append(method) + .append("(CoinbasePrimeClient client) {\n"); + s.append(" return new ") + .append(d.getJavaServiceImplName()) + .append("(client);\n"); + s.append(" }\n\n"); + } + s.append("}\n"); + return s.toString(); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ModelEnumPhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ModelEnumPhase.java new file mode 100644 index 00000000..8cd518f7 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ModelEnumPhase.java @@ -0,0 +1,26 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.modelgenerator.OpenApiGenerator; +import com.coinbase.tools.modelgenerator.PostProcessor; +import org.slf4j.Logger; + +import java.nio.file.Path; + +/** + * Runs OpenAPI Generator for models/enums then post-processes into the SDK tree. + */ +public final class ModelEnumPhase { + + private ModelEnumPhase() {} + + public static void run(Logger log, Path projectRoot, String specPath) throws Exception { + Path generated = projectRoot.resolve("generated"); + Path modelDir = projectRoot.resolve("src/main/java/com/coinbase/prime/model"); + Path enumsDir = modelDir.resolve("enums"); + log.info("Phase: model/enum OpenAPI generation into {}", modelDir); + OpenApiGenerator generator = new OpenApiGenerator(specPath, generated); + generator.generateModels(); + PostProcessor postProcessor = new PostProcessor(generated, modelDir, enumsDir); + postProcessor.processModels(); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/RequestPhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/RequestPhase.java new file mode 100644 index 00000000..cbe53ddb --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/RequestPhase.java @@ -0,0 +1,366 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.sdkgenerator.CopyrightHelper; +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.NamingResolver; +import com.coinbase.tools.sdkgenerator.processing.OpenApiSchemaCodegen; +import com.coinbase.tools.sdkgenerator.processing.OpenApiSchemaCodegen.JavaTypeResult; +import com.coinbase.tools.sdkgenerator.processing.SchemaProperty; +import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; +import com.coinbase.tools.sdkgenerator.processing.SharedTransforms; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.ParsedParameter; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.TreeSet; +import java.util.stream.Collectors; + +/** + * Emits per-operation *Request.java (builder style matching hand-written Prime SDK). + */ +public final class RequestPhase { + + private RequestPhase() {} + + public static String emitRequest( + ParsedOpenApiDocument doc, + GeneratorConfiguration cfg, + SharedTransforms transforms, + SdkOperationBinding b, + ParsedOperation op) { + ServiceDefinition svc = NamingResolver.requireService(cfg, b.getService()); + String pkg = svc.getJavaPackage(); + String sdk = b.getSdkMethod(); + String className = sdk + "Request"; + + List pathParams = + op.getParameters().stream() + .filter(p -> "path".equals(p.getIn())) + .collect(Collectors.toList()); + List queryParams = + op.getParameters().stream() + .filter(p -> "query".equals(p.getIn())) + .collect(Collectors.toList()); + List bodyProps = + op.getRequestBodyJsonSchema() != null + ? OpenApiSchemaCodegen.listProperties( + doc.getRoot(), op.getRequestBodyJsonSchema(), transforms) + : new ArrayList<>(); + + boolean paginated = + b.isForcePaginated() + || queryParams.stream() + .anyMatch( + p -> + "cursor".equals(p.getName()) + || "sort_direction".equals(p.getName())); + + List queryParamsForMembers = + paginated + ? queryParams.stream() + .filter( + p -> + !"cursor".equals(p.getName()) + && !"limit".equals(p.getName()) + && !"sort_direction" + .equals(p.getName())) + .collect(Collectors.toList()) + : queryParams; + + TreeSet modelImports = new TreeSet<>(); + TreeSet enumImports = new TreeSet<>(); + for (SchemaProperty p : bodyProps) { + modelImports.addAll(p.getReferencedModelTypeNames()); + enumImports.addAll(p.getReferencedEnumTypeNames()); + } + for (ParsedParameter p : pathParams) { + JavaTypeResult tr = + OpenApiSchemaCodegen.toJavaType(doc.getRoot(), p.getSchema(), transforms); + modelImports.addAll(tr.getModelTypeNames()); + enumImports.addAll(tr.getEnumTypeNames()); + } + for (ParsedParameter p : queryParamsForMembers) { + JavaTypeResult tr = + OpenApiSchemaCodegen.toJavaType(doc.getRoot(), p.getSchema(), transforms); + modelImports.addAll(tr.getModelTypeNames()); + enumImports.addAll(tr.getEnumTypeNames()); + } + if (paginated) { + enumImports.add("SortDirection"); + } + + StringBuilder i = new StringBuilder(); + i.append(CopyrightHelper.javaFileHeader()); + i.append("package ").append(pkg).append(";\n\n"); + i.append("import com.coinbase.core.errors.CoinbaseClientException;\n"); + if (paginated) { + i.append("import com.coinbase.prime.common.PrimeListRequest;\n"); + i.append("import com.coinbase.prime.common.Pagination;\n"); + } + for (String m : modelImports) { + i.append("import com.coinbase.prime.model.").append(m).append(";\n"); + } + for (String e : enumImports) { + i.append("import com.coinbase.prime.model.enums.").append(e).append(";\n"); + } + i.append("import com.fasterxml.jackson.annotation.JsonIgnore;\n"); + i.append("import com.fasterxml.jackson.annotation.JsonProperty;\n"); + i.append("\nimport static com.coinbase.core.utils.Utils.isNullOrEmpty;\n\n"); + + if (op.getSummary() != null && !op.getSummary().isEmpty()) { + i.append("/**\n * ").append(escapeJavadoc(op.getSummary())).append("\n */\n"); + } + + if (paginated) { + i.append("public class ").append(className).append(" extends PrimeListRequest {\n"); + } else { + i.append("public class ").append(className).append(" {\n"); + } + + for (ParsedParameter p : pathParams) { + String jt = mapPathParamJava(doc, transforms, b, p); + String prop = OpenApiSchemaCodegen.toPascalCase(p.getName()); + i.append(" @JsonProperty"); + if (p.isRequired()) { + i.append("(required = true, value = \"").append(p.getName()).append("\")"); + } else { + i.append("(\"").append(p.getName()).append("\")"); + } + i.append("\n"); + i.append(" @JsonIgnore\n"); + i.append(" private ").append(jt).append(" ").append(camelize(prop)).append(";\n\n"); + } + for (ParsedParameter p : queryParamsForMembers) { + String jt = mapQueryParamJava(doc, transforms, b, p); + i.append(" @JsonProperty(\"").append(p.getName()).append("\")\n"); + i.append(" private ") + .append(jt) + .append(" ") + .append(camelize(OpenApiSchemaCodegen.toPascalCase(p.getName()))) + .append(";\n\n"); + } + for (SchemaProperty p : bodyProps) { + i.append(" @JsonProperty(\"").append(p.getJsonName()).append("\")\n"); + i.append(" private ") + .append(p.getJavaType()) + .append(" ") + .append(camelize(p.getJavaName())) + .append(";\n\n"); + } + + i.append(" public ").append(className).append("() {\n }\n\n"); + + if (paginated) { + i.append(" public ").append(className).append("(Builder builder) {\n"); + i.append(" super(builder.cursor, builder.sortDirection, builder.limit);\n"); + for (ParsedParameter p : pathParams) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + i.append(" this.").append(c).append(" = builder.").append(c).append(";\n"); + } + for (ParsedParameter p : queryParamsForMembers) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + i.append(" this.").append(c).append(" = builder.").append(c).append(";\n"); + } + for (SchemaProperty p : bodyProps) { + String c = camelize(p.getJavaName()); + i.append(" this.").append(c).append(" = builder.").append(c).append(";\n"); + } + i.append(" }\n\n"); + } else { + i.append(" public ").append(className).append("(Builder builder) {\n"); + for (ParsedParameter p : pathParams) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + i.append(" this.").append(c).append(" = builder.").append(c).append(";\n"); + } + for (ParsedParameter p : queryParamsForMembers) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + i.append(" this.").append(c).append(" = builder.").append(c).append(";\n"); + } + for (SchemaProperty p : bodyProps) { + String c = camelize(p.getJavaName()); + i.append(" this.").append(c).append(" = builder.").append(c).append(";\n"); + } + i.append(" }\n\n"); + } + + for (ParsedParameter p : pathParams) { + appendAccessorPair( + i, + mapPathParamJava(doc, transforms, b, p), + OpenApiSchemaCodegen.toPascalCase(p.getName()), + camelize(OpenApiSchemaCodegen.toPascalCase(p.getName()))); + } + for (ParsedParameter p : queryParamsForMembers) { + appendAccessorPair( + i, + mapQueryParamJava(doc, transforms, b, p), + OpenApiSchemaCodegen.toPascalCase(p.getName()), + camelize(OpenApiSchemaCodegen.toPascalCase(p.getName()))); + } + for (SchemaProperty p : bodyProps) { + appendAccessorPair( + i, p.getJavaType(), p.getJavaName(), camelize(p.getJavaName())); + } + + i.append(" public static class Builder {\n"); + for (ParsedParameter p : pathParams) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + String jt = mapPathParamJava(doc, transforms, b, p); + i.append(" private ").append(jt).append(" ").append(c).append(";\n"); + } + for (ParsedParameter p : queryParamsForMembers) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + String jt = mapQueryParamJava(doc, transforms, b, p); + i.append(" private ").append(jt).append(" ").append(c).append(";\n"); + } + for (SchemaProperty p : bodyProps) { + String c = camelize(p.getJavaName()); + i.append(" private ").append(p.getJavaType()).append(" ").append(c).append(";\n"); + } + if (paginated) { + i.append(" private String cursor;\n"); + i.append(" private SortDirection sortDirection;\n"); + i.append(" private Integer limit;\n"); + } + + i.append("\n public Builder() {\n }\n\n"); + + for (ParsedParameter p : pathParams) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + String g = OpenApiSchemaCodegen.toPascalCase(p.getName()); + String jt = mapPathParamJava(doc, transforms, b, p); + i.append(" public Builder ") + .append(camelize(g)) + .append("(") + .append(jt) + .append(" ") + .append(c) + .append(") {\n"); + i.append(" this.").append(c).append(" = ").append(c).append(";\n"); + i.append(" return this;\n"); + i.append(" }\n\n"); + } + for (ParsedParameter p : queryParamsForMembers) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + String g = OpenApiSchemaCodegen.toPascalCase(p.getName()); + String jt = mapQueryParamJava(doc, transforms, b, p); + i.append(" public Builder ") + .append(camelize(g)) + .append("(") + .append(jt) + .append(" ") + .append(c) + .append(") {\n"); + i.append(" this.").append(c).append(" = ").append(c).append(";\n"); + i.append(" return this;\n"); + i.append(" }\n\n"); + } + for (SchemaProperty p : bodyProps) { + String c = camelize(p.getJavaName()); + i.append(" public Builder ") + .append(c) + .append("(") + .append(p.getJavaType()) + .append(" ") + .append(c) + .append(") {\n"); + i.append(" this.").append(c).append(" = ").append(c).append(";\n"); + i.append(" return this;\n"); + i.append(" }\n\n"); + } + if (paginated) { + i.append(" public Builder limit(Integer limit) {\n"); + i.append(" this.limit = limit;\n"); + i.append(" return this;\n"); + i.append(" }\n\n"); + i.append(" public Builder pagination(Pagination pagination) {\n"); + i.append(" this.cursor = pagination.getNextCursor();\n"); + i.append(" this.sortDirection = pagination.getSortDirection();\n"); + i.append(" return this;\n"); + i.append(" }\n\n"); + } + + i.append(" public ").append(className).append(" build() throws CoinbaseClientException {\n"); + i.append(" validate();\n"); + i.append(" return new ").append(className).append("(this);\n"); + i.append(" }\n\n"); + i.append(" private void validate() throws CoinbaseClientException {\n"); + for (ParsedParameter p : pathParams) { + if (p.isRequired() && p.getSchema() != null) { + String jt = mapPathParamJava(doc, transforms, b, p); + if ("String".equals(jt)) { + String c = camelize(OpenApiSchemaCodegen.toPascalCase(p.getName())); + String g = OpenApiSchemaCodegen.toPascalCase(p.getName()); + i.append(" if (isNullOrEmpty(this.") + .append(c) + .append(")) {\n"); + i.append(" throw new CoinbaseClientException(\"") + .append(g) + .append(" is required\");\n"); + i.append(" }\n"); + } + } + } + i.append(" }\n"); + i.append(" }\n"); + i.append("}\n"); + return i.toString(); + } + + private static void appendAccessorPair( + StringBuilder i, String javaType, String pascalName, String fieldCamel) { + i.append(" public ") + .append(javaType) + .append(" get") + .append(pascalName) + .append("() {\n"); + i.append(" return ").append(fieldCamel).append(";\n"); + i.append(" }\n\n"); + i.append(" public void set") + .append(pascalName) + .append("(") + .append(javaType) + .append(" ") + .append(fieldCamel) + .append(") {\n"); + i.append(" this.").append(fieldCamel).append(" = ").append(fieldCamel).append(";\n"); + i.append(" }\n\n"); + } + + private static String camelize(String pascal) { + if (pascal == null || pascal.isEmpty()) { + return pascal; + } + return pascal.substring(0, 1).toLowerCase(Locale.ROOT) + pascal.substring(1); + } + + private static String escapeJavadoc(String s) { + return s.replace("*/", "* /"); + } + + private static String mapPathParamJava( + ParsedOpenApiDocument doc, SharedTransforms transforms, SdkOperationBinding b, ParsedParameter p) { + if (b.getParamTypeOverrides().containsKey(p.getName()) && b.getParamTypeOverrides().get(p.getName()) != null) { + String o = b.getParamTypeOverrides().get(p.getName()).trim(); + if (!o.isEmpty()) { + return o; + } + } + return OpenApiSchemaCodegen.toJavaType(doc.getRoot(), p.getSchema(), transforms).getJavaType(); + } + + private static String mapQueryParamJava( + ParsedOpenApiDocument doc, SharedTransforms transforms, SdkOperationBinding b, ParsedParameter p) { + if (b.getParamTypeOverrides().containsKey(p.getName()) && b.getParamTypeOverrides().get(p.getName()) != null) { + String o = b.getParamTypeOverrides().get(p.getName()).trim(); + if (!o.isEmpty()) { + return o; + } + } + return OpenApiSchemaCodegen.toJavaType(doc.getRoot(), p.getSchema(), transforms).getJavaType(); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ResponsePhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ResponsePhase.java new file mode 100644 index 00000000..87bf9cf8 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ResponsePhase.java @@ -0,0 +1,116 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.sdkgenerator.CopyrightHelper; +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.NamingResolver; +import com.coinbase.tools.sdkgenerator.processing.OpenApiSchemaCodegen; +import com.coinbase.tools.sdkgenerator.processing.SchemaProperty; +import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; +import com.coinbase.tools.sdkgenerator.processing.SharedTransforms; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import com.coinbase.tools.sdkgenerator.spec.SpecRef; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; +import java.util.TreeSet; + +public final class ResponsePhase { + + private ResponsePhase() {} + + public static String emitResponse( + ParsedOpenApiDocument doc, + GeneratorConfiguration cfg, + SharedTransforms transforms, + SdkOperationBinding b, + ParsedOperation op) { + ServiceDefinition svc = NamingResolver.requireService(cfg, b.getService()); + String pkg = svc.getJavaPackage(); + String name = b.getSdkMethod() + "Response"; + StringBuilder o = new StringBuilder(); + o.append(CopyrightHelper.javaFileHeader()); + o.append("package ").append(pkg).append(";\n\n"); + + if (op.getSuccessResponseSchemaRef() == null || op.getSuccessResponseSchemaRef().isEmpty()) { + o.append("/**\n * Response for ").append(b.getSdkMethod()).append(".\n */\n"); + o.append("public class ").append(name).append(" {\n"); + o.append(" public ").append(name).append("() {\n }\n"); + o.append("}\n"); + return o.toString(); + } + + JsonNode schema = SpecRef.resolveRef(doc.getRoot(), op.getSuccessResponseSchemaRef()); + if (schema == null) { + o.append("public class ").append(name).append(" {\n"); + o.append(" public ").append(name).append("() {\n }\n"); + o.append("}\n"); + return o.toString(); + } + List props = OpenApiSchemaCodegen.listProperties(doc.getRoot(), schema, transforms); + TreeSet modelImports = new TreeSet<>(); + TreeSet enumImports = new TreeSet<>(); + for (SchemaProperty p : props) { + modelImports.addAll(p.getReferencedModelTypeNames()); + enumImports.addAll(p.getReferencedEnumTypeNames()); + } + for (String m : modelImports) { + if ("Pagination".equals(m)) { + o.append("import com.coinbase.prime.common.Pagination;\n"); + } else { + o.append("import com.coinbase.prime.model.").append(m).append(";\n"); + } + } + for (String e : enumImports) { + o.append("import com.coinbase.prime.model.enums.").append(e).append(";\n"); + } + o.append("import com.fasterxml.jackson.annotation.JsonProperty;\n\n"); + + if (op.getSummary() != null && !op.getSummary().isEmpty()) { + o.append("/**\n * ").append(escape(op.getSummary())).append("\n */\n"); + } + o.append("public class ").append(name).append(" {\n"); + for (SchemaProperty p : props) { + o.append(" @JsonProperty(\"").append(p.getJsonName()).append("\")\n"); + o.append(" private ") + .append(p.getJavaType()) + .append(" ") + .append(camelize(p.getJavaName())) + .append(";\n\n"); + } + o.append(" public ").append(name).append("() {\n }\n\n"); + for (SchemaProperty p : props) { + String c = camelize(p.getJavaName()); + o.append(" public ") + .append(p.getJavaType()) + .append(" get") + .append(p.getJavaName()) + .append("() {\n"); + o.append(" return ").append(c).append(";\n"); + o.append(" }\n\n"); + o.append(" public void set") + .append(p.getJavaName()) + .append("(") + .append(p.getJavaType()) + .append(" ") + .append(c) + .append(") {\n"); + o.append(" this.").append(c).append(" = ").append(c).append(";\n"); + o.append(" }\n\n"); + } + o.append("}\n"); + return o.toString(); + } + + private static String camelize(String pascal) { + if (pascal == null || pascal.isEmpty()) { + return pascal; + } + return pascal.substring(0, 1).toLowerCase() + pascal.substring(1); + } + + private static String escape(String s) { + return s.replace("*/", "* /"); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ServicePhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ServicePhase.java new file mode 100644 index 00000000..a4b3692a --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ServicePhase.java @@ -0,0 +1,255 @@ +package com.coinbase.tools.sdkgenerator.phases; + +import com.coinbase.tools.sdkgenerator.CopyrightHelper; +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; +import com.coinbase.tools.sdkgenerator.processing.OpenApiSchemaCodegen; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +public final class ServicePhase { + + private static final Pattern PATH_PARAM = Pattern.compile("\\{([^}]+)}"); + + private ServicePhase() {} + + public static String emitInterface( + ServiceDefinition svc, List operations) { + StringBuilder s = new StringBuilder(); + s.append(CopyrightHelper.javaFileHeader()); + s.append("package ").append(svc.getJavaPackage()).append(";\n\n"); + s.append("import com.coinbase.core.errors.CoinbaseClientException;\n"); + s.append("import com.coinbase.prime.errors.CoinbasePrimeException;\n\n"); + s.append("public interface ").append(svc.getJavaInterfaceName()).append(" {\n"); + for (SdkOpPair pair : operations) { + if (pair.op.getSummary() != null && !pair.op.getSummary().isEmpty()) { + s.append(" /** ").append(escapeJavadoc(pair.op.getSummary())).append(" */\n"); + } + if (pair.binding.isOmitRequest()) { + s.append(" ") + .append(pair.binding.getSdkMethod()) + .append("Response ") + .append(camelizeMethod(pair.binding.getSdkMethod())) + .append("()") + .append(" throws CoinbaseClientException, CoinbasePrimeException;\n"); + } else { + s.append(" ") + .append(pair.binding.getSdkMethod()) + .append("Response ") + .append(camelizeMethod(pair.binding.getSdkMethod())) + .append("(") + .append(pair.binding.getSdkMethod()) + .append("Request request)") + .append(" throws CoinbaseClientException, CoinbasePrimeException;\n"); + } + } + s.append("}\n"); + return s.toString(); + } + + public static String emitServiceImpl( + GeneratorConfiguration cfg, ServiceDefinition svc, List operations) { + StringBuilder s = new StringBuilder(); + s.append(CopyrightHelper.javaFileHeader()); + s.append("package ").append(svc.getJavaPackage()).append(";\n\n"); + s.append("import com.coinbase.core.common.HttpMethod;\n"); + s.append("import com.coinbase.core.service.CoinbaseServiceImpl;\n"); + s.append("import com.coinbase.prime.client.CoinbasePrimeClient;\n"); + s.append("import com.coinbase.prime.errors.CoinbasePrimeException;\n"); + s.append("import com.fasterxml.jackson.core.type.TypeReference;\n\n"); + s.append("import java.util.List;\n\n"); + s.append("public class ") + .append(svc.getJavaServiceImplName()) + .append(" extends CoinbaseServiceImpl implements ") + .append(svc.getJavaInterfaceName()) + .append(" {\n"); + s.append(" public ") + .append(svc.getJavaServiceImplName()) + .append("(CoinbasePrimeClient client) {\n"); + s.append(" super(client);\n }\n\n"); + + for (SdkOpPair pair : operations) { + String m = pair.binding.getSdkMethod(); + s.append(" @Override\n"); + s.append(" public ") + .append(m) + .append("Response ") + .append(camelizeMethod(m)) + .append("("); + if (!pair.binding.isOmitRequest()) { + s.append(m).append("Request request"); + } + s.append(") throws CoinbasePrimeException {\n"); + s.append(" return this.request(\n"); + s.append(" HttpMethod.").append(httpMethodConst(pair.op.getHttpMethod())).append(",\n"); + s.append(" ") + .append(pathExpression(cfg, pair.binding, pair.op)) + .append(",\n"); + s.append(" ") + .append(requestBodyArg(pair.binding, pair.op)) + .append(",\n"); + s.append(" List.of(") + .append( + javaStatusList(cfg, pair.binding.getSdkMethod(), pair.op).stream() + .map(String::valueOf) + .collect(Collectors.joining(", "))) + .append("),\n"); + s.append(" new TypeReference<") + .append(m) + .append("Response>() {});\n"); + s.append(" }\n\n"); + } + s.append("}\n"); + return s.toString(); + } + + public static String requestBodyArg(SdkOperationBinding b, ParsedOperation op) { + if (b.isOmitRequest()) { + return "null"; + } + return "request"; + } + + public static String pathExpression( + GeneratorConfiguration cfg, SdkOperationBinding b, ParsedOperation op) { + if (b.isOmitRequest()) { + if (PATH_PARAM.matcher(op.getPath()).find()) { + throw new IllegalStateException( + "omitRequest operations cannot include path template parameters."); + } + return stringLiteral(trimApiPrefix(op.getPath())); + } + String p = trimApiPrefix(op.getPath()); + List paramNames = new ArrayList<>(); + Matcher m = PATH_PARAM.matcher(p); + while (m.find()) { + paramNames.add(m.group(1)); + } + if (paramNames.isEmpty()) { + return stringLiteral(p); + } + String formatStr = p.replaceAll("\\{[^}]+}", "%s"); + StringBuilder sb = new StringBuilder("String.format(\"" + escapeForJavaString(formatStr) + "\""); + for (String raw : paramNames) { + String prop = OpenApiSchemaCodegen.toPascalCase(raw); + sb.append(", request.get").append(prop).append("()"); + } + sb.append(")"); + return sb.toString(); + } + + private static String stringLiteral(String path) { + return "\"" + escapeForJavaString(path) + "\""; + } + + private static String escapeForJavaString(String s) { + return s.replace("\\", "\\\\").replace("\"", "\\\""); + } + + private static String trimApiPrefix(String openApiPath) { + if (openApiPath.startsWith("/v1/")) { + return openApiPath.substring(3); + } + return openApiPath; + } + + private static String httpMethodConst(String method) { + switch (method.toUpperCase()) { + case "GET": + return "GET"; + case "POST": + return "POST"; + case "PUT": + return "PUT"; + case "PATCH": + return "PATCH"; + case "DELETE": + return "DELETE"; + default: + return "GET"; + } + } + + public static List javaStatusList( + GeneratorConfiguration cfg, String sdkMethod, ParsedOperation op) { + List codes; + if (cfg.getStatusCodeOverrides().containsKey(sdkMethod) + && cfg.getStatusCodeOverrides().get(sdkMethod) != null + && !cfg.getStatusCodeOverrides().get(sdkMethod).isEmpty()) { + codes = + cfg.getStatusCodeOverrides().get(sdkMethod).stream() + .map(ServicePhase::mapStatusToken) + .collect(Collectors.toCollection(ArrayList::new)); + } else if (op.getSuccessStatusCodes().isEmpty()) { + codes = new ArrayList<>(); + codes.add(200); + } else { + codes = new ArrayList<>(op.getSuccessStatusCodes()); + } + codes.sort((a, b) -> compareSuccessStatus(a, b)); + return codes; + } + + private static int mapStatusToken(String token) { + if (token == null) { + return 200; + } + switch (token.toUpperCase()) { + case "OK": + return 200; + case "CREATED": + return 201; + case "ACCEPTED": + return 202; + case "NO_CONTENT": + return 204; + default: + try { + return Integer.parseInt(token); + } catch (NumberFormatException e) { + return 200; + } + } + } + + private static int compareSuccessStatus(int a, int b) { + if (a == b) { + return 0; + } + if (a == 201 && b == 200) { + return -1; + } + if (a == 200 && b == 201) { + return 1; + } + return Integer.compare(a, b); + } + + private static String escapeJavadoc(String s) { + return s == null ? "" : s.replace("*/", "* /"); + } + + private static String camelizeMethod(String pascal) { + if (pascal == null || pascal.isEmpty()) { + return pascal; + } + return pascal.substring(0, 1).toLowerCase() + pascal.substring(1); + } + + public static final class SdkOpPair { + public final SdkOperationBinding binding; + public final ParsedOperation op; + + public SdkOpPair(SdkOperationBinding binding, ParsedOperation op) { + this.binding = binding; + this.op = op; + } + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/GeneratorConfiguration.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/GeneratorConfiguration.java new file mode 100644 index 00000000..dbb5b2ec --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/GeneratorConfiguration.java @@ -0,0 +1,270 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import com.coinbase.tools.sdkgenerator.GeneratorPaths; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GeneratorConfiguration { + @JsonProperty("specUrl") + private String specUrl = "https://api.prime.coinbase.com/v1/openapi.yaml"; + + @JsonProperty("filePathReplacements") + private Map filePathReplacements = new LinkedHashMap<>(); + + @JsonProperty("contentReplacements") + private Map contentReplacements = new LinkedHashMap<>(); + + @JsonProperty("acronymMappings") + private List acronymMappings = new ArrayList<>(); + + @JsonProperty("enumNameMappings") + private Map enumNameMappings = new LinkedHashMap<>(); + + @JsonProperty("tagToFolderOverrides") + private Map tagToFolderOverrides = new LinkedHashMap<>(); + + @JsonIgnore + private Map tagToFolder = new LinkedHashMap<>(); + + @JsonIgnore + private Map services = new LinkedHashMap<>(); + + @JsonProperty("serviceMethodOrderOverrides") + private Map> serviceMethodOrderOverrides = new LinkedHashMap<>(); + + @JsonProperty("statusCodeOverrides") + private Map> statusCodeOverrides = new LinkedHashMap<>(); + + public String getSpecUrl() { + return specUrl; + } + + public Map getFilePathReplacements() { + return filePathReplacements; + } + + public Map getContentReplacements() { + return contentReplacements; + } + + public List getAcronymMappings() { + return acronymMappings; + } + + public Map getEnumNameMappings() { + return enumNameMappings; + } + + public Map getTagToFolderOverrides() { + return tagToFolderOverrides; + } + + public Map getTagToFolder() { + return tagToFolder; + } + + public void setTagToFolder(Map tagToFolder) { + this.tagToFolder = tagToFolder; + } + + public Map getServices() { + return services; + } + + public void setServices(Map services) { + this.services = services; + } + + public Map> getServiceMethodOrderOverrides() { + return serviceMethodOrderOverrides; + } + + public Map> getStatusCodeOverrides() { + return statusCodeOverrides; + } + + public static GeneratorConfiguration load(Path projectRoot) throws IOException { + Path path = GeneratorPaths.configDirectory(projectRoot).resolve("generator-config.json"); + ObjectMapper om = + new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + return om.readValue(path.toFile(), GeneratorConfiguration.class); + } + + public static List loadOperationBindingOverrides(Path projectRoot) + throws IOException { + Path path = GeneratorPaths.configDirectory(projectRoot).resolve("operations-overrides.json"); + if (!path.toFile().exists()) { + return new ArrayList<>(); + } + ObjectMapper om = new ObjectMapper(); + return om.readValue( + path.toFile(), + new TypeReference>() {}); + } + + public static OperationBindingMergeResult mergeOperationBindings( + ParsedOpenApiDocument document, GeneratorConfiguration cfg, Path projectRoot) + throws IOException { + List derived = OperationBindingGenerator.deriveAll(document, cfg); + List patches = loadOperationBindingOverrides(projectRoot); + Map mergedById = new LinkedHashMap<>(); + for (SdkOperationBinding b : derived) { + mergedById.put(b.getOperationId(), cloneBinding(b)); + } + for (SdkOperationBindingPatch patch : patches) { + SdkOperationBinding binding = mergedById.get(patch.getOperationId()); + if (binding == null) { + throw new IllegalStateException( + "operations-overrides.json references operationId '" + + patch.getOperationId() + + "' that is not in the OpenAPI spec."); + } + applyOperationBindingPatch(binding, patch); + } + List merged = + mergedById.values().stream() + .sorted( + (a, b) -> + a.getOperationId() + .compareTo(b.getOperationId())) + .collect(Collectors.toList()); + return new OperationBindingMergeResult(derived, merged, patches); + } + + private static SdkOperationBinding cloneBinding(SdkOperationBinding b) { + SdkOperationBinding c = new SdkOperationBinding(); + c.setOperationId(b.getOperationId()); + c.setSdkMethod(b.getSdkMethod()); + c.setService(b.getService()); + c.setOmitRequest(b.isOmitRequest()); + c.setForcePaginated(b.isForcePaginated()); + c.setParamTypeOverrides(new HashMap<>(b.getParamTypeOverrides())); + return c; + } + + private static void applyOperationBindingPatch( + SdkOperationBinding binding, SdkOperationBindingPatch patch) { + if (patch.getSdkMethod() != null) { + binding.setSdkMethod(patch.getSdkMethod()); + } + if (patch.getService() != null) { + binding.setService(patch.getService()); + } + if (patch.getOmitRequest() != null) { + binding.setOmitRequest(patch.getOmitRequest()); + } + if (patch.getForcePaginated() != null) { + binding.setForcePaginated(patch.getForcePaginated()); + } + if (patch.getParamTypeOverrides() != null) { + for (Map.Entry e : patch.getParamTypeOverrides().entrySet()) { + binding.getParamTypeOverrides().put(e.getKey(), e.getValue()); + } + } + } + + public static final class AcronymMappingEntry { + @JsonProperty("acronym") + private String acronym = ""; + + @JsonProperty("normalized") + private String normalized = ""; + + public String getAcronym() { + return acronym; + } + + public String getNormalized() { + return normalized; + } + } + + public static class SdkOperationBindingPatch { + @JsonProperty("operationId") + private String operationId = ""; + + @JsonProperty("sdkMethod") + private String sdkMethod; + + @JsonProperty("service") + private String service; + + @JsonProperty("omitRequest") + private Boolean omitRequest; + + @JsonProperty("forcePaginated") + private Boolean forcePaginated; + + @JsonProperty("paramTypeOverrides") + private Map paramTypeOverrides; + + public String getOperationId() { + return operationId; + } + + public String getSdkMethod() { + return sdkMethod; + } + + public String getService() { + return service; + } + + public Boolean getOmitRequest() { + return omitRequest; + } + + public Boolean getForcePaginated() { + return forcePaginated; + } + + public Map getParamTypeOverrides() { + return paramTypeOverrides; + } + } + + public static final class OperationBindingMergeResult { + private final List derived; + private final List merged; + private final List patches; + + public OperationBindingMergeResult( + List derived, + List merged, + List patches) { + this.derived = derived; + this.merged = merged; + this.patches = patches; + } + + public List getDerived() { + return derived; + } + + public List getMerged() { + return merged; + } + + public List getPatches() { + return patches; + } + } + +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/NamingResolver.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/NamingResolver.java new file mode 100644 index 00000000..157b25c2 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/NamingResolver.java @@ -0,0 +1,14 @@ +package com.coinbase.tools.sdkgenerator.processing; + +public final class NamingResolver { + + private NamingResolver() {} + + public static ServiceDefinition requireService(GeneratorConfiguration cfg, String serviceKey) { + ServiceDefinition def = cfg.getServices().get(serviceKey); + if (def == null) { + throw new IllegalStateException("Unknown service key '" + serviceKey + "' in operation bindings."); + } + return def; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OpenApiSchemaCodegen.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OpenApiSchemaCodegen.java new file mode 100644 index 00000000..3b82f0a1 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OpenApiSchemaCodegen.java @@ -0,0 +1,300 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import com.coinbase.tools.sdkgenerator.spec.SpecRef; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * OpenAPI JSON Schema → Java type strings, mirroring the .NET OpenApiSchemaCodegen. + */ +public final class OpenApiSchemaCodegen { + + public static class JavaTypeResult { + private final String javaType; + private final boolean needsModel; + private final boolean needsEnum; + private final Set modelTypeNames; + private final Set enumTypeNames; + + public JavaTypeResult( + String javaType, + boolean needsModel, + boolean needsEnum, + Set modelTypeNames, + Set enumTypeNames) { + this.javaType = javaType; + this.needsModel = needsModel; + this.needsEnum = needsEnum; + this.modelTypeNames = Set.copyOf(modelTypeNames); + this.enumTypeNames = Set.copyOf(enumTypeNames); + } + + public String getJavaType() { + return javaType; + } + + public boolean isNeedsModel() { + return needsModel; + } + + public boolean isNeedsEnum() { + return needsEnum; + } + + public Set getModelTypeNames() { + return modelTypeNames; + } + + public Set getEnumTypeNames() { + return enumTypeNames; + } + } + + private OpenApiSchemaCodegen() {} + + public static JavaTypeResult toJavaType( + JsonNode documentRoot, JsonNode node, SharedTransforms transforms) { + Set models = new HashSet<>(); + Set enums = new HashSet<>(); + String t = mapType(documentRoot, node, transforms, models, enums); + return new JavaTypeResult(t, !models.isEmpty(), !enums.isEmpty(), models, enums); + } + + private static String mapType( + JsonNode documentRoot, + JsonNode node, + SharedTransforms transforms, + Set modelTypes, + Set enumTypes) { + if (node == null || node.isNull()) { + return "Object"; + } + if (!node.isObject()) { + return "Object"; + } + if (node.has("$ref") && node.get("$ref").isTextual()) { + String r = node.get("$ref").asText(); + JsonNode resolved = SpecRef.resolveRef(documentRoot, r); + String refName = SpecRef.getRefName(r); + if (resolved == null || refName == null) { + return "Object"; + } + if (resolved.has("enum") && resolved.get("enum").isArray()) { + String t = transforms.transformSchemaRefToJavaName(refName); + enumTypes.add(t); + return t; + } + String t = transforms.transformSchemaRefToJavaName(refName); + modelTypes.add(t); + return t; + } + if (node.has("type")) { + String type = node.get("type").asText(); + if ("array".equals(type) && node.has("items")) { + JsonNode items = node.get("items"); + if (items != null && items.isObject()) { + String matched = findMatchingNamedEnum(documentRoot, (ObjectNode) items, transforms); + if (matched != null) { + enumTypes.add(matched); + return matched + "[]"; + } + } + String inner = mapType(documentRoot, items, transforms, modelTypes, enumTypes); + return normalizeArrayElementType(inner) + "[]"; + } + if ("string".equals(type) + && node.has("enum") + && node.get("enum").isArray()) { + String matched = findMatchingNamedEnum(documentRoot, (ObjectNode) node, transforms); + if (matched != null) { + enumTypes.add(matched); + return matched; + } + } + return mapPrimitive((ObjectNode) node, type); + } + if (node.has("oneOf") || node.has("anyOf")) { + return "Object"; + } + return "Object"; + } + + private static Set getInlineEnumValues(ObjectNode node) { + if (!node.has("enum") || !node.get("enum").isArray()) { + return new HashSet<>(); + } + Set s = new HashSet<>(); + for (JsonNode n : node.get("enum")) { + if (n != null && n.isTextual()) { + s.add(n.asText()); + } + } + return s; + } + + private static String findMatchingNamedEnum( + JsonNode documentRoot, ObjectNode inlineNode, SharedTransforms transforms) { + Set inlineValues = getInlineEnumValues(inlineNode); + if (inlineValues.isEmpty()) { + return null; + } + if (!documentRoot.has("components") || !documentRoot.get("components").isObject()) { + return null; + } + JsonNode schemas = documentRoot.get("components").path("schemas"); + if (!schemas.isObject()) { + return null; + } + Iterator it = ((ObjectNode) schemas).fieldNames(); + while (it.hasNext()) { + String key = it.next(); + JsonNode schema = schemas.get(key); + if (schema == null + || !schema.isObject() + || !schema.has("enum") + || !schema.get("enum").isArray()) { + continue; + } + Set schemaValues = getInlineEnumValues((ObjectNode) schema); + if (schemaValues.containsAll(inlineValues)) { + return transforms.transformSchemaRefToJavaName(key); + } + } + return null; + } + + private static String mapPrimitive(ObjectNode mm, String type) { + switch (type) { + case "string": + return "String"; + case "integer": + if (mm.has("format") + && "int64".equals(mm.get("format").asText())) { + return "Long"; + } + return "Integer"; + case "number": + return "String"; + case "boolean": + return "Boolean"; + case "object": + return "Object"; + default: + return "String"; + } + } + + public static List listProperties( + JsonNode documentRoot, JsonNode schema, SharedTransforms transforms) { + List list = new ArrayList<>(); + if (schema == null + || !schema.isObject() + || !schema.has("properties") + || !schema.get("properties").isObject()) { + return list; + } + ObjectNode schemaObj = (ObjectNode) schema; + ObjectNode props = (ObjectNode) schema.get("properties"); + Set required = new HashSet<>(); + if (schemaObj.has("required") && schemaObj.get("required").isArray()) { + for (JsonNode r : schemaObj.get("required")) { + if (r != null && r.isTextual()) { + required.add(r.asText()); + } + } + } + Iterator> it = props.fields(); + while (it.hasNext()) { + Map.Entry e = it.next(); + String jsonName = e.getKey(); + JsonNode pnode = e.getValue(); + String javaName = toPascalCase(jsonName); + Set model = new HashSet<>(); + Set enums = new HashSet<>(); + String jt = mapType(documentRoot, pnode, transforms, model, enums); + boolean isReq = required.contains(jsonName); + boolean usesEnum = !enums.isEmpty(); + if (!isReq && usesEnum && !jt.endsWith("[]")) { + jt = optionalScalarEnumJava(jt); + } + list.add( + new SchemaProperty( + jsonName, + javaName, + jt, + isReq, + !model.isEmpty(), + usesEnum, + model, + enums)); + } + return list; + } + + public static String toPascalCase(String snakeOrDotted) { + if (snakeOrDotted == null) { + return ""; + } + String[] segments = snakeOrDotted.split("\\."); + StringBuilder sb = new StringBuilder(); + for (String segment : segments) { + if (segment == null || segment.isEmpty()) { + continue; + } + String[] parts = segment.split("_"); + for (String p : parts) { + if (p == null || p.isEmpty()) { + continue; + } + sb.append(Character.toUpperCase(p.charAt(0))); + if (p.length() > 1) { + sb.append(p, 1, p.length()); + } + } + } + String s = sb.toString(); + return s.isEmpty() ? snakeOrDotted : s; + } + + private static String normalizeArrayElementType(String element) { + if ("String".equals(element)) { + return "String"; + } + return element; + } + + private static String optionalScalarEnumJava(String jt) { + if (jt.endsWith("?")) { + return jt; + } + return jt; // Java: reference type already nullable; primitives need wrapper — enums are refs + } + + public static boolean typeIsEnumRef(JsonNode documentRoot, JsonNode node) { + if (node == null) { + return false; + } + if (node.isObject() && node.has("type")) { + String type = node.get("type").asText(); + if ("array".equals(type) && node.has("items")) { + return typeIsEnumRef(documentRoot, node.get("items")); + } + if ("string".equals(type) && node.has("enum") && node.get("enum").isArray()) { + return true; + } + } + if (node.isObject() && node.has("$ref") && node.get("$ref").isTextual()) { + String r = node.get("$ref").asText(); + JsonNode resolved = SpecRef.resolveRef(documentRoot, r); + return resolved != null && resolved.isObject() && resolved.has("enum"); + } + return false; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingGenerator.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingGenerator.java new file mode 100644 index 00000000..51bc70a3 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingGenerator.java @@ -0,0 +1,150 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.ParsedParameter; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import com.coinbase.tools.sdkgenerator.spec.SpecResponseSchema; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public final class OperationBindingGenerator { + + private static final String OPERATION_ID_PREFIX = "PrimeRESTAPI_"; + + private OperationBindingGenerator() {} + + public static List deriveAll( + ParsedOpenApiDocument doc, GeneratorConfiguration cfg) { + SharedTransforms transforms = new SharedTransforms(cfg); + List sorted = new ArrayList<>(doc.getOperationsById().values()); + sorted.sort(Comparator.comparing(ParsedOperation::getOperationId)); + List list = new ArrayList<>(); + for (ParsedOperation op : sorted) { + list.add(deriveOne(doc.getRoot(), cfg, transforms, op)); + } + return list; + } + + private static SdkOperationBinding deriveOne( + JsonNode root, + GeneratorConfiguration cfg, + SharedTransforms transforms, + ParsedOperation op) { + String sdkMethod = deriveSdkMethod(op, transforms); + String service = resolveServiceKey(cfg, op); + boolean omitRequest = deriveOmitRequest(op); + Map paramOverrides = deriveParamTypeOverrides(root, transforms, op); + boolean forcePaginated = deriveForcePaginated(root, op); + + SdkOperationBinding b = new SdkOperationBinding(); + b.setOperationId(op.getOperationId()); + b.setSdkMethod(sdkMethod); + b.setService(service); + b.setOmitRequest(omitRequest); + b.setForcePaginated(forcePaginated); + b.getParamTypeOverrides().putAll(paramOverrides); + return b; + } + + private static String deriveSdkMethod(ParsedOperation op, SharedTransforms transforms) { + if (op.getExtensionSdkMethodName() != null + && !op.getExtensionSdkMethodName().trim().isEmpty()) { + String ext = op.getExtensionSdkMethodName().trim(); + ext = transforms.normalizeAcronyms(ext); + return transforms.applyWeb3ToOnchainName(ext); + } + String name = op.getOperationId(); + if (name.startsWith(OPERATION_ID_PREFIX)) { + name = name.substring(OPERATION_ID_PREFIX.length()); + } + name = transforms.normalizeAcronyms(name); + name = transforms.applyWeb3ToOnchainName(name); + if ("GET".equals(op.getHttpMethod()) + && op.getSummary() != null + && op.getSummary().startsWith("List ") + && name.startsWith("Get")) { + name = "List" + name.substring(3); + } + name = applyPortfolioPathPrefix(name, op); + return name; + } + + private static final java.util.Set PORTFOLIO_SCOPED_GET_SUFFIXES = + new java.util.HashSet<>(java.util.Arrays.asList("BuyingPower", "WithdrawalPower")); + + private static String applyPortfolioPathPrefix(String name, ParsedOperation op) { + String path = op.getPath(); + if (path == null + || (!path.contains("{portfolio_id}") && !path.contains("/portfolios/"))) { + return name; + } + if (!name.startsWith("Get") + || name.contains("Portfolio") + || name.length() <= 3) { + return name; + } + String rest = name.substring(3); + if (!PORTFOLIO_SCOPED_GET_SUFFIXES.contains(rest)) { + return name; + } + return "GetPortfolio" + rest; + } + + private static String resolveServiceKey(GeneratorConfiguration cfg, ParsedOperation op) { + for (String tag : op.getTags()) { + if (cfg.getTagToFolder().containsKey(tag)) { + String folder = cfg.getTagToFolder().get(tag); + if (cfg.getServices().containsKey(folder)) { + return folder; + } + } + } + throw new IllegalStateException( + "Operation '" + + op.getOperationId() + + "' has no tag mapped in tagToFolder (tags: " + + String.join(", ", op.getTags()) + + ")."); + } + + private static boolean deriveOmitRequest(ParsedOperation op) { + return op.getParameters().isEmpty() && op.getRequestBodyJsonSchema() == null; + } + + private static boolean deriveForcePaginated(JsonNode root, ParsedOperation op) { + return "GET".equals(op.getHttpMethod()) + && SpecResponseSchema.responseSchemaSuggestsPagination(root, op); + } + + private static Map deriveParamTypeOverrides( + JsonNode root, SharedTransforms transforms, ParsedOperation op) { + Map result = new HashMap<>(); + for (ParsedParameter p : op.getParameters()) { + if (!"query".equals(p.getIn())) { + continue; + } + if (!"symbols".equals(p.getName())) { + continue; + } + JsonNode schema = p.getSchema(); + if (schema == null || !schema.isObject()) { + continue; + } + if (!schema.has("type") || !"string".equals(schema.get("type").asText())) { + continue; + } + OpenApiSchemaCodegen.JavaTypeResult def = + OpenApiSchemaCodegen.toJavaType(root, schema, transforms); + if (!"String[]".equals(def.getJavaType())) { + result.put("symbols", "String[]"); + } + } + return result; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingValidator.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingValidator.java new file mode 100644 index 00000000..aa8d22fe --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/OperationBindingValidator.java @@ -0,0 +1,95 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; +import org.slf4j.Logger; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +public final class OperationBindingValidator { + + private OperationBindingValidator() {} + + public static void validateOperationBindings( + Logger logger, + ParsedOpenApiDocument document, + GeneratorConfiguration.OperationBindingMergeResult merge) { + List merged = merge.getMerged(); + List missing = + merged.stream() + .filter(b -> !document.getOperationsById().containsKey(b.getOperationId())) + .map(SdkOperationBinding::getOperationId) + .distinct() + .sorted() + .collect(Collectors.toList()); + if (!missing.isEmpty()) { + throw new IllegalStateException( + "Merged operation bindings reference operationId values that are not in the OpenAPI spec: " + + String.join(", ", missing)); + } + Map derivedById = + merge.getDerived().stream() + .collect(Collectors.toMap(SdkOperationBinding::getOperationId, b -> b)); + + for (GeneratorConfiguration.SdkOperationBindingPatch patch : merge.getPatches()) { + if (!document.getOperationsById().containsKey(patch.getOperationId())) { + throw new IllegalStateException( + "operations-overrides.json references operationId '" + + patch.getOperationId() + + "' that is not in the OpenAPI spec."); + } + SdkOperationBinding derived = derivedById.get(patch.getOperationId()); + if (derived == null) { + continue; + } + if (patchMatchesDerived(patch, derived)) { + logger.warn( + "operations-overrides.json entry for operationId {} matches derived defaults and can be removed.", + patch.getOperationId()); + } + } + } + + private static boolean patchMatchesDerived( + GeneratorConfiguration.SdkOperationBindingPatch patch, SdkOperationBinding derived) { + boolean any = false; + if (patch.getSdkMethod() != null) { + any = true; + if (!Objects.equals(patch.getSdkMethod(), derived.getSdkMethod())) { + return false; + } + } + if (patch.getService() != null) { + any = true; + if (!Objects.equals(patch.getService(), derived.getService())) { + return false; + } + } + if (patch.getOmitRequest() != null) { + any = true; + if (patch.getOmitRequest() != derived.isOmitRequest()) { + return false; + } + } + if (patch.getForcePaginated() != null) { + any = true; + if (patch.getForcePaginated() != derived.isForcePaginated()) { + return false; + } + } + if (patch.getParamTypeOverrides() != null && !patch.getParamTypeOverrides().isEmpty()) { + any = true; + for (Map.Entry kv : patch.getParamTypeOverrides().entrySet()) { + if (!derived.getParamTypeOverrides().containsKey(kv.getKey()) + || !Objects.equals( + kv.getValue(), derived.getParamTypeOverrides().get(kv.getKey()))) { + return false; + } + } + } + return any; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SchemaProperty.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SchemaProperty.java new file mode 100644 index 00000000..49763f14 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SchemaProperty.java @@ -0,0 +1,65 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import java.util.Set; + +public final class SchemaProperty { + private final String jsonName; + private final String javaName; + private final String javaType; + private final boolean required; + private final boolean usesModel; + private final boolean usesEnum; + private final Set referencedModelTypeNames; + private final Set referencedEnumTypeNames; + + public SchemaProperty( + String jsonName, + String javaName, + String javaType, + boolean required, + boolean usesModel, + boolean usesEnum, + Set referencedModelTypeNames, + Set referencedEnumTypeNames) { + this.jsonName = jsonName; + this.javaName = javaName; + this.javaType = javaType; + this.required = required; + this.usesModel = usesModel; + this.usesEnum = usesEnum; + this.referencedModelTypeNames = Set.copyOf(referencedModelTypeNames); + this.referencedEnumTypeNames = Set.copyOf(referencedEnumTypeNames); + } + + public String getJsonName() { + return jsonName; + } + + public String getJavaName() { + return javaName; + } + + public String getJavaType() { + return javaType; + } + + public boolean isRequired() { + return required; + } + + public boolean isUsesModel() { + return usesModel; + } + + public boolean isUsesEnum() { + return usesEnum; + } + + public Set getReferencedModelTypeNames() { + return referencedModelTypeNames; + } + + public Set getReferencedEnumTypeNames() { + return referencedEnumTypeNames; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/ServiceDefinition.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/ServiceDefinition.java new file mode 100644 index 00000000..e1477d18 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/ServiceDefinition.java @@ -0,0 +1,35 @@ +package com.coinbase.tools.sdkgenerator.processing; + +/** + * Per-tag service metadata. {@link #pascalName} is the PascalCase name segment (C# "namespace" + * field) used to build e.g. {@code ActivitiesService} and {@code ActivitiesServiceImpl}. + */ +public final class ServiceDefinition { + private final String folder; + private final String pascalName; + + public ServiceDefinition(String folder, String pascalName) { + this.folder = folder; + this.pascalName = pascalName; + } + + public String getFolder() { + return folder; + } + + public String getPascalName() { + return pascalName; + } + + public String getJavaInterfaceName() { + return pascalName + "Service"; + } + + public String getJavaServiceImplName() { + return pascalName + "ServiceImpl"; + } + + public String getJavaPackage() { + return "com.coinbase.prime." + folder; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SharedTransforms.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SharedTransforms.java new file mode 100644 index 00000000..ffe4588e --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SharedTransforms.java @@ -0,0 +1,98 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import java.util.Comparator; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +public final class SharedTransforms { + private final GeneratorConfiguration cfg; + + public SharedTransforms(GeneratorConfiguration cfg) { + this.cfg = cfg; + } + + public String applyContentReplacements(String content) { + String result = content; + for (Map.Entry e : + cfg.getContentReplacements().entrySet().stream() + .sorted(Comparator.comparingInt((Map.Entry p) -> -p.getKey().length())) + .collect(Collectors.toList())) { + result = result.replace(e.getKey(), e.getValue()); + } + return normalizeAcronymsInContent(result); + } + + public String stripCommonPrefixes(String className) { + String result = className; + for (Map.Entry e : + cfg.getFilePathReplacements().entrySet().stream() + .sorted(Comparator.comparingInt((Map.Entry p) -> -p.getKey().length())) + .collect(Collectors.toList())) { + if (result.contains(e.getKey())) { + result = result.replace(e.getKey(), e.getValue()); + } + } + return normalizeAcronyms(result); + } + + public String transformSchemaRefToJavaName(String refName) { + if (refName == null) { + return ""; + } + String[] dotSegments = refName.split("\\."); + StringBuilder sb = new StringBuilder(); + for (String dotSeg : dotSegments) { + if (dotSeg == null || dotSeg.isEmpty()) { + continue; + } + String[] underscoreParts = dotSeg.split("_"); + for (String part : underscoreParts) { + if (part == null || part.isEmpty()) { + continue; + } + sb.append(Character.toUpperCase(part.charAt(0))); + if (part.length() > 1) { + sb.append(part, 1, part.length()); + } + } + } + String name = sb.toString(); + name = stripCommonPrefixes(name); + name = applyContentReplacements(name); + name = name.replace(".", ""); + return applyWeb3ToOnchainName(name); + } + + public String applyWeb3ToOnchainName(String name) { + return name == null ? "" : name.replace("Web3", "Onchain"); + } + + public String normalizeAcronyms(String value) { + String result = value; + for (GeneratorConfiguration.AcronymMappingEntry pair : cfg.getAcronymMappings()) { + String acronym = pair.getAcronym(); + String normalized = pair.getNormalized(); + Pattern p = Pattern.compile("\\b" + Pattern.quote(acronym) + "(?=[A-Z])"); + result = p.matcher(result).replaceAll(Matcher.quoteReplacement(normalized)); + if (result.endsWith(acronym)) { + result = result.substring(0, result.length() - acronym.length()) + normalized; + } + } + return result; + } + + public String normalizeAcronymsInContent(String content) { + String result = content; + for (GeneratorConfiguration.AcronymMappingEntry pair : cfg.getAcronymMappings()) { + String acronym = pair.getAcronym(); + String normalized = pair.getNormalized(); + result = Pattern.compile("\\b" + Pattern.quote(acronym) + "(?=[A-Z](?!_))").matcher(result).replaceAll(Matcher.quoteReplacement(normalized)); + result = Pattern.compile("\\b" + Pattern.quote(acronym) + "(?=\\s+[a-z])").matcher(result).replaceAll(Matcher.quoteReplacement(normalized)); + result = Pattern.compile("\\b" + Pattern.quote(acronym) + "(?=[<>;])").matcher(result).replaceAll(Matcher.quoteReplacement(normalized)); + result = Pattern.compile("\\b" + Pattern.quote(acronym) + "(?=\\.)").matcher(result).replaceAll(Matcher.quoteReplacement(normalized)); + } + return result; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SpecAnalyzer.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SpecAnalyzer.java new file mode 100644 index 00000000..1d703f78 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/processing/SpecAnalyzer.java @@ -0,0 +1,182 @@ +package com.coinbase.tools.sdkgenerator.processing; + +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.fasterxml.jackson.databind.JsonNode; +import org.slf4j.Logger; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +public final class SpecAnalyzer { + + private static final int MIN_PREFIX_LENGTH = 6; + private static final int MIN_PREFIX_SCHEMA_COUNT = 3; + + private SpecAnalyzer() {} + + public static void apply(ParsedOpenApiDocument doc, GeneratorConfiguration cfg, Logger logger) { + discoverAndMergeFilePathPrefixes(doc, cfg, logger); + deriveTagToFolderAndServices(doc, cfg, logger); + } + + public static String defaultFolderFromTag(String tag) { + String[] parts = tag.split(" "); + StringBuilder sb = new StringBuilder(); + for (String p : parts) { + if (p != null && !p.isEmpty()) { + sb.append(p.toLowerCase()); + } + } + return sb.toString(); + } + + private static void deriveTagToFolderAndServices( + ParsedOpenApiDocument doc, GeneratorConfiguration cfg, Logger logger) { + Set usedTags = new TreeSet<>(); + for (ParsedOperation op : doc.getOperationsById().values()) { + usedTags.addAll(op.getTags()); + } + Map tagToFolder = new LinkedHashMap<>(); + for (String tag : usedTags) { + if (cfg.getTagToFolderOverrides().containsKey(tag) + && cfg.getTagToFolderOverrides().get(tag) != null + && !cfg.getTagToFolderOverrides().get(tag).trim().isEmpty()) { + tagToFolder.put(tag, cfg.getTagToFolderOverrides().get(tag).trim()); + } else { + tagToFolder.put(tag, defaultFolderFromTag(tag)); + } + } + cfg.setTagToFolder(tagToFolder); + + Map services = new LinkedHashMap<>(); + List sorted = + doc.getOperationsById().values().stream() + .sorted(Comparator.comparing(ParsedOperation::getOperationId)) + .collect(Collectors.toList()); + for (ParsedOperation op : sorted) { + for (String tag : op.getTags()) { + if (!tagToFolder.containsKey(tag)) { + continue; + } + String folder = tagToFolder.get(tag); + if (services.containsKey(folder)) { + continue; + } + String canonicalTag = findCanonicalTagForFolder(usedTags, tagToFolder, folder); + services.put(folder, buildServiceDefinition(canonicalTag, folder)); + } + } + cfg.setServices(services); + logger.info( + "Derived {} tag folder mappings and {} services from the OpenAPI spec.", + tagToFolder.size(), + services.size()); + } + + private static String findCanonicalTagForFolder( + Set usedTags, Map tagToFolder, String folder) { + for (String tag : usedTags) { + if (!tagToFolder.containsKey(tag) || !folder.equals(tagToFolder.get(tag))) { + continue; + } + if (defaultFolderFromTag(tag).equals(folder)) { + return tag; + } + } + return usedTags.stream() + .filter(t -> folder.equals(tagToFolder.get(t))) + .min(Comparator.naturalOrder()) + .orElseThrow(); + } + + private static ServiceDefinition buildServiceDefinition(String tag, String folder) { + String pascal = namespaceFromTag(tag); + return new ServiceDefinition(folder, pascal); + } + + private static String namespaceFromTag(String tag) { + String[] parts = tag.split(" "); + StringBuilder sb = new StringBuilder(); + for (String p : parts) { + if (p == null || p.isEmpty()) { + continue; + } + sb.append(Character.toUpperCase(p.charAt(0))); + if (p.length() > 1) { + sb.append(p.substring(1).toLowerCase()); + } + } + return sb.toString(); + } + + private static void discoverAndMergeFilePathPrefixes( + ParsedOpenApiDocument doc, GeneratorConfiguration cfg, Logger logger) { + JsonNode root = doc.getRoot(); + if (!root.has("components") || !root.get("components").isObject()) { + return; + } + JsonNode schemas = root.get("components").path("schemas"); + if (!schemas.isObject()) { + return; + } + Set names = new HashSet<>(); + schemas.fieldNames().forEachRemaining(names::add); + Map prefixHits = new HashMap<>(); + for (String name : names) { + for (String prefix : enumeratePascalPrefixes(name)) { + if (prefix.length() < MIN_PREFIX_LENGTH) { + continue; + } + prefixHits.merge(prefix, 1, Integer::sum); + } + } + List candidates = + prefixHits.entrySet().stream() + .filter(e -> e.getValue() >= MIN_PREFIX_SCHEMA_COUNT) + .map(Map.Entry::getKey) + .sorted(Comparator.comparingInt(String::length).reversed()) + .collect(Collectors.toList()); + List addedKeys = new ArrayList<>(); + int added = 0; + for (String prefix : candidates) { + if (cfg.getFilePathReplacements().containsKey(prefix)) { + continue; + } + if (names.contains(prefix)) { + continue; + } + if (addedKeys.stream().anyMatch(a -> a.startsWith(prefix))) { + continue; + } + cfg.getFilePathReplacements().put(prefix, ""); + addedKeys.add(prefix); + added++; + } + if (added > 0) { + logger.info("Merged {} auto-detected schema prefixes into filePathReplacements.", added); + } + } + + private static List enumeratePascalPrefixes(String name) { + List list = new ArrayList<>(); + if (name == null || name.isEmpty()) { + return list; + } + for (int i = 1; i < name.length(); i++) { + if (Character.isUpperCase(name.charAt(i))) { + list.add(name.substring(0, i)); + } + } + list.add(name); + return list; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOpenApiDocument.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOpenApiDocument.java new file mode 100644 index 00000000..a890b7d5 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOpenApiDocument.java @@ -0,0 +1,29 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * OpenAPI document root as {@link JsonNode} and parsed {@link ParsedOperation} map keyed by + * operationId. + */ +public final class ParsedOpenApiDocument { + private final JsonNode root; + private final Map operationsById; + + public ParsedOpenApiDocument(JsonNode root, Map operationsById) { + this.root = root; + this.operationsById = Collections.unmodifiableMap(new LinkedHashMap<>(operationsById)); + } + + public JsonNode getRoot() { + return root; + } + + public Map getOperationsById() { + return operationsById; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOperation.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOperation.java new file mode 100644 index 00000000..2826a8d3 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedOperation.java @@ -0,0 +1,82 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.Collections; +import java.util.List; + +public final class ParsedOperation { + private final String operationId; + private final String httpMethod; + private final String path; + private final List tags; + private final List parameters; + private final JsonNode requestBodyJsonSchema; + private final String successResponseSchemaRef; + private final List successStatusCodes; + private final String summary; + private final String extensionSdkMethodName; + + public ParsedOperation( + String operationId, + String httpMethod, + String path, + List tags, + List parameters, + JsonNode requestBodyJsonSchema, + String successResponseSchemaRef, + List successStatusCodes, + String summary, + String extensionSdkMethodName) { + this.operationId = operationId; + this.httpMethod = httpMethod; + this.path = path; + this.tags = tags; + this.parameters = parameters; + this.requestBodyJsonSchema = requestBodyJsonSchema; + this.successResponseSchemaRef = successResponseSchemaRef; + this.successStatusCodes = successStatusCodes; + this.summary = summary; + this.extensionSdkMethodName = extensionSdkMethodName; + } + + public String getOperationId() { + return operationId; + } + + public String getHttpMethod() { + return httpMethod; + } + + public String getPath() { + return path; + } + + public List getTags() { + return Collections.unmodifiableList(tags); + } + + public List getParameters() { + return Collections.unmodifiableList(parameters); + } + + public JsonNode getRequestBodyJsonSchema() { + return requestBodyJsonSchema; + } + + public String getSuccessResponseSchemaRef() { + return successResponseSchemaRef; + } + + public List getSuccessStatusCodes() { + return Collections.unmodifiableList(successStatusCodes); + } + + public String getSummary() { + return summary; + } + + public String getExtensionSdkMethodName() { + return extensionSdkMethodName; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedParameter.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedParameter.java new file mode 100644 index 00000000..de88946a --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/ParsedParameter.java @@ -0,0 +1,36 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * A single OpenAPI operation parameter. + */ +public final class ParsedParameter { + private final String name; + private final String in; + private final boolean required; + private final JsonNode schema; + + public ParsedParameter(String name, String in, boolean required, JsonNode schema) { + this.name = name; + this.in = in; + this.required = required; + this.schema = schema; + } + + public String getName() { + return name; + } + + public String getIn() { + return in; + } + + public boolean isRequired() { + return required; + } + + public JsonNode getSchema() { + return schema; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SdkOperationBinding.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SdkOperationBinding.java new file mode 100644 index 00000000..78be24df --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SdkOperationBinding.java @@ -0,0 +1,64 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import java.util.HashMap; +import java.util.Map; + +public class SdkOperationBinding { + private String operationId = ""; + private String sdkMethod = ""; + private String service = ""; + private boolean omitRequest; + private final Map paramTypeOverrides = new HashMap<>(); + private boolean forcePaginated; + + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + public String getSdkMethod() { + return sdkMethod; + } + + public void setSdkMethod(String sdkMethod) { + this.sdkMethod = sdkMethod; + } + + public String getService() { + return service; + } + + public void setService(String service) { + this.service = service; + } + + public boolean isOmitRequest() { + return omitRequest; + } + + public void setOmitRequest(boolean omitRequest) { + this.omitRequest = omitRequest; + } + + public Map getParamTypeOverrides() { + return paramTypeOverrides; + } + + public void setParamTypeOverrides(Map paramTypeOverrides) { + this.paramTypeOverrides.clear(); + if (paramTypeOverrides != null) { + this.paramTypeOverrides.putAll(paramTypeOverrides); + } + } + + public boolean isForcePaginated() { + return forcePaginated; + } + + public void setForcePaginated(boolean forcePaginated) { + this.forcePaginated = forcePaginated; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecParser.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecParser.java new file mode 100644 index 00000000..d9ddefc1 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecParser.java @@ -0,0 +1,185 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * Loads OpenAPI YAML and extracts {@link ParsedOperation} entries (same contract as the .NET + * generator's SpecParser). + */ +public final class SpecParser { + + private static final String[] HTTP_VERBS = { + "get", "post", "put", "patch", "delete", "head", "options" + }; + + private SpecParser() {} + + public static ParsedOpenApiDocument load(Path yamlPath) throws IOException { + ObjectMapper om = new ObjectMapper(new YAMLFactory()); + try (InputStream in = Files.newInputStream(yamlPath)) { + return load(om.readTree(in)); + } + } + + public static ParsedOpenApiDocument load(JsonNode root) { + Map ops = new LinkedHashMap<>(); + JsonNode paths = root.path("paths"); + if (!paths.isObject()) { + return new ParsedOpenApiDocument(root, ops); + } + paths.fields().forEachRemaining( + pathEntry -> { + String pathKey = pathEntry.getKey(); + JsonNode pathItem = pathEntry.getValue(); + if (!pathItem.isObject()) { + return; + } + for (String methodKey : HTTP_VERBS) { + if (!pathItem.has(methodKey)) { + continue; + } + JsonNode opNode = pathItem.get(methodKey); + if (opNode == null || !opNode.isObject()) { + continue; + } + if (!opNode.has("operationId")) { + continue; + } + String operationId = opNode.get("operationId").asText(); + String summary = opNode.has("summary") ? opNode.get("summary").asText() : null; + + List tags = new ArrayList<>(); + if (opNode.has("tags") && opNode.get("tags").isArray()) { + for (JsonNode t : opNode.get("tags")) { + if (t != null && t.isTextual() && !t.asText().isEmpty()) { + tags.add(t.asText()); + } + } + } + + List parameters = new ArrayList<>(); + if (opNode.has("parameters") && opNode.get("parameters").isArray()) { + for (JsonNode p : opNode.get("parameters")) { + if (p == null || !p.isObject()) { + continue; + } + if (!p.has("name") || !p.has("in") || !p.has("schema")) { + continue; + } + String name = p.get("name").asText(); + String in = p.get("in").asText(); + boolean required = + p.has("required") && p.get("required").asBoolean(); + parameters.add( + new ParsedParameter( + name, in, required, p.get("schema"))); + } + } + + JsonNode bodySchema = null; + if (opNode.has("requestBody") + && opNode.get("requestBody").isObject()) { + JsonNode rb = opNode.get("requestBody"); + JsonNode content = rb.path("content"); + JsonNode appJson = content.path("application/json"); + if (appJson.isObject() && appJson.has("schema")) { + bodySchema = resolveSchemaNode(root, appJson.get("schema")); + } + } + + String successRef = null; + List successStatusCodes = new ArrayList<>(); + if (opNode.has("responses") && opNode.get("responses").isObject()) { + JsonNode responses = opNode.get("responses"); + for (String[] pair : + new String[][] { + {"200", "200"}, + {"201", "201"}, + {"202", "202"}, + {"204", "204"} + }) { + String codeStr = pair[0]; + int codeInt = Integer.parseInt(pair[1]); + if (!responses.has(codeStr)) { + continue; + } + JsonNode resp = responses.get(codeStr); + if (codeInt == 204) { + successStatusCodes.add(codeInt); + continue; + } + if (!resp.isObject() || !resp.has("content")) { + continue; + } + JsonNode respContent = resp.get("content"); + JsonNode aj = respContent.path("application/json"); + if (!aj.isObject() || !aj.has("schema")) { + continue; + } + successStatusCodes.add(codeInt); + if (successRef == null) { + JsonNode schemaNode = aj.get("schema"); + successRef = extractRef(schemaNode); + } + } + } + + String extensionSdk = null; + if (opNode.has("x-sdk-method-name") + && opNode.get("x-sdk-method-name").isTextual()) { + String v = opNode.get("x-sdk-method-name").asText(); + if (v != null && !v.isEmpty()) { + extensionSdk = v; + } + } + + String httpMethod = methodKey.toUpperCase(); + ops.put( + operationId, + new ParsedOperation( + operationId, + httpMethod, + pathKey, + tags, + parameters, + bodySchema, + successRef, + successStatusCodes, + summary, + extensionSdk)); + } + }); + return new ParsedOpenApiDocument(root, ops); + } + + private static String extractRef(JsonNode schemaNode) { + if (schemaNode != null + && schemaNode.isObject() + && schemaNode.has("$ref") + && schemaNode.get("$ref").isTextual()) { + return schemaNode.get("$ref").asText(); + } + return null; + } + + public static JsonNode resolveSchemaNode(JsonNode documentRoot, JsonNode schemaNode) { + if (schemaNode == null) { + return null; + } + if (schemaNode.isObject() && schemaNode.has("$ref") && schemaNode.get("$ref").isTextual()) { + return SpecRef.resolveRef(documentRoot, schemaNode.get("$ref").asText()); + } + return schemaNode; + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecRef.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecRef.java new file mode 100644 index 00000000..bacdcdb0 --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecRef.java @@ -0,0 +1,47 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.Iterator; +import java.util.Map; + +/** + * Resolves #/components/schemas/Name references in the OpenAPI document. + */ +public final class SpecRef { + private static final String PREFIX = "#/components/schemas/"; + + private SpecRef() {} + + public static JsonNode resolveRef(JsonNode documentRoot, String ref) { + if (ref == null || !ref.startsWith(PREFIX)) { + return null; + } + String name = ref.substring(PREFIX.length()); + JsonNode components = documentRoot.path("components"); + if (!components.isObject()) { + return null; + } + JsonNode schemas = components.path("schemas"); + if (!schemas.isObject()) { + return null; + } + JsonNode schema = null; + Iterator> it = schemas.fields(); + while (it.hasNext()) { + Map.Entry e = it.next(); + if (name.equals(e.getKey())) { + schema = e.getValue(); + break; + } + } + return schema; + } + + public static String getRefName(String ref) { + if (ref == null || !ref.startsWith(PREFIX)) { + return null; + } + return ref.substring(PREFIX.length()); + } +} diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecResponseSchema.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecResponseSchema.java new file mode 100644 index 00000000..740dee0c --- /dev/null +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/spec/SpecResponseSchema.java @@ -0,0 +1,111 @@ +package com.coinbase.tools.sdkgenerator.spec; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.Iterator; +import java.util.Map; + +/** + * Heuristics for pagination detection from success response schemas. + */ +public final class SpecResponseSchema { + + private static final String[] PAGINATION_PROPERTY_NAMES = { + "pagination", "has_next", "hasNext", "next_cursor", "nextCursor", "cursor" + }; + + private SpecResponseSchema() {} + + public static boolean responseSchemaSuggestsPagination(JsonNode root, ParsedOperation op) { + JsonNode resolved = tryResolveSuccessResponseSchema(root, op); + if (resolved == null) { + return false; + } + return schemaNodeSuggestsPagination(root, resolved); + } + + public static JsonNode tryResolveSuccessResponseSchema(JsonNode root, ParsedOperation op) { + if (op.getSuccessResponseSchemaRef() == null + || op.getSuccessResponseSchemaRef().isEmpty()) { + return null; + } + JsonNode node = SpecRef.resolveRef(root, op.getSuccessResponseSchemaRef()); + if (node == null) { + return null; + } + return unwrapSchemaObject(root, node); + } + + private static JsonNode unwrapSchemaObject(JsonNode root, JsonNode schema) { + if (schema == null + || !schema.isObject() + || !schema.has("allOf") + || !schema.get("allOf").isArray()) { + return schema; + } + for (JsonNode child : schema.get("allOf")) { + if (child == null || !child.isObject()) { + continue; + } + JsonNode inner = + child.has("$ref") + ? SpecRef.resolveRef(root, child.get("$ref").asText()) + : child; + if (inner != null && inner.isObject() && inner.has("properties")) { + return inner; + } + } + return schema; + } + + private static boolean schemaNodeSuggestsPagination(JsonNode root, JsonNode schema) { + if (schema == null + || !schema.isObject() + || !schema.has("properties") + || !schema.get("properties").isObject()) { + return false; + } + JsonNode props = schema.get("properties"); + for (String hint : PAGINATION_PROPERTY_NAMES) { + Iterator it = props.fieldNames(); + boolean has = false; + while (it.hasNext()) { + if (hint.equals(it.next())) { + has = true; + break; + } + } + if (!has) { + continue; + } + if ("pagination".equals(hint)) { + JsonNode propSchema = null; + Iterator> pIt = props.fields(); + while (pIt.hasNext()) { + Map.Entry e = pIt.next(); + if (hint.equals(e.getKey())) { + propSchema = e.getValue(); + break; + } + } + if (propSchema != null + && propSchema.isObject() + && propSchema.has("$ref") + && propSchema.get("$ref").isTextual() + && propSchema + .get("$ref") + .asText() + .contains("PaginatedResponse")) { + return true; + } + } else if ("has_next".equals(hint) + || "next_cursor".equals(hint) + || "cursor".equals(hint) + || "hasNext".equals(hint) + || "nextCursor".equals(hint)) { + return true; + } + } + return false; + } +} diff --git a/tools/model-generator/src/test/java/com/coinbase/tools/sdkgenerator/SpecParserTest.java b/tools/model-generator/src/test/java/com/coinbase/tools/sdkgenerator/SpecParserTest.java new file mode 100644 index 00000000..be035ab9 --- /dev/null +++ b/tools/model-generator/src/test/java/com/coinbase/tools/sdkgenerator/SpecParserTest.java @@ -0,0 +1,46 @@ +package com.coinbase.tools.sdkgenerator; + +import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; +import com.coinbase.tools.sdkgenerator.processing.OpenApiSchemaCodegen; +import com.coinbase.tools.sdkgenerator.processing.SharedTransforms; +import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; +import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; +import com.coinbase.tools.sdkgenerator.spec.SpecParser; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class SpecParserTest { + + @Test + void loadsMinimalOpenApi() throws Exception { + Path p = + Path.of("src/test/resources/openapi-minimal.yaml") + .toAbsolutePath(); + ParsedOpenApiDocument doc = SpecParser.load(p); + assertNotNull(doc.getRoot()); + ParsedOperation op = doc.getOperationsById().get("PrimeRESTAPI_GetFoo"); + assertNotNull(op); + assertEquals("get", op.getHttpMethod().toLowerCase()); + assertEquals("/v1/entities/{entity_id}/foo", op.getPath()); + } + + @Test + void schemaToJava() throws Exception { + Path projectRoot = GeneratorPaths.findProjectRoot(); + GeneratorConfiguration cfg = GeneratorConfiguration.load(projectRoot); + SharedTransforms t = new SharedTransforms(cfg); + Path p = Path.of("src/test/resources/openapi-minimal.yaml").toAbsolutePath(); + ParsedOpenApiDocument doc = SpecParser.load(p); + assertTrue( + OpenApiSchemaCodegen.toJavaType( + doc.getRoot(), doc.getRoot().at("/components/schemas/FooItem"), t) + .getJavaType() + .length() + > 0); + } +} diff --git a/tools/model-generator/src/test/resources/openapi-minimal.yaml b/tools/model-generator/src/test/resources/openapi-minimal.yaml new file mode 100644 index 00000000..e2479678 --- /dev/null +++ b/tools/model-generator/src/test/resources/openapi-minimal.yaml @@ -0,0 +1,45 @@ +openapi: 3.0.0 +info: + title: Test + version: 1.0.0 +paths: + /v1/entities/{entity_id}/foo: + get: + operationId: PrimeRESTAPI_GetFoo + summary: List entity foo + tags: + - Test Tag + parameters: + - name: entity_id + in: path + required: true + schema: + type: string + - name: cursor + in: query + required: false + schema: + type: string + responses: + "200": + description: ok + content: + application/json: + schema: + $ref: '#/components/schemas/FooResponse' +components: + schemas: + FooItem: + type: object + properties: + name: + type: string + FooResponse: + type: object + properties: + items: + type: array + items: + $ref: '#/components/schemas/FooItem' + has_next: + type: boolean From e7170f626f0ad4ec35fb4b092f7c9ef552c9ac2c Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 13:04:45 -0700 Subject: [PATCH 2/8] test: add Failsafe integration tests for GET endpoints Add BaseIntegrationTest and domain IT classes covering Prime REST GET operations with optional query parameters where applicable. Tests skip when COINBASE_PRIME_* env vars are absent or when an endpoint requires features the account does not have (financing locates, staking currency support). Run with: mvn test-compile failsafe:integration-test or mvn verify -Dgpg.skip=true. Made-with: Cursor --- .../prime/integration/ActivitiesIT.java | 86 +++++ .../prime/integration/AddressBookIT.java | 56 ++++ .../prime/integration/AdvancedTransferIT.java | 92 ++++++ .../coinbase/prime/integration/AssetsIT.java | 41 +++ .../prime/integration/BalancesIT.java | 106 ++++++ .../integration/BaseIntegrationTest.java | 52 +++ .../prime/integration/CommissionIT.java | 54 +++ .../prime/integration/FinancingIT.java | 308 ++++++++++++++++++ .../coinbase/prime/integration/FuturesIT.java | 124 +++++++ .../coinbase/prime/integration/InvoiceIT.java | 58 ++++ .../integration/OnchainAddressBookIT.java | 41 +++ .../coinbase/prime/integration/OrdersIT.java | 115 +++++++ .../prime/integration/PaymentMethodsIT.java | 41 +++ .../prime/integration/PortfoliosIT.java | 47 +++ .../prime/integration/PositionsIT.java | 77 +++++ .../prime/integration/ProductsIT.java | 69 ++++ .../coinbase/prime/integration/StakingIT.java | 99 ++++++ .../prime/integration/TransactionsIT.java | 108 ++++++ .../coinbase/prime/integration/UsersIT.java | 77 +++++ .../coinbase/prime/integration/WalletsIT.java | 132 ++++++++ 20 files changed, 1783 insertions(+) create mode 100644 src/test/java/com/coinbase/prime/integration/ActivitiesIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/AddressBookIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/AdvancedTransferIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/AssetsIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/BalancesIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/BaseIntegrationTest.java create mode 100644 src/test/java/com/coinbase/prime/integration/CommissionIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/FinancingIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/FuturesIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/InvoiceIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/OnchainAddressBookIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/OrdersIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/PaymentMethodsIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/PortfoliosIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/PositionsIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/ProductsIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/StakingIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/TransactionsIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/UsersIT.java create mode 100644 src/test/java/com/coinbase/prime/integration/WalletsIT.java diff --git a/src/test/java/com/coinbase/prime/integration/ActivitiesIT.java b/src/test/java/com/coinbase/prime/integration/ActivitiesIT.java new file mode 100644 index 00000000..d6dbf937 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/ActivitiesIT.java @@ -0,0 +1,86 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.activities.*; +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.ActivityCategory; +import com.coinbase.prime.model.enums.ActivityStatus; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class ActivitiesIT extends BaseIntegrationTest { + + @Test + public void testListPortfolioActivities() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + ActivitiesService service = PrimeServiceFactory.createActivitiesService(client); + ListPortfolioActivitiesResponse response = service.listPortfolioActivities( + new ListPortfolioActivitiesRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioActivitiesWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + ActivitiesService service = PrimeServiceFactory.createActivitiesService(client); + ListPortfolioActivitiesResponse response = service.listPortfolioActivities( + new ListPortfolioActivitiesRequest.Builder() + .portfolioId(portfolioId) + .symbols(new String[]{"BTC", "ETH"}) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testListEntityActivities() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + ActivitiesService service = PrimeServiceFactory.createActivitiesService(client); + ListEntityActivitiesResponse response = service.listEntityActivities( + new ListEntityActivitiesRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListEntityActivitiesWithOptionals() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + ActivitiesService service = PrimeServiceFactory.createActivitiesService(client); + ListEntityActivitiesResponse response = service.listEntityActivities( + new ListEntityActivitiesRequest.Builder() + .entityId(entityId) + .categories(new ActivityCategory[]{ActivityCategory.ACTIVITY_CATEGORY_ORDER}) + .statuses(new ActivityStatus[]{ActivityStatus.ACTIVITY_STATUS_COMPLETED}) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/AddressBookIT.java b/src/test/java/com/coinbase/prime/integration/AddressBookIT.java new file mode 100644 index 00000000..22e1e1bf --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/AddressBookIT.java @@ -0,0 +1,56 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.addressbook.AddressBookService; +import com.coinbase.prime.addressbook.ListAddressBookRequest; +import com.coinbase.prime.addressbook.ListAddressBookResponse; +import com.coinbase.prime.factory.PrimeServiceFactory; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class AddressBookIT extends BaseIntegrationTest { + + @Test + public void testListAddressBook() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + AddressBookService service = PrimeServiceFactory.createAddressBookService(client); + ListAddressBookResponse response = service.listAddressBook( + new ListAddressBookRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListAddressBookWithSearch() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + AddressBookService service = PrimeServiceFactory.createAddressBookService(client); + ListAddressBookResponse response = service.listAddressBook( + new ListAddressBookRequest.Builder() + .portfolioId(portfolioId) + .currencySymbol("BTC") + .search("") + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/AdvancedTransferIT.java b/src/test/java/com/coinbase/prime/integration/AdvancedTransferIT.java new file mode 100644 index 00000000..6fce7880 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/AdvancedTransferIT.java @@ -0,0 +1,92 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.advancedtransfer.*; +import com.coinbase.prime.factory.PrimeServiceFactory; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class AdvancedTransferIT extends BaseIntegrationTest { + + @Test + public void testListAdvancedTransfers() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + AdvancedTransferService service = PrimeServiceFactory.createAdvancedTransferService(client); + ListAdvancedTransfersResponse response = service.listAdvancedTransfers( + new ListAdvancedTransfersRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListAdvancedTransfersWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + AdvancedTransferService service = PrimeServiceFactory.createAdvancedTransferService(client); + ListAdvancedTransfersResponse response = service.listAdvancedTransfers( + new ListAdvancedTransfersRequest.Builder() + .portfolioId(portfolioId) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testGetPortfolioCounterpartyId() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + AdvancedTransferService service = PrimeServiceFactory.createAdvancedTransferService(client); + GetPortfolioCounterpartyIdResponse response = service.getPortfolioCounterpartyId( + new GetPortfolioCounterpartyIdRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListAdvancedTransferTransactions() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + + AdvancedTransferService service = PrimeServiceFactory.createAdvancedTransferService(client); + ListAdvancedTransfersResponse transfers = service.listAdvancedTransfers( + new ListAdvancedTransfersRequest.Builder() + .portfolioId(portfolioId) + .limit(1) + .build()); + + assumeTrue(transfers != null && transfers.getAdvancedTransfers() != null + && transfers.getAdvancedTransfers().length > 0, + "Skipping: no advanced transfers found for portfolio"); + + String advancedTransferId = transfers.getAdvancedTransfers()[0].getId(); + + ListAdvancedTransferTransactionsResponse response = service.listAdvancedTransferTransactions( + new ListAdvancedTransferTransactionsRequest.Builder() + .portfolioId(portfolioId) + .advancedTransferId(advancedTransferId) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/AssetsIT.java b/src/test/java/com/coinbase/prime/integration/AssetsIT.java new file mode 100644 index 00000000..ffef158e --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/AssetsIT.java @@ -0,0 +1,41 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.assets.AssetsService; +import com.coinbase.prime.assets.ListAssetsRequest; +import com.coinbase.prime.assets.ListAssetsResponse; +import com.coinbase.prime.factory.PrimeServiceFactory; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class AssetsIT extends BaseIntegrationTest { + + @Test + public void testListAssets() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + AssetsService service = PrimeServiceFactory.createAssetsService(client); + ListAssetsResponse response = service.listAssets( + new ListAssetsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/BalancesIT.java b/src/test/java/com/coinbase/prime/integration/BalancesIT.java new file mode 100644 index 00000000..1c089508 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/BalancesIT.java @@ -0,0 +1,106 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.balances.*; +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.WalletType; +import com.coinbase.prime.wallets.ListWalletsRequest; +import com.coinbase.prime.wallets.ListWalletsResponse; +import com.coinbase.prime.wallets.WalletsService; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class BalancesIT extends BaseIntegrationTest { + + @Test + public void testListEntityBalances() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + BalancesService service = PrimeServiceFactory.createBalancesService(client); + ListEntityBalancesResponse response = service.listEntityBalances( + new ListEntityBalancesRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListEntityBalancesWithSymbols() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + BalancesService service = PrimeServiceFactory.createBalancesService(client); + ListEntityBalancesResponse response = service.listEntityBalances( + new ListEntityBalancesRequest.Builder() + .entityId(entityId) + .symbols(new String[]{"BTC", "ETH", "USDC"}) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioBalances() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + BalancesService service = PrimeServiceFactory.createBalancesService(client); + ListPortfolioBalancesResponse response = service.listPortfolioBalances( + new ListPortfolioBalancesRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioBalancesWithSymbols() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + BalancesService service = PrimeServiceFactory.createBalancesService(client); + ListPortfolioBalancesResponse response = service.listPortfolioBalances( + new ListPortfolioBalancesRequest.Builder() + .portfolioId(portfolioId) + .symbols(new String[]{"BTC", "ETH"}) + .build()); + assertNotNull(response); + } + + @Test + public void testListOnchainWalletBalances() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + + WalletsService walletsService = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse wallets = walletsService.listWallets( + new ListWalletsRequest.Builder() + .portfolioId(portfolioId) + .type(WalletType.ONCHAIN) + .build()); + assumeTrue(wallets != null && wallets.getWallets() != null && wallets.getWallets().length > 0, + "Skipping: no ONCHAIN wallets found for portfolio"); + + String walletId = wallets.getWallets()[0].getId(); + + BalancesService service = PrimeServiceFactory.createBalancesService(client); + ListOnchainWalletBalancesResponse response = service.listOnchainWalletBalances( + new ListOnchainWalletBalancesRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/BaseIntegrationTest.java b/src/test/java/com/coinbase/prime/integration/BaseIntegrationTest.java new file mode 100644 index 00000000..c70a7d0b --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/BaseIntegrationTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.credentials.CoinbasePrimeCredentials; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +/** + * Base class for live integration tests. Tests are skipped automatically when + * COINBASE_PRIME_CREDENTIALS is not set in the environment. + * + * Required env vars: + * COINBASE_PRIME_CREDENTIALS - JSON with accessKey, passphrase, signingKey + * COINBASE_PRIME_PORTFOLIO_ID - portfolio UUID used in portfolio-scoped calls + * COINBASE_PRIME_ENTITY_ID - entity UUID used in entity-scoped calls + */ +public abstract class BaseIntegrationTest { + + protected CoinbasePrimeClient client; + protected String portfolioId; + protected String entityId; + + @BeforeEach + public void setUpBase() throws Exception { + String credentialsJson = System.getenv("COINBASE_PRIME_CREDENTIALS"); + assumeTrue(credentialsJson != null && !credentialsJson.isEmpty(), + "Skipping integration test: COINBASE_PRIME_CREDENTIALS not set"); + + portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID"); + entityId = System.getenv("COINBASE_PRIME_ENTITY_ID"); + + CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(credentialsJson); + client = new CoinbasePrimeClient(credentials); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/CommissionIT.java b/src/test/java/com/coinbase/prime/integration/CommissionIT.java new file mode 100644 index 00000000..ebe737d9 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/CommissionIT.java @@ -0,0 +1,54 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.commission.CommissionService; +import com.coinbase.prime.commission.GetPortfolioCommissionRequest; +import com.coinbase.prime.commission.GetPortfolioCommissionResponse; +import com.coinbase.prime.factory.PrimeServiceFactory; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class CommissionIT extends BaseIntegrationTest { + + @Test + public void testGetPortfolioCommission() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + CommissionService service = PrimeServiceFactory.createCommissionService(client); + GetPortfolioCommissionResponse response = service.getPortfolioCommission( + new GetPortfolioCommissionRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetPortfolioCommissionWithProductId() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + CommissionService service = PrimeServiceFactory.createCommissionService(client); + GetPortfolioCommissionResponse response = service.getPortfolioCommission( + new GetPortfolioCommissionRequest.Builder() + .portfolioId(portfolioId) + .productId("BTC-USD") + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/FinancingIT.java b/src/test/java/com/coinbase/prime/integration/FinancingIT.java new file mode 100644 index 00000000..75cdc566 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/FinancingIT.java @@ -0,0 +1,308 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.financing.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class FinancingIT extends BaseIntegrationTest { + + @Test + public void testListInterestAccruals() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + ListInterestAccrualsResponse response = service.listInterestAccruals( + new ListInterestAccrualsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListInterestAccrualsWithDateRange() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + ListInterestAccrualsResponse response = service.listInterestAccruals( + new ListInterestAccrualsRequest.Builder() + .entityId(entityId) + .startDate("2025-01-01") + .endDate("2025-12-31") + .build()); + assertNotNull(response); + } + + @Test + public void testGetCrossMarginOverview() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetCrossMarginOverviewResponse response = service.getCrossMarginOverview( + new GetCrossMarginOverviewRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetEntityLocateAvailabilities() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetEntityLocateAvailabilitiesResponse response = service.getEntityLocateAvailabilities( + new GetEntityLocateAvailabilitiesRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetMarginInformation() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetMarginInformationResponse response = service.getMarginInformation( + new GetMarginInformationRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListMarginCallSummaries() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + ListMarginCallSummariesResponse response = service.listMarginCallSummaries( + new ListMarginCallSummariesRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListMarginCallSummariesWithDateRange() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + ListMarginCallSummariesResponse response = service.listMarginCallSummaries( + new ListMarginCallSummariesRequest.Builder() + .entityId(entityId) + .startDate("2025-01-01") + .endDate("2025-12-31") + .build()); + assertNotNull(response); + } + + @Test + public void testListTradeFinanceObligations() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + ListTradeFinanceObligationsResponse response = service.listTradeFinanceObligations( + new ListTradeFinanceObligationsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetTradeFinanceTieredPricingFees() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetTradeFinanceTieredPricingFeesResponse response = service.getTradeFinanceTieredPricingFees( + new GetTradeFinanceTieredPricingFeesRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListFinancingEligibleAssets() throws Exception { + FinancingService service = PrimeServiceFactory.createFinancingService(client); + ListFinancingEligibleAssetsResponse response = service.listFinancingEligibleAssets(); + assertNotNull(response); + } + + @Test + public void testListInterestAccrualsForPortfolio() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + try { + ListInterestAccrualsForPortfolioResponse response = service.listInterestAccrualsForPortfolio( + new ListInterestAccrualsForPortfolioRequest.Builder() + .portfolioId(portfolioId) + .startDate("2025-01-01") + .endDate("2025-12-31") + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("InvalidArgument") && !causeMsg.contains("not enabled") + && !causeMsg.contains("precondition"), + "Skipping: portfolio does not have access to interest accruals or date format unsupported"); + throw e; + } + } + + @Test + public void testListInterestAccrualsForPortfolioWithDateRange() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + try { + ListInterestAccrualsForPortfolioResponse response = service.listInterestAccrualsForPortfolio( + new ListInterestAccrualsForPortfolioRequest.Builder() + .portfolioId(portfolioId) + .startDate("2025-01-01") + .endDate("2025-06-30") + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("InvalidArgument") && !causeMsg.contains("not enabled") + && !causeMsg.contains("precondition"), + "Skipping: portfolio does not have access to interest accruals or date format unsupported"); + throw e; + } + } + + @Test + public void testGetPortfolioBuyingPower() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetPortfolioBuyingPowerResponse response = service.getPortfolioBuyingPower( + new GetPortfolioBuyingPowerRequest.Builder() + .portfolioId(portfolioId) + .baseCurrency("BTC") + .quoteCurrency("USD") + .build()); + assertNotNull(response); + } + + @Test + public void testGetPortfolioCreditInformation() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetPortfolioCreditInformationResponse response = service.getPortfolioCreditInformation( + new GetPortfolioCreditInformationRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListExistingLocates() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + try { + ListExistingLocatesResponse response = service.listExistingLocates( + new ListExistingLocatesRequest.Builder() + .portfolioId(portfolioId) + .locateDate("2025-01-01") + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("precondition") && !causeMsg.contains("not enabled") + && !causeMsg.contains("missing") && !causeMsg.contains("Invalid"), + "Skipping: portfolio does not have access to locates"); + throw e; + } + } + + @Test + public void testListMarginConversions() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + try { + ListMarginConversionsResponse response = service.listMarginConversions( + new ListMarginConversionsRequest.Builder() + .portfolioId(portfolioId) + .startDate("2025-01-01") + .endDate("2025-12-31") + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("InvalidArgument") && !causeMsg.contains("not enabled") + && !causeMsg.contains("precondition"), + "Skipping: portfolio does not have access to margin conversions or date format unsupported"); + throw e; + } + } + + @Test + public void testListMarginConversionsWithDateRange() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + try { + ListMarginConversionsResponse response = service.listMarginConversions( + new ListMarginConversionsRequest.Builder() + .portfolioId(portfolioId) + .startDate("2025-01-01") + .endDate("2025-06-30") + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("InvalidArgument") && !causeMsg.contains("not enabled") + && !causeMsg.contains("precondition"), + "Skipping: portfolio does not have access to margin conversions or date format unsupported"); + throw e; + } + } + + @Test + public void testGetPortfolioWithdrawalPower() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetPortfolioWithdrawalPowerResponse response = service.getPortfolioWithdrawalPower( + new GetPortfolioWithdrawalPowerRequest.Builder() + .portfolioId(portfolioId) + .symbol("BTC") + .build()); + assertNotNull(response); + } + + @Test + public void testGetPortfolioWithdrawalPowerWithSymbol() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + FinancingService service = PrimeServiceFactory.createFinancingService(client); + GetPortfolioWithdrawalPowerResponse response = service.getPortfolioWithdrawalPower( + new GetPortfolioWithdrawalPowerRequest.Builder() + .portfolioId(portfolioId) + .symbol("BTC") + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/FuturesIT.java b/src/test/java/com/coinbase/prime/integration/FuturesIT.java new file mode 100644 index 00000000..32fd29e3 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/FuturesIT.java @@ -0,0 +1,124 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.futures.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class FuturesIT extends BaseIntegrationTest { + + @Test + public void testGetEntityFcmBalance() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetEntityFcmBalanceResponse response = service.getEntityFcmBalance( + new GetEntityFcmBalanceRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetFcmMarginCallDetails() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetFcmMarginCallDetailsResponse response = service.getFcmMarginCallDetails( + new GetFcmMarginCallDetailsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetPositions() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetPositionsResponse response = service.getPositions( + new GetPositionsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetPositionsWithProductId() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetPositionsResponse response = service.getPositions( + new GetPositionsRequest.Builder() + .entityId(entityId) + .productId("BTC-28MAR25-CDE") + .build()); + assertNotNull(response); + } + + @Test + public void testGetFcmRiskLimits() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetFcmRiskLimitsResponse response = service.getFcmRiskLimits( + new GetFcmRiskLimitsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetFcmSettings() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetFcmSettingsResponse response = service.getFcmSettings( + new GetFcmSettingsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListEntityFuturesSweeps() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + ListEntityFuturesSweepsResponse response = service.listEntityFuturesSweeps( + new ListEntityFuturesSweepsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testGetFcmEquity() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + FuturesService service = PrimeServiceFactory.createFuturesService(client); + GetFcmEquityResponse response = service.getFcmEquity( + new GetFcmEquityRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/InvoiceIT.java b/src/test/java/com/coinbase/prime/integration/InvoiceIT.java new file mode 100644 index 00000000..34536723 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/InvoiceIT.java @@ -0,0 +1,58 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.invoice.InvoiceService; +import com.coinbase.prime.invoice.ListInvoicesRequest; +import com.coinbase.prime.invoice.ListInvoicesResponse; +import com.coinbase.prime.model.enums.InvoiceState; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class InvoiceIT extends BaseIntegrationTest { + + @Test + public void testListInvoices() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + InvoiceService service = PrimeServiceFactory.createInvoiceService(client); + ListInvoicesResponse response = service.listInvoices( + new ListInvoicesRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListInvoicesWithOptionals() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + InvoiceService service = PrimeServiceFactory.createInvoiceService(client); + ListInvoicesResponse response = service.listInvoices( + new ListInvoicesRequest.Builder() + .entityId(entityId) + .states(new InvoiceState[]{InvoiceState.INVOICE_STATE_BILLED}) + .billingYear(2025) + .billingMonth(1) + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/OnchainAddressBookIT.java b/src/test/java/com/coinbase/prime/integration/OnchainAddressBookIT.java new file mode 100644 index 00000000..30e99143 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/OnchainAddressBookIT.java @@ -0,0 +1,41 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.onchainaddressbook.ListOnchainAddressGroupsRequest; +import com.coinbase.prime.onchainaddressbook.ListOnchainAddressGroupsResponse; +import com.coinbase.prime.onchainaddressbook.OnchainAddressBookService; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class OnchainAddressBookIT extends BaseIntegrationTest { + + @Test + public void testListOnchainAddressGroups() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OnchainAddressBookService service = PrimeServiceFactory.createOnchainAddressBookService(client); + ListOnchainAddressGroupsResponse response = service.listOnchainAddressGroups( + new ListOnchainAddressGroupsRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/OrdersIT.java b/src/test/java/com/coinbase/prime/integration/OrdersIT.java new file mode 100644 index 00000000..6f8846a5 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/OrdersIT.java @@ -0,0 +1,115 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.OrderSide; +import com.coinbase.prime.model.enums.OrderStatus; +import com.coinbase.prime.orders.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class OrdersIT extends BaseIntegrationTest { + + @Test + public void testListPortfolioOrders() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OrdersService service = PrimeServiceFactory.createOrdersService(client); + ListPortfolioOrdersResponse response = service.listPortfolioOrders( + new ListPortfolioOrdersRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioOrdersWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OrdersService service = PrimeServiceFactory.createOrdersService(client); + ListPortfolioOrdersResponse response = service.listPortfolioOrders( + new ListPortfolioOrdersRequest.Builder() + .portfolioId(portfolioId) + .orderStatuses(new OrderStatus[]{OrderStatus.FILLED}) + .productIds(new String[]{"BTC-USD"}) + .orderSide(OrderSide.BUY) + .startDate("2025-01-01T00:00:00Z") + .endDate("2025-12-31T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testListOpenOrders() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OrdersService service = PrimeServiceFactory.createOrdersService(client); + ListOpenOrdersResponse response = service.listOpenOrders( + new ListOpenOrdersRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListOpenOrdersWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OrdersService service = PrimeServiceFactory.createOrdersService(client); + ListOpenOrdersResponse response = service.listOpenOrders( + new ListOpenOrdersRequest.Builder() + .portfolioId(portfolioId) + .productIds(new String[]{"BTC-USD", "ETH-USD"}) + .orderSide(OrderSide.BUY) + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioFills() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OrdersService service = PrimeServiceFactory.createOrdersService(client); + ListPortfolioFillsResponse response = service.listPortfolioFills( + new ListPortfolioFillsRequest.Builder() + .portfolioId(portfolioId) + .startDate("2025-01-01T00:00:00Z") + .endDate("2025-12-31T23:59:59Z") + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioFillsWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + OrdersService service = PrimeServiceFactory.createOrdersService(client); + ListPortfolioFillsResponse response = service.listPortfolioFills( + new ListPortfolioFillsRequest.Builder() + .portfolioId(portfolioId) + .startDate("2025-01-01T00:00:00Z") + .endDate("2025-06-30T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/PaymentMethodsIT.java b/src/test/java/com/coinbase/prime/integration/PaymentMethodsIT.java new file mode 100644 index 00000000..cd9db110 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/PaymentMethodsIT.java @@ -0,0 +1,41 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.paymentmethods.ListPaymentMethodsRequest; +import com.coinbase.prime.paymentmethods.ListPaymentMethodsResponse; +import com.coinbase.prime.paymentmethods.PaymentMethodsService; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class PaymentMethodsIT extends BaseIntegrationTest { + + @Test + public void testListPaymentMethods() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + PaymentMethodsService service = PrimeServiceFactory.createPaymentMethodsService(client); + ListPaymentMethodsResponse response = service.listPaymentMethods( + new ListPaymentMethodsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/PortfoliosIT.java b/src/test/java/com/coinbase/prime/integration/PortfoliosIT.java new file mode 100644 index 00000000..c6686992 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/PortfoliosIT.java @@ -0,0 +1,47 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.portfolios.GetPortfolioRequest; +import com.coinbase.prime.portfolios.GetPortfolioResponse; +import com.coinbase.prime.portfolios.ListPortfoliosResponse; +import com.coinbase.prime.portfolios.PortfoliosService; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class PortfoliosIT extends BaseIntegrationTest { + + @Test + public void testListPortfolios() throws Exception { + PortfoliosService service = PrimeServiceFactory.createPortfoliosService(client); + ListPortfoliosResponse response = service.listPortfolios(); + assertNotNull(response); + } + + @Test + public void testGetPortfolio() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + PortfoliosService service = PrimeServiceFactory.createPortfoliosService(client); + GetPortfolioResponse response = service.getPortfolio( + new GetPortfolioRequest.Builder().portfolioId(portfolioId).build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/PositionsIT.java b/src/test/java/com/coinbase/prime/integration/PositionsIT.java new file mode 100644 index 00000000..81647438 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/PositionsIT.java @@ -0,0 +1,77 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.positions.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class PositionsIT extends BaseIntegrationTest { + + @Test + public void testListPositions() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + PositionsService service = PrimeServiceFactory.createPositionsService(client); + ListPositionsResponse response = service.listPositions( + new ListPositionsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPositionsWithPagination() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + PositionsService service = PrimeServiceFactory.createPositionsService(client); + ListPositionsResponse response = service.listPositions( + new ListPositionsRequest.Builder() + .entityId(entityId) + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testListAggregatePositions() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + PositionsService service = PrimeServiceFactory.createPositionsService(client); + ListAggregatePositionsResponse response = service.listAggregatePositions( + new ListAggregatePositionsRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListAggregatePositionsWithPagination() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + PositionsService service = PrimeServiceFactory.createPositionsService(client); + ListAggregatePositionsResponse response = service.listAggregatePositions( + new ListAggregatePositionsRequest.Builder() + .entityId(entityId) + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/ProductsIT.java b/src/test/java/com/coinbase/prime/integration/ProductsIT.java new file mode 100644 index 00000000..15bec5a1 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/ProductsIT.java @@ -0,0 +1,69 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.CandlesGranularity; +import com.coinbase.prime.products.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class ProductsIT extends BaseIntegrationTest { + + @Test + public void testListPortfolioProducts() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + ProductsService service = PrimeServiceFactory.createProductsService(client); + ListPortfolioProductsResponse response = service.listPortfolioProducts( + new ListPortfolioProductsRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioProductsWithPagination() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + ProductsService service = PrimeServiceFactory.createProductsService(client); + ListPortfolioProductsResponse response = service.listPortfolioProducts( + new ListPortfolioProductsRequest.Builder() + .portfolioId(portfolioId) + .limit(10) + .build()); + assertNotNull(response); + } + + @Test + public void testGetCandles() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + ProductsService service = PrimeServiceFactory.createProductsService(client); + GetCandlesResponse response = service.getCandles( + new GetCandlesRequest.Builder() + .portfolioId(portfolioId) + .productId("BTC-USD") + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-01-02T00:00:00Z") + .granularity(CandlesGranularity.ONE_HOUR) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/StakingIT.java b/src/test/java/com/coinbase/prime/integration/StakingIT.java new file mode 100644 index 00000000..fa2bb765 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/StakingIT.java @@ -0,0 +1,99 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.errors.CoinbasePrimeException; +import com.coinbase.prime.model.enums.WalletType; +import com.coinbase.prime.staking.GetStakingStatusRequest; +import com.coinbase.prime.staking.GetStakingStatusResponse; +import com.coinbase.prime.staking.GetUnstakingStatusRequest; +import com.coinbase.prime.staking.GetUnstakingStatusResponse; +import com.coinbase.prime.staking.StakingService; +import com.coinbase.prime.wallets.ListWalletsRequest; +import com.coinbase.prime.wallets.ListWalletsResponse; +import com.coinbase.prime.wallets.WalletsService; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class StakingIT extends BaseIntegrationTest { + + /** + * Finds a VAULT-type wallet (most likely to support staking). + */ + private String resolveStakingWalletId() throws Exception { + WalletsService walletsService = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse wallets = walletsService.listWallets( + new ListWalletsRequest.Builder() + .portfolioId(portfolioId) + .type(WalletType.VAULT) + .build()); + if (wallets == null || wallets.getWallets() == null || wallets.getWallets().length == 0) { + return null; + } + return wallets.getWallets()[0].getId(); + } + + @Test + public void testGetStakingStatus() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + String walletId = resolveStakingWalletId(); + assumeTrue(walletId != null, "Skipping: no VAULT wallets found for portfolio"); + + StakingService service = PrimeServiceFactory.createStakingService(client); + try { + GetStakingStatusResponse response = service.getStakingStatus( + new GetStakingStatusRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("not supported for staking"), + "Skipping: wallet currency does not support staking status via Prime API"); + throw e; + } + } + + @Test + public void testGetUnstakingStatus() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + String walletId = resolveStakingWalletId(); + assumeTrue(walletId != null, "Skipping: no VAULT wallets found for portfolio"); + + StakingService service = PrimeServiceFactory.createStakingService(client); + try { + GetUnstakingStatusResponse response = service.getUnstakingStatus( + new GetUnstakingStatusRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .build()); + assertNotNull(response); + } catch (CoinbaseClientException e) { + String causeMsg = e.getCause() != null ? e.getCause().getMessage() : ""; + assumeTrue(!causeMsg.contains("not supported for unstaking") && !causeMsg.contains("not supported for staking"), + "Skipping: wallet currency does not support unstaking status via Prime API"); + throw e; + } + } +} diff --git a/src/test/java/com/coinbase/prime/integration/TransactionsIT.java b/src/test/java/com/coinbase/prime/integration/TransactionsIT.java new file mode 100644 index 00000000..3de9d645 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/TransactionsIT.java @@ -0,0 +1,108 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.TransactionType; +import com.coinbase.prime.transactions.*; +import com.coinbase.prime.wallets.ListWalletsRequest; +import com.coinbase.prime.wallets.ListWalletsResponse; +import com.coinbase.prime.wallets.WalletsService; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class TransactionsIT extends BaseIntegrationTest { + + @Test + public void testListPortfolioTransactions() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + TransactionsService service = PrimeServiceFactory.createTransactionsService(client); + ListPortfolioTransactionsResponse response = service.listPortfolioTransactions( + new ListPortfolioTransactionsRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioTransactionsWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + TransactionsService service = PrimeServiceFactory.createTransactionsService(client); + ListPortfolioTransactionsResponse response = service.listPortfolioTransactions( + new ListPortfolioTransactionsRequest.Builder() + .portfolioId(portfolioId) + .symbols(new String[]{"BTC", "ETH"}) + .types(new TransactionType[]{TransactionType.WITHDRAWAL, TransactionType.DEPOSIT}) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testListWalletTransactions() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + + WalletsService walletsService = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse wallets = walletsService.listWallets( + new ListWalletsRequest.Builder().portfolioId(portfolioId).build()); + assumeTrue(wallets != null && wallets.getWallets() != null && wallets.getWallets().length > 0, + "Skipping: no wallets found for portfolio"); + + String walletId = wallets.getWallets()[0].getId(); + + TransactionsService service = PrimeServiceFactory.createTransactionsService(client); + ListWalletTransactionsResponse response = service.listWalletTransactions( + new ListWalletTransactionsRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .build()); + assertNotNull(response); + } + + @Test + public void testListWalletTransactionsWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + + WalletsService walletsService = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse wallets = walletsService.listWallets( + new ListWalletsRequest.Builder().portfolioId(portfolioId).build()); + assumeTrue(wallets != null && wallets.getWallets() != null && wallets.getWallets().length > 0, + "Skipping: no wallets found for portfolio"); + + String walletId = wallets.getWallets()[0].getId(); + + TransactionsService service = PrimeServiceFactory.createTransactionsService(client); + ListWalletTransactionsResponse response = service.listWalletTransactions( + new ListWalletTransactionsRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .types(new TransactionType[]{TransactionType.WITHDRAWAL}) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/UsersIT.java b/src/test/java/com/coinbase/prime/integration/UsersIT.java new file mode 100644 index 00000000..f3b16790 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/UsersIT.java @@ -0,0 +1,77 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.users.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class UsersIT extends BaseIntegrationTest { + + @Test + public void testListEntityUsers() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + UsersService service = PrimeServiceFactory.createUsersService(client); + ListEntityUsersResponse response = service.listEntityUsers( + new ListEntityUsersRequest.Builder() + .entityId(entityId) + .build()); + assertNotNull(response); + } + + @Test + public void testListEntityUsersWithPagination() throws Exception { + assumeTrue(entityId != null && !entityId.isEmpty(), + "Skipping: COINBASE_PRIME_ENTITY_ID not set"); + UsersService service = PrimeServiceFactory.createUsersService(client); + ListEntityUsersResponse response = service.listEntityUsers( + new ListEntityUsersRequest.Builder() + .entityId(entityId) + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioUsers() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + UsersService service = PrimeServiceFactory.createUsersService(client); + ListPortfolioUsersResponse response = service.listPortfolioUsers( + new ListPortfolioUsersRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListPortfolioUsersWithPagination() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + UsersService service = PrimeServiceFactory.createUsersService(client); + ListPortfolioUsersResponse response = service.listPortfolioUsers( + new ListPortfolioUsersRequest.Builder() + .portfolioId(portfolioId) + .limit(5) + .build()); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/integration/WalletsIT.java b/src/test/java/com/coinbase/prime/integration/WalletsIT.java new file mode 100644 index 00000000..e9e83bd4 --- /dev/null +++ b/src/test/java/com/coinbase/prime/integration/WalletsIT.java @@ -0,0 +1,132 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.integration; + +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.WalletDepositInstructionType; +import com.coinbase.prime.model.enums.WalletType; +import com.coinbase.prime.wallets.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +public class WalletsIT extends BaseIntegrationTest { + + private String resolveWalletId() throws Exception { + WalletsService service = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse wallets = service.listWallets( + new ListWalletsRequest.Builder().portfolioId(portfolioId).build()); + if (wallets == null || wallets.getWallets() == null || wallets.getWallets().length == 0) { + return null; + } + return wallets.getWallets()[0].getId(); + } + + @Test + public void testListWallets() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + WalletsService service = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse response = service.listWallets( + new ListWalletsRequest.Builder() + .portfolioId(portfolioId) + .build()); + assertNotNull(response); + } + + @Test + public void testListWalletsWithOptionals() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + WalletsService service = PrimeServiceFactory.createWalletsService(client); + ListWalletsResponse response = service.listWallets( + new ListWalletsRequest.Builder() + .portfolioId(portfolioId) + .type(WalletType.TRADING) + .symbols(new String[]{"BTC", "ETH", "USDC"}) + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testGetWallet() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + String walletId = resolveWalletId(); + assumeTrue(walletId != null, "Skipping: no wallets found for portfolio"); + + WalletsService service = PrimeServiceFactory.createWalletsService(client); + GetWalletResponse response = service.getWallet( + new GetWalletRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .build()); + assertNotNull(response); + } + + @Test + public void testListWalletAddresses() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + String walletId = resolveWalletId(); + assumeTrue(walletId != null, "Skipping: no wallets found for portfolio"); + + WalletsService service = PrimeServiceFactory.createWalletsService(client); + ListWalletAddressesResponse response = service.listWalletAddresses( + new ListWalletAddressesRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .build()); + assertNotNull(response); + } + + @Test + public void testListWalletAddressesWithPagination() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + String walletId = resolveWalletId(); + assumeTrue(walletId != null, "Skipping: no wallets found for portfolio"); + + WalletsService service = PrimeServiceFactory.createWalletsService(client); + ListWalletAddressesResponse response = service.listWalletAddresses( + new ListWalletAddressesRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .limit(5) + .build()); + assertNotNull(response); + } + + @Test + public void testGetWalletDepositInstructions() throws Exception { + assumeTrue(portfolioId != null && !portfolioId.isEmpty(), + "Skipping: COINBASE_PRIME_PORTFOLIO_ID not set"); + String walletId = resolveWalletId(); + assumeTrue(walletId != null, "Skipping: no wallets found for portfolio"); + + WalletsService service = PrimeServiceFactory.createWalletsService(client); + GetWalletDepositInstructionsResponse response = service.getWalletDepositInstructions( + new GetWalletDepositInstructionsRequest.Builder() + .portfolioId(portfolioId) + .walletId(walletId) + .depositType(WalletDepositInstructionType.CRYPTO) + .build()); + assertNotNull(response); + } +} From fe9d5e4c69c7ee25796191e7030de015159de049 Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 13:27:13 -0700 Subject: [PATCH 3/8] chore(examples): remove stub examples that only printed TODO placeholders Delete generated sample mains that contained only System.out.println stubs with no SDK usage. Keeps existing fuller Example/*.java samples intact. Made-with: Cursor --- .../activities/ListPortfolioActivities.java | 27 ------------------ .../addressbook/ListAddressBookEntries.java | 27 ------------------ .../CancelAdvancedTransfer.java | 27 ------------------ .../CreateAdvancedTransfer.java | 27 ------------------ .../GetPortfolioCounterparty.java | 27 ------------------ .../GetPortfolioCounterpartyId.java | 27 ------------------ .../ListAdvancedTransferTransactions.java | 27 ------------------ .../ListAdvancedTransfers.java | 27 ------------------ .../allocations/CreateAllocation.java | 27 ------------------ .../allocations/CreateNetAllocation.java | 27 ------------------ .../examples/allocations/GetAllocation.java | 27 ------------------ .../ListAllocationsByClientNettingId.java | 27 ------------------ .../ListAllocationsByNettingId.java | 27 ------------------ .../allocations/ListPortfolioAllocations.java | 27 ------------------ .../examples/financing/CreateNewLocates.java | 27 ------------------ .../financing/GetCrossMarginOverview.java | 27 ------------------ .../GetEntityLocateAvailabilities.java | 27 ------------------ .../financing/GetMarginInformation.java | 27 ------------------ .../financing/GetPortfolioBuyingPower.java | 27 ------------------ .../GetPortfolioCreditInformation.java | 27 ------------------ .../GetPortfolioWithdrawalPower.java | 27 ------------------ .../GetTradeFinanceTieredPricingFees.java | 27 ------------------ .../financing/ListExistingLocates.java | 27 ------------------ .../financing/ListInterestAccruals.java | 27 ------------------ .../ListInterestAccrualsForPortfolio.java | 27 ------------------ .../financing/ListMarginCallSummaries.java | 27 ------------------ .../financing/ListMarginConversions.java | 27 ------------------ .../ListTradeFinanceObligations.java | 27 ------------------ .../financing/UpdateFundingSettings.java | 27 ------------------ .../futures/CancelEntityFuturesSweep.java | 27 ------------------ .../examples/futures/GetEntityFcmBalance.java | 27 ------------------ .../examples/futures/GetFcmEquity.java | 27 ------------------ .../futures/GetFcmMarginCallDetails.java | 27 ------------------ .../examples/futures/GetFcmRiskLimits.java | 27 ------------------ .../examples/futures/GetPositions.java | 27 ------------------ .../futures/ListEntityFuturesSweeps.java | 27 ------------------ .../futures/ScheduleEntityFuturesSweep.java | 27 ------------------ .../examples/futures/SetAutoSweep.java | 27 ------------------ .../coinbase/examples/orders/GetOrder.java | 27 ------------------ .../examples/orders/GetOrderByOrderId.java | 27 ------------------ .../examples/orders/GetOrderPreview.java | 27 ------------------ .../GetPaymentMethodDetails.java | 28 ------------------- .../paymentmethods/ListPaymentMethods.java | 27 ------------------ .../ListAggregateEntityPositions.java | 27 ------------------ .../positions/ListEntityPositions.java | 27 ------------------ .../examples/products/GetCandles.java | 27 ------------------ .../examples/staking/ClaimStakingRewards.java | 27 ------------------ .../staking/CreatePortfolioStake.java | 27 ------------------ .../staking/CreatePortfolioUnstake.java | 27 ------------------ .../CreateOnchainTransaction.java | 27 ------------------ .../examples/transactions/CreateTransfer.java | 27 ------------------ .../transactions/CreateWithdrawal.java | 27 ------------------ .../SubmitDepositTravelRuleData.java | 27 ------------------ .../coinbase/examples/users/ListUsers.java | 27 ------------------ .../examples/wallets/ListWallets.java | 27 ------------------ 55 files changed, 1486 deletions(-) delete mode 100644 src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java delete mode 100644 src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java delete mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java delete mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java delete mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java delete mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java delete mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java delete mode 100644 src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java delete mode 100644 src/main/java/com/coinbase/examples/allocations/CreateAllocation.java delete mode 100644 src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java delete mode 100644 src/main/java/com/coinbase/examples/allocations/GetAllocation.java delete mode 100644 src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java delete mode 100644 src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java delete mode 100644 src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java delete mode 100644 src/main/java/com/coinbase/examples/financing/CreateNewLocates.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetMarginInformation.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java delete mode 100644 src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java delete mode 100644 src/main/java/com/coinbase/examples/financing/ListExistingLocates.java delete mode 100644 src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java delete mode 100644 src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java delete mode 100644 src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java delete mode 100644 src/main/java/com/coinbase/examples/financing/ListMarginConversions.java delete mode 100644 src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java delete mode 100644 src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java delete mode 100644 src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java delete mode 100644 src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java delete mode 100644 src/main/java/com/coinbase/examples/futures/GetFcmEquity.java delete mode 100644 src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java delete mode 100644 src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java delete mode 100644 src/main/java/com/coinbase/examples/futures/GetPositions.java delete mode 100644 src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java delete mode 100644 src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java delete mode 100644 src/main/java/com/coinbase/examples/futures/SetAutoSweep.java delete mode 100644 src/main/java/com/coinbase/examples/orders/GetOrder.java delete mode 100644 src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java delete mode 100644 src/main/java/com/coinbase/examples/orders/GetOrderPreview.java delete mode 100644 src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java delete mode 100644 src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java delete mode 100644 src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java delete mode 100644 src/main/java/com/coinbase/examples/positions/ListEntityPositions.java delete mode 100644 src/main/java/com/coinbase/examples/products/GetCandles.java delete mode 100644 src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java delete mode 100644 src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java delete mode 100644 src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java delete mode 100644 src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java delete mode 100644 src/main/java/com/coinbase/examples/transactions/CreateTransfer.java delete mode 100644 src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java delete mode 100644 src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java delete mode 100644 src/main/java/com/coinbase/examples/users/ListUsers.java delete mode 100644 src/main/java/com/coinbase/examples/wallets/ListWallets.java diff --git a/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java b/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java deleted file mode 100644 index daf93d1d..00000000 --- a/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.activities; - -/** - * Example stub for ListPortfolioActivities (GET /v1/portfolios/{portfolio_id}/activities). - * Replace with a real example using requests from this package. - */ -public class ListPortfolioActivities { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListPortfolioActivities"); - } -} diff --git a/src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java b/src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java deleted file mode 100644 index 07fa86b6..00000000 --- a/src/main/java/com/coinbase/examples/addressbook/ListAddressBookEntries.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.addressbook; - -/** - * Example stub for ListAddressBookEntries (GET /v1/portfolios/{portfolio_id}/address_book). - * Replace with a real example using requests from this package. - */ -public class ListAddressBookEntries { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListAddressBookEntries"); - } -} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java b/src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java deleted file mode 100644 index 150546e7..00000000 --- a/src/main/java/com/coinbase/examples/advancedtransfer/CancelAdvancedTransfer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.advancedtransfer; - -/** - * Example stub for CancelAdvancedTransfer (POST /v1/portfolios/{portfolio_id}/advanced_transfers/{advanced_transfer_id}/cancel). - * Replace with a real example using requests from this package. - */ -public class CancelAdvancedTransfer { - public static void main(String[] args) { - System.out.println("TODO: implement example for CancelAdvancedTransfer"); - } -} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java b/src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java deleted file mode 100644 index d5ca0507..00000000 --- a/src/main/java/com/coinbase/examples/advancedtransfer/CreateAdvancedTransfer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.advancedtransfer; - -/** - * Example stub for CreateAdvancedTransfer (POST /v1/portfolios/{portfolio_id}/advanced_transfers). - * Replace with a real example using requests from this package. - */ -public class CreateAdvancedTransfer { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateAdvancedTransfer"); - } -} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java b/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java deleted file mode 100644 index 3eb9db32..00000000 --- a/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterparty.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.advancedtransfer; - -/** - * Example stub for GetPortfolioCounterparty (GET /v1/portfolios/{portfolio_id}/counterparty). - * Replace with a real example using requests from this package. - */ -public class GetPortfolioCounterparty { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPortfolioCounterparty"); - } -} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java b/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java deleted file mode 100644 index 762b2a08..00000000 --- a/src/main/java/com/coinbase/examples/advancedtransfer/GetPortfolioCounterpartyId.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2025-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.advancedtransfer; - -/** - * Example stub for GetPortfolioCounterpartyId (GET /v1/portfolios/{portfolio_id}/counterparty). - * Replace with a real example using requests from this package. - */ -public class GetPortfolioCounterpartyId { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPortfolioCounterpartyId"); - } -} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java b/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java deleted file mode 100644 index 4175e947..00000000 --- a/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransferTransactions.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.advancedtransfer; - -/** - * Example stub for ListAdvancedTransferTransactions (GET /v1/portfolios/{portfolio_id}/advanced_transfers/{advanced_transfer_id}/transactions). - * Replace with a real example using requests from this package. - */ -public class ListAdvancedTransferTransactions { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListAdvancedTransferTransactions"); - } -} diff --git a/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java b/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java deleted file mode 100644 index 82df5e42..00000000 --- a/src/main/java/com/coinbase/examples/advancedtransfer/ListAdvancedTransfers.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.advancedtransfer; - -/** - * Example stub for ListAdvancedTransfers (GET /v1/portfolios/{portfolio_id}/advanced_transfers). - * Replace with a real example using requests from this package. - */ -public class ListAdvancedTransfers { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListAdvancedTransfers"); - } -} diff --git a/src/main/java/com/coinbase/examples/allocations/CreateAllocation.java b/src/main/java/com/coinbase/examples/allocations/CreateAllocation.java deleted file mode 100644 index b5b8488e..00000000 --- a/src/main/java/com/coinbase/examples/allocations/CreateAllocation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.allocations; - -/** - * Example stub for CreateAllocation (POST /v1/allocations). - * Replace with a real example using requests from this package. - */ -public class CreateAllocation { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateAllocation"); - } -} diff --git a/src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java b/src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java deleted file mode 100644 index 012c3e9d..00000000 --- a/src/main/java/com/coinbase/examples/allocations/CreateNetAllocation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.allocations; - -/** - * Example stub for CreateNetAllocation (POST /v1/allocations/net). - * Replace with a real example using requests from this package. - */ -public class CreateNetAllocation { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateNetAllocation"); - } -} diff --git a/src/main/java/com/coinbase/examples/allocations/GetAllocation.java b/src/main/java/com/coinbase/examples/allocations/GetAllocation.java deleted file mode 100644 index 77ab2a27..00000000 --- a/src/main/java/com/coinbase/examples/allocations/GetAllocation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.allocations; - -/** - * Example stub for GetAllocation (GET /v1/portfolios/{portfolio_id}/allocations/{allocation_id}). - * Replace with a real example using requests from this package. - */ -public class GetAllocation { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetAllocation"); - } -} diff --git a/src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java b/src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java deleted file mode 100644 index c3f2eaca..00000000 --- a/src/main/java/com/coinbase/examples/allocations/ListAllocationsByClientNettingId.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.allocations; - -/** - * Example stub for ListAllocationsByClientNettingId (GET /v1/portfolios/{portfolio_id}/allocations/net/{netting_id}). - * Replace with a real example using requests from this package. - */ -public class ListAllocationsByClientNettingId { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListAllocationsByClientNettingId"); - } -} diff --git a/src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java b/src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java deleted file mode 100644 index 63fb3821..00000000 --- a/src/main/java/com/coinbase/examples/allocations/ListAllocationsByNettingId.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2025-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.allocations; - -/** - * Example stub for ListAllocationsByNettingId (GET /v1/portfolios/{portfolio_id}/allocations/net/{netting_id}). - * Replace with a real example using requests from this package. - */ -public class ListAllocationsByNettingId { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListAllocationsByNettingId"); - } -} diff --git a/src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java b/src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java deleted file mode 100644 index 09659326..00000000 --- a/src/main/java/com/coinbase/examples/allocations/ListPortfolioAllocations.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.allocations; - -/** - * Example stub for ListPortfolioAllocations (GET /v1/portfolios/{portfolio_id}/allocations). - * Replace with a real example using requests from this package. - */ -public class ListPortfolioAllocations { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListPortfolioAllocations"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/CreateNewLocates.java b/src/main/java/com/coinbase/examples/financing/CreateNewLocates.java deleted file mode 100644 index 37304191..00000000 --- a/src/main/java/com/coinbase/examples/financing/CreateNewLocates.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for CreateNewLocates (POST /v1/portfolios/{portfolio_id}/locates). - * Replace with a real example using requests from this package. - */ -public class CreateNewLocates { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateNewLocates"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java b/src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java deleted file mode 100644 index 5e341653..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetCrossMarginOverview.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetCrossMarginOverview (GET /v1/entities/{entity_id}/cross_margin). - * Replace with a real example using requests from this package. - */ -public class GetCrossMarginOverview { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetCrossMarginOverview"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java b/src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java deleted file mode 100644 index 5beb5544..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetEntityLocateAvailabilities.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetEntityLocateAvailabilities (GET /v1/entities/{entity_id}/locates_availability). - * Replace with a real example using requests from this package. - */ -public class GetEntityLocateAvailabilities { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetEntityLocateAvailabilities"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetMarginInformation.java b/src/main/java/com/coinbase/examples/financing/GetMarginInformation.java deleted file mode 100644 index 2cadb7b8..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetMarginInformation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetMarginInformation (GET /v1/entities/{entity_id}/margin). - * Replace with a real example using requests from this package. - */ -public class GetMarginInformation { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetMarginInformation"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java b/src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java deleted file mode 100644 index 39b8e5c5..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetPortfolioBuyingPower.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetPortfolioBuyingPower (GET /v1/portfolios/{portfolio_id}/buying_power). - * Replace with a real example using requests from this package. - */ -public class GetPortfolioBuyingPower { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPortfolioBuyingPower"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java b/src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java deleted file mode 100644 index 3709f061..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetPortfolioCreditInformation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetPortfolioCreditInformation (GET /v1/portfolios/{portfolio_id}/credit). - * Replace with a real example using requests from this package. - */ -public class GetPortfolioCreditInformation { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPortfolioCreditInformation"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java b/src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java deleted file mode 100644 index 9e267e83..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetPortfolioWithdrawalPower.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetPortfolioWithdrawalPower (GET /v1/portfolios/{portfolio_id}/withdrawal_power). - * Replace with a real example using requests from this package. - */ -public class GetPortfolioWithdrawalPower { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPortfolioWithdrawalPower"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java b/src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java deleted file mode 100644 index 872d8fbb..00000000 --- a/src/main/java/com/coinbase/examples/financing/GetTradeFinanceTieredPricingFees.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for GetTradeFinanceTieredPricingFees (GET /v1/entities/{entity_id}/tf_tiered_fees). - * Replace with a real example using requests from this package. - */ -public class GetTradeFinanceTieredPricingFees { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetTradeFinanceTieredPricingFees"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/ListExistingLocates.java b/src/main/java/com/coinbase/examples/financing/ListExistingLocates.java deleted file mode 100644 index 01ab14ca..00000000 --- a/src/main/java/com/coinbase/examples/financing/ListExistingLocates.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for ListExistingLocates (GET /v1/portfolios/{portfolio_id}/locates). - * Replace with a real example using requests from this package. - */ -public class ListExistingLocates { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListExistingLocates"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java b/src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java deleted file mode 100644 index 1af11051..00000000 --- a/src/main/java/com/coinbase/examples/financing/ListInterestAccruals.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for ListInterestAccruals (GET /v1/entities/{entity_id}/accruals). - * Replace with a real example using requests from this package. - */ -public class ListInterestAccruals { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListInterestAccruals"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java b/src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java deleted file mode 100644 index 48d9beca..00000000 --- a/src/main/java/com/coinbase/examples/financing/ListInterestAccrualsForPortfolio.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for ListInterestAccrualsForPortfolio (GET /v1/portfolios/{portfolio_id}/accruals). - * Replace with a real example using requests from this package. - */ -public class ListInterestAccrualsForPortfolio { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListInterestAccrualsForPortfolio"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java b/src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java deleted file mode 100644 index 56cbc887..00000000 --- a/src/main/java/com/coinbase/examples/financing/ListMarginCallSummaries.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for ListMarginCallSummaries (GET /v1/entities/{entity_id}/margin_summaries). - * Replace with a real example using requests from this package. - */ -public class ListMarginCallSummaries { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListMarginCallSummaries"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/ListMarginConversions.java b/src/main/java/com/coinbase/examples/financing/ListMarginConversions.java deleted file mode 100644 index 0c9e025c..00000000 --- a/src/main/java/com/coinbase/examples/financing/ListMarginConversions.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for ListMarginConversions (GET /v1/portfolios/{portfolio_id}/margin_conversions). - * Replace with a real example using requests from this package. - */ -public class ListMarginConversions { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListMarginConversions"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java b/src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java deleted file mode 100644 index 37a1abad..00000000 --- a/src/main/java/com/coinbase/examples/financing/ListTradeFinanceObligations.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for ListTradeFinanceObligations (GET /v1/entities/{entity_id}/tf_obligations). - * Replace with a real example using requests from this package. - */ -public class ListTradeFinanceObligations { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListTradeFinanceObligations"); - } -} diff --git a/src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java b/src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java deleted file mode 100644 index c136786d..00000000 --- a/src/main/java/com/coinbase/examples/financing/UpdateFundingSettings.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.financing; - -/** - * Example stub for UpdateFundingSettings (POST /v1/entities/{entity_id}/funding-settings). - * Replace with a real example using requests from this package. - */ -public class UpdateFundingSettings { - public static void main(String[] args) { - System.out.println("TODO: implement example for UpdateFundingSettings"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java b/src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java deleted file mode 100644 index 94f77a24..00000000 --- a/src/main/java/com/coinbase/examples/futures/CancelEntityFuturesSweep.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for CancelEntityFuturesSweep (DELETE /v1/entities/{entity_id}/futures/sweeps). - * Replace with a real example using requests from this package. - */ -public class CancelEntityFuturesSweep { - public static void main(String[] args) { - System.out.println("TODO: implement example for CancelEntityFuturesSweep"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java b/src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java deleted file mode 100644 index 77c429d1..00000000 --- a/src/main/java/com/coinbase/examples/futures/GetEntityFcmBalance.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for GetEntityFcmBalance (GET /v1/entities/{entity_id}/futures/balance_summary). - * Replace with a real example using requests from this package. - */ -public class GetEntityFcmBalance { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetEntityFcmBalance"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/GetFcmEquity.java b/src/main/java/com/coinbase/examples/futures/GetFcmEquity.java deleted file mode 100644 index 5beea54d..00000000 --- a/src/main/java/com/coinbase/examples/futures/GetFcmEquity.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for GetFcmEquity (GET /v1/entities/{entity_id}/futures/equity). - * Replace with a real example using requests from this package. - */ -public class GetFcmEquity { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetFcmEquity"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java b/src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java deleted file mode 100644 index b02987f8..00000000 --- a/src/main/java/com/coinbase/examples/futures/GetFcmMarginCallDetails.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for GetFcmMarginCallDetails (GET /v1/entities/{entity_id}/futures/margin_call_details). - * Replace with a real example using requests from this package. - */ -public class GetFcmMarginCallDetails { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetFcmMarginCallDetails"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java b/src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java deleted file mode 100644 index 9e6d7032..00000000 --- a/src/main/java/com/coinbase/examples/futures/GetFcmRiskLimits.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for GetFcmRiskLimits (GET /v1/entities/{entity_id}/futures/risk_limits). - * Replace with a real example using requests from this package. - */ -public class GetFcmRiskLimits { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetFcmRiskLimits"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/GetPositions.java b/src/main/java/com/coinbase/examples/futures/GetPositions.java deleted file mode 100644 index d0a74a50..00000000 --- a/src/main/java/com/coinbase/examples/futures/GetPositions.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for GetPositions (GET /v1/entities/{entity_id}/futures/positions). - * Replace with a real example using requests from this package. - */ -public class GetPositions { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPositions"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java b/src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java deleted file mode 100644 index 67e21ed7..00000000 --- a/src/main/java/com/coinbase/examples/futures/ListEntityFuturesSweeps.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for ListEntityFuturesSweeps (GET /v1/entities/{entity_id}/futures/sweeps). - * Replace with a real example using requests from this package. - */ -public class ListEntityFuturesSweeps { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListEntityFuturesSweeps"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java b/src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java deleted file mode 100644 index 1df1666a..00000000 --- a/src/main/java/com/coinbase/examples/futures/ScheduleEntityFuturesSweep.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for ScheduleEntityFuturesSweep (POST /v1/entities/{entity_id}/futures/sweeps). - * Replace with a real example using requests from this package. - */ -public class ScheduleEntityFuturesSweep { - public static void main(String[] args) { - System.out.println("TODO: implement example for ScheduleEntityFuturesSweep"); - } -} diff --git a/src/main/java/com/coinbase/examples/futures/SetAutoSweep.java b/src/main/java/com/coinbase/examples/futures/SetAutoSweep.java deleted file mode 100644 index ef31f210..00000000 --- a/src/main/java/com/coinbase/examples/futures/SetAutoSweep.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.futures; - -/** - * Example stub for SetAutoSweep (POST /v1/entities/{entity_id}/futures/auto_sweep). - * Replace with a real example using requests from this package. - */ -public class SetAutoSweep { - public static void main(String[] args) { - System.out.println("TODO: implement example for SetAutoSweep"); - } -} diff --git a/src/main/java/com/coinbase/examples/orders/GetOrder.java b/src/main/java/com/coinbase/examples/orders/GetOrder.java deleted file mode 100644 index 68e1035c..00000000 --- a/src/main/java/com/coinbase/examples/orders/GetOrder.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.orders; - -/** - * Example stub for GetOrder (GET /v1/portfolios/{portfolio_id}/orders/{order_id}). - * Replace with a real example using requests from this package. - */ -public class GetOrder { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetOrder"); - } -} diff --git a/src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java b/src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java deleted file mode 100644 index 17ab7e7e..00000000 --- a/src/main/java/com/coinbase/examples/orders/GetOrderByOrderId.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2025-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.orders; - -/** - * Example stub for GetOrderByOrderId (GET /v1/portfolios/{portfolio_id}/orders/{order_id}). - * Replace with a real example using requests from this package. - */ -public class GetOrderByOrderId { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetOrderByOrderId"); - } -} diff --git a/src/main/java/com/coinbase/examples/orders/GetOrderPreview.java b/src/main/java/com/coinbase/examples/orders/GetOrderPreview.java deleted file mode 100644 index bff1a01a..00000000 --- a/src/main/java/com/coinbase/examples/orders/GetOrderPreview.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.orders; - -/** - * Example stub for GetOrderPreview (POST /v1/portfolios/{portfolio_id}/order_preview). - * Replace with a real example using requests from this package. - */ -public class GetOrderPreview { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetOrderPreview"); - } -} diff --git a/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java b/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java deleted file mode 100644 index 7499d3f9..00000000 --- a/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.paymentmethods; - -/** - * Example stub for GetPaymentMethodDetails (GET - * /v1/entities/{entity_id}/payment-methods/{payment_method_id}). - * Replace with a real example using requests from this package. - */ -public class GetPaymentMethodDetails { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetPaymentMethodDetails"); - } -} diff --git a/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java b/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java deleted file mode 100644 index 63161bf2..00000000 --- a/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.paymentmethods; - -/** - * Example stub for ListPaymentMethods (GET /v1/entities/{entity_id}/payment-methods). - * Replace with a real example using requests from this package. - */ -public class ListPaymentMethods { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListPaymentMethods"); - } -} diff --git a/src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java b/src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java deleted file mode 100644 index 218d7ae8..00000000 --- a/src/main/java/com/coinbase/examples/positions/ListAggregateEntityPositions.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.positions; - -/** - * Example stub for ListAggregateEntityPositions (GET /v1/entities/{entity_id}/aggregate_positions). - * Replace with a real example using requests from this package. - */ -public class ListAggregateEntityPositions { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListAggregateEntityPositions"); - } -} diff --git a/src/main/java/com/coinbase/examples/positions/ListEntityPositions.java b/src/main/java/com/coinbase/examples/positions/ListEntityPositions.java deleted file mode 100644 index 97c92ae1..00000000 --- a/src/main/java/com/coinbase/examples/positions/ListEntityPositions.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.positions; - -/** - * Example stub for ListEntityPositions (GET /v1/entities/{entity_id}/positions). - * Replace with a real example using requests from this package. - */ -public class ListEntityPositions { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListEntityPositions"); - } -} diff --git a/src/main/java/com/coinbase/examples/products/GetCandles.java b/src/main/java/com/coinbase/examples/products/GetCandles.java deleted file mode 100644 index 2765df03..00000000 --- a/src/main/java/com/coinbase/examples/products/GetCandles.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.products; - -/** - * Example stub for GetCandles (GET /v1/portfolios/{portfolio_id}/candles). - * Replace with a real example using requests from this package. - */ -public class GetCandles { - public static void main(String[] args) { - System.out.println("TODO: implement example for GetCandles"); - } -} diff --git a/src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java b/src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java deleted file mode 100644 index 26fad6ae..00000000 --- a/src/main/java/com/coinbase/examples/staking/ClaimStakingRewards.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.staking; - -/** - * Example stub for ClaimStakingRewards (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/staking/claim_rewards). - * Replace with a real example using requests from this package. - */ -public class ClaimStakingRewards { - public static void main(String[] args) { - System.out.println("TODO: implement example for ClaimStakingRewards"); - } -} diff --git a/src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java b/src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java deleted file mode 100644 index d1e95b6a..00000000 --- a/src/main/java/com/coinbase/examples/staking/CreatePortfolioStake.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.staking; - -/** - * Example stub for CreatePortfolioStake (POST /v1/portfolios/{portfolio_id}/staking/initiate). - * Replace with a real example using requests from this package. - */ -public class CreatePortfolioStake { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreatePortfolioStake"); - } -} diff --git a/src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java b/src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java deleted file mode 100644 index e988d9a2..00000000 --- a/src/main/java/com/coinbase/examples/staking/CreatePortfolioUnstake.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.staking; - -/** - * Example stub for CreatePortfolioUnstake (POST /v1/portfolios/{portfolio_id}/staking/unstake). - * Replace with a real example using requests from this package. - */ -public class CreatePortfolioUnstake { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreatePortfolioUnstake"); - } -} diff --git a/src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java b/src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java deleted file mode 100644 index 92f0fd0c..00000000 --- a/src/main/java/com/coinbase/examples/transactions/CreateOnchainTransaction.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.transactions; - -/** - * Example stub for CreateOnchainTransaction (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/onchain_transaction). - * Replace with a real example using requests from this package. - */ -public class CreateOnchainTransaction { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateOnchainTransaction"); - } -} diff --git a/src/main/java/com/coinbase/examples/transactions/CreateTransfer.java b/src/main/java/com/coinbase/examples/transactions/CreateTransfer.java deleted file mode 100644 index 479f7e04..00000000 --- a/src/main/java/com/coinbase/examples/transactions/CreateTransfer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.transactions; - -/** - * Example stub for CreateTransfer (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transfers). - * Replace with a real example using requests from this package. - */ -public class CreateTransfer { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateTransfer"); - } -} diff --git a/src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java b/src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java deleted file mode 100644 index 0cffb326..00000000 --- a/src/main/java/com/coinbase/examples/transactions/CreateWithdrawal.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.transactions; - -/** - * Example stub for CreateWithdrawal (POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/withdrawals). - * Replace with a real example using requests from this package. - */ -public class CreateWithdrawal { - public static void main(String[] args) { - System.out.println("TODO: implement example for CreateWithdrawal"); - } -} diff --git a/src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java b/src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java deleted file mode 100644 index 529e2e07..00000000 --- a/src/main/java/com/coinbase/examples/transactions/SubmitDepositTravelRuleData.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.transactions; - -/** - * Example stub for SubmitDepositTravelRuleData (POST /v1/portfolios/{portfolio_id}/transactions/{transaction_id}/travel_rule/deposit). - * Replace with a real example using requests from this package. - */ -public class SubmitDepositTravelRuleData { - public static void main(String[] args) { - System.out.println("TODO: implement example for SubmitDepositTravelRuleData"); - } -} diff --git a/src/main/java/com/coinbase/examples/users/ListUsers.java b/src/main/java/com/coinbase/examples/users/ListUsers.java deleted file mode 100644 index 9cd0e63e..00000000 --- a/src/main/java/com/coinbase/examples/users/ListUsers.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.users; - -/** - * Example stub for ListUsers (GET /v1/entities/{entity_id}/users). - * Replace with a real example using requests from this package. - */ -public class ListUsers { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListUsers"); - } -} diff --git a/src/main/java/com/coinbase/examples/wallets/ListWallets.java b/src/main/java/com/coinbase/examples/wallets/ListWallets.java deleted file mode 100644 index f16b5ea9..00000000 --- a/src/main/java/com/coinbase/examples/wallets/ListWallets.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2026-present Coinbase Global, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.coinbase.examples.wallets; - -/** - * Example stub for ListWallets (GET /v1/portfolios/{portfolio_id}/wallets). - * Replace with a real example using requests from this package. - */ -public class ListWallets { - public static void main(String[] args) { - System.out.println("TODO: implement example for ListWallets"); - } -} From 8750876731f848ee5da70b60c730e2bd54fd9324 Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 13:29:17 -0700 Subject: [PATCH 4/8] chore(generator): drop ExamplePhase TODO example stubs Remove ExamplePhase from SdkGeneratorMain; delete the phase class. Docs now state that com.coinbase.examples is hand-maintained only. Made-with: Cursor --- CHANGELOG.md | 2 +- CLAUDE.md | 4 +- README.md | 2 +- tools/model-generator/README.md | 6 +- .../tools/sdkgenerator/SdkGeneratorMain.java | 7 +- .../sdkgenerator/phases/ExamplePhase.java | 89 ------------------- 6 files changed, 8 insertions(+), 102 deletions(-) delete mode 100644 tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java diff --git a/CHANGELOG.md b/CHANGELOG.md index ab7f89f9..61466a16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ - `GetStakingStatus` - Wallet staking status ### Changed -- **SDK generator (tools/model-generator)**: Holistic generation aligned with .NET — models, enums, per-operation `*Request`/`*Response`, `*Service`/`*ServiceImpl`, `PrimeServiceFactory`, and missing example stubs via `com.coinbase.tools.sdkgenerator`; config in `tools/model-generator/config/generator-config.json` and `operations-overrides.json`. Root Maven profile renamed from `generate-models` to **`generate`** (`mvn -Pgenerate`); use `-Dgenerator.args=--diff` or `--dry-run` as needed. +- **SDK generator (tools/model-generator)**: Holistic generation aligned with .NET — models, enums, per-operation `*Request`/`*Response`, `*Service`/`*ServiceImpl`, and `PrimeServiceFactory` via `com.coinbase.tools.sdkgenerator`; config in `tools/model-generator/config/generator-config.json` and `operations-overrides.json`. Root Maven profile renamed from `generate-models` to **`generate`** (`mvn -Pgenerate`); use `-Dgenerator.args=--diff` or `--dry-run` as needed. - Regenerated `com.coinbase.prime.model` and `model.enums` from latest Prime OpenAPI spec (`https://api.prime.coinbase.com/v1/openapi.yaml`) - **Model generator** (`PostProcessor`): map `GoogleTypeDate` to `DateOfBirth` so `TravelRuleParty.date_of_birth` compiles when `Google*` types are excluded - `ActivityMetadataConsensus`, `Asset`, `CreateAllocationResponseBody`, `CreateNetAllocationResponseBody`, `CrossMarginOverview`, `EvmParams`, `FcmTradingSessionDetails`, `FuturesSweep`, `MarginSummary`, `NetworkDetails`, `OnchainTransactionDetails`, `Order`, `PmAssetInfo`, `PostTradeCreditInformation`, `RequestToSubmitTravelRuleDataForAnExistingDepositTransaction`, `RfqProductDetails`, `RiskAssessment`, `RpcConfig`, `TravelRuleData`, `TravelRuleParty`, `XmPosition`, `XmRiskNettingInfo`, `UserRole` - field updates per spec diff --git a/CLAUDE.md b/CLAUDE.md index c10b665b..7b10491d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -128,7 +128,7 @@ mvn -Pgenerate This tool: - Downloads the OpenAPI spec, generates models and enums (OpenAPI Generator + `PostProcessor`) -- Generates `*Request`, `*Response`, `*Service`, `*ServiceImpl` per tag/operation, `PrimeServiceFactory`, and missing example stubs under `com.coinbase.examples` +- Generates `*Request`, `*Response`, `*Service`, `*ServiceImpl` per tag/operation and `PrimeServiceFactory` - Maintains SDK conventions (Builder pattern, proper annotations) - Prevents drift between spec and implementation - Processes all models from the spec, updating existing files to catch changes @@ -145,7 +145,7 @@ When the OpenAPI spec adds or changes operations: 2. **Run the holistic generator** from the repo root: `mvn -Pgenerate` (or `-Dgenerator.args=--diff` to compare without writing) 3. **Build**: `mvn clean install` and fix any generator gaps in `tools/model-generator` (not by editing generated Java by hand, except where noted below) -Hand-maintained (not overwritten by the generator) includes: `com.coinbase.prime.common` (e.g. `PrimeListRequest`, `Pagination`), credentials/client/utils, and **curated** examples under `com.coinbase.examples` (the generator only adds a missing stub if no file exists) +Hand-maintained (not overwritten by the generator) includes: `com.coinbase.prime.common` (e.g. `PrimeListRequest`, `Pagination`), credentials/client/utils, and **curated** examples under `com.coinbase.examples` ### Endpoint Discovery To identify available endpoints: diff --git a/README.md b/README.md index 2c6ebb4f..44160ee3 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,6 @@ mvn -Pgenerate Optional: compare without writing files: `mvn -Pgenerate -Dgenerator.args=--diff`, or dry run: `-Dgenerator.args=--dry-run`. -This regenerates domain models and enums, per-operation `*Request` / `*Response` types, `*Service` / `*ServiceImpl`, `PrimeServiceFactory`, and adds missing example stubs only when an example file does not already exist. +This regenerates domain models and enums, per-operation `*Request` / `*Response` types, `*Service` / `*ServiceImpl`, and `PrimeServiceFactory`. Example programs under `com.coinbase.examples` are maintained separately. See [`tools/model-generator/README.md`](tools/model-generator/README.md) for configuration (`config/generator-config.json`, `operations-overrides.json`) and module details. diff --git a/tools/model-generator/README.md b/tools/model-generator/README.md index 7c7f046a..f8f263e3 100644 --- a/tools/model-generator/README.md +++ b/tools/model-generator/README.md @@ -7,7 +7,8 @@ Generates the majority of the Prime Java SDK from the published OpenAPI spec, al 1. **Models & enums** — OpenAPI Generator (`OpenApiGenerator`) → `PostProcessor` → `com.coinbase.prime.model` / `model.enums` 2. **Client surface** — `SdkGeneratorMain` / `ClientSurfacePhase`: per-operation `*Request`, `*Response`, `*Service`, `*ServiceImpl` under `com.coinbase.prime./` 3. **Factory** — `com.coinbase.prime.factory.PrimeServiceFactory` -4. **Examples** — If `com.coinbase.examples//.java` does not exist, a minimal stub is created (existing files are never overwritten) + +Hand-written samples live under `com.coinbase.examples`; the generator does not create or update them. ## Configuration @@ -49,8 +50,7 @@ The root profile runs `mvn` in this module with `-Pgenerate` and forwards `gener 2. Parse YAML to `JsonNode` (`SpecParser`); build operation bindings (`OperationBindingGenerator` + `operations-overrides.json`) 3. Run model/enum generation unless `--dry-run` / `--diff` 4. Emit request/response/service and write files (`ClientSurfacePhase`) -5. Emit missing example stubs (`ExamplePhase`) -6. Regenerate `PrimeServiceFactory` (`FactoryPhase`) +5. Regenerate `PrimeServiceFactory` (`FactoryPhase`) ## Tests diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java index 2e02ba1d..a8c8df49 100644 --- a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java @@ -1,7 +1,6 @@ package com.coinbase.tools.sdkgenerator; import com.coinbase.tools.sdkgenerator.phases.ClientSurfacePhase; -import com.coinbase.tools.sdkgenerator.phases.ExamplePhase; import com.coinbase.tools.sdkgenerator.phases.FactoryPhase; import com.coinbase.tools.sdkgenerator.phases.ModelEnumPhase; import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; @@ -23,7 +22,7 @@ import java.util.List; /** - * Holistic Prime Java SDK generator: models, enums, client surface, factory, examples. + * Holistic Prime Java SDK generator: models, enums, client surface, factory. */ public final class SdkGeneratorMain { @@ -80,10 +79,6 @@ public static void main(String[] args) throws Exception { new ClientSurfacePhase(log, document, cfg, transforms, primeRoot); client.run(operations, dryRun, diffMode); - Path examplesRoot = projectRoot.resolve("src/main/java/com/coinbase/examples"); - ExamplePhase examples = new ExamplePhase(log, document, cfg, examplesRoot); - examples.run(operations, dryRun, diffMode); - String factory = FactoryPhase.emit(cfg); Path factoryPath = projectRoot.resolve("src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java"); diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java deleted file mode 100644 index f20082ba..00000000 --- a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ExamplePhase.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.coinbase.tools.sdkgenerator.phases; - -import com.coinbase.tools.sdkgenerator.CopyrightHelper; -import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; -import com.coinbase.tools.sdkgenerator.processing.NamingResolver; -import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; -import com.coinbase.tools.sdkgenerator.spec.ParsedOpenApiDocument; -import com.coinbase.tools.sdkgenerator.spec.ParsedOperation; -import com.coinbase.tools.sdkgenerator.spec.SdkOperationBinding; -import org.slf4j.Logger; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; - -/** - * Creates minimal example .java under {@code com.coinbase.examples} when missing. - */ -public final class ExamplePhase { - - private final Logger log; - private final ParsedOpenApiDocument doc; - @SuppressWarnings("unused") - private final GeneratorConfiguration cfg; - private final Path examplesRoot; - - public ExamplePhase( - Logger log, ParsedOpenApiDocument doc, GeneratorConfiguration cfg, Path examplesRoot) { - this.log = log; - this.doc = doc; - this.cfg = cfg; - this.examplesRoot = examplesRoot; - } - - public void run(List bindings, boolean dryRun, boolean diffMode) - throws IOException { - for (SdkOperationBinding b : bindings) { - ParsedOperation op = doc.getOperationsById().get(b.getOperationId()); - if (op == null) { - continue; - } - ServiceDefinition svc = NamingResolver.requireService(cfg, b.getService()); - Path p = - examplesRoot - .resolve(svc.getFolder()) - .resolve(b.getSdkMethod() + ".java"); - if (Files.exists(p)) { - if (!diffMode) { - log.info("EXAMPLE skip (exists): {}", p); - } - continue; - } - String content = emitStub(b, op, svc); - if (dryRun) { - log.info("EXAMPLE DRY-RUN would create {} ({} chars)", p, content.length()); - continue; - } - if (diffMode) { - log.info("EXAMPLE DIFF missing: {}", p); - continue; - } - Files.createDirectories(p.getParent()); - Files.writeString(p, content); - log.info("EXAMPLE created: {}", p); - } - } - - private static String emitStub( - SdkOperationBinding b, ParsedOperation op, ServiceDefinition svc) { - String name = b.getSdkMethod(); - StringBuilder s = new StringBuilder(); - s.append(CopyrightHelper.javaFileHeader()); - s.append("package com.coinbase.examples.").append(svc.getFolder()).append(";\n\n"); - s.append("/**\n * Example stub for ") - .append(name) - .append(" (") - .append(op.getHttpMethod()) - .append(" ") - .append(op.getPath()) - .append(").\n * Replace with a real example using requests from this package.\n */\n"); - s.append("public class ").append(name).append(" {\n"); - s.append(" public static void main(String[] args) {\n"); - s.append(" System.out.println(\"TODO: implement example for ").append(name).append("\");\n"); - s.append(" }\n"); - s.append("}\n"); - return s.toString(); - } -} From b75d78076f62e96f52f25f6ace064187377e3bf4 Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 13:52:55 -0700 Subject: [PATCH 5/8] revert: restore examples to main branch state Reverts all changes to src/main/java/com/coinbase/examples/ introduced on nm/generate-endpoints, restoring the 3 deleted example files. Made-with: Cursor --- .../activities/ListPortfolioActivities.java | 75 +++++++++++++++++++ .../GetPaymentMethodDetails.java | 50 +++++++++++++ .../paymentmethods/ListPaymentMethods.java | 46 ++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java create mode 100644 src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java create mode 100644 src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java diff --git a/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java b/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java new file mode 100644 index 00000000..543faa29 --- /dev/null +++ b/src/main/java/com/coinbase/examples/activities/ListPortfolioActivities.java @@ -0,0 +1,75 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.activities; + +import com.coinbase.prime.activities.ActivitiesService; +import com.coinbase.prime.activities.ListPortfolioActivitiesRequest; +import com.coinbase.prime.activities.ListPortfolioActivitiesResponse; +import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.credentials.CoinbasePrimeCredentials; +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.model.enums.ActivityCategory; +import com.coinbase.prime.utils.Utils; + +public class ListPortfolioActivities { + public static void main(String[] args) { + try { + CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS")); + CoinbasePrimeClient client = new CoinbasePrimeClient(credentials); + String portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID"); + + System.out.println("Using Portfolio ID: " + portfolioId); + + // Parse symbols from CSV if provided as first argument + // Parse categories from CSV if provided as second argument + ListPortfolioActivitiesRequest.Builder builder = new ListPortfolioActivitiesRequest.Builder(portfolioId); + + if (args.length > 0 && !args[0].isEmpty()) { + String[] symbols = args[0].split(","); + for (int i = 0; i < symbols.length; i++) { + symbols[i] = symbols[i].trim(); + } + builder.symbols(symbols); + System.out.println("Filtering by symbols: " + String.join(", ", symbols)); + } + + if (args.length > 1 && !args[1].isEmpty()) { + String[] categoryStrings = args[1].split(","); + ActivityCategory[] categories = new ActivityCategory[categoryStrings.length]; + + for (int i = 0; i < categoryStrings.length; i++) { + try { + categories[i] = ActivityCategory.valueOf(categoryStrings[i].trim()); + } catch (IllegalArgumentException e) { + System.err.println("Invalid category: " + categoryStrings[i].trim()); + return; + } + } + + builder.categories(categories); + System.out.println("Filtering by categories: " + String.join(", ", categoryStrings)); + } + + ActivitiesService service = PrimeServiceFactory.createActivitiesService(client); + ListPortfolioActivitiesResponse response = service.listPortfolioActivities(builder.build()); + + System.out.println(Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java b/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java new file mode 100644 index 00000000..0176ac33 --- /dev/null +++ b/src/main/java/com/coinbase/examples/paymentmethods/GetPaymentMethodDetails.java @@ -0,0 +1,50 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.paymentmethods; + +import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.credentials.CoinbasePrimeCredentials; +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.paymentmethods.GetPaymentMethodDetailsRequest; +import com.coinbase.prime.paymentmethods.GetPaymentMethodDetailsResponse; +import com.coinbase.prime.paymentmethods.PaymentMethodsService; +import com.coinbase.prime.utils.Utils; + +public class GetPaymentMethodDetails { + public static void main(String[] args) { + try { + CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials( + System.getenv("COINBASE_PRIME_CREDENTIALS")); + CoinbasePrimeClient client = new CoinbasePrimeClient(credentials); + String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID"); + String paymentMethodId = args[0]; + + System.out.println("Using Entity ID: " + entityId + ", Payment Method ID: " + paymentMethodId); + + PaymentMethodsService service = PrimeServiceFactory.createPaymentMethodsService(client); + GetPaymentMethodDetailsResponse response = service.getPaymentMethodDetails( + new GetPaymentMethodDetailsRequest.Builder() + .entityId(entityId) + .paymentMethodId(paymentMethodId) + .build()); + + System.out.println(Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java b/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java new file mode 100644 index 00000000..7fe2133b --- /dev/null +++ b/src/main/java/com/coinbase/examples/paymentmethods/ListPaymentMethods.java @@ -0,0 +1,46 @@ +/* + * Copyright 2025-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.examples.paymentmethods; + +import com.coinbase.prime.client.CoinbasePrimeClient; +import com.coinbase.prime.credentials.CoinbasePrimeCredentials; +import com.coinbase.prime.factory.PrimeServiceFactory; +import com.coinbase.prime.paymentmethods.ListPaymentMethodsRequest; +import com.coinbase.prime.paymentmethods.ListPaymentMethodsResponse; +import com.coinbase.prime.paymentmethods.PaymentMethodsService; +import com.coinbase.prime.utils.Utils; + +public class ListPaymentMethods { + public static void main(String[] args) { + try { + CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials( + System.getenv("COINBASE_PRIME_CREDENTIALS")); + CoinbasePrimeClient client = new CoinbasePrimeClient(credentials); + String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID"); + + System.out.println("Using Entity ID: " + entityId); + + PaymentMethodsService service = PrimeServiceFactory.createPaymentMethodsService(client); + ListPaymentMethodsResponse response = service.listPaymentMethods( + new ListPaymentMethodsRequest.Builder(entityId).build()); + + System.out.println(Utils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} From 010f4e98eb6a3d8fda9cc37d43bb75478ae925a4 Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 14:06:00 -0700 Subject: [PATCH 6/8] fix(generator): preserve copyright year, mirror prime-sdk-dotnet helper Generator now resolves the SDK-emitted copyright year from the first git commit that added the anchor file (RequestPhase.java) and preserves the existing on-disk year for already-tracked files via applyCopyrightYear. Restores headers on pre-existing files that prior runs had bumped, and sets new files to the anchor year (2026). Made-with: Cursor --- .../prime/activities/ActivitiesService.java | 2 +- .../activities/ActivitiesServiceImpl.java | 2 +- .../ListPortfolioActivitiesRequest.java | 2 +- .../ListPortfolioActivitiesResponse.java | 2 +- .../prime/addressbook/AddressBookService.java | 2 +- .../addressbook/AddressBookServiceImpl.java | 2 +- .../ListAddressBookEntriesRequest.java | 2 +- .../ListAddressBookEntriesResponse.java | 2 +- .../AdvancedTransferService.java | 2 +- .../AdvancedTransferServiceImpl.java | 2 +- .../CancelAdvancedTransferRequest.java | 2 +- .../CancelAdvancedTransferResponse.java | 2 +- .../CreateAdvancedTransferRequest.java | 2 +- .../CreateAdvancedTransferResponse.java | 2 +- .../GetPortfolioCounterpartyIdRequest.java | 2 +- .../GetPortfolioCounterpartyIdResponse.java | 2 +- .../GetPortfolioCounterpartyRequest.java | 2 +- .../GetPortfolioCounterpartyResponse.java | 2 +- ...stAdvancedTransferTransactionsRequest.java | 2 +- ...tAdvancedTransferTransactionsResponse.java | 2 +- .../ListAdvancedTransfersRequest.java | 2 +- .../ListAdvancedTransfersResponse.java | 2 +- .../prime/allocations/AllocationsService.java | 2 +- .../allocations/AllocationsServiceImpl.java | 2 +- ...stAllocationsByClientNettingIdRequest.java | 2 +- ...tAllocationsByClientNettingIdResponse.java | 2 +- .../coinbase/prime/assets/AssetsService.java | 2 +- .../prime/assets/AssetsServiceImpl.java | 2 +- .../prime/balances/BalancesService.java | 2 +- .../prime/balances/BalancesServiceImpl.java | 2 +- .../prime/commission/CommissionService.java | 2 +- .../commission/CommissionServiceImpl.java | 2 +- .../prime/factory/PrimeServiceFactory.java | 2 +- .../ListTradeFinanceObligationsRequest.java | 2 +- .../ListTradeFinanceObligationsResponse.java | 2 +- .../UpdateFundingSettingsRequest.java | 2 +- .../UpdateFundingSettingsResponse.java | 2 +- .../prime/futures/GetFcmEquityRequest.java | 2 +- .../prime/futures/GetFcmEquityResponse.java | 2 +- .../prime/invoice/InvoiceService.java | 2 +- .../prime/invoice/InvoiceServiceImpl.java | 2 +- .../prime/model/ActiveLiquidationSummary.java | 2 +- .../prime/model/AdvancedTransfer.java | 2 +- .../prime/model/BlindMatchMetadata.java | 2 +- .../prime/model/CommissionDetailTotal.java | 2 +- .../prime/model/FcmScheduledMaintenance.java | 2 +- .../prime/model/FcmTradingSessionDetails.java | 2 +- .../coinbase/prime/model/FundMovement.java | 2 +- .../prime/model/FutureProductDetails.java | 2 +- .../prime/model/PerpetualProductDetails.java | 2 +- ...leDataForAnExistingDepositTransaction.java | 2 +- .../coinbase/prime/model/StakingStatus.java | 2 +- .../coinbase/prime/model/TravelRuleData.java | 2 +- .../prime/model/ValidatorAllocation.java | 2 +- .../prime/model/ValidatorStakingInfo.java | 2 +- .../prime/model/ValidatorUnstakePreview.java | 2 +- .../model/enums/AdvancedTransferState.java | 2 +- .../model/enums/AdvancedTransferType.java | 2 +- .../prime/model/enums/ContractExpiryType.java | 2 +- .../model/enums/ExpiringContractStatus.java | 2 +- .../model/enums/FcmMarginHealthState.java | 2 +- .../enums/FcmTradingSessionClosedReason.java | 2 +- .../model/enums/FcmTradingSessionState.java | 2 +- .../prime/model/enums/ProductType.java | 2 +- .../prime/model/enums/RiskManagementType.java | 2 +- .../model/enums/SecondaryPermission.java | 2 +- .../coinbase/prime/model/enums/StakeType.java | 2 +- .../model/enums/XmLiquidationStatus.java | 2 +- .../prime/orders/GetOrderRequest.java | 2 +- .../prime/orders/GetOrderResponse.java | 2 +- .../coinbase/prime/orders/OrdersService.java | 2 +- .../prime/orders/OrdersServiceImpl.java | 2 +- .../paymentmethods/PaymentMethodsService.java | 2 +- .../PaymentMethodsServiceImpl.java | 2 +- .../prime/portfolios/PortfoliosService.java | 2 +- .../portfolios/PortfoliosServiceImpl.java | 2 +- .../ListAggregateEntityPositionsRequest.java | 2 +- .../ListAggregateEntityPositionsResponse.java | 2 +- .../positions/ListEntityPositionsRequest.java | 2 +- .../ListEntityPositionsResponse.java | 2 +- .../prime/products/GetCandlesRequest.java | 2 +- .../prime/products/GetCandlesResponse.java | 2 +- .../prime/products/ProductsService.java | 2 +- .../prime/products/ProductsServiceImpl.java | 2 +- .../staking/ClaimStakingRewardsRequest.java | 2 +- .../staking/ClaimStakingRewardsResponse.java | 2 +- .../staking/CreatePortfolioStakeRequest.java | 2 +- .../staking/CreatePortfolioStakeResponse.java | 2 +- .../CreatePortfolioUnstakeRequest.java | 2 +- .../CreatePortfolioUnstakeResponse.java | 2 +- .../staking/GetStakingStatusRequest.java | 2 +- .../staking/GetStakingStatusResponse.java | 2 +- .../transactions/CreateTransferRequest.java | 2 +- .../transactions/CreateTransferResponse.java | 2 +- .../transactions/CreateWithdrawalRequest.java | 2 +- .../CreateWithdrawalResponse.java | 2 +- .../GetTransactionTravelRuleDataRequest.java | 2 +- .../GetTransactionTravelRuleDataResponse.java | 2 +- .../SubmitDepositTravelRuleDataRequest.java | 2 +- .../SubmitDepositTravelRuleDataResponse.java | 2 +- .../transactions/TransactionsService.java | 2 +- .../transactions/TransactionsServiceImpl.java | 2 +- .../prime/users/ListUsersRequest.java | 2 +- .../prime/users/ListUsersResponse.java | 2 +- .../coinbase/prime/users/UsersService.java | 2 +- .../prime/users/UsersServiceImpl.java | 2 +- .../prime/wallets/WalletsService.java | 2 +- .../prime/wallets/WalletsServiceImpl.java | 2 +- .../tools/modelgenerator/PostProcessor.java | 1 + .../tools/sdkgenerator/CopyrightHelper.java | 141 +++++++++++++++++- .../tools/sdkgenerator/SdkGeneratorMain.java | 2 + .../phases/ClientSurfacePhase.java | 3 +- 112 files changed, 250 insertions(+), 113 deletions(-) diff --git a/src/main/java/com/coinbase/prime/activities/ActivitiesService.java b/src/main/java/com/coinbase/prime/activities/ActivitiesService.java index 23548c14..ef3e33dc 100644 --- a/src/main/java/com/coinbase/prime/activities/ActivitiesService.java +++ b/src/main/java/com/coinbase/prime/activities/ActivitiesService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java b/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java index b74de654..4d26dcdb 100644 --- a/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java +++ b/src/main/java/com/coinbase/prime/activities/ActivitiesServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java index 7add23a8..b58d80e3 100644 --- a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java +++ b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java index e6407baf..86c13048 100644 --- a/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java +++ b/src/main/java/com/coinbase/prime/activities/ListPortfolioActivitiesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java b/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java index eef39861..2f08b8df 100644 --- a/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java +++ b/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java b/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java index f47343d5..a2c3aeb4 100644 --- a/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java +++ b/src/main/java/com/coinbase/prime/addressbook/AddressBookServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java index 5c0b4a27..2b33c4f4 100644 --- a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java +++ b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java index 54f24e7c..5efa81b5 100644 --- a/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java +++ b/src/main/java/com/coinbase/prime/addressbook/ListAddressBookEntriesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java index 7c4f66e4..cfe1c8d3 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java index da4e9d18..667f164a 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java index cf401c4e..f2dd4e0c 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java index 3ab45c0a..fff1d598 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CancelAdvancedTransferResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java index 375ed42d..6a1b5ee6 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java index a4391ef4..29d39f05 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/CreateAdvancedTransferResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java index 76203da6..8a9a123c 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java index 1d13ce99..b7317098 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyIdResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java index 60980ed2..ae70c2c8 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java index 46f74ad9..4342ebc2 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/GetPortfolioCounterpartyResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java index ae7fe7b9..37e2ee48 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java index 5bd5e4c9..02595690 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransferTransactionsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java index 1b093392..2ae287b4 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java index 5be67b90..66b3192f 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/ListAdvancedTransfersResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/allocations/AllocationsService.java b/src/main/java/com/coinbase/prime/allocations/AllocationsService.java index ada4530a..03375a57 100644 --- a/src/main/java/com/coinbase/prime/allocations/AllocationsService.java +++ b/src/main/java/com/coinbase/prime/allocations/AllocationsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java b/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java index 3d3128c0..a45a9e08 100644 --- a/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/allocations/AllocationsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java index c1c07e6f..504169b9 100644 --- a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java +++ b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java index 429ba702..6bb921e2 100644 --- a/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java +++ b/src/main/java/com/coinbase/prime/allocations/ListAllocationsByClientNettingIdResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/assets/AssetsService.java b/src/main/java/com/coinbase/prime/assets/AssetsService.java index 488beafb..74b3556e 100644 --- a/src/main/java/com/coinbase/prime/assets/AssetsService.java +++ b/src/main/java/com/coinbase/prime/assets/AssetsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java b/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java index 6a9a971c..2d4393d7 100644 --- a/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/assets/AssetsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/balances/BalancesService.java b/src/main/java/com/coinbase/prime/balances/BalancesService.java index 1268fd6a..58ef0b22 100644 --- a/src/main/java/com/coinbase/prime/balances/BalancesService.java +++ b/src/main/java/com/coinbase/prime/balances/BalancesService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java b/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java index 4f545178..e5c0e9e9 100644 --- a/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java +++ b/src/main/java/com/coinbase/prime/balances/BalancesServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/commission/CommissionService.java b/src/main/java/com/coinbase/prime/commission/CommissionService.java index 83ccf77b..95980445 100644 --- a/src/main/java/com/coinbase/prime/commission/CommissionService.java +++ b/src/main/java/com/coinbase/prime/commission/CommissionService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java b/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java index 326b102d..7b7d445e 100644 --- a/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java +++ b/src/main/java/com/coinbase/prime/commission/CommissionServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java b/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java index 881ad9a9..224471a3 100644 --- a/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java +++ b/src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java index 3ed0a27a..49fbcf1b 100644 --- a/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java +++ b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java index f03c7e98..e5596cba 100644 --- a/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java +++ b/src/main/java/com/coinbase/prime/financing/ListTradeFinanceObligationsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java index 71c1e914..869e1d26 100644 --- a/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java +++ b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java index 5e4bfa96..644d03c3 100644 --- a/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java +++ b/src/main/java/com/coinbase/prime/financing/UpdateFundingSettingsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java b/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java index 1291bb8b..34569534 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmEquityRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java b/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java index 5a48e715..d86d23e5 100644 --- a/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java +++ b/src/main/java/com/coinbase/prime/futures/GetFcmEquityResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/invoice/InvoiceService.java b/src/main/java/com/coinbase/prime/invoice/InvoiceService.java index f721655c..8de185ab 100644 --- a/src/main/java/com/coinbase/prime/invoice/InvoiceService.java +++ b/src/main/java/com/coinbase/prime/invoice/InvoiceService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java b/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java index b7a53829..adfabe74 100644 --- a/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java +++ b/src/main/java/com/coinbase/prime/invoice/InvoiceServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java b/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java index c911675b..b5dfd6f2 100644 --- a/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java +++ b/src/main/java/com/coinbase/prime/model/ActiveLiquidationSummary.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java b/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java index 51e8a5dd..4f1ad4f5 100644 --- a/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java +++ b/src/main/java/com/coinbase/prime/model/AdvancedTransfer.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java b/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java index 2d1d394f..4479727c 100644 --- a/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java +++ b/src/main/java/com/coinbase/prime/model/BlindMatchMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java b/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java index 2f54dc6e..08257da5 100644 --- a/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java +++ b/src/main/java/com/coinbase/prime/model/CommissionDetailTotal.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java b/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java index 4cfa62bb..1e15f799 100644 --- a/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java +++ b/src/main/java/com/coinbase/prime/model/FcmScheduledMaintenance.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java b/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java index 1621024e..0e7f0ef1 100644 --- a/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java +++ b/src/main/java/com/coinbase/prime/model/FcmTradingSessionDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FundMovement.java b/src/main/java/com/coinbase/prime/model/FundMovement.java index 0157ea1b..39de3afd 100644 --- a/src/main/java/com/coinbase/prime/model/FundMovement.java +++ b/src/main/java/com/coinbase/prime/model/FundMovement.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/FutureProductDetails.java b/src/main/java/com/coinbase/prime/model/FutureProductDetails.java index 202b3fdd..7ccfc60d 100644 --- a/src/main/java/com/coinbase/prime/model/FutureProductDetails.java +++ b/src/main/java/com/coinbase/prime/model/FutureProductDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java b/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java index 310577a5..ead345a0 100644 --- a/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java +++ b/src/main/java/com/coinbase/prime/model/PerpetualProductDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java b/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java index 8cabeb4e..713ee0c8 100644 --- a/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java +++ b/src/main/java/com/coinbase/prime/model/RequestToSubmitTravelRuleDataForAnExistingDepositTransaction.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/StakingStatus.java b/src/main/java/com/coinbase/prime/model/StakingStatus.java index f944c64d..da906c63 100644 --- a/src/main/java/com/coinbase/prime/model/StakingStatus.java +++ b/src/main/java/com/coinbase/prime/model/StakingStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/TravelRuleData.java b/src/main/java/com/coinbase/prime/model/TravelRuleData.java index 4718874c..29ffceef 100644 --- a/src/main/java/com/coinbase/prime/model/TravelRuleData.java +++ b/src/main/java/com/coinbase/prime/model/TravelRuleData.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java b/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java index 5107ca52..2a7fd881 100644 --- a/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java +++ b/src/main/java/com/coinbase/prime/model/ValidatorAllocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java b/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java index 2cc3254a..8c2fc0c7 100644 --- a/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java +++ b/src/main/java/com/coinbase/prime/model/ValidatorStakingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java b/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java index eadcd9b6..5e9d9b1a 100644 --- a/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java +++ b/src/main/java/com/coinbase/prime/model/ValidatorUnstakePreview.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java index 9bf2adc5..161e54af 100644 --- a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java +++ b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferState.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java index 22660dd0..a0fbf47b 100644 --- a/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java +++ b/src/main/java/com/coinbase/prime/model/enums/AdvancedTransferType.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java b/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java index c8166c83..1eaf6cc1 100644 --- a/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java +++ b/src/main/java/com/coinbase/prime/model/enums/ContractExpiryType.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java b/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java index 3a980ca0..6866fd8b 100644 --- a/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java +++ b/src/main/java/com/coinbase/prime/model/enums/ExpiringContractStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java b/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java index 5834673c..7cb75093 100644 --- a/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java +++ b/src/main/java/com/coinbase/prime/model/enums/FcmMarginHealthState.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java index 9c8f2733..33d2d64d 100644 --- a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java +++ b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionClosedReason.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java index 8d547f86..ec40172e 100644 --- a/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java +++ b/src/main/java/com/coinbase/prime/model/enums/FcmTradingSessionState.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/ProductType.java b/src/main/java/com/coinbase/prime/model/enums/ProductType.java index b89fd0a8..b38f342c 100644 --- a/src/main/java/com/coinbase/prime/model/enums/ProductType.java +++ b/src/main/java/com/coinbase/prime/model/enums/ProductType.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java b/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java index 318afec4..bc6c7ec5 100644 --- a/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java +++ b/src/main/java/com/coinbase/prime/model/enums/RiskManagementType.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java b/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java index a3301021..a4d1f872 100644 --- a/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java +++ b/src/main/java/com/coinbase/prime/model/enums/SecondaryPermission.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/StakeType.java b/src/main/java/com/coinbase/prime/model/enums/StakeType.java index cc3b6c13..5cf323e6 100644 --- a/src/main/java/com/coinbase/prime/model/enums/StakeType.java +++ b/src/main/java/com/coinbase/prime/model/enums/StakeType.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java b/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java index 3ded3fa7..e185f4ac 100644 --- a/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java +++ b/src/main/java/com/coinbase/prime/model/enums/XmLiquidationStatus.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * This file is generated by Openapi Generator https://github.com/openapitools/openapi-generator * diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java b/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java index 6974354c..d3be7084 100644 --- a/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/orders/GetOrderResponse.java b/src/main/java/com/coinbase/prime/orders/GetOrderResponse.java index 7383ea36..debebfbc 100644 --- a/src/main/java/com/coinbase/prime/orders/GetOrderResponse.java +++ b/src/main/java/com/coinbase/prime/orders/GetOrderResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/orders/OrdersService.java b/src/main/java/com/coinbase/prime/orders/OrdersService.java index ad7552b4..7ed57bb4 100644 --- a/src/main/java/com/coinbase/prime/orders/OrdersService.java +++ b/src/main/java/com/coinbase/prime/orders/OrdersService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java b/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java index 8b92176f..7a8d35f0 100644 --- a/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java +++ b/src/main/java/com/coinbase/prime/orders/OrdersServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java index 475cf3e9..27a3b6bc 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java index 05a3c164..35a13f8a 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java b/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java index e816c61e..6050010d 100644 --- a/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java +++ b/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java b/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java index 9369fa5b..a6dd4d3f 100644 --- a/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java +++ b/src/main/java/com/coinbase/prime/portfolios/PortfoliosServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java index 0de9b32c..bf525bba 100644 --- a/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java +++ b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java index 88dfbaca..d1b9a62a 100644 --- a/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java +++ b/src/main/java/com/coinbase/prime/positions/ListAggregateEntityPositionsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java index 4419b7e1..5435f25e 100644 --- a/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java +++ b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java index c07886a0..bb9f81ca 100644 --- a/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java +++ b/src/main/java/com/coinbase/prime/positions/ListEntityPositionsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java b/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java index 7792b92f..65db5591 100644 --- a/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java +++ b/src/main/java/com/coinbase/prime/products/GetCandlesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/products/GetCandlesResponse.java b/src/main/java/com/coinbase/prime/products/GetCandlesResponse.java index 6a7889ee..ed85f042 100644 --- a/src/main/java/com/coinbase/prime/products/GetCandlesResponse.java +++ b/src/main/java/com/coinbase/prime/products/GetCandlesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/products/ProductsService.java b/src/main/java/com/coinbase/prime/products/ProductsService.java index ba6b6941..548e0277 100644 --- a/src/main/java/com/coinbase/prime/products/ProductsService.java +++ b/src/main/java/com/coinbase/prime/products/ProductsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java b/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java index db9d514e..23083b53 100644 --- a/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/products/ProductsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java index 57ab9acc..e678533b 100644 --- a/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java +++ b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java index 003829ce..fdde5845 100644 --- a/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java +++ b/src/main/java/com/coinbase/prime/staking/ClaimStakingRewardsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java index ba8b4081..f4fd962e 100644 --- a/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java index a975cc08..48188714 100644 --- a/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioStakeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java index 271ff9a8..154ba7c9 100644 --- a/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java index 7a8aeaf7..8101ee74 100644 --- a/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java +++ b/src/main/java/com/coinbase/prime/staking/CreatePortfolioUnstakeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java b/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java index 38ead00e..44e9f96b 100644 --- a/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java +++ b/src/main/java/com/coinbase/prime/staking/GetStakingStatusRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java b/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java index ba05e5f7..166a4020 100644 --- a/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java +++ b/src/main/java/com/coinbase/prime/staking/GetStakingStatusResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java index edc02967..d4a16ab2 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateTransferRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java index 9b612b0d..93a41152 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateTransferResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java index 825ed385..46f01a50 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java index 3d41b24d..60f4ea5a 100644 --- a/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/CreateWithdrawalResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java index b867d79f..3f97b952 100644 --- a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java index 6360cdb1..d85102a9 100644 --- a/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/GetTransactionTravelRuleDataResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java index 14322a26..c3956b43 100644 --- a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java +++ b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java index 5b8086bf..6b6dd84d 100644 --- a/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java +++ b/src/main/java/com/coinbase/prime/transactions/SubmitDepositTravelRuleDataResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/TransactionsService.java b/src/main/java/com/coinbase/prime/transactions/TransactionsService.java index 1de91902..138568c2 100644 --- a/src/main/java/com/coinbase/prime/transactions/TransactionsService.java +++ b/src/main/java/com/coinbase/prime/transactions/TransactionsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java b/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java index ccdb5574..e426d4a6 100644 --- a/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/transactions/TransactionsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/users/ListUsersRequest.java b/src/main/java/com/coinbase/prime/users/ListUsersRequest.java index f236dbdc..98bf1780 100644 --- a/src/main/java/com/coinbase/prime/users/ListUsersRequest.java +++ b/src/main/java/com/coinbase/prime/users/ListUsersRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/users/ListUsersResponse.java b/src/main/java/com/coinbase/prime/users/ListUsersResponse.java index 885e6629..56f51e27 100644 --- a/src/main/java/com/coinbase/prime/users/ListUsersResponse.java +++ b/src/main/java/com/coinbase/prime/users/ListUsersResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/users/UsersService.java b/src/main/java/com/coinbase/prime/users/UsersService.java index ed43ec6a..825c130d 100644 --- a/src/main/java/com/coinbase/prime/users/UsersService.java +++ b/src/main/java/com/coinbase/prime/users/UsersService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java b/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java index 90612e33..1f6076d7 100644 --- a/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java +++ b/src/main/java/com/coinbase/prime/users/UsersServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/wallets/WalletsService.java b/src/main/java/com/coinbase/prime/wallets/WalletsService.java index 62470605..d67b7910 100644 --- a/src/main/java/com/coinbase/prime/wallets/WalletsService.java +++ b/src/main/java/com/coinbase/prime/wallets/WalletsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java b/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java index b17cc9f1..f2a7b9a1 100644 --- a/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java +++ b/src/main/java/com/coinbase/prime/wallets/WalletsServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2024-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/PostProcessor.java b/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/PostProcessor.java index f370d809..d86a194d 100644 --- a/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/PostProcessor.java +++ b/tools/model-generator/src/main/java/com/coinbase/tools/modelgenerator/PostProcessor.java @@ -278,6 +278,7 @@ private void processFile(Path file, Path targetDir, boolean isEnum) throws IOExc content = applyBooleanPrimitiveConversion(content); } + content = com.coinbase.tools.sdkgenerator.CopyrightHelper.applyCopyrightYear(outputPath, content); Files.writeString(outputPath, content); if (!existsBefore) { diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java index 4139b119..31de24b6 100644 --- a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/CopyrightHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2025-present Coinbase Global, Inc. + * Copyright 2026-present Coinbase Global, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,116 @@ package com.coinbase.tools.sdkgenerator; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Copyright year handling: resolves years from Git first-commit dates where possible, and + * normalizes generated SDK file content via {@link #applyCopyrightYear(Path, String)}. + * + *

Mirrors the behavior of the .NET generator's CopyrightHelper. Newly emitted files use + * the year of the first commit that added the generator anchor file ({@code RequestPhase.java}). + * Files that already exist on disk preserve their existing on-disk year. + */ public final class CopyrightHelper { - public static final int DEFAULT_YEAR = 2025; + + private static final Pattern COPYRIGHT_YEAR_PATTERN = + Pattern.compile("Copyright (\\d{4})-present"); + private static final Pattern COPYRIGHT_REPLACE_PATTERN = + Pattern.compile("Copyright \\d{4}-present"); + + private static int sdkEmittedCopyrightYear; private CopyrightHelper() {} - public static String javaFileHeader() { + /** + * Calendar year used in newly emitted Java file headers (requests, responses, services, + * factory). Set by {@link #initializeSdkEmittedCopyrightYear(Path)} from Git; falls back to + * UTC year if unset. + */ + public static int getSdkEmittedCopyrightYear() { + return sdkEmittedCopyrightYear > 0 + ? sdkEmittedCopyrightYear + : ZonedDateTime.now(ZoneOffset.UTC).getYear(); + } + + /** + * Resolves the year from the first commit that added + * {@code tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/RequestPhase.java}, + * used as the copyright year for all holistically generated Java surface files. + */ + public static void initializeSdkEmittedCopyrightYear(Path projectRoot) { + Path anchor = + projectRoot + .resolve("tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/RequestPhase.java"); + sdkEmittedCopyrightYear = getFirstCommitYearForPath(projectRoot, anchor); + } + + /** + * Returns the commit year (UTC) of the first commit that added {@code absolutePath}, or the + * current UTC year if Git is unavailable or the file is not yet tracked. + */ + public static int getFirstCommitYearForPath(Path gitRepositoryRoot, Path absolutePath) { + try { + Path full = absolutePath.toAbsolutePath().normalize(); + Path root = gitRepositoryRoot.toAbsolutePath().normalize(); + if (!full.startsWith(root)) { + return ZonedDateTime.now(ZoneOffset.UTC).getYear(); + } + String relPosix = root.relativize(full).toString().replace('\\', '/'); + + ProcessBuilder pb = + new ProcessBuilder( + "git", + "log", + "--diff-filter=A", + "--format=%cs", + "--reverse", + "--", + relPosix) + .directory(root.toFile()) + .redirectErrorStream(false); + Process proc = pb.start(); + String output; + try (var in = proc.getInputStream()) { + output = new String(in.readAllBytes(), StandardCharsets.UTF_8); + } + proc.waitFor(); + String firstLine = + output.lines() + .map(String::trim) + .filter(s -> !s.isEmpty()) + .findFirst() + .orElse(null); + if (firstLine == null || firstLine.length() < 4) { + return ZonedDateTime.now(ZoneOffset.UTC).getYear(); + } + try { + return Integer.parseInt(firstLine.substring(0, 4)); + } catch (NumberFormatException ex) { + return ZonedDateTime.now(ZoneOffset.UTC).getYear(); + } + } catch (IOException | InterruptedException e) { + if (e instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + return ZonedDateTime.now(ZoneOffset.UTC).getYear(); + } + } + + /** + * Standard Apache 2.0 comment block for generated Java files using the given copyright year. + */ + public static String javaFileHeader(int year) { return "/*\n" + " * Copyright " - + DEFAULT_YEAR + + year + "-present Coinbase Global, Inc.\n" + " *\n" + " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" @@ -40,4 +141,36 @@ public static String javaFileHeader() { + " * limitations under the License.\n" + " */\n\n"; } + + /** Convenience wrapper using the SDK-emitted copyright year. */ + public static String javaFileHeader() { + return javaFileHeader(getSdkEmittedCopyrightYear()); + } + + /** + * Replaces the hardcoded copyright year in {@code content} with: + * + *

    + *
  • The existing year from the on-disk file at {@code outputPath} (if it exists), or + *
  • {@link #getSdkEmittedCopyrightYear()} for brand-new generated files. + *
+ */ + public static String applyCopyrightYear(Path outputPath, String content) { + String targetYear; + if (outputPath != null && Files.exists(outputPath)) { + try { + String onDisk = Files.readString(outputPath); + Matcher m = COPYRIGHT_YEAR_PATTERN.matcher(onDisk); + targetYear = + m.find() ? m.group(1) : Integer.toString(getSdkEmittedCopyrightYear()); + } catch (IOException ex) { + targetYear = Integer.toString(getSdkEmittedCopyrightYear()); + } + } else { + targetYear = Integer.toString(getSdkEmittedCopyrightYear()); + } + return COPYRIGHT_REPLACE_PATTERN + .matcher(content) + .replaceAll("Copyright " + targetYear + "-present"); + } } diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java index a8c8df49..d35e6527 100644 --- a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/SdkGeneratorMain.java @@ -45,6 +45,7 @@ public static void main(String[] args) throws Exception { } Path projectRoot = GeneratorPaths.findProjectRoot(); + CopyrightHelper.initializeSdkEmittedCopyrightYear(projectRoot); GeneratorConfiguration cfg = GeneratorConfiguration.load(projectRoot); SharedTransforms transforms = new SharedTransforms(cfg); @@ -82,6 +83,7 @@ public static void main(String[] args) throws Exception { String factory = FactoryPhase.emit(cfg); Path factoryPath = projectRoot.resolve("src/main/java/com/coinbase/prime/factory/PrimeServiceFactory.java"); + factory = CopyrightHelper.applyCopyrightYear(factoryPath, factory); if (diffMode) { if (!Files.exists(factoryPath)) { log.info("DIFF missing factory would be created: {}", factoryPath); diff --git a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java index 74938bf5..d787c642 100644 --- a/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java +++ b/tools/model-generator/src/main/java/com/coinbase/tools/sdkgenerator/phases/ClientSurfacePhase.java @@ -1,5 +1,6 @@ package com.coinbase.tools.sdkgenerator.phases; +import com.coinbase.tools.sdkgenerator.CopyrightHelper; import com.coinbase.tools.sdkgenerator.processing.GeneratorConfiguration; import com.coinbase.tools.sdkgenerator.processing.NamingResolver; import com.coinbase.tools.sdkgenerator.processing.ServiceDefinition; @@ -104,7 +105,7 @@ public void run( private void writeOrDiff(Path path, String content, boolean dryRun, boolean diffMode) throws IOException { - content = content.replace("\r\n", "\n"); + content = CopyrightHelper.applyCopyrightYear(path, content).replace("\r\n", "\n"); if (diffMode) { if (!Files.exists(path)) { log.info("DIFF missing file would be created: {}", path); From 3242f2c4079fe68289eb31833ca5abe8423cd842 Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 14:20:18 -0700 Subject: [PATCH 7/8] Remove low-value generated comments above service interface methods Made-with: Cursor --- .../prime/activities/ActivitiesService.java | 4 ---- .../prime/addressbook/AddressBookService.java | 2 -- .../AdvancedTransferService.java | 5 ----- .../prime/allocations/AllocationsService.java | 5 ----- .../com/coinbase/prime/assets/AssetsService.java | 1 - .../coinbase/prime/balances/BalancesService.java | 4 ---- .../prime/commission/CommissionService.java | 1 - .../prime/financing/FinancingService.java | 16 ---------------- .../coinbase/prime/futures/FuturesService.java | 11 ----------- .../coinbase/prime/invoice/InvoiceService.java | 1 - .../OnchainAddressBookService.java | 4 ---- .../com/coinbase/prime/orders/OrdersService.java | 12 ------------ .../paymentmethods/PaymentMethodsService.java | 2 -- .../prime/portfolios/PortfoliosService.java | 2 -- .../prime/positions/PositionsService.java | 2 -- .../coinbase/prime/products/ProductsService.java | 2 -- .../coinbase/prime/staking/StakingService.java | 9 --------- .../prime/transactions/TransactionsService.java | 9 --------- .../com/coinbase/prime/users/UsersService.java | 2 -- .../coinbase/prime/wallets/WalletsService.java | 6 ------ 20 files changed, 100 deletions(-) diff --git a/src/main/java/com/coinbase/prime/activities/ActivitiesService.java b/src/main/java/com/coinbase/prime/activities/ActivitiesService.java index ef3e33dc..768a4ade 100644 --- a/src/main/java/com/coinbase/prime/activities/ActivitiesService.java +++ b/src/main/java/com/coinbase/prime/activities/ActivitiesService.java @@ -20,12 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface ActivitiesService { - /** List Activities */ ListPortfolioActivitiesResponse listPortfolioActivities(ListPortfolioActivitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Entity Activities */ ListEntityActivitiesResponse listEntityActivities(ListEntityActivitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Activity by Activity ID */ GetActivityResponse getActivity(GetActivityRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Portfolio Activity by Activity ID */ GetPortfolioActivityResponse getPortfolioActivity(GetPortfolioActivityRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java b/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java index 2f08b8df..717d4cd4 100644 --- a/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java +++ b/src/main/java/com/coinbase/prime/addressbook/AddressBookService.java @@ -20,8 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AddressBookService { - /** Get Address Book */ ListAddressBookResponse listAddressBook(ListAddressBookRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Address Book Entry */ CreateAddressBookEntryResponse createAddressBookEntry(CreateAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java index cfe1c8d3..3b7ff457 100644 --- a/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java +++ b/src/main/java/com/coinbase/prime/advancedtransfer/AdvancedTransferService.java @@ -20,14 +20,9 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AdvancedTransferService { - /** List Advanced Transfers */ ListAdvancedTransfersResponse listAdvancedTransfers(ListAdvancedTransfersRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Advanced Transfer */ CreateAdvancedTransferResponse createAdvancedTransfer(CreateAdvancedTransferRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Cancel Advanced Transfer */ CancelAdvancedTransferResponse cancelAdvancedTransfer(CancelAdvancedTransferRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List transactions associated with an Advanced Transfer */ ListAdvancedTransferTransactionsResponse listAdvancedTransferTransactions(ListAdvancedTransferTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Portfolio Counterparty ID */ GetPortfolioCounterpartyIdResponse getPortfolioCounterpartyId(GetPortfolioCounterpartyIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/allocations/AllocationsService.java b/src/main/java/com/coinbase/prime/allocations/AllocationsService.java index 03375a57..8c349926 100644 --- a/src/main/java/com/coinbase/prime/allocations/AllocationsService.java +++ b/src/main/java/com/coinbase/prime/allocations/AllocationsService.java @@ -20,14 +20,9 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AllocationsService { - /** Create Portfolio Allocations */ CreateAllocationResponse createAllocation(CreateAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Portfolio Net Allocations */ CreateNetAllocationResponse createNetAllocation(CreateNetAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Portfolio Allocations */ ListPortfolioAllocationsResponse listPortfolioAllocations(ListPortfolioAllocationsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Net Allocations by Netting ID */ ListAllocationsByNettingIdResponse listAllocationsByNettingId(ListAllocationsByNettingIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Allocation by ID */ GetAllocationResponse getAllocation(GetAllocationRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/assets/AssetsService.java b/src/main/java/com/coinbase/prime/assets/AssetsService.java index 74b3556e..c4d690a9 100644 --- a/src/main/java/com/coinbase/prime/assets/AssetsService.java +++ b/src/main/java/com/coinbase/prime/assets/AssetsService.java @@ -20,6 +20,5 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface AssetsService { - /** List Assets */ ListAssetsResponse listAssets(ListAssetsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/balances/BalancesService.java b/src/main/java/com/coinbase/prime/balances/BalancesService.java index 58ef0b22..966a7a06 100644 --- a/src/main/java/com/coinbase/prime/balances/BalancesService.java +++ b/src/main/java/com/coinbase/prime/balances/BalancesService.java @@ -20,12 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface BalancesService { - /** List Entity Balances */ ListEntityBalancesResponse listEntityBalances(ListEntityBalancesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Portfolio Balances */ ListPortfolioBalancesResponse listPortfolioBalances(ListPortfolioBalancesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Wallet Balance */ GetWalletBalanceResponse getWalletBalance(GetWalletBalanceRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Onchain Wallet Balances */ ListOnchainWalletBalancesResponse listOnchainWalletBalances(ListOnchainWalletBalancesRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/commission/CommissionService.java b/src/main/java/com/coinbase/prime/commission/CommissionService.java index 95980445..62107c08 100644 --- a/src/main/java/com/coinbase/prime/commission/CommissionService.java +++ b/src/main/java/com/coinbase/prime/commission/CommissionService.java @@ -20,6 +20,5 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface CommissionService { - /** Get Portfolio Commission */ GetPortfolioCommissionResponse getPortfolioCommission(GetPortfolioCommissionRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/financing/FinancingService.java b/src/main/java/com/coinbase/prime/financing/FinancingService.java index 30b78e67..fdc64788 100644 --- a/src/main/java/com/coinbase/prime/financing/FinancingService.java +++ b/src/main/java/com/coinbase/prime/financing/FinancingService.java @@ -20,36 +20,20 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface FinancingService { - /** List Interest Accruals */ ListInterestAccrualsResponse listInterestAccruals(ListInterestAccrualsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Cross Margin Overview */ GetCrossMarginOverviewResponse getCrossMarginOverview(GetCrossMarginOverviewRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Entity Locate Availabilities */ GetEntityLocateAvailabilitiesResponse getEntityLocateAvailabilities(GetEntityLocateAvailabilitiesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Margin Information */ GetMarginInformationResponse getMarginInformation(GetMarginInformationRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Margin Call Summaries */ ListMarginCallSummariesResponse listMarginCallSummaries(ListMarginCallSummariesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Trade Finance Obligations */ ListTradeFinanceObligationsResponse listTradeFinanceObligations(ListTradeFinanceObligationsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Trade Finance Tiered Pricing Fees */ GetTradeFinanceTieredPricingFeesResponse getTradeFinanceTieredPricingFees(GetTradeFinanceTieredPricingFeesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Financing Eligible Assets */ ListFinancingEligibleAssetsResponse listFinancingEligibleAssets() throws CoinbaseClientException, CoinbasePrimeException; - /** List Interest Accruals For Portfolio */ ListInterestAccrualsForPortfolioResponse listInterestAccrualsForPortfolio(ListInterestAccrualsForPortfolioRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Portfolio Buying Power */ GetPortfolioBuyingPowerResponse getPortfolioBuyingPower(GetPortfolioBuyingPowerRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Portfolio Credit Information */ GetPortfolioCreditInformationResponse getPortfolioCreditInformation(GetPortfolioCreditInformationRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Existing Locates */ ListExistingLocatesResponse listExistingLocates(ListExistingLocatesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create New Locates */ CreateNewLocatesResponse createNewLocates(CreateNewLocatesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Margin Conversions */ ListMarginConversionsResponse listMarginConversions(ListMarginConversionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Portfolio Withdrawal Power */ GetPortfolioWithdrawalPowerResponse getPortfolioWithdrawalPower(GetPortfolioWithdrawalPowerRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Update Funding Settings (Beta) */ UpdateFundingSettingsResponse updateFundingSettings(UpdateFundingSettingsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/futures/FuturesService.java b/src/main/java/com/coinbase/prime/futures/FuturesService.java index f619f365..fb2b3b7f 100644 --- a/src/main/java/com/coinbase/prime/futures/FuturesService.java +++ b/src/main/java/com/coinbase/prime/futures/FuturesService.java @@ -20,26 +20,15 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface FuturesService { - /** Set Auto Sweep */ SetAutoSweepResponse setAutoSweep(SetAutoSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Entity FCM Balance */ GetEntityFcmBalanceResponse getEntityFcmBalance(GetEntityFcmBalanceRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get FCM Margin Call Details */ GetFcmMarginCallDetailsResponse getFcmMarginCallDetails(GetFcmMarginCallDetailsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Entity Positions */ GetPositionsResponse getPositions(GetPositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get FCM Risk Limits */ GetFcmRiskLimitsResponse getFcmRiskLimits(GetFcmRiskLimitsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get FCM Settings */ GetFcmSettingsResponse getFcmSettings(GetFcmSettingsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Set FCM Settings */ SetFcmSettingsResponse setFcmSettings(SetFcmSettingsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Entity Futures Sweeps */ ListEntityFuturesSweepsResponse listEntityFuturesSweeps(ListEntityFuturesSweepsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Schedule Entity Futures Sweep */ ScheduleEntityFuturesSweepResponse scheduleEntityFuturesSweep(ScheduleEntityFuturesSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Cancel Entity Futures Sweep */ CancelEntityFuturesSweepResponse cancelEntityFuturesSweep(CancelEntityFuturesSweepRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get FCM Equity */ GetFcmEquityResponse getFcmEquity(GetFcmEquityRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/invoice/InvoiceService.java b/src/main/java/com/coinbase/prime/invoice/InvoiceService.java index 8de185ab..a6716636 100644 --- a/src/main/java/com/coinbase/prime/invoice/InvoiceService.java +++ b/src/main/java/com/coinbase/prime/invoice/InvoiceService.java @@ -20,6 +20,5 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface InvoiceService { - /** List Invoices */ ListInvoicesResponse listInvoices(ListInvoicesRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java b/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java index 9fef83cb..f986cdba 100644 --- a/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java +++ b/src/main/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookService.java @@ -20,12 +20,8 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface OnchainAddressBookService { - /** Update Onchain Address Book Entry */ UpdateOnchainAddressBookEntryResponse updateOnchainAddressBookEntry(UpdateOnchainAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Onchain Address Book Entry */ CreateOnchainAddressBookEntryResponse createOnchainAddressBookEntry(CreateOnchainAddressBookEntryRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Delete Onchain Address Group */ DeleteOnchainAddressGroupResponse deleteOnchainAddressGroup(DeleteOnchainAddressGroupRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Onchain Address Groups */ ListOnchainAddressGroupsResponse listOnchainAddressGroups(ListOnchainAddressGroupsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/orders/OrdersService.java b/src/main/java/com/coinbase/prime/orders/OrdersService.java index 7ed57bb4..a945b0c3 100644 --- a/src/main/java/com/coinbase/prime/orders/OrdersService.java +++ b/src/main/java/com/coinbase/prime/orders/OrdersService.java @@ -20,28 +20,16 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface OrdersService { - /** Accept Quote */ AcceptQuoteResponse acceptQuote(AcceptQuoteRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Portfolio Fills */ ListPortfolioFillsResponse listPortfolioFills(ListPortfolioFillsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Open Orders */ ListOpenOrdersResponse listOpenOrders(ListOpenOrdersRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Order */ CreateOrderResponse createOrder(CreateOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Order Preview */ GetOrderPreviewResponse getOrderPreview(GetOrderPreviewRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Portfolio Orders */ ListPortfolioOrdersResponse listPortfolioOrders(ListPortfolioOrdersRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Order by Order ID */ GetOrderByOrderIdResponse getOrderByOrderId(GetOrderByOrderIdRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Cancel Order */ CancelOrderResponse cancelOrder(CancelOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Edit Order (Beta) */ EditOrderResponse editOrder(EditOrderRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Order Edit History */ ListOrderEditHistoryResponse listOrderEditHistory(ListOrderEditHistoryRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Order Fills */ ListOrderFillsResponse listOrderFills(ListOrderFillsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Quote Request */ CreateQuoteResponse createQuote(CreateQuoteRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java index 27a3b6bc..f278cdee 100644 --- a/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java +++ b/src/main/java/com/coinbase/prime/paymentmethods/PaymentMethodsService.java @@ -20,8 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface PaymentMethodsService { - /** List Entity Payment Methods */ ListPaymentMethodsResponse listPaymentMethods(ListPaymentMethodsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Entity Payment Method */ GetPaymentMethodDetailsResponse getPaymentMethodDetails(GetPaymentMethodDetailsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java b/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java index 6050010d..dc216f4b 100644 --- a/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java +++ b/src/main/java/com/coinbase/prime/portfolios/PortfoliosService.java @@ -20,8 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface PortfoliosService { - /** List Portfolios */ ListPortfoliosResponse listPortfolios() throws CoinbaseClientException, CoinbasePrimeException; - /** Get Portfolio by Portfolio ID */ GetPortfolioResponse getPortfolio(GetPortfolioRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/positions/PositionsService.java b/src/main/java/com/coinbase/prime/positions/PositionsService.java index 2c25c58a..634bfba8 100644 --- a/src/main/java/com/coinbase/prime/positions/PositionsService.java +++ b/src/main/java/com/coinbase/prime/positions/PositionsService.java @@ -20,8 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface PositionsService { - /** List Aggregate Entity Positions */ ListAggregatePositionsResponse listAggregatePositions(ListAggregatePositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Entity Positions */ ListPositionsResponse listPositions(ListPositionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/products/ProductsService.java b/src/main/java/com/coinbase/prime/products/ProductsService.java index 548e0277..65057d91 100644 --- a/src/main/java/com/coinbase/prime/products/ProductsService.java +++ b/src/main/java/com/coinbase/prime/products/ProductsService.java @@ -20,8 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface ProductsService { - /** List Portfolio Products */ ListPortfolioProductsResponse listPortfolioProducts(ListPortfolioProductsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Public Product Candles (Beta) */ GetCandlesResponse getCandles(GetCandlesRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/staking/StakingService.java b/src/main/java/com/coinbase/prime/staking/StakingService.java index f28d2d22..ffb3b9ea 100644 --- a/src/main/java/com/coinbase/prime/staking/StakingService.java +++ b/src/main/java/com/coinbase/prime/staking/StakingService.java @@ -20,22 +20,13 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface StakingService { - /** Claim Wallet Staking Rewards (Alpha) */ ClaimRewardsResponse claimRewards(ClaimRewardsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Request to stake or delegate a wallet */ CreateStakeResponse createStake(CreateStakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Request to unstake a wallet */ CreateUnstakeResponse createUnstake(CreateUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Transaction Validators */ ListTransactionValidatorsResponse listTransactionValidators(ListTransactionValidatorsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Request to stake currency in a portfolio */ PortfolioStakingInitiateResponse portfolioStakingInitiate(PortfolioStakingInitiateRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Request to unstake currency across a portfolio */ PortfolioStakingUnstakeResponse portfolioStakingUnstake(PortfolioStakingUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Staking Status */ GetStakingStatusResponse getStakingStatus(GetStakingStatusRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Unstaking Status */ GetUnstakingStatusResponse getUnstakingStatus(GetUnstakingStatusRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Preview Unstake */ PreviewUnstakeResponse previewUnstake(PreviewUnstakeRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/transactions/TransactionsService.java b/src/main/java/com/coinbase/prime/transactions/TransactionsService.java index 138568c2..caab8bda 100644 --- a/src/main/java/com/coinbase/prime/transactions/TransactionsService.java +++ b/src/main/java/com/coinbase/prime/transactions/TransactionsService.java @@ -20,22 +20,13 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface TransactionsService { - /** List Portfolio Transactions */ ListPortfolioTransactionsResponse listPortfolioTransactions(ListPortfolioTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Transaction by Transaction ID */ GetTransactionResponse getTransaction(GetTransactionRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Conversion */ CreateConversionResponse createConversion(CreateConversionRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Onchain Transaction */ CreateOnchainTransactionResponse createOnchainTransaction(CreateOnchainTransactionRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Wallet Transactions */ ListWalletTransactionsResponse listWalletTransactions(ListWalletTransactionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Transfer */ CreateWalletTransferResponse createWalletTransfer(CreateWalletTransferRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Withdrawal */ CreateWalletWithdrawalResponse createWalletWithdrawal(CreateWalletWithdrawalRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Transaction Travel Rule Data */ GetTransactionTravelRuleDataResponse getTransactionTravelRuleData(GetTransactionTravelRuleDataRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Submit Deposit Travel Rule Data */ SubmitDepositTravelRuleDataResponse submitDepositTravelRuleData(SubmitDepositTravelRuleDataRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/users/UsersService.java b/src/main/java/com/coinbase/prime/users/UsersService.java index 825c130d..25711387 100644 --- a/src/main/java/com/coinbase/prime/users/UsersService.java +++ b/src/main/java/com/coinbase/prime/users/UsersService.java @@ -20,8 +20,6 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface UsersService { - /** List Users */ ListEntityUsersResponse listEntityUsers(ListEntityUsersRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Portfolio Users */ ListPortfolioUsersResponse listPortfolioUsers(ListPortfolioUsersRequest request) throws CoinbaseClientException, CoinbasePrimeException; } diff --git a/src/main/java/com/coinbase/prime/wallets/WalletsService.java b/src/main/java/com/coinbase/prime/wallets/WalletsService.java index d67b7910..030b9a2e 100644 --- a/src/main/java/com/coinbase/prime/wallets/WalletsService.java +++ b/src/main/java/com/coinbase/prime/wallets/WalletsService.java @@ -20,16 +20,10 @@ import com.coinbase.prime.errors.CoinbasePrimeException; public interface WalletsService { - /** List Portfolio Wallets */ ListWalletsResponse listWallets(ListWalletsRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Wallet */ CreateWalletResponse createWallet(CreateWalletRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Wallet by Wallet ID */ GetWalletResponse getWallet(GetWalletRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** List Wallet Addresses */ ListWalletAddressesResponse listWalletAddresses(ListWalletAddressesRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Create Wallet Deposit Address */ CreateWalletDepositAddressResponse createWalletDepositAddress(CreateWalletDepositAddressRequest request) throws CoinbaseClientException, CoinbasePrimeException; - /** Get Wallet Deposit Instructions */ GetWalletDepositInstructionsResponse getWalletDepositInstructions(GetWalletDepositInstructionsRequest request) throws CoinbaseClientException, CoinbasePrimeException; } From bde79161f9b4015baf695ac7d3ad2815d15afae3 Mon Sep 17 00:00:00 2001 From: Nick Morgan Date: Tue, 28 Apr 2026 14:54:12 -0700 Subject: [PATCH 8/8] test: add serialization and deserialization tests for all service endpoints Adds comprehensive serialization/deserialization test coverage for all 19 service packages that previously had no tests. Each test file validates request construction, builder validation, request serialization (including @JsonIgnore behavior for path params), and response deserialization using Jackson ObjectMapper configured to match production SDK behavior. Made-with: Cursor --- .../ActivitiesServiceSerializationTest.java | 139 ++++++ .../AddressBookServiceSerializationTest.java | 124 +++++ ...ncedTransfersServiceSerializationTest.java | 147 ++++++ .../AllocationsServiceSerializationTest.java | 194 ++++++++ .../AssetsServiceSerializationTest.java | 68 +++ .../BalancesServiceSerializationTest.java | 177 +++++++ .../CommissionServiceSerializationTest.java | 70 +++ .../FinancingServiceSerializationTest.java | 454 ++++++++++++++++++ .../FuturesServiceSerializationTest.java | 323 +++++++++++++ .../InvoiceServiceSerializationTest.java | 75 +++ ...inAddressBookServiceSerializationTest.java | 149 ++++++ ...aymentMethodsServiceSerializationTest.java | 109 +++++ .../PortfoliosServiceSerializationTest.java | 116 +++++ .../PositionsServiceSerializationTest.java | 97 ++++ .../ProductsServiceSerializationTest.java | 126 +++++ .../StakingServiceSerializationTest.java | 313 ++++++++++++ .../TransactionsServiceSerializationTest.java | 271 +++++++++++ .../users/UsersServiceSerializationTest.java | 102 ++++ .../WalletsServiceSerializationTest.java | 195 +++++++- 19 files changed, 3245 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/coinbase/prime/activities/ActivitiesServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/addressbook/AddressBookServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/advancedtransfers/AdvancedTransfersServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/allocations/AllocationsServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/assets/AssetsServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/balances/BalancesServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/commission/CommissionServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/financing/FinancingServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/futures/FuturesServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/invoice/InvoiceServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/portfolios/PortfoliosServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/positions/PositionsServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/products/ProductsServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/staking/StakingServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/transactions/TransactionsServiceSerializationTest.java create mode 100644 src/test/java/com/coinbase/prime/users/UsersServiceSerializationTest.java diff --git a/src/test/java/com/coinbase/prime/activities/ActivitiesServiceSerializationTest.java b/src/test/java/com/coinbase/prime/activities/ActivitiesServiceSerializationTest.java new file mode 100644 index 00000000..544e2b66 --- /dev/null +++ b/src/test/java/com/coinbase/prime/activities/ActivitiesServiceSerializationTest.java @@ -0,0 +1,139 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.activities; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class ActivitiesServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== GetActivity Tests ==================== + + @Test + public void testGetActivityRequestConstruction() { + GetActivityRequest request = new GetActivityRequest("activity-123"); + assertNotNull(request); + assertEquals("activity-123", request.getActivityId()); + } + + @Test + public void testGetActivityResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity\":{" + + "\"id\":\"activity-123\"," + + "\"category\":\"ACTIVITY_CATEGORY_ORDER\"," + + "\"status\":\"ACTIVITY_STATUS_COMPLETED\"" + + "}" + + "}"; + + GetActivityResponse response = objectMapper.readValue(json, GetActivityResponse.class); + assertNotNull(response); + assertNotNull(response.getActivity()); + assertEquals("activity-123", response.getActivity().getId()); + } + + // ==================== GetPortfolioActivity Tests ==================== + + @Test + public void testGetPortfolioActivityRequestConstruction() throws CoinbaseClientException { + GetPortfolioActivityRequest request = new GetPortfolioActivityRequest.Builder() + .portfolioId("portfolio-123") + .activityId("activity-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("activity-456", request.getActivityId()); + } + + @Test + public void testGetPortfolioActivityRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new GetPortfolioActivityRequest.Builder() + .activityId("activity-456") + .build()); + + assertThrows(CoinbaseClientException.class, () -> + new GetPortfolioActivityRequest.Builder() + .portfolioId("portfolio-123") + .build()); + } + + @Test + public void testGetPortfolioActivityResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity\":{" + + "\"id\":\"activity-789\"," + + "\"category\":\"ACTIVITY_CATEGORY_TRANSACTION\"," + + "\"status\":\"ACTIVITY_STATUS_PROCESSING\"" + + "}" + + "}"; + + GetPortfolioActivityResponse response = objectMapper.readValue(json, GetPortfolioActivityResponse.class); + assertNotNull(response); + assertNotNull(response.getActivity()); + assertEquals("activity-789", response.getActivity().getId()); + } + + // ==================== ListPortfolioActivities Tests ==================== + + @Test + public void testListPortfolioActivitiesRequestConstruction() throws CoinbaseClientException { + ListPortfolioActivitiesRequest request = new ListPortfolioActivitiesRequest.Builder("portfolio-123") + .symbols(new String[]{"BTC", "ETH"}) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testListPortfolioActivitiesRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListPortfolioActivitiesRequest.Builder(null).build()); + } + + @Test + public void testListPortfolioActivitiesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activities\":[" + + "{\"id\":\"act-1\",\"category\":\"ACTIVITY_CATEGORY_ORDER\"}," + + "{\"id\":\"act-2\",\"category\":\"ACTIVITY_CATEGORY_TRANSACTION\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"cursor-123\",\"has_next\":true}" + + "}"; + + ListPortfolioActivitiesResponse response = objectMapper.readValue(json, ListPortfolioActivitiesResponse.class); + assertNotNull(response); + assertNotNull(response.getActivities()); + assertEquals(2, response.getActivities().length); + assertEquals("act-1", response.getActivities()[0].getId()); + } +} diff --git a/src/test/java/com/coinbase/prime/addressbook/AddressBookServiceSerializationTest.java b/src/test/java/com/coinbase/prime/addressbook/AddressBookServiceSerializationTest.java new file mode 100644 index 00000000..802e9db0 --- /dev/null +++ b/src/test/java/com/coinbase/prime/addressbook/AddressBookServiceSerializationTest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.addressbook; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class AddressBookServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListAddressBook Tests ==================== + + @Test + public void testListAddressBookRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ListAddressBookRequest request = new ListAddressBookRequest.Builder("portfolio-123") + .currencySymbol("BTC") + .search("my-address") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"currency_symbol\":\"BTC\"")); + assertTrue(json.contains("\"search\":\"my-address\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testListAddressBookRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListAddressBookRequest.Builder(null).build()); + } + + @Test + public void testListAddressBookResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"addresses\":[" + + "{\"id\":\"addr-1\",\"address\":\"bc1qxy2kgdygjrsqtzq2n0yrf2\",\"currency_symbol\":\"BTC\"}," + + "{\"id\":\"addr-2\",\"address\":\"0xabc123\",\"currency_symbol\":\"ETH\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"cursor-abc\",\"has_next\":false}" + + "}"; + + ListAddressBookResponse response = objectMapper.readValue(json, ListAddressBookResponse.class); + assertNotNull(response); + assertNotNull(response.getAddresses()); + assertEquals(2, response.getAddresses().length); + assertEquals("addr-1", response.getAddresses()[0].getId()); + } + + // ==================== CreateAddressBookEntry Tests ==================== + + @Test + public void testCreateAddressBookEntryRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + CreateAddressBookEntryRequest request = new CreateAddressBookEntryRequest.Builder("portfolio-123") + .address("bc1qxy2kgdygjrsqtzq2n0yrf2") + .currencySymbol("BTC") + .name("My Bitcoin Address") + .accountIdentifier("memo-123") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"address\":\"bc1qxy2kgdygjrsqtzq2n0yrf2\"")); + assertTrue(json.contains("\"currency_symbol\":\"BTC\"")); + assertTrue(json.contains("\"name\":\"My Bitcoin Address\"")); + assertTrue(json.contains("\"account_identifier\":\"memo-123\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testCreateAddressBookEntryRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new CreateAddressBookEntryRequest.Builder("portfolio-123") + .address("bc1q") + .currencySymbol("BTC") + .build()); + + assertThrows(CoinbaseClientException.class, () -> + new CreateAddressBookEntryRequest.Builder("portfolio-123") + .currencySymbol("BTC") + .name("name") + .build()); + } + + @Test + public void testCreateAddressBookEntryResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_type\":\"ACTIVITY_TYPE_ADDRESS_BOOK\"," + + "\"num_approvals_remaining\":2," + + "\"activity_id\":\"act-abc123\"" + + "}"; + + CreateAddressBookEntryResponse response = objectMapper.readValue(json, CreateAddressBookEntryResponse.class); + assertNotNull(response); + assertEquals(2, response.getNumApprovalsRemaining()); + assertEquals("act-abc123", response.getActivityId()); + } +} diff --git a/src/test/java/com/coinbase/prime/advancedtransfers/AdvancedTransfersServiceSerializationTest.java b/src/test/java/com/coinbase/prime/advancedtransfers/AdvancedTransfersServiceSerializationTest.java new file mode 100644 index 00000000..2f7d1986 --- /dev/null +++ b/src/test/java/com/coinbase/prime/advancedtransfers/AdvancedTransfersServiceSerializationTest.java @@ -0,0 +1,147 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.advancedtransfers; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class AdvancedTransfersServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListAdvancedTransfers Tests ==================== + + @Test + public void testListAdvancedTransfersRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ListAdvancedTransfersRequest request = new ListAdvancedTransfersRequest.Builder() + .portfolioId("portfolio-123") + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .referenceId("ref-abc") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"start_time\":\"2025-01-01T00:00:00Z\"")); + assertTrue(json.contains("\"end_time\":\"2025-12-31T23:59:59Z\"")); + assertTrue(json.contains("\"reference_id\":\"ref-abc\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testListAdvancedTransfersRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListAdvancedTransfersRequest.Builder().build()); + } + + @Test + public void testListAdvancedTransfersResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"advanced_transfers\":[" + + "{\"id\":\"at-1\",\"state\":\"ADVANCED_TRANSFER_STATE_CREATED\"}," + + "{\"id\":\"at-2\",\"state\":\"ADVANCED_TRANSFER_STATE_DONE\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListAdvancedTransfersResponse response = objectMapper.readValue(json, ListAdvancedTransfersResponse.class); + assertNotNull(response); + assertNotNull(response.getAdvancedTransfers()); + assertEquals(2, response.getAdvancedTransfers().length); + } + + // ==================== CreateAdvancedTransfer Tests ==================== + + @Test + public void testCreateAdvancedTransferRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + CreateAdvancedTransferRequest request = new CreateAdvancedTransferRequest.Builder() + .portfolioId("portfolio-123") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testCreateAdvancedTransferRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new CreateAdvancedTransferRequest.Builder().build()); + } + + @Test + public void testCreateAdvancedTransferResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"advanced_transfer\":{" + + "\"id\":\"at-new-1\"," + + "\"state\":\"ADVANCED_TRANSFER_STATE_CREATED\"," + + "\"type\":\"ADVANCED_TRANSFER_TYPE_BLIND_MATCH\"," + + "\"amount\":\"1000.00\"," + + "\"currency\":\"USD\"" + + "}" + + "}"; + + CreateAdvancedTransferResponse response = objectMapper.readValue(json, CreateAdvancedTransferResponse.class); + assertNotNull(response); + assertNotNull(response.getAdvancedTransfer()); + assertEquals("at-new-1", response.getAdvancedTransfer().getId()); + } + + // ==================== CancelAdvancedTransfer Tests ==================== + + @Test + public void testCancelAdvancedTransferRequestConstruction() throws CoinbaseClientException { + CancelAdvancedTransferRequest request = new CancelAdvancedTransferRequest.Builder() + .portfolioId("portfolio-123") + .advancedTransferId("at-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("at-456", request.getAdvancedTransferId()); + } + + @Test + public void testCancelAdvancedTransferRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new CancelAdvancedTransferRequest.Builder() + .portfolioId("portfolio-123") + .build()); + assertThrows(CoinbaseClientException.class, () -> + new CancelAdvancedTransferRequest.Builder() + .advancedTransferId("at-456") + .build()); + } + + @Test + public void testCancelAdvancedTransferResponseDeserialization() throws JsonProcessingException { + String json = "{\"advanced_transfer_id\":\"at-456\"}"; + CancelAdvancedTransferResponse response = objectMapper.readValue(json, CancelAdvancedTransferResponse.class); + assertNotNull(response); + assertEquals("at-456", response.getAdvancedTransferId()); + } +} diff --git a/src/test/java/com/coinbase/prime/allocations/AllocationsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/allocations/AllocationsServiceSerializationTest.java new file mode 100644 index 00000000..aa8136c0 --- /dev/null +++ b/src/test/java/com/coinbase/prime/allocations/AllocationsServiceSerializationTest.java @@ -0,0 +1,194 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.allocations; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class AllocationsServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== CreateAllocation Tests ==================== + + @Test + public void testCreateAllocationRequestSerialization() throws JsonProcessingException { + CreateAllocationRequest request = new CreateAllocationRequest.Builder() + .allocationId("alloc-123") + .sourcePortfolioId("portfolio-source") + .productId("BTC-USD") + .orderIds(new String[]{"order-1", "order-2"}) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"allocation_id\":\"alloc-123\"")); + assertTrue(json.contains("\"source_portfolio_id\":\"portfolio-source\"")); + assertTrue(json.contains("\"product_id\":\"BTC-USD\"")); + assertTrue(json.contains("\"order_ids\"")); + } + + @Test + public void testCreateAllocationResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"success\":true," + + "\"allocation_id\":\"alloc-123\"" + + "}"; + + CreateAllocationResponse response = objectMapper.readValue(json, CreateAllocationResponse.class); + assertNotNull(response); + assertTrue(response.isSuccess()); + assertEquals("alloc-123", response.getAllocationId()); + } + + @Test + public void testCreateAllocationResponseFailureDeserialization() throws JsonProcessingException { + String json = "{" + + "\"success\":false," + + "\"failure_reason\":\"Insufficient orders\"" + + "}"; + + CreateAllocationResponse response = objectMapper.readValue(json, CreateAllocationResponse.class); + assertNotNull(response); + assertFalse(response.isSuccess()); + assertEquals("Insufficient orders", response.getFailureReason()); + } + + // ==================== CreateNetAllocation Tests ==================== + + @Test + public void testCreateNetAllocationRequestSerialization() throws JsonProcessingException { + CreateNetAllocationRequest request = new CreateNetAllocationRequest.Builder() + .sourcePortfolioId("portfolio-source") + .productId("ETH-USD") + .nettingId("netting-456") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"source_portfolio_id\":\"portfolio-source\"")); + assertTrue(json.contains("\"product_id\":\"ETH-USD\"")); + assertTrue(json.contains("\"netting_id\":\"netting-456\"")); + } + + @Test + public void testCreateNetAllocationResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"success\":true," + + "\"netting_id\":\"netting-456\"," + + "\"buy_allocation_id\":\"buy-alloc-1\"," + + "\"sell_allocation_id\":\"sell-alloc-2\"" + + "}"; + + CreateNetAllocationResponse response = objectMapper.readValue(json, CreateNetAllocationResponse.class); + assertNotNull(response); + assertTrue(response.isSuccess()); + assertEquals("netting-456", response.getNettingId()); + assertEquals("buy-alloc-1", response.getBuyAllocationId()); + assertEquals("sell-alloc-2", response.getSellAllocationId()); + } + + // ==================== GetAllocation Tests ==================== + + @Test + public void testGetAllocationRequestConstruction() throws CoinbaseClientException { + GetAllocationRequest request = new GetAllocationRequest.Builder("portfolio-123", "alloc-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("alloc-456", request.getAllocationId()); + } + + @Test + public void testGetAllocationResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"allocation\":{" + + "\"allocation_id\":\"alloc-456\"," + + "\"product_id\":\"BTC-USD\"" + + "}" + + "}"; + + GetAllocationResponse response = objectMapper.readValue(json, GetAllocationResponse.class); + assertNotNull(response); + assertNotNull(response.getAllocation()); + } + + // ==================== ListAllocationsByNettingId Tests ==================== + + @Test + public void testListAllocationsByNettingIdRequestConstruction() throws CoinbaseClientException { + ListAllocationsByNettingIdRequest request = new ListAllocationsByNettingIdRequest.Builder("portfolio-123", "netting-789") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("netting-789", request.getNettingId()); + } + + @Test + public void testListAllocationsByNettingIdResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"allocations\":[" + + "{\"allocation_id\":\"alloc-1\",\"product_id\":\"BTC-USD\"}," + + "{\"allocation_id\":\"alloc-2\",\"product_id\":\"BTC-USD\"}" + + "]" + + "}"; + + ListAllocationsByNettingIdResponse response = objectMapper.readValue(json, ListAllocationsByNettingIdResponse.class); + assertNotNull(response); + assertNotNull(response.getAllocations()); + assertEquals(2, response.getAllocations().length); + } + + // ==================== ListPortfolioAllocations Tests ==================== + + @Test + public void testListPortfolioAllocationsRequestConstruction() throws CoinbaseClientException { + ListPortfolioAllocationsRequest request = new ListPortfolioAllocationsRequest.Builder("portfolio-123") + .productIds(new String[]{"BTC-USD", "ETH-USD"}) + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testListPortfolioAllocationsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"allocations\":[" + + "{\"allocation_id\":\"alloc-1\",\"product_id\":\"BTC-USD\"}," + + "{\"allocation_id\":\"alloc-2\",\"product_id\":\"ETH-USD\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"page-2\",\"has_next\":true}" + + "}"; + + ListPortfolioAllocationsResponse response = objectMapper.readValue(json, ListPortfolioAllocationsResponse.class); + assertNotNull(response); + assertNotNull(response.getAllocations()); + assertEquals(2, response.getAllocations().length); + assertNotNull(response.getPagination()); + } +} diff --git a/src/test/java/com/coinbase/prime/assets/AssetsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/assets/AssetsServiceSerializationTest.java new file mode 100644 index 00000000..66385cc8 --- /dev/null +++ b/src/test/java/com/coinbase/prime/assets/AssetsServiceSerializationTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.assets; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class AssetsServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + @Test + public void testListAssetsRequestConstruction() throws CoinbaseClientException { + ListAssetsRequest request = new ListAssetsRequest.Builder("entity-123").build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testListAssetsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListAssetsRequest.Builder(null).build()); + assertThrows(CoinbaseClientException.class, () -> + new ListAssetsRequest.Builder("").build()); + } + + @Test + public void testListAssetsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"assets\":[" + + "{\"name\":\"Bitcoin\",\"symbol\":\"BTC\",\"decimal_precision\":\"8\"}," + + "{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimal_precision\":\"18\"}" + + "]" + + "}"; + + ListAssetsResponse response = objectMapper.readValue(json, ListAssetsResponse.class); + assertNotNull(response); + assertNotNull(response.getAssets()); + assertEquals(2, response.getAssets().length); + assertEquals("BTC", response.getAssets()[0].getSymbol()); + assertEquals("ETH", response.getAssets()[1].getSymbol()); + } +} diff --git a/src/test/java/com/coinbase/prime/balances/BalancesServiceSerializationTest.java b/src/test/java/com/coinbase/prime/balances/BalancesServiceSerializationTest.java new file mode 100644 index 00000000..75fb0440 --- /dev/null +++ b/src/test/java/com/coinbase/prime/balances/BalancesServiceSerializationTest.java @@ -0,0 +1,177 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.balances; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class BalancesServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListEntityBalances Tests ==================== + + @Test + public void testListEntityBalancesRequestSerialization() throws JsonProcessingException { + ListEntityBalancesRequest request = new ListEntityBalancesRequest.Builder() + .entityId("entity-123") + .symbols("BTC,ETH") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"symbols\":\"BTC,ETH\"")); + assertFalse(json.contains("\"entity_id\"")); + } + + @Test + public void testListEntityBalancesRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListEntityBalancesRequest.Builder().build()); + } + + @Test + public void testListEntityBalancesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"balances\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"1.5\",\"holds\":\"0.0\"}," + + "{\"symbol\":\"ETH\",\"amount\":\"10.0\",\"holds\":\"0.5\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"cursor-xyz\",\"has_next\":false}" + + "}"; + + ListEntityBalancesResponse response = objectMapper.readValue(json, ListEntityBalancesResponse.class); + assertNotNull(response); + assertNotNull(response.getBalances()); + assertEquals(2, response.getBalances().length); + } + + // ==================== ListPortfolioBalances Tests ==================== + + @Test + public void testListPortfolioBalancesRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ListPortfolioBalancesRequest request = new ListPortfolioBalancesRequest.Builder() + .portfolioId("portfolio-123") + .symbols(new String[]{"BTC", "ETH"}) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"symbols\"")); + assertFalse(json.contains("\"portfolio_id\"")); + } + + @Test + public void testListPortfolioBalancesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"balances\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"2.0\",\"holds\":\"0.1\"}" + + "]," + + "\"type\":\"TRADING_BALANCES\"," + + "\"trading_balances\":{\"total\":\"100000.00\",\"holds\":\"5000.00\"}," + + "\"vault_balances\":{\"total\":\"50000.00\",\"holds\":\"0.00\"}" + + "}"; + + ListPortfolioBalancesResponse response = objectMapper.readValue(json, ListPortfolioBalancesResponse.class); + assertNotNull(response); + assertNotNull(response.getBalances()); + assertEquals(1, response.getBalances().length); + assertNotNull(response.getTradingBalances()); + assertNotNull(response.getVaultBalances()); + } + + // ==================== GetWalletBalance Tests ==================== + + @Test + public void testGetWalletBalanceRequestConstruction() throws CoinbaseClientException { + GetWalletBalanceRequest request = new GetWalletBalanceRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("wallet-456", request.getWalletId()); + } + + @Test + public void testGetWalletBalanceRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new GetWalletBalanceRequest.Builder() + .walletId("wallet-456") + .build()); + assertThrows(CoinbaseClientException.class, () -> + new GetWalletBalanceRequest.Builder() + .portfolioId("portfolio-123") + .build()); + } + + @Test + public void testGetWalletBalanceResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"balance\":{" + + "\"symbol\":\"BTC\"," + + "\"amount\":\"0.5\"," + + "\"holds\":\"0.0\"" + + "}" + + "}"; + + GetWalletBalanceResponse response = objectMapper.readValue(json, GetWalletBalanceResponse.class); + assertNotNull(response); + assertNotNull(response.getBalance()); + assertEquals("BTC", response.getBalance().getSymbol()); + } + + // ==================== ListOnchainWalletBalances Tests ==================== + + @Test + public void testListOnchainWalletBalancesRequestConstruction() throws CoinbaseClientException { + ListOnchainWalletBalancesRequest request = new ListOnchainWalletBalancesRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("wallet-456", request.getWalletId()); + } + + @Test + public void testListOnchainWalletBalancesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"balances\":[" + + "{\"asset\":{\"name\":\"USDC\",\"symbol\":\"USDC\"},\"amount\":\"500.00\"}," + + "{\"asset\":{\"name\":\"Ether\",\"symbol\":\"ETH\"},\"amount\":\"2.5\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListOnchainWalletBalancesResponse response = objectMapper.readValue(json, ListOnchainWalletBalancesResponse.class); + assertNotNull(response); + assertNotNull(response.getBalances()); + assertEquals(2, response.getBalances().length); + } +} diff --git a/src/test/java/com/coinbase/prime/commission/CommissionServiceSerializationTest.java b/src/test/java/com/coinbase/prime/commission/CommissionServiceSerializationTest.java new file mode 100644 index 00000000..a7de9999 --- /dev/null +++ b/src/test/java/com/coinbase/prime/commission/CommissionServiceSerializationTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.commission; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class CommissionServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + @Test + public void testGetPortfolioCommissionRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + GetPortfolioCommissionRequest request = new GetPortfolioCommissionRequest.Builder() + .portfolioId("portfolio-123") + .productId("BTC-USD") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"product_id\":\"BTC-USD\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testGetPortfolioCommissionRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new GetPortfolioCommissionRequest.Builder().build()); + } + + @Test + public void testGetPortfolioCommissionResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"commission\":{" + + "\"type\":\"COMMISSION_TYPE_TAKER\"," + + "\"rate\":\"0.0005\"" + + "}" + + "}"; + + GetPortfolioCommissionResponse response = objectMapper.readValue(json, GetPortfolioCommissionResponse.class); + assertNotNull(response); + assertNotNull(response.getCommission()); + assertEquals("0.0005", response.getCommission().getRate()); + } +} diff --git a/src/test/java/com/coinbase/prime/financing/FinancingServiceSerializationTest.java b/src/test/java/com/coinbase/prime/financing/FinancingServiceSerializationTest.java new file mode 100644 index 00000000..f31c2d40 --- /dev/null +++ b/src/test/java/com/coinbase/prime/financing/FinancingServiceSerializationTest.java @@ -0,0 +1,454 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.financing; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class FinancingServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== CreateNewLocates Tests ==================== + + @Test + public void testCreateNewLocatesRequestSerialization() throws JsonProcessingException { + CreateNewLocatesRequest request = new CreateNewLocatesRequest.Builder() + .portfolioId("portfolio-123") + .symbol("BTC") + .amount("1.0") + .locateDate("2025-01-15") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"symbol\":\"BTC\"")); + assertTrue(json.contains("\"amount\":\"1.0\"")); + assertTrue(json.contains("\"locate_date\":\"2025-01-15\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testCreateNewLocatesResponseDeserialization() throws JsonProcessingException { + String json = "{\"locate_id\":\"locate-abc123\"}"; + CreateNewLocatesResponse response = objectMapper.readValue(json, CreateNewLocatesResponse.class); + assertNotNull(response); + assertEquals("locate-abc123", response.getLocateId()); + } + + // ==================== GetCrossMarginOverview Tests ==================== + + @Test + public void testGetCrossMarginOverviewRequestConstruction() { + GetCrossMarginOverviewRequest request = new GetCrossMarginOverviewRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testGetCrossMarginOverviewResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"overview\":{" + + "\"equity\":\"50000.00\"," + + "\"margin_used\":\"10000.00\"" + + "}" + + "}"; + + GetCrossMarginOverviewResponse response = objectMapper.readValue(json, GetCrossMarginOverviewResponse.class); + assertNotNull(response); + assertNotNull(response.getOverview()); + } + + // ==================== GetEntityLocateAvailabilities Tests ==================== + + @Test + public void testGetEntityLocateAvailabilitiesRequestSerialization() throws JsonProcessingException { + GetEntityLocateAvailabilitiesRequest request = new GetEntityLocateAvailabilitiesRequest.Builder() + .entityId("entity-123") + .conversionDate("2025-01-15") + .locateDate("2025-01-15") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"conversion_date\":\"2025-01-15\"")); + assertTrue(json.contains("\"locate_date\":\"2025-01-15\"")); + } + + @Test + public void testGetEntityLocateAvailabilitiesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"locates\":[" + + "{\"symbol\":\"BTC\",\"available\":\"5.0\"}," + + "{\"symbol\":\"ETH\",\"available\":\"50.0\"}" + + "]" + + "}"; + + GetEntityLocateAvailabilitiesResponse response = objectMapper.readValue(json, GetEntityLocateAvailabilitiesResponse.class); + assertNotNull(response); + assertNotNull(response.getLocates()); + assertEquals(2, response.getLocates().length); + } + + // ==================== GetMarginInformation Tests ==================== + + @Test + public void testGetMarginInformationRequestConstruction() { + GetMarginInformationRequest request = new GetMarginInformationRequest.Builder() + .entityId("entity-456") + .build(); + assertNotNull(request); + assertEquals("entity-456", request.getEntityId()); + } + + @Test + public void testGetMarginInformationResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"margin_information\":{" + + "\"leverage\":\"3.0\"," + + "\"margin_call_state\":\"FCM_MARGIN_CALL_STATE_OK\"" + + "}" + + "}"; + + GetMarginInformationResponse response = objectMapper.readValue(json, GetMarginInformationResponse.class); + assertNotNull(response); + assertNotNull(response.getMarginInformation()); + } + + // ==================== GetPortfolioBuyingPower Tests ==================== + + @Test + public void testGetPortfolioBuyingPowerRequestSerialization() throws JsonProcessingException { + GetPortfolioBuyingPowerRequest request = new GetPortfolioBuyingPowerRequest.Builder() + .portfolioId("portfolio-123") + .baseCurrency("BTC") + .quoteCurrency("USD") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"base_currency\":\"BTC\"")); + assertTrue(json.contains("\"quote_currency\":\"USD\"")); + assertFalse(json.contains("\"portfolio_id\"")); + } + + @Test + public void testGetPortfolioBuyingPowerResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"buying_power\":{" + + "\"symbol\":\"BTC\"," + + "\"quantity\":\"0.5\"," + + "\"local_currency\":\"USD\"," + + "\"local_currency_quantity\":\"25000.00\"" + + "}" + + "}"; + + GetPortfolioBuyingPowerResponse response = objectMapper.readValue(json, GetPortfolioBuyingPowerResponse.class); + assertNotNull(response); + assertNotNull(response.getBuyingPower()); + } + + // ==================== GetPortfolioCreditInformation Tests ==================== + + @Test + public void testGetPortfolioCreditInformationRequestConstruction() { + GetPortfolioCreditInformationRequest request = new GetPortfolioCreditInformationRequest.Builder() + .portfolioId("portfolio-123") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testGetPortfolioCreditInformationResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"postTradeCredit\":{" + + "\"portfolio_id\":\"portfolio-123\"," + + "\"currency\":\"USD\"," + + "\"limit\":\"1000000.00\"," + + "\"utilized\":\"50000.00\"" + + "}" + + "}"; + + GetPortfolioCreditInformationResponse response = objectMapper.readValue(json, GetPortfolioCreditInformationResponse.class); + assertNotNull(response); + } + + // ==================== GetPortfolioWithdrawalPower Tests ==================== + + @Test + public void testGetPortfolioWithdrawalPowerRequestSerialization() throws JsonProcessingException { + GetPortfolioWithdrawalPowerRequest request = new GetPortfolioWithdrawalPowerRequest.Builder() + .portfolioId("portfolio-123") + .symbol("BTC") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"symbol\":\"BTC\"")); + } + + @Test + public void testGetPortfolioWithdrawalPowerResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"withdrawal_power\":{" + + "\"symbol\":\"BTC\"," + + "\"quantity\":\"0.25\"" + + "}" + + "}"; + + GetPortfolioWithdrawalPowerResponse response = objectMapper.readValue(json, GetPortfolioWithdrawalPowerResponse.class); + assertNotNull(response); + assertNotNull(response.getWithdrawalPower()); + } + + // ==================== GetTradeFinanceTieredPricingFees Tests ==================== + + @Test + public void testGetTradeFinanceTieredPricingFeesRequestSerialization() throws JsonProcessingException { + GetTradeFinanceTieredPricingFeesRequest request = new GetTradeFinanceTieredPricingFeesRequest.Builder() + .entityId("entity-123") + .effectiveAt("2025-01-01T00:00:00Z") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"effective_at\":\"2025-01-01T00:00:00Z\"")); + } + + @Test + public void testGetTradeFinanceTieredPricingFeesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"fees\":[" + + "{\"tier\":\"1\",\"rate\":\"0.01\"}," + + "{\"tier\":\"2\",\"rate\":\"0.008\"}" + + "]" + + "}"; + + GetTradeFinanceTieredPricingFeesResponse response = objectMapper.readValue(json, GetTradeFinanceTieredPricingFeesResponse.class); + assertNotNull(response); + assertNotNull(response.getFees()); + assertEquals(2, response.getFees().length); + } + + // ==================== ListExistingLocates Tests ==================== + + @Test + public void testListExistingLocatesRequestSerialization() throws JsonProcessingException { + ListExistingLocatesRequest request = new ListExistingLocatesRequest.Builder() + .portfolioId("portfolio-123") + .locateIds(new String[]{"locate-1", "locate-2"}) + .locateDate("2025-01-15") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"locate_ids\"")); + assertTrue(json.contains("\"locate_date\":\"2025-01-15\"")); + } + + @Test + public void testListExistingLocatesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"locates\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"1.0\",\"locate_date\":\"2025-01-15\"}," + + "{\"symbol\":\"ETH\",\"amount\":\"10.0\",\"locate_date\":\"2025-01-15\"}" + + "]" + + "}"; + + ListExistingLocatesResponse response = objectMapper.readValue(json, ListExistingLocatesResponse.class); + assertNotNull(response); + assertNotNull(response.getLocates()); + assertEquals(2, response.getLocates().length); + } + + // ==================== ListFinancingEligibleAssets Tests ==================== + + @Test + public void testListFinancingEligibleAssetsRequestConstruction() { + ListFinancingEligibleAssetsRequest request = new ListFinancingEligibleAssetsRequest.Builder().build(); + assertNotNull(request); + } + + @Test + public void testListFinancingEligibleAssetsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"assets\":[" + + "{\"symbol\":\"BTC\",\"name\":\"Bitcoin\"}," + + "{\"symbol\":\"ETH\",\"name\":\"Ethereum\"}" + + "]" + + "}"; + + ListFinancingEligibleAssetsResponse response = objectMapper.readValue(json, ListFinancingEligibleAssetsResponse.class); + assertNotNull(response); + assertNotNull(response.getAssets()); + assertEquals(2, response.getAssets().size()); + } + + // ==================== ListInterestAccruals Tests ==================== + + @Test + public void testListInterestAccrualsRequestSerialization() throws JsonProcessingException { + ListInterestAccrualsRequest request = new ListInterestAccrualsRequest.Builder() + .entityId("entity-123") + .portfolioId("portfolio-456") + .startDate("2025-01-01") + .endDate("2025-01-31") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"portfolio_id\":\"portfolio-456\"")); + assertTrue(json.contains("\"start_date\":\"2025-01-01\"")); + assertTrue(json.contains("\"end_date\":\"2025-01-31\"")); + } + + @Test + public void testListInterestAccrualsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"total_notional_accrual\":\"150.00\"," + + "\"accruals\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"100.00\"}," + + "{\"symbol\":\"ETH\",\"amount\":\"50.00\"}" + + "]" + + "}"; + + ListInterestAccrualsResponse response = objectMapper.readValue(json, ListInterestAccrualsResponse.class); + assertNotNull(response); + assertEquals("150.00", response.getTotalNotionalAccrual()); + assertNotNull(response.getAccruals()); + assertEquals(2, response.getAccruals().length); + } + + // ==================== ListInterestAccrualsForPortfolio Tests ==================== + + @Test + public void testListInterestAccrualsForPortfolioResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"total_notional_accrual\":\"75.50\"," + + "\"accruals\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"75.50\"}" + + "]" + + "}"; + + ListInterestAccrualsForPortfolioResponse response = objectMapper.readValue(json, ListInterestAccrualsForPortfolioResponse.class); + assertNotNull(response); + assertEquals("75.50", response.getTotalNotionalAccrual()); + assertNotNull(response.getAccruals()); + assertEquals(1, response.getAccruals().length); + } + + // ==================== ListMarginCallSummaries Tests ==================== + + @Test + public void testListMarginCallSummariesRequestSerialization() throws JsonProcessingException { + ListMarginCallSummariesRequest request = new ListMarginCallSummariesRequest.Builder() + .entityId("entity-123") + .startDate("2025-01-01") + .endDate("2025-01-31") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"start_date\":\"2025-01-01\"")); + assertTrue(json.contains("\"end_date\":\"2025-01-31\"")); + } + + @Test + public void testListMarginCallSummariesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"margin_summaries\":[" + + "{\"date\":\"2025-01-10\",\"state\":\"FCM_MARGIN_CALL_STATE_OK\"}," + + "{\"date\":\"2025-01-11\",\"state\":\"FCM_MARGIN_CALL_STATE_CLOSED\"}" + + "]" + + "}"; + + ListMarginCallSummariesResponse response = objectMapper.readValue(json, ListMarginCallSummariesResponse.class); + assertNotNull(response); + assertNotNull(response.getMarginSummaries()); + assertEquals(2, response.getMarginSummaries().length); + } + + // ==================== ListMarginConversions Tests ==================== + + @Test + public void testListMarginConversionsRequestSerialization() throws JsonProcessingException { + ListMarginConversionsRequest request = new ListMarginConversionsRequest.Builder() + .portfolioId("portfolio-123") + .startDate("2025-01-01") + .endDate("2025-01-31") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"start_date\":\"2025-01-01\"")); + assertTrue(json.contains("\"end_date\":\"2025-01-31\"")); + } + + @Test + public void testListMarginConversionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"conversions\":[" + + "{\"id\":\"conv-1\",\"symbol\":\"BTC\",\"amount\":\"0.5\"}," + + "{\"id\":\"conv-2\",\"symbol\":\"ETH\",\"amount\":\"5.0\"}" + + "]" + + "}"; + + ListMarginConversionsResponse response = objectMapper.readValue(json, ListMarginConversionsResponse.class); + assertNotNull(response); + assertNotNull(response.getConversions()); + assertEquals(2, response.getConversions().length); + } + + // ==================== ListTfObligations Tests ==================== + + @Test + public void testListTfObligationsRequestConstruction() { + ListTfObligationsRequest request = new ListTfObligationsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testListTfObligationsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"obligations\":[" + + "{\"id\":\"obl-1\",\"symbol\":\"BTC\",\"amount\":\"1.0\"}," + + "{\"id\":\"obl-2\",\"symbol\":\"ETH\",\"amount\":\"10.0\"}" + + "]" + + "}"; + + ListTfObligationsResponse response = objectMapper.readValue(json, ListTfObligationsResponse.class); + assertNotNull(response); + assertNotNull(response.getObligations()); + assertEquals(2, response.getObligations().size()); + } +} diff --git a/src/test/java/com/coinbase/prime/futures/FuturesServiceSerializationTest.java b/src/test/java/com/coinbase/prime/futures/FuturesServiceSerializationTest.java new file mode 100644 index 00000000..014d3dcb --- /dev/null +++ b/src/test/java/com/coinbase/prime/futures/FuturesServiceSerializationTest.java @@ -0,0 +1,323 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.futures; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class FuturesServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== SetAutoSweep Tests ==================== + + @Test + public void testSetAutoSweepRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + SetAutoSweepRequest request = new SetAutoSweepRequest.Builder() + .entityId("entity-123") + .autoSweep(true) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"auto_sweep\":true")); + assertFalse(json.contains("entity_id")); + } + + @Test + public void testSetAutoSweepResponseDeserialization() throws JsonProcessingException { + String json = "{\"success\":true}"; + SetAutoSweepResponse response = objectMapper.readValue(json, SetAutoSweepResponse.class); + assertNotNull(response); + assertTrue(response.getSuccess()); + } + + // ==================== GetEntityFcmBalance Tests ==================== + + @Test + public void testGetEntityFcmBalanceRequestConstruction() throws CoinbaseClientException { + GetEntityFcmBalanceRequest request = new GetEntityFcmBalanceRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testGetEntityFcmBalanceResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"portfolio_id\":\"portfolio-123\"," + + "\"cfm_usd_balance\":\"100000.00\"," + + "\"unrealized_pnl\":\"500.00\"," + + "\"daily_realized_pnl\":\"250.00\"," + + "\"excess_liquidity\":\"50000.00\"," + + "\"futures_buying_power\":\"75000.00\"," + + "\"initial_margin\":\"10000.00\"," + + "\"maintenance_margin\":\"8000.00\"," + + "\"clearing_account_id\":\"clr-abc\"," + + "\"cfm_unsettled_accrued_funding_pnl\":\"10.00\"" + + "}"; + + GetEntityFcmBalanceResponse response = objectMapper.readValue(json, GetEntityFcmBalanceResponse.class); + assertNotNull(response); + assertEquals("portfolio-123", response.getPortfolioId()); + assertEquals("100000.00", response.getCfmUsdBalance()); + assertEquals("500.00", response.getUnrealizedPnl()); + assertEquals("250.00", response.getDailyRealizedPnl()); + assertEquals("clr-abc", response.getClearingAccountId()); + } + + // ==================== GetPositions Tests ==================== + + @Test + public void testGetPositionsRequestConstruction() throws CoinbaseClientException { + GetPositionsRequest request = new GetPositionsRequest.Builder() + .entityId("entity-123") + .productId("BTC-PERP") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + assertEquals("BTC-PERP", request.getProductId()); + } + + @Test + public void testGetPositionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"positions\":[" + + "{\"product_id\":\"BTC-PERP\",\"entry_price\":\"50000.00\",\"quantity\":\"0.1\"}," + + "{\"product_id\":\"ETH-PERP\",\"entry_price\":\"3000.00\",\"quantity\":\"1.0\"}" + + "]," + + "\"clearing_account_id\":\"clr-xyz\"" + + "}"; + + GetPositionsResponse response = objectMapper.readValue(json, GetPositionsResponse.class); + assertNotNull(response); + assertNotNull(response.getPositions()); + assertEquals(2, response.getPositions().length); + assertEquals("clr-xyz", response.getClearingAccountId()); + } + + // ==================== ListEntityFuturesSweeps Tests ==================== + + @Test + public void testListEntityFuturesSweepsRequestConstruction() throws CoinbaseClientException { + ListEntityFuturesSweepsRequest request = new ListEntityFuturesSweepsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testListEntityFuturesSweepsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"sweeps\":[" + + "{\"id\":\"sweep-1\",\"amount\":\"1000.00\",\"currency\":\"USD\"}," + + "{\"id\":\"sweep-2\",\"amount\":\"2000.00\",\"currency\":\"USD\"}" + + "]," + + "\"auto_sweep\":true" + + "}"; + + ListEntityFuturesSweepsResponse response = objectMapper.readValue(json, ListEntityFuturesSweepsResponse.class); + assertNotNull(response); + assertNotNull(response.getSweeps()); + assertEquals(2, response.getSweeps().length); + assertTrue(response.getAutoSweep()); + } + + // ==================== CancelEntityFuturesSweep Tests ==================== + + @Test + public void testCancelEntityFuturesSweepRequestConstruction() throws CoinbaseClientException { + CancelEntityFuturesSweepRequest request = new CancelEntityFuturesSweepRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testCancelEntityFuturesSweepResponseDeserialization() throws JsonProcessingException { + String json = "{\"success\":true,\"request_id\":\"req-abc123\"}"; + CancelEntityFuturesSweepResponse response = objectMapper.readValue(json, CancelEntityFuturesSweepResponse.class); + assertNotNull(response); + assertTrue(response.getSuccess()); + assertEquals("req-abc123", response.getRequestId()); + } + + // ==================== ScheduleEntityFuturesSweep Tests ==================== + + @Test + public void testScheduleEntityFuturesSweepRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ScheduleEntityFuturesSweepRequest request = new ScheduleEntityFuturesSweepRequest(); + request.setEntityId("entity-123"); + request.setAmount("5000.00"); + request.setCurrency("USD"); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"amount\":\"5000.00\"")); + assertTrue(json.contains("\"currency\":\"USD\"")); + assertFalse(json.contains("entity_id")); + } + + @Test + public void testScheduleEntityFuturesSweepResponseDeserialization() throws JsonProcessingException { + String json = "{\"success\":true,\"request_id\":\"req-xyz789\"}"; + ScheduleEntityFuturesSweepResponse response = objectMapper.readValue(json, ScheduleEntityFuturesSweepResponse.class); + assertNotNull(response); + assertTrue(response.getSuccess()); + assertEquals("req-xyz789", response.getRequestId()); + } + + // ==================== GetFcmMarginCallDetails Tests ==================== + + @Test + public void testGetFcmMarginCallDetailsRequestConstruction() throws CoinbaseClientException { + GetFcmMarginCallDetailsRequest request = new GetFcmMarginCallDetailsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testGetFcmMarginCallDetailsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"margin_call_details\":{" + + "\"state\":\"FCM_MARGIN_CALL_STATE_OK\"," + + "\"portfolio_id\":\"portfolio-123\"" + + "}" + + "}"; + + GetFcmMarginCallDetailsResponse response = objectMapper.readValue(json, GetFcmMarginCallDetailsResponse.class); + assertNotNull(response); + } + + // ==================== GetFcmRiskLimits Tests ==================== + + @Test + public void testGetFcmRiskLimitsRequestConstruction() throws CoinbaseClientException { + GetFcmRiskLimitsRequest request = new GetFcmRiskLimitsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testGetFcmRiskLimitsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"cfm_risk_limit\":\"100000.00\"," + + "\"cfm_risk_limit_utilization\":\"0.50\"," + + "\"cfm_total_margin\":\"50000.00\"," + + "\"cfm_delta_ote\":\"1000.00\"," + + "\"cfm_unsettled_realized_pnl\":\"500.00\"," + + "\"cfm_unsettled_accrued_funding_pnl\":\"25.00\"" + + "}"; + + GetFcmRiskLimitsResponse response = objectMapper.readValue(json, GetFcmRiskLimitsResponse.class); + assertNotNull(response); + assertEquals("100000.00", response.getCfmRiskLimit()); + assertEquals("0.50", response.getCfmRiskLimitUtilization()); + assertEquals("50000.00", response.getCfmTotalMargin()); + assertEquals("1000.00", response.getCfmDeltaOte()); + assertEquals("500.00", response.getCfmUnsettledRealizedPnl()); + assertEquals("25.00", response.getCfmUnsettledAccruedFundingPnl()); + } + + // ==================== GetFcmSettings Tests ==================== + + @Test + public void testGetFcmSettingsRequestConstruction() { + GetFcmSettingsRequest request = new GetFcmSettingsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testGetFcmSettingsResponseDeserialization() throws JsonProcessingException { + String json = "{\"target_derivatives_excess\":\"10000.00\"}"; + GetFcmSettingsResponse response = objectMapper.readValue(json, GetFcmSettingsResponse.class); + assertNotNull(response); + assertEquals("10000.00", response.getTargetDerivativesExcess()); + } + + // ==================== SetFcmSettings Tests ==================== + + @Test + public void testSetFcmSettingsRequestSerialization() throws JsonProcessingException { + SetFcmSettingsRequest request = new SetFcmSettingsRequest.Builder() + .entityId("entity-123") + .targetDerivativesExcess("15000.00") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"target_derivatives_excess\":\"15000.00\"")); + assertFalse(json.contains("entity_id")); + } + + @Test + public void testSetFcmSettingsResponseDeserialization() throws JsonProcessingException { + String json = "{\"success\":true}"; + SetFcmSettingsResponse response = objectMapper.readValue(json, SetFcmSettingsResponse.class); + assertNotNull(response); + assertTrue(response.getSuccess()); + } + + // ==================== GetFcmEquity Tests ==================== + + @Test + public void testGetFcmEquityRequestConstruction() { + GetFcmEquityRequest request = new GetFcmEquityRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testGetFcmEquityResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"available_to_sweep\":\"5000.00\"," + + "\"current_excess_deficit\":\"2000.00\"," + + "\"eod_account_equity\":\"105000.00\"," + + "\"eod_unrealized_pnl\":\"500.00\"" + + "}"; + + GetFcmEquityResponse response = objectMapper.readValue(json, GetFcmEquityResponse.class); + assertNotNull(response); + assertEquals("5000.00", response.getAvailableToSweep()); + assertEquals("2000.00", response.getCurrentExcessDeficit()); + assertEquals("105000.00", response.getEodAccountEquity()); + assertEquals("500.00", response.getEodUnrealizedPnl()); + } +} diff --git a/src/test/java/com/coinbase/prime/invoice/InvoiceServiceSerializationTest.java b/src/test/java/com/coinbase/prime/invoice/InvoiceServiceSerializationTest.java new file mode 100644 index 00000000..87879d59 --- /dev/null +++ b/src/test/java/com/coinbase/prime/invoice/InvoiceServiceSerializationTest.java @@ -0,0 +1,75 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.invoice; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.enums.InvoiceState; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class InvoiceServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + @Test + public void testListInvoicesRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ListInvoicesRequest request = new ListInvoicesRequest.Builder("entity-123") + .states(new InvoiceState[]{InvoiceState.INVOICE_STATE_BILLED, InvoiceState.INVOICE_STATE_PAID}) + .billingMonth(1) + .billingYear(2025) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"states\"")); + assertTrue(json.contains("\"billing_month\":1")); + assertTrue(json.contains("\"billing_year\":2025")); + assertFalse(json.contains("entity_id")); + } + + @Test + public void testListInvoicesRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListInvoicesRequest.Builder(null).build()); + } + + @Test + public void testListInvoicesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"invoices\":[" + + "{\"id\":\"inv-1\",\"state\":\"INVOICE_STATE_BILLED\",\"billing_month\":1,\"billing_year\":2025}," + + "{\"id\":\"inv-2\",\"state\":\"INVOICE_STATE_PAID\",\"billing_month\":12,\"billing_year\":2024}" + + "]" + + "}"; + + ListInvoicesResponse response = objectMapper.readValue(json, ListInvoicesResponse.class); + assertNotNull(response); + assertNotNull(response.getInvoices()); + assertEquals(2, response.getInvoices().length); + assertEquals("inv-1", response.getInvoices()[0].getId()); + } +} diff --git a/src/test/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceSerializationTest.java b/src/test/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceSerializationTest.java new file mode 100644 index 00000000..024e70ff --- /dev/null +++ b/src/test/java/com/coinbase/prime/onchainaddressbook/OnchainAddressBookServiceSerializationTest.java @@ -0,0 +1,149 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.onchainaddressbook; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class OnchainAddressBookServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== CreateOnchainAddressBookEntry Tests ==================== + + @Test + public void testCreateOnchainAddressBookEntryRequestSerialization() throws JsonProcessingException { + CreateOnchainAddressBookEntryRequest request = new CreateOnchainAddressBookEntryRequest.Builder() + .portfolioId("portfolio-123") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testCreateOnchainAddressBookEntryResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_type\":\"ACTIVITY_TYPE_ADDRESS_BOOK\"," + + "\"num_approvals_remaining\":1," + + "\"activity_id\":\"act-abc123\"" + + "}"; + + CreateOnchainAddressBookEntryResponse response = objectMapper.readValue(json, CreateOnchainAddressBookEntryResponse.class); + assertNotNull(response); + assertEquals(1, response.getNumApprovalsRemaining()); + assertEquals("act-abc123", response.getActivityId()); + } + + // ==================== DeleteOnchainAddressGroup Tests ==================== + + @Test + public void testDeleteOnchainAddressGroupRequestConstruction() { + DeleteOnchainAddressGroupRequest request = new DeleteOnchainAddressGroupRequest.Builder() + .portfolioId("portfolio-123") + .addressGroupId("group-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("group-456", request.getAddressGroupId()); + } + + @Test + public void testDeleteOnchainAddressGroupResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_type\":\"ACTIVITY_TYPE_ADDRESS_BOOK\"," + + "\"num_approvals_remaining\":2," + + "\"activity_id\":\"act-def456\"" + + "}"; + + DeleteOnchainAddressGroupResponse response = objectMapper.readValue(json, DeleteOnchainAddressGroupResponse.class); + assertNotNull(response); + assertEquals(2, response.getNumApprovalsRemaining()); + assertEquals("act-def456", response.getActivityId()); + } + + // ==================== ListOnchainAddressGroups Tests ==================== + + @Test + public void testListOnchainAddressGroupsRequestConstruction() throws CoinbaseClientException { + ListOnchainAddressGroupsRequest request = new ListOnchainAddressGroupsRequest.Builder() + .portfolioId("portfolio-123") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testListOnchainAddressGroupsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListOnchainAddressGroupsRequest.Builder().build()); + } + + @Test + public void testListOnchainAddressGroupsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"address_groups\":[" + + "{\"id\":\"group-1\",\"name\":\"Hot Wallets\"}," + + "{\"id\":\"group-2\",\"name\":\"Cold Wallets\"}" + + "]" + + "}"; + + ListOnchainAddressGroupsResponse response = objectMapper.readValue(json, ListOnchainAddressGroupsResponse.class); + assertNotNull(response); + assertNotNull(response.getAddressGroups()); + assertEquals(2, response.getAddressGroups().size()); + } + + // ==================== UpdateOnchainAddressBookEntry Tests ==================== + + @Test + public void testUpdateOnchainAddressBookEntryRequestSerialization() throws JsonProcessingException { + UpdateOnchainAddressBookEntryRequest request = new UpdateOnchainAddressBookEntryRequest.Builder() + .portfolioId("portfolio-123") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testUpdateOnchainAddressBookEntryResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_type\":\"ACTIVITY_TYPE_ADDRESS_BOOK\"," + + "\"num_approvals_remaining\":0," + + "\"activity_id\":\"act-ghi789\"" + + "}"; + + UpdateOnchainAddressBookEntryResponse response = objectMapper.readValue(json, UpdateOnchainAddressBookEntryResponse.class); + assertNotNull(response); + assertEquals(0, response.getNumApprovalsRemaining()); + assertEquals("act-ghi789", response.getActivityId()); + } +} diff --git a/src/test/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceSerializationTest.java new file mode 100644 index 00000000..3ff080c4 --- /dev/null +++ b/src/test/java/com/coinbase/prime/paymentmethods/PaymentMethodsServiceSerializationTest.java @@ -0,0 +1,109 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.paymentmethods; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class PaymentMethodsServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListPaymentMethods Tests ==================== + + @Test + public void testListPaymentMethodsRequestConstruction() throws CoinbaseClientException { + ListPaymentMethodsRequest request = new ListPaymentMethodsRequest.Builder("entity-123").build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testListPaymentMethodsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListPaymentMethodsRequest.Builder(null).build()); + } + + @Test + public void testListPaymentMethodsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"payment_methods\":[" + + "{\"id\":\"pm-1\",\"name\":\"Wire Transfer\",\"currency\":\"USD\"}," + + "{\"id\":\"pm-2\",\"name\":\"ACH Transfer\",\"currency\":\"USD\"}" + + "]" + + "}"; + + ListPaymentMethodsResponse response = objectMapper.readValue(json, ListPaymentMethodsResponse.class); + assertNotNull(response); + assertNotNull(response.getPaymentMethods()); + assertEquals(2, response.getPaymentMethods().length); + assertEquals("pm-1", response.getPaymentMethods()[0].getId()); + } + + // ==================== GetPaymentMethodDetails Tests ==================== + + @Test + public void testGetPaymentMethodDetailsRequestConstruction() throws CoinbaseClientException { + GetPaymentMethodDetailsRequest request = new GetPaymentMethodDetailsRequest.Builder() + .entityId("entity-123") + .paymentMethodId("pm-456") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + assertEquals("pm-456", request.getPaymentMethodId()); + } + + @Test + public void testGetPaymentMethodDetailsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new GetPaymentMethodDetailsRequest.Builder() + .paymentMethodId("pm-456") + .build()); + assertThrows(CoinbaseClientException.class, () -> + new GetPaymentMethodDetailsRequest.Builder() + .entityId("entity-123") + .build()); + } + + @Test + public void testGetPaymentMethodDetailsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"details\":{" + + "\"id\":\"pm-456\"," + + "\"name\":\"Wire Transfer\"," + + "\"currency\":\"USD\"," + + "\"verified\":true" + + "}" + + "}"; + + GetPaymentMethodDetailsResponse response = objectMapper.readValue(json, GetPaymentMethodDetailsResponse.class); + assertNotNull(response); + assertNotNull(response.getDetails()); + assertEquals("pm-456", response.getDetails().getId()); + } +} diff --git a/src/test/java/com/coinbase/prime/portfolios/PortfoliosServiceSerializationTest.java b/src/test/java/com/coinbase/prime/portfolios/PortfoliosServiceSerializationTest.java new file mode 100644 index 00000000..a38b02aa --- /dev/null +++ b/src/test/java/com/coinbase/prime/portfolios/PortfoliosServiceSerializationTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.portfolios; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class PortfoliosServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListPortfolios Tests ==================== + + @Test + public void testListPortfoliosRequestConstruction() { + ListPortfoliosRequest request = new ListPortfoliosRequest.Builder().build(); + assertNotNull(request); + } + + @Test + public void testListPortfoliosResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"portfolios\":[" + + "{\"id\":\"port-1\",\"name\":\"Trading Portfolio\",\"entity_id\":\"entity-abc\"}," + + "{\"id\":\"port-2\",\"name\":\"Vault Portfolio\",\"entity_id\":\"entity-abc\"}" + + "]" + + "}"; + + ListPortfoliosResponse response = objectMapper.readValue(json, ListPortfoliosResponse.class); + assertNotNull(response); + assertNotNull(response.getPortfolios()); + assertEquals(2, response.getPortfolios().length); + assertEquals("port-1", response.getPortfolios()[0].getId()); + } + + // ==================== GetPortfolio Tests ==================== + + @Test + public void testGetPortfolioRequestConstruction() throws CoinbaseClientException { + GetPortfolioRequest request = new GetPortfolioRequest.Builder("portfolio-123").build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testGetPortfolioRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new GetPortfolioRequest.Builder(null).build()); + } + + @Test + public void testGetPortfolioResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"portfolio\":{" + + "\"id\":\"portfolio-123\"," + + "\"name\":\"My Portfolio\"," + + "\"entity_id\":\"entity-xyz\"" + + "}" + + "}"; + + GetPortfolioResponse response = objectMapper.readValue(json, GetPortfolioResponse.class); + assertNotNull(response); + assertNotNull(response.getPortfolio()); + assertEquals("portfolio-123", response.getPortfolio().getId()); + assertEquals("My Portfolio", response.getPortfolio().getName()); + } + + // ==================== GetPortfolioCounterpartyId Tests ==================== + + @Test + public void testGetPortfolioCounterpartyIdRequestConstruction() throws CoinbaseClientException { + GetPortfolioCounterpartyIdRequest request = new GetPortfolioCounterpartyIdRequest.Builder("portfolio-123").build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testGetPortfolioCounterpartyIdResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"counterparty\":{" + + "\"counterparty_id\":\"cpty-abc123\"," + + "\"name\":\"Counterparty Name\"" + + "}" + + "}"; + + GetPortfolioCounterpartyIdResponse response = objectMapper.readValue(json, GetPortfolioCounterpartyIdResponse.class); + assertNotNull(response); + assertNotNull(response.getCounterparty()); + assertEquals("cpty-abc123", response.getCounterparty().getCounterpartyId()); + } +} diff --git a/src/test/java/com/coinbase/prime/positions/PositionsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/positions/PositionsServiceSerializationTest.java new file mode 100644 index 00000000..2c98e2bb --- /dev/null +++ b/src/test/java/com/coinbase/prime/positions/PositionsServiceSerializationTest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.positions; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class PositionsServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListAggregatePositions Tests ==================== + + @Test + public void testListAggregatePositionsRequestConstruction() throws CoinbaseClientException { + ListAggregatePositionsRequest request = new ListAggregatePositionsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getId()); + } + + @Test + public void testListAggregatePositionsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListAggregatePositionsRequest.Builder().build()); + } + + @Test + public void testListAggregatePositionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"positions\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"0.5\",\"cost_basis\":\"25000.00\"}," + + "{\"symbol\":\"ETH\",\"amount\":\"5.0\",\"cost_basis\":\"15000.00\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListAggregatePositionsResponse response = objectMapper.readValue(json, ListAggregatePositionsResponse.class); + assertNotNull(response); + assertNotNull(response.getPositions()); + assertEquals(2, response.getPositions().length); + } + + // ==================== ListPositions Tests ==================== + + @Test + public void testListPositionsRequestConstruction() throws CoinbaseClientException { + ListPositionsRequest request = new ListPositionsRequest.Builder() + .entityId("entity-123") + .build(); + assertNotNull(request); + assertEquals("entity-123", request.getId()); + } + + @Test + public void testListPositionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"positions\":[" + + "{\"symbol\":\"BTC\",\"amount\":\"1.0\",\"cost_basis\":\"50000.00\"}," + + "{\"symbol\":\"ETH\",\"amount\":\"10.0\",\"cost_basis\":\"30000.00\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"pos-cursor\",\"has_next\":true}" + + "}"; + + ListPositionsResponse response = objectMapper.readValue(json, ListPositionsResponse.class); + assertNotNull(response); + assertNotNull(response.getPositions()); + assertEquals(2, response.getPositions().length); + assertNotNull(response.getPagination()); + } +} diff --git a/src/test/java/com/coinbase/prime/products/ProductsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/products/ProductsServiceSerializationTest.java new file mode 100644 index 00000000..b87a0865 --- /dev/null +++ b/src/test/java/com/coinbase/prime/products/ProductsServiceSerializationTest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.products; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.coinbase.prime.model.enums.CandlesGranularity; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class ProductsServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListCandles Tests ==================== + + @Test + public void testListCandlesRequestSerialization() throws JsonProcessingException { + ListCandlesRequest request = new ListCandlesRequest.Builder() + .portfolioId("portfolio-123") + .productId("BTC-USD") + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-01-02T00:00:00Z") + .granularity(CandlesGranularity.ONE_DAY) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"product_id\":\"BTC-USD\"")); + assertTrue(json.contains("\"start_time\":\"2025-01-01T00:00:00Z\"")); + assertTrue(json.contains("\"end_time\":\"2025-01-02T00:00:00Z\"")); + assertTrue(json.contains("\"granularity\":\"ONE_DAY\"")); + assertFalse(json.contains("\"portfolio_id\"")); + } + + @Test + public void testListCandlesRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListCandlesRequest.Builder() + .productId("BTC-USD") + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-01-02T00:00:00Z") + .granularity(CandlesGranularity.ONE_DAY) + .build()); + + assertThrows(CoinbaseClientException.class, () -> + new ListCandlesRequest.Builder() + .portfolioId("portfolio-123") + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-01-02T00:00:00Z") + .granularity(CandlesGranularity.ONE_DAY) + .build()); + } + + @Test + public void testListCandlesResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"candles\":[" + + "{\"start\":\"1704067200\",\"high\":\"50000.00\",\"low\":\"48000.00\",\"open\":\"49000.00\",\"close\":\"49500.00\",\"volume\":\"1000.0\"}," + + "{\"start\":\"1704153600\",\"high\":\"51000.00\",\"low\":\"49000.00\",\"open\":\"49500.00\",\"close\":\"50500.00\",\"volume\":\"1200.0\"}" + + "]" + + "}"; + + ListCandlesResponse response = objectMapper.readValue(json, ListCandlesResponse.class); + assertNotNull(response); + assertNotNull(response.getCandles()); + assertEquals(2, response.getCandles().size()); + } + + // ==================== ListPortfolioProducts Tests ==================== + + @Test + public void testListPortfolioProductsRequestConstruction() throws CoinbaseClientException { + ListPortfolioProductsRequest request = new ListPortfolioProductsRequest.Builder() + .portfolioId("portfolio-123") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testListPortfolioProductsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListPortfolioProductsRequest.Builder().build()); + } + + @Test + public void testListPortfolioProductsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"products\":[" + + "{\"id\":\"BTC-USD\",\"base_currency\":\"BTC\",\"quote_currency\":\"USD\"}," + + "{\"id\":\"ETH-USD\",\"base_currency\":\"ETH\",\"quote_currency\":\"USD\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListPortfolioProductsResponse response = objectMapper.readValue(json, ListPortfolioProductsResponse.class); + assertNotNull(response); + assertNotNull(response.getProducts()); + assertEquals(2, response.getProducts().length); + assertEquals("BTC-USD", response.getProducts()[0].getId()); + } +} diff --git a/src/test/java/com/coinbase/prime/staking/StakingServiceSerializationTest.java b/src/test/java/com/coinbase/prime/staking/StakingServiceSerializationTest.java new file mode 100644 index 00000000..be980879 --- /dev/null +++ b/src/test/java/com/coinbase/prime/staking/StakingServiceSerializationTest.java @@ -0,0 +1,313 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.staking; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class StakingServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ClaimRewards Tests ==================== + + @Test + public void testClaimRewardsRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ClaimRewardsRequest request = new ClaimRewardsRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .idempotencyKey("idem-key-abc") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"idempotency_key\":\"idem-key-abc\"")); + assertFalse(json.contains("portfolio_id")); + assertFalse(json.contains("wallet_id")); + } + + @Test + public void testClaimRewardsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ClaimRewardsRequest.Builder() + .walletId("wallet-456") + .idempotencyKey("idem-key") + .build()); + } + + @Test + public void testClaimRewardsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"wallet_id\":\"wallet-456\"," + + "\"transaction_id\":\"txn-abc123\"," + + "\"activity_id\":\"act-xyz789\"" + + "}"; + + ClaimRewardsResponse response = objectMapper.readValue(json, ClaimRewardsResponse.class); + assertNotNull(response); + assertEquals("wallet-456", response.getWalletId()); + assertEquals("txn-abc123", response.getTransactionId()); + assertEquals("act-xyz789", response.getActivityId()); + } + + // ==================== CreateStake Tests ==================== + + @Test + public void testCreateStakeRequestSerialization() throws JsonProcessingException { + CreateStakeRequest request = new CreateStakeRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .idempotencyKey("idem-key-def") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"idempotency_key\":\"idem-key-def\"")); + assertFalse(json.contains("portfolio_id")); + assertFalse(json.contains("wallet_id")); + } + + @Test + public void testCreateStakeResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"wallet_id\":\"wallet-456\"," + + "\"transaction_id\":\"txn-stake-1\"," + + "\"activity_id\":\"act-stake-1\"" + + "}"; + + CreateStakeResponse response = objectMapper.readValue(json, CreateStakeResponse.class); + assertNotNull(response); + assertEquals("wallet-456", response.getWalletId()); + assertEquals("txn-stake-1", response.getTransactionId()); + assertEquals("act-stake-1", response.getActivityId()); + } + + // ==================== CreateUnstake Tests ==================== + + @Test + public void testCreateUnstakeResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"wallet_id\":\"wallet-456\"," + + "\"transaction_id\":\"txn-unstake-1\"," + + "\"activity_id\":\"act-unstake-1\"" + + "}"; + + CreateUnstakeResponse response = objectMapper.readValue(json, CreateUnstakeResponse.class); + assertNotNull(response); + assertEquals("wallet-456", response.getWalletId()); + assertEquals("txn-unstake-1", response.getTransactionId()); + assertEquals("act-unstake-1", response.getActivityId()); + } + + // ==================== PortfolioStakingInitiate Tests ==================== + + @Test + public void testPortfolioStakingInitiateRequestSerialization() throws JsonProcessingException { + PortfolioStakingInitiateRequest request = new PortfolioStakingInitiateRequest.Builder() + .portfolioId("portfolio-123") + .idempotencyKey("idem-init-1") + .currencySymbol("ETH") + .amount("10.0") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"idempotency_key\":\"idem-init-1\"")); + assertTrue(json.contains("\"currency_symbol\":\"ETH\"")); + assertTrue(json.contains("\"amount\":\"10.0\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testPortfolioStakingInitiateResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_id\":\"act-init-1\"," + + "\"transaction_id\":\"txn-init-1\"" + + "}"; + + PortfolioStakingInitiateResponse response = objectMapper.readValue(json, PortfolioStakingInitiateResponse.class); + assertNotNull(response); + assertEquals("act-init-1", response.getActivityId()); + assertEquals("txn-init-1", response.getTransactionId()); + } + + // ==================== PortfolioStakingUnstake Tests ==================== + + @Test + public void testPortfolioStakingUnstakeRequestSerialization() throws JsonProcessingException { + PortfolioStakingUnstakeRequest request = new PortfolioStakingUnstakeRequest.Builder() + .portfolioId("portfolio-123") + .idempotencyKey("idem-unstake-1") + .currencySymbol("ETH") + .amount("5.0") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"idempotency_key\":\"idem-unstake-1\"")); + assertTrue(json.contains("\"currency_symbol\":\"ETH\"")); + assertTrue(json.contains("\"amount\":\"5.0\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testPortfolioStakingUnstakeResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_id\":\"act-unstake-1\"," + + "\"transaction_id\":\"txn-unstake-1\"" + + "}"; + + PortfolioStakingUnstakeResponse response = objectMapper.readValue(json, PortfolioStakingUnstakeResponse.class); + assertNotNull(response); + assertEquals("act-unstake-1", response.getActivityId()); + assertEquals("txn-unstake-1", response.getTransactionId()); + } + + // ==================== PreviewUnstake Tests ==================== + + @Test + public void testPreviewUnstakeRequestSerialization() throws JsonProcessingException { + PreviewUnstakeRequest request = new PreviewUnstakeRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .amount("5.0") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"amount\":\"5.0\"")); + assertFalse(json.contains("portfolio_id")); + assertFalse(json.contains("wallet_id")); + } + + @Test + public void testPreviewUnstakeResponseDeserialization() throws JsonProcessingException { + String json = "{\"estimated_amount\":\"4.9\"}"; + PreviewUnstakeResponse response = objectMapper.readValue(json, PreviewUnstakeResponse.class); + assertNotNull(response); + assertEquals("4.9", response.getEstimatedAmount()); + } + + // ==================== GetStakingStatus Tests ==================== + + @Test + public void testGetStakingStatusRequestConstruction() { + GetStakingStatusRequest request = new GetStakingStatusRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("wallet-456", request.getWalletId()); + } + + @Test + public void testGetStakingStatusResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"portfolio_id\":\"portfolio-123\"," + + "\"wallet_id\":\"wallet-456\"," + + "\"wallet_address\":\"0xabc123\"," + + "\"current_timestamp\":\"2025-01-01T00:00:00Z\"," + + "\"validators\":[" + + "{\"public_key\":\"0xpubkey1\",\"status\":\"active\"}" + + "]" + + "}"; + + GetStakingStatusResponse response = objectMapper.readValue(json, GetStakingStatusResponse.class); + assertNotNull(response); + assertEquals("portfolio-123", response.getPortfolioId()); + assertEquals("wallet-456", response.getWalletId()); + assertEquals("0xabc123", response.getWalletAddress()); + assertNotNull(response.getValidators()); + assertEquals(1, response.getValidators().size()); + } + + // ==================== GetUnstakingStatus Tests ==================== + + @Test + public void testGetUnstakingStatusRequestConstruction() { + GetUnstakingStatusRequest request = new GetUnstakingStatusRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("wallet-456", request.getWalletId()); + } + + @Test + public void testGetUnstakingStatusResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"portfolio_id\":\"portfolio-123\"," + + "\"wallet_id\":\"wallet-456\"," + + "\"wallet_address\":\"0xabc123\"," + + "\"current_timestamp\":\"2025-01-01T00:00:00Z\"," + + "\"validators\":[" + + "{\"public_key\":\"0xpubkey1\",\"exit_epoch\":\"100\"}" + + "]" + + "}"; + + GetUnstakingStatusResponse response = objectMapper.readValue(json, GetUnstakingStatusResponse.class); + assertNotNull(response); + assertEquals("portfolio-123", response.getPortfolioId()); + assertEquals("wallet-456", response.getWalletId()); + assertNotNull(response.getValidators()); + assertEquals(1, response.getValidators().size()); + } + + // ==================== ListTransactionValidators Tests ==================== + + @Test + public void testListTransactionValidatorsRequestSerialization() throws JsonProcessingException { + ListTransactionValidatorsRequest request = new ListTransactionValidatorsRequest.Builder() + .portfolioId("portfolio-123") + .transactionIds(java.util.Arrays.asList("txn-1", "txn-2")) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"transaction_ids\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testListTransactionValidatorsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"transaction_validators\":[" + + "{\"transaction_id\":\"txn-1\",\"validators\":[{\"public_key\":\"0xpub1\"}]}," + + "{\"transaction_id\":\"txn-2\",\"validators\":[{\"public_key\":\"0xpub2\"}]}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListTransactionValidatorsResponse response = objectMapper.readValue(json, ListTransactionValidatorsResponse.class); + assertNotNull(response); + assertNotNull(response.getTransactionValidators()); + assertEquals(2, response.getTransactionValidators().size()); + } +} diff --git a/src/test/java/com/coinbase/prime/transactions/TransactionsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/transactions/TransactionsServiceSerializationTest.java new file mode 100644 index 00000000..8ab58850 --- /dev/null +++ b/src/test/java/com/coinbase/prime/transactions/TransactionsServiceSerializationTest.java @@ -0,0 +1,271 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.transactions; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class TransactionsServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListPortfolioTransactions Tests ==================== + + @Test + public void testListPortfolioTransactionsRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ListPortfolioTransactionsRequest request = new ListPortfolioTransactionsRequest.Builder() + .portfolioId("portfolio-123") + .symbols(new String[]{"BTC", "ETH"}) + .startTime("2025-01-01T00:00:00Z") + .endTime("2025-12-31T23:59:59Z") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"symbols\"")); + assertTrue(json.contains("\"start_time\":\"2025-01-01T00:00:00Z\"")); + assertTrue(json.contains("\"end_time\":\"2025-12-31T23:59:59Z\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testListPortfolioTransactionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"transactions\":[" + + "{\"id\":\"txn-1\",\"type\":\"DEPOSIT\",\"status\":\"TRANSACTION_DONE\"}," + + "{\"id\":\"txn-2\",\"type\":\"WITHDRAWAL\",\"status\":\"TRANSACTION_PROCESSING\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"txn-cursor\",\"has_next\":true}" + + "}"; + + ListPortfolioTransactionsResponse response = objectMapper.readValue(json, ListPortfolioTransactionsResponse.class); + assertNotNull(response); + assertNotNull(response.getTransactions()); + assertEquals(2, response.getTransactions().length); + assertNotNull(response.getPagination()); + } + + // ==================== GetTransaction Tests ==================== + + @Test + public void testGetTransactionRequestConstruction() throws CoinbaseClientException { + GetTransactionRequest request = new GetTransactionRequest.Builder("portfolio-123", "txn-456").build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("txn-456", request.getTransactionId()); + } + + @Test + public void testGetTransactionResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"transaction\":{" + + "\"id\":\"txn-456\"," + + "\"type\":\"DEPOSIT\"," + + "\"status\":\"TRANSACTION_DONE\"," + + "\"amount\":\"1.5\"," + + "\"symbol\":\"BTC\"" + + "}" + + "}"; + + GetTransactionResponse response = objectMapper.readValue(json, GetTransactionResponse.class); + assertNotNull(response); + assertNotNull(response.getTransaction()); + assertEquals("txn-456", response.getTransaction().getId()); + } + + // ==================== CreateConversion Tests ==================== + + @Test + public void testCreateConversionRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + CreateConversionRequest request = new CreateConversionRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .amount("100.0") + .destination("wallet-789") + .sourceSymbol("USD") + .destinationSymbol("USDC") + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"amount\":\"100.0\"")); + assertTrue(json.contains("\"destination\":\"wallet-789\"")); + assertTrue(json.contains("\"source_symbol\":\"USD\"")); + assertTrue(json.contains("\"destination_symbol\":\"USDC\"")); + assertFalse(json.contains("\"portfolio_id\"")); + assertFalse(json.contains("\"wallet_id\"")); + } + + @Test + public void testCreateConversionResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_id\":\"act-conv-1\"," + + "\"source_symbol\":\"USD\"," + + "\"destination_symbol\":\"USDC\"," + + "\"amount\":\"100.0\"," + + "\"destination\":\"wallet-789\"," + + "\"source\":\"wallet-456\"," + + "\"transaction_id\":\"txn-conv-1\"" + + "}"; + + CreateConversionResponse response = objectMapper.readValue(json, CreateConversionResponse.class); + assertNotNull(response); + assertEquals("act-conv-1", response.getActivityId()); + assertEquals("USD", response.getSourceSymbol()); + assertEquals("USDC", response.getDestinationSymbol()); + assertEquals("txn-conv-1", response.getTransactionId()); + } + + // ==================== CreateOnchainTransaction Tests ==================== + + @Test + public void testCreateOnchainTransactionRequestSerialization() throws JsonProcessingException, com.coinbase.core.errors.CoinbaseClientException { + com.coinbase.prime.model.RpcConfig rpc = new com.coinbase.prime.model.RpcConfig.Builder() + .url("https://rpc.example.com") + .build(); + CreateOnchainTransactionRequest request = new CreateOnchainTransactionRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .rawUnsignedTxn("0xrawunsignedtxn") + .rpc(rpc) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"raw_unsigned_txn\":\"0xrawunsignedtxn\"")); + assertFalse(json.contains("\"portfolio_id\"")); + assertFalse(json.contains("\"wallet_id\"")); + } + + @Test + public void testCreateOnchainTransactionResponseDeserialization() throws JsonProcessingException { + String json = "{\"transaction_id\":\"txn-onchain-1\"}"; + CreateOnchainTransactionResponse response = objectMapper.readValue(json, CreateOnchainTransactionResponse.class); + assertNotNull(response); + assertEquals("txn-onchain-1", response.getTransactionId()); + } + + // ==================== ListWalletTransactions Tests ==================== + + @Test + public void testListWalletTransactionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"transactions\":[" + + "{\"id\":\"txn-w1\",\"type\":\"DEPOSIT\",\"status\":\"TRANSACTION_DONE\"}," + + "{\"id\":\"txn-w2\",\"type\":\"WITHDRAWAL\",\"status\":\"TRANSACTION_PROCESSING\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListWalletTransactionsResponse response = objectMapper.readValue(json, ListWalletTransactionsResponse.class); + assertNotNull(response); + assertNotNull(response.getTransactions()); + assertEquals(2, response.getTransactions().length); + } + + // ==================== CreateWalletTransfer Tests ==================== + + @Test + public void testCreateWalletTransferResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_id\":\"act-transfer-1\"," + + "\"source_symbol\":\"BTC\"," + + "\"destination_symbol\":\"BTC\"," + + "\"amount\":\"0.5\"," + + "\"destination\":\"wallet-dest\"," + + "\"source\":\"wallet-src\"," + + "\"transaction_id\":\"txn-transfer-1\"" + + "}"; + + CreateWalletTransferResponse response = objectMapper.readValue(json, CreateWalletTransferResponse.class); + assertNotNull(response); + assertEquals("act-transfer-1", response.getActivityId()); + assertEquals("txn-transfer-1", response.getTransactionId()); + } + + // ==================== CreateWalletWithdrawal Tests ==================== + + @Test + public void testCreateWalletWithdrawalResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_id\":\"act-withdraw-1\"," + + "\"source_symbol\":\"BTC\"," + + "\"destination_symbol\":\"BTC\"," + + "\"amount\":\"0.25\"," + + "\"destination\":\"bc1qexternal\"," + + "\"source\":\"wallet-src\"," + + "\"transaction_id\":\"txn-withdraw-1\"" + + "}"; + + CreateWalletWithdrawalResponse response = objectMapper.readValue(json, CreateWalletWithdrawalResponse.class); + assertNotNull(response); + assertEquals("act-withdraw-1", response.getActivityId()); + assertEquals("txn-withdraw-1", response.getTransactionId()); + } + + // ==================== ListAdvancedTransferTransactions Tests ==================== + + @Test + public void testListAdvancedTransferTransactionsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"transactions\":[" + + "{\"id\":\"txn-at1\",\"type\":\"WITHDRAWAL\",\"status\":\"TRANSACTION_DONE\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListAdvancedTransferTransactionsResponse response = objectMapper.readValue(json, ListAdvancedTransferTransactionsResponse.class); + assertNotNull(response); + assertNotNull(response.getTransactions()); + assertEquals(1, response.getTransactions().length); + } + + // ==================== GetTransactionTravelRuleData Tests ==================== + + @Test + public void testGetTransactionTravelRuleDataResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"originator_name\":\"John Doe\"," + + "\"originator_account_number\":\"acc-123\"," + + "\"beneficiary_name\":\"Jane Smith\"," + + "\"beneficiary_account_number\":\"acc-456\"" + + "}"; + + GetTransactionTravelRuleDataResponse response = objectMapper.readValue(json, GetTransactionTravelRuleDataResponse.class); + assertNotNull(response); + } + + // ==================== SubmitDepositTravelRuleData Tests ==================== + + @Test + public void testSubmitDepositTravelRuleDataResponseDeserialization() throws JsonProcessingException { + String json = "{}"; + SubmitDepositTravelRuleDataResponse response = objectMapper.readValue(json, SubmitDepositTravelRuleDataResponse.class); + assertNotNull(response); + } +} diff --git a/src/test/java/com/coinbase/prime/users/UsersServiceSerializationTest.java b/src/test/java/com/coinbase/prime/users/UsersServiceSerializationTest.java new file mode 100644 index 00000000..0cb89572 --- /dev/null +++ b/src/test/java/com/coinbase/prime/users/UsersServiceSerializationTest.java @@ -0,0 +1,102 @@ +/* + * Copyright 2026-present Coinbase Global, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.coinbase.prime.users; + +import com.coinbase.core.errors.CoinbaseClientException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class UsersServiceSerializationTest { + + private ObjectMapper objectMapper; + + @BeforeEach + public void setUp() { + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + // ==================== ListEntityUsers Tests ==================== + + @Test + public void testListEntityUsersRequestConstruction() throws CoinbaseClientException { + ListEntityUsersRequest request = new ListEntityUsersRequest.Builder("entity-123").build(); + assertNotNull(request); + assertEquals("entity-123", request.getEntityId()); + } + + @Test + public void testListEntityUsersRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListEntityUsersRequest.Builder(null).build()); + } + + @Test + public void testListEntityUsersResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"users\":[" + + "{\"id\":\"user-1\",\"name\":\"Alice Smith\",\"role\":\"ADMIN\"}," + + "{\"id\":\"user-2\",\"name\":\"Bob Jones\",\"role\":\"AUDITOR\"}" + + "]," + + "\"pagination\":{\"has_next\":false}" + + "}"; + + ListEntityUsersResponse response = objectMapper.readValue(json, ListEntityUsersResponse.class); + assertNotNull(response); + assertNotNull(response.getUsers()); + assertEquals(2, response.getUsers().length); + assertEquals("user-1", response.getUsers()[0].getId()); + } + + // ==================== ListPortfolioUsers Tests ==================== + + @Test + public void testListPortfolioUsersRequestConstruction() throws CoinbaseClientException { + ListPortfolioUsersRequest request = new ListPortfolioUsersRequest.Builder() + .portfolioId("portfolio-123") + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + } + + @Test + public void testListPortfolioUsersRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListPortfolioUsersRequest.Builder().build()); + } + + @Test + public void testListPortfolioUsersResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"users\":[" + + "{\"id\":\"user-3\",\"name\":\"Carol White\",\"role\":\"TRADER\"}," + + "{\"id\":\"user-4\",\"name\":\"Dave Brown\",\"role\":\"AUDITOR\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"user-cursor\",\"has_next\":true}" + + "}"; + + ListPortfolioUsersResponse response = objectMapper.readValue(json, ListPortfolioUsersResponse.class); + assertNotNull(response); + assertNotNull(response.getUsers()); + assertEquals(2, response.getUsers().length); + assertNotNull(response.getPagination()); + } +} diff --git a/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java b/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java index f55a87c5..1854e4bc 100644 --- a/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java +++ b/src/test/java/com/coinbase/prime/wallets/WalletsServiceSerializationTest.java @@ -18,6 +18,7 @@ import com.coinbase.core.errors.CoinbaseClientException; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,7 +34,7 @@ public class WalletsServiceSerializationTest { @BeforeEach public void setUp() { - objectMapper = new ObjectMapper(); + objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } // ==================== CreateWalletDepositAddress Tests ==================== @@ -99,6 +100,15 @@ public void testCreateWalletDepositAddressResponseWithNullAccountIdentifier() th @Test public void testCreateWalletDepositAddressRequestBuilderValidation() { + // Missing required fields should throw + assertThrows(CoinbaseClientException.class, () -> { + new CreateWalletDepositAddressRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-123") + // missing networkId + .build(); + }); + assertThrows(CoinbaseClientException.class, () -> { new CreateWalletDepositAddressRequest.Builder() .portfolioId("portfolio-123") @@ -132,8 +142,185 @@ public void testListWalletAddressesResponseDeserialization() throws JsonProcessi assertNotNull(response); assertNotNull(response.getAddresses()); - assertEquals(2, response.getAddresses().length); - assertEquals("0xabc123", response.getAddresses()[0].getAddress()); - assertEquals("0xdef456", response.getAddresses()[1].getAddress()); + assertEquals(2, response.getAddresses().size()); + assertEquals("0xabc123", response.getAddresses().get(0).getAddress()); + assertEquals("0xdef456", response.getAddresses().get(1).getAddress()); + } + + // ==================== ListWallets Tests ==================== + + @Test + public void testListWalletsRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + ListWalletsRequest request = new ListWalletsRequest.Builder() + .portfolioId("portfolio-123") + .symbols(new String[]{"BTC", "ETH"}) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"symbols\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testListWalletsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new ListWalletsRequest.Builder().build()); + } + + @Test + public void testListWalletsResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"wallets\":[" + + "{\"id\":\"wallet-1\",\"name\":\"BTC Trading\",\"symbol\":\"BTC\",\"type\":\"TRADING\"}," + + "{\"id\":\"wallet-2\",\"name\":\"ETH Vault\",\"symbol\":\"ETH\",\"type\":\"VAULT\"}" + + "]," + + "\"pagination\":{\"next_cursor\":\"wallet-cursor\",\"has_next\":true}" + + "}"; + + ListWalletsResponse response = objectMapper.readValue(json, ListWalletsResponse.class); + assertNotNull(response); + assertNotNull(response.getWallets()); + assertEquals(2, response.getWallets().length); + assertEquals("wallet-1", response.getWallets()[0].getId()); + assertNotNull(response.getPagination()); + } + + // ==================== CreateWallet Tests ==================== + + @Test + public void testCreateWalletRequestSerialization() throws CoinbaseClientException, JsonProcessingException { + CreateWalletRequest request = new CreateWalletRequest.Builder() + .portfolioId("portfolio-123") + .name("My BTC Wallet") + .symbol("BTC") + .type(com.coinbase.prime.model.enums.WalletType.VAULT) + .build(); + + String json = objectMapper.writeValueAsString(request); + assertNotNull(json); + assertTrue(json.contains("\"name\":\"My BTC Wallet\"")); + assertTrue(json.contains("\"symbol\":\"BTC\"")); + assertTrue(json.contains("\"wallet_type\":\"VAULT\"")); + assertFalse(json.contains("portfolio_id")); + } + + @Test + public void testCreateWalletRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new CreateWalletRequest.Builder() + .portfolioId("portfolio-123") + .symbol("BTC") + .type(com.coinbase.prime.model.enums.WalletType.VAULT) + .build()); + + assertThrows(CoinbaseClientException.class, () -> + new CreateWalletRequest.Builder() + .portfolioId("portfolio-123") + .name("My Wallet") + .type(com.coinbase.prime.model.enums.WalletType.VAULT) + .build()); + } + + @Test + public void testCreateWalletResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"activity_id\":\"act-wallet-1\"," + + "\"name\":\"My BTC Wallet\"," + + "\"symbol\":\"BTC\"," + + "\"wallet_type\":\"VAULT\"," + + "\"network_family\":\"NETWORK_FAMILY_EVM\"" + + "}"; + + CreateWalletResponse response = objectMapper.readValue(json, CreateWalletResponse.class); + assertNotNull(response); + assertEquals("act-wallet-1", response.getActivityId()); + assertEquals("My BTC Wallet", response.getName()); + assertEquals("BTC", response.getSymbol()); + } + + // ==================== GetWallet Tests ==================== + + @Test + public void testGetWalletRequestConstruction() throws CoinbaseClientException { + GetWalletRequest request = new GetWalletRequest.Builder("portfolio-123", "wallet-456").build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("wallet-456", request.getWalletId()); + } + + @Test + public void testGetWalletResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"wallet\":{" + + "\"id\":\"wallet-456\"," + + "\"name\":\"My BTC Wallet\"," + + "\"symbol\":\"BTC\"," + + "\"type\":\"VAULT\"" + + "}" + + "}"; + + GetWalletResponse response = objectMapper.readValue(json, GetWalletResponse.class); + assertNotNull(response); + assertNotNull(response.getWallet()); + assertEquals("wallet-456", response.getWallet().getId()); + } + + // ==================== GetWalletDepositInstructions Tests ==================== + + @Test + public void testGetWalletDepositInstructionsRequestConstruction() throws CoinbaseClientException { + GetWalletDepositInstructionsRequest request = new GetWalletDepositInstructionsRequest.Builder() + .portfolioId("portfolio-123") + .walletId("wallet-456") + .depositType(com.coinbase.prime.model.enums.WalletDepositInstructionType.CRYPTO) + .build(); + assertNotNull(request); + assertEquals("portfolio-123", request.getPortfolioId()); + assertEquals("wallet-456", request.getWalletId()); + assertEquals(com.coinbase.prime.model.enums.WalletDepositInstructionType.CRYPTO, request.getDepositType()); + } + + @Test + public void testGetWalletDepositInstructionsRequestBuilderValidation() { + assertThrows(CoinbaseClientException.class, () -> + new GetWalletDepositInstructionsRequest.Builder() + .walletId("wallet-456") + .depositType(com.coinbase.prime.model.enums.WalletDepositInstructionType.CRYPTO) + .build()); + } + + @Test + public void testGetWalletDepositInstructionsCryptoResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"crypto_instructions\":{" + + "\"address\":\"0xabc123\"," + + "\"account_identifier\":\"memo-xyz\"," + + "\"destination_tag\":\"12345\"," + + "\"network\":{\"id\":\"ethereum\",\"type\":\"mainnet\"}" + + "}" + + "}"; + + GetWalletDepositInstructionsResponse response = objectMapper.readValue(json, GetWalletDepositInstructionsResponse.class); + assertNotNull(response); + assertNotNull(response.getCryptoDepositInstructions()); + assertEquals("0xabc123", response.getCryptoDepositInstructions().getAddress()); + assertNull(response.getFiatDepositInstructions()); + } + + @Test + public void testGetWalletDepositInstructionsFiatResponseDeserialization() throws JsonProcessingException { + String json = "{" + + "\"fiat_instructions\":{" + + "\"account_number\":\"123456789\"," + + "\"routing_number\":\"021000021\"," + + "\"reference\":\"REF-001\"" + + "}" + + "}"; + + GetWalletDepositInstructionsResponse response = objectMapper.readValue(json, GetWalletDepositInstructionsResponse.class); + assertNotNull(response); + assertNotNull(response.getFiatDepositInstructions()); + assertNull(response.getCryptoDepositInstructions()); } }