public class FlattrConnection extends Object implements Connection
Connection
.Constructor and Description |
---|
FlattrConnection(RequestType type)
Creates a new
FlattrConnection for the given RequestType . |
Modifier and Type | Method and Description |
---|---|
Connection |
call(String call)
Call to be placed against the URL.
|
protected org.apache.http.impl.client.AbstractHttpClient |
createHttpClient()
Creates a
AbstractHttpClient for sending the request. |
Connection |
data(FlattrObject data)
Data to be transported to the call.
|
protected void |
disposeHttpClient(org.apache.http.impl.client.AbstractHttpClient cl)
Disposes a
AbstractHttpClient , releasing all resources. |
Connection |
form(String name,
String value)
Form parameter to be sent.
|
Connection |
key(ConsumerKey key)
Consumer key to be used.
|
Connection |
parameter(String name,
String value)
A parameter to be used for a placeholder in the call string.
|
Connection |
parameterArray(String name,
String[] value)
An array of parameters to be used for a placeholder in the call string.
|
Connection |
query(String name,
String value)
Query parameter to be used in the URL.
|
Connection |
rateLimit(RateLimit limit)
RateLimit object to keep updated. |
Collection<FlattrObject> |
result()
Invokes the call and returns a Collection of
FlattrObject as response. |
FlattrObject |
singleResult()
Invokes the call and returns a single
FlattrObject as response. |
Connection |
token(AccessToken token)
Access token to be used for calls that require authentication.
|
Connection |
url(String url)
Base URL to connect to.
|
public FlattrConnection(RequestType type)
FlattrConnection
for the given RequestType
.type
- RequestType
to be usedpublic Connection url(String url)
Connection
url
in interface Connection
url
- URL to connect to.public Connection call(String call)
Connection
If no call is set, the Connection.url(String)
is invoked unchanged.
call
in interface Connection
call
- Signature of the call to be invokedpublic Connection token(AccessToken token)
Connection
AccessToken
is set, the call will be placed anonymously.token
in interface Connection
token
- AccessToken
to be usedpublic Connection key(ConsumerKey key)
Connection
key
in interface Connection
key
- ConsumerKey
to be usedpublic Connection parameter(String name, String value)
Connection
parameter
in interface Connection
name
- Parameter name, without colon prependedvalue
- Value to be used. Will be URL encoded.public Connection parameterArray(String name, String[] value)
Connection
parameterArray
in interface Connection
name
- Parameter name, without colon prependedvalue
- Values to be used.public Connection query(String name, String value)
Connection
query
in interface Connection
name
- Parameter namevalue
- Parameter valuepublic Connection data(FlattrObject data)
Connection
RequestType.POST
or
RequestType.PATCH
, otherwise an exception will be thrown.data
in interface Connection
data
- Data to be sentpublic Connection form(String name, String value)
Connection
RequestType.POST
, otherwise an
exception will be thrown. Do not mix with Connection.data(FlattrObject)
.form
in interface Connection
name
- Parameter namevalue
- Parameter valuepublic Connection rateLimit(RateLimit limit)
Connection
RateLimit
object to keep updated.rateLimit
in interface Connection
limit
- RateLimit
objectpublic Collection<FlattrObject> result() throws FlattrException
Connection
FlattrObject
as response.result
in interface Connection
FlattrObject
, may be empty but never
null
FlattrException
- if the call could not be invoked or the web service returned an errorpublic FlattrObject singleResult() throws FlattrException
Connection
FlattrObject
as response.singleResult
in interface Connection
FlattrObject
, never null
FlattrException
- if the call could not be invoked or the web service returned an errorprotected org.apache.http.impl.client.AbstractHttpClient createHttpClient()
AbstractHttpClient
for sending the request.AbstractHttpClient
protected void disposeHttpClient(org.apache.http.impl.client.AbstractHttpClient cl)
AbstractHttpClient
, releasing all resources.cl
- AbstractHttpClient
to releaseCopyright © 2010–2014. All rights reserved.