forked from Petersoj/alpaca-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountEndpoint.java
More file actions
39 lines (35 loc) · 1.27 KB
/
Copy pathAccountEndpoint.java
File metadata and controls
39 lines (35 loc) · 1.27 KB
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
39
package net.jacobpeterson.alpaca.rest.endpoint.account;
import net.jacobpeterson.alpaca.model.endpoint.account.Account;
import net.jacobpeterson.alpaca.rest.AlpacaClient;
import net.jacobpeterson.alpaca.rest.AlpacaClientException;
import net.jacobpeterson.alpaca.rest.endpoint.AlpacaEndpoint;
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);
}
}