forked from Petersoj/alpaca-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountEndpoint.java
38 lines (34 loc) · 1.2 KB
/
AccountEndpoint.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package net.jacobpeterson.alpaca.rest.endpoint;
import net.jacobpeterson.alpaca.model.endpoint.account.Account;
import net.jacobpeterson.alpaca.rest.AlpacaClient;
import net.jacobpeterson.alpaca.rest.AlpacaClientException;
import okhttp3.HttpUrl;
import okhttp3.Request;
/**
* {@link AlpacaEndpoint} for <a href="https://docs.alpaca.markets/api-documentation/api-v2/account/">Account</a>.
*/
public class AccountEndpoint extends AlpacaEndpoint {
/**
* Instantiates a new {@link AccountEndpoint}.
*
* @param alpacaClient the {@link AlpacaClient}
*/
public AccountEndpoint(AlpacaClient alpacaClient) {
super(alpacaClient, "account");
}
/**
* Returns the {@link Account}.
*
* @return the {@link Account}
*
* @throws AlpacaClientException thrown for {@link AlpacaClientException}s
*/
public Account get() throws AlpacaClientException {
HttpUrl.Builder urlBuilder = alpacaClient.urlBuilder()
.addPathSegment(endpointPathSegment);
Request request = alpacaClient.requestBuilder(urlBuilder.build())
.get()
.build();
return alpacaClient.requestObject(request, Account.class);
}
}