Skip to content

Commit 9be24d8

Browse files
authored
Merge pull request #29 from coinbase-samples/null-fix
chore: fix null reference and add tests
2 parents eacd0fe + c7a642d commit 9be24d8

25 files changed

+848
-33
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [1.5.3] - 2025-11-05
4+
5+
### Fixed
6+
- Fixed not passing request in GetWalletDepositInstructions
7+
8+
### Added
9+
- Unit tests and examples for several endpoints
10+
311
## [1.5.2] - 2025-11-04
412

513
### Changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<description>Sample Java SDK for the Coinbase Prime REST APIs</description>
2222
<groupId>com.coinbase.prime</groupId>
2323
<url>https://github.com/coinbase-samples/prime-sdk-java</url>
24-
<version>1.5.2</version>
24+
<version>1.5.3</version>
2525
<licenses>
2626
<license>
2727
<name>Apache License, Version 2.0</name>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.activities;
18+
19+
import com.coinbase.prime.activities.ActivitiesService;
20+
import com.coinbase.prime.activities.GetActivityRequest;
21+
import com.coinbase.prime.activities.GetActivityResponse;
22+
import com.coinbase.prime.client.CoinbasePrimeClient;
23+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
24+
import com.coinbase.prime.factory.PrimeServiceFactory;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class GetActivityExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String activityId = args.length > 0 ? args[0] : "activity-id";
33+
34+
ActivitiesService service = PrimeServiceFactory.createActivitiesService(client);
35+
GetActivityResponse response = service.getActivity(new GetActivityRequest(activityId));
36+
37+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
38+
} catch (Exception e) {
39+
e.printStackTrace();
40+
}
41+
}
42+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.activities;
18+
19+
import com.coinbase.prime.activities.ActivitiesService;
20+
import com.coinbase.prime.activities.ListPortfolioActivitiesRequest;
21+
import com.coinbase.prime.activities.ListPortfolioActivitiesResponse;
22+
import com.coinbase.prime.client.CoinbasePrimeClient;
23+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
24+
import com.coinbase.prime.factory.PrimeServiceFactory;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class ListPortfolioActivitiesExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID");
33+
34+
ActivitiesService service = PrimeServiceFactory.createActivitiesService(client);
35+
ListPortfolioActivitiesResponse response = service.listPortfolioActivities(
36+
new ListPortfolioActivitiesRequest.Builder(portfolioId).build());
37+
38+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
39+
} catch (Exception e) {
40+
e.printStackTrace();
41+
}
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.allocations;
18+
19+
import com.coinbase.prime.allocations.AllocationsService;
20+
import com.coinbase.prime.allocations.ListPortfolioAllocationsRequest;
21+
import com.coinbase.prime.allocations.ListPortfolioAllocationsResponse;
22+
import com.coinbase.prime.client.CoinbasePrimeClient;
23+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
24+
import com.coinbase.prime.factory.PrimeServiceFactory;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class ListPortfolioAllocationsExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID");
33+
34+
AllocationsService service = PrimeServiceFactory.createAllocationsService(client);
35+
ListPortfolioAllocationsResponse response = service.getPortfolioAllocations(
36+
new ListPortfolioAllocationsRequest.Builder(portfolioId).build());
37+
38+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
39+
} catch (Exception e) {
40+
e.printStackTrace();
41+
}
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.assets;
18+
19+
import com.coinbase.prime.assets.AssetsService;
20+
import com.coinbase.prime.assets.ListAssetsRequest;
21+
import com.coinbase.prime.assets.ListAssetsResponse;
22+
import com.coinbase.prime.client.CoinbasePrimeClient;
23+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
24+
import com.coinbase.prime.factory.PrimeServiceFactory;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class ListAssetsExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID");
33+
34+
AssetsService service = PrimeServiceFactory.createAssetsService(client);
35+
ListAssetsResponse response = service.listAssets(
36+
new ListAssetsRequest.Builder(entityId).build());
37+
38+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
39+
} catch (Exception e) {
40+
e.printStackTrace();
41+
}
42+
}
43+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.balances;
18+
19+
import com.coinbase.prime.balances.BalancesService;
20+
import com.coinbase.prime.balances.ListPortfolioBalancesRequest;
21+
import com.coinbase.prime.balances.ListPortfolioBalancesResponse;
22+
import com.coinbase.prime.client.CoinbasePrimeClient;
23+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
24+
import com.coinbase.prime.factory.PrimeServiceFactory;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class ListPortfolioBalancesExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID");
33+
34+
BalancesService service = PrimeServiceFactory.createBalancesService(client);
35+
ListPortfolioBalancesResponse response = service.listPortfolioBalances(
36+
new ListPortfolioBalancesRequest.Builder()
37+
.portfolioId(portfolioId)
38+
.build());
39+
40+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
41+
} catch (Exception e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.commission;
18+
19+
import com.coinbase.prime.client.CoinbasePrimeClient;
20+
import com.coinbase.prime.commission.CommissionService;
21+
import com.coinbase.prime.commission.GetPortfolioCommissionRequest;
22+
import com.coinbase.prime.commission.GetPortfolioCommissionResponse;
23+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
24+
import com.coinbase.prime.factory.PrimeServiceFactory;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class GetPortfolioCommissionExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String portfolioId = System.getenv("COINBASE_PRIME_PORTFOLIO_ID");
33+
34+
CommissionService service = PrimeServiceFactory.createCommissionService(client);
35+
GetPortfolioCommissionResponse response = service.getPortfolioCommission(
36+
new GetPortfolioCommissionRequest.Builder()
37+
.portfolioId(portfolioId)
38+
.build());
39+
40+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
41+
} catch (Exception e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.financing;
18+
19+
import com.coinbase.prime.client.CoinbasePrimeClient;
20+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
21+
import com.coinbase.prime.factory.PrimeServiceFactory;
22+
import com.coinbase.prime.financing.FinancingService;
23+
import com.coinbase.prime.financing.GetMarginInformationRequest;
24+
import com.coinbase.prime.financing.GetMarginInformationResponse;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class GetMarginInformationExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID");
33+
34+
FinancingService service = PrimeServiceFactory.createFinancingService(client);
35+
GetMarginInformationResponse response = service.getMarginInformation(
36+
new GetMarginInformationRequest.Builder()
37+
.entityId(entityId)
38+
.build());
39+
40+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
41+
} catch (Exception e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2025-present Coinbase Global, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.coinbase.examples.futures;
18+
19+
import com.coinbase.prime.client.CoinbasePrimeClient;
20+
import com.coinbase.prime.credentials.CoinbasePrimeCredentials;
21+
import com.coinbase.prime.factory.PrimeServiceFactory;
22+
import com.coinbase.prime.futures.FuturesService;
23+
import com.coinbase.prime.futures.GetEntityFcmBalanceRequest;
24+
import com.coinbase.prime.futures.GetEntityFcmBalanceResponse;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
26+
27+
public class GetEntityFcmBalanceExample {
28+
public static void main(String[] args) {
29+
try {
30+
CoinbasePrimeCredentials credentials = new CoinbasePrimeCredentials(System.getenv("COINBASE_PRIME_CREDENTIALS"));
31+
CoinbasePrimeClient client = new CoinbasePrimeClient(credentials);
32+
String entityId = System.getenv("COINBASE_PRIME_ENTITY_ID");
33+
34+
FuturesService service = PrimeServiceFactory.createFuturesService(client);
35+
GetEntityFcmBalanceResponse response = service.getEntityFcmBalance(
36+
new GetEntityFcmBalanceRequest.Builder()
37+
.entityId(entityId)
38+
.build());
39+
40+
System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response));
41+
} catch (Exception e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)