Package org.stellar.sdk.requests
Class OffersRequestBuilder
java.lang.Object
org.stellar.sdk.requests.RequestBuilder
org.stellar.sdk.requests.OffersRequestBuilder
Builds requests connected to offers.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.stellar.sdk.requests.RequestBuilder
RequestBuilder.Order
-
Constructor Summary
ConstructorDescriptionOffersRequestBuilder
(okhttp3.OkHttpClient httpClient, okhttp3.HttpUrl serverURI) -
Method Summary
Modifier and TypeMethodDescriptionSetscursor
parameter on the request.execute()
Build and execute request.static Page
<OfferResponse> execute
(okhttp3.OkHttpClient httpClient, okhttp3.HttpUrl uri) forBuyingAsset
(Asset asset) Returns all offers buying an asset.Returns all offers where the given account is the seller.forSellingAsset
(Asset asset) Returns all offers selling an asset.forSponsor
(String sponsor) Returns all offers sponsored by a given account.limit
(int number) Setslimit
parameter on the request.offer
(long offerId) The offer details endpoint provides information on a single offer.offer
(okhttp3.HttpUrl uri) Requests specificuri
and returnsOfferResponse
.order
(RequestBuilder.Order direction) Setsorder
parameter on the request.stream
(EventListener<OfferResponse> listener) An overloaded version ofstream(EventListener, long)
with default reconnect timeout.stream
(EventListener<OfferResponse> listener, long reconnectTimeout) Allows to stream SSE events from horizon.Methods inherited from class org.stellar.sdk.requests.RequestBuilder
setAssetParameter, setAssetsParameter
-
Constructor Details
-
OffersRequestBuilder
public OffersRequestBuilder(okhttp3.OkHttpClient httpClient, okhttp3.HttpUrl serverURI)
-
-
Method Details
-
offer
Requests specificuri
and returnsOfferResponse
. This method is helpful for getting the links.- Returns:
OfferResponse
- Throws:
NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
offer
The offer details endpoint provides information on a single offer.- Parameters:
offerId
- specifies which offer to load.- Returns:
OfferResponse
- Throws:
NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
forSponsor
Returns all offers sponsored by a given account.- Parameters:
sponsor
- Account ID of the sponsor.- Returns:
- current
OffersRequestBuilder
instance - See Also:
-
forSeller
Returns all offers where the given account is the seller.- Parameters:
seller
- Account ID of the offer creator.- Returns:
- current
OffersRequestBuilder
instance - See Also:
-
forBuyingAsset
Returns all offers buying an asset.- Parameters:
asset
- The Asset being bought.- Returns:
- current
OffersRequestBuilder
instance - See Also:
-
forSellingAsset
Returns all offers selling an asset.- Parameters:
asset
- The Asset being sold.- Returns:
- current
OffersRequestBuilder
instance - See Also:
-
execute
Requests specificuri
and returnsPage
ofOfferResponse
. This method is helpful for getting the next set of results.- Parameters:
httpClient
-OkHttpClient
to use to send the request.uri
-HttpUrl
URI to send the request to.- Returns:
Page
ofOfferResponse
- Throws:
NetworkException
- All the exceptions below are subclasses of NetworkErrorBadRequestException
- if the request fails due to a bad request (4xx)BadResponseException
- if the request fails due to a bad response from the server (5xx)TooManyRequestsException
- if the request fails due to too many requests sent to the serverRequestTimeoutException
- When Horizon returns aTimeout
or connection timeout occurredUnknownResponseException
- if the server returns an unknown status codeConnectionErrorException
- When the request cannot be executed due to cancellation or connectivity problems, etc.
-
stream
public SSEStream<OfferResponse> stream(EventListener<OfferResponse> listener, long reconnectTimeout) Allows to stream SSE events from horizon. Certain endpoints in Horizon can be called in streaming mode using Server-Sent Events. This mode will keep the connection to horizon open and horizon will continue to return responses as ledgers close.- Parameters:
listener
-EventListener
implementation withOfferResponse
typereconnectTimeout
- Custom stream connection timeout in ms- Returns:
- EventSource object, so you can
close()
connection when not needed anymore - See Also:
-
stream
An overloaded version ofstream(EventListener, long)
with default reconnect timeout. -
execute
Build and execute request.- Returns:
Page
ofOfferResponse
- Throws:
TooManyRequestsException
- when too many requests were sent to the Horizon server.ConnectionErrorException
- if the request fails due to an IOException, including but not limited to a timeout, connection failure etc.
-
cursor
Description copied from class:RequestBuilder
Setscursor
parameter on the request. A cursor is a value that points to a specific location in a collection of resources. The cursor attribute itself is an opaque value meaning that users should not try to parse it.- Overrides:
cursor
in classRequestBuilder
- Parameters:
token
- A cursor is a value that points to a specific location in a collection of resources.- See Also:
-
limit
Description copied from class:RequestBuilder
Setslimit
parameter on the request. It defines maximum number of records to return. For range and default values check documentation of the endpoint requested.- Overrides:
limit
in classRequestBuilder
- Parameters:
number
- maxium number of records to return
-
order
Description copied from class:RequestBuilder
Setsorder
parameter on the request.- Overrides:
order
in classRequestBuilder
- Parameters:
direction
-RequestBuilder.Order
-