public class FlattrServiceImpl extends Object implements FlattrService
FlattrService
.Constructor and Description |
---|
FlattrServiceImpl(Connector connector) |
Modifier and Type | Method and Description |
---|---|
ThingId |
create(Submission thing)
Creates a new Thing.
|
void |
delete(ThingId thingId)
Deletes a Thing.
|
MiniThing |
flattr(AutoSubmission submission)
Flattrs an
AutoSubmission . |
MiniThing |
flattr(String url)
Flattrs a URL.
|
MiniThing |
flattr(ThingId thingId)
Flattrs a Thing.
|
List<Activity> |
getActivities(UserId user,
Activity.Type type)
Returns all
Activity of the given user ID. |
List<Category> |
getCategories()
Gets a list of all Flattr
Category . |
protected Connector |
getConnector()
Returns the
Connector used for calling the API. |
RateLimit |
getCurrentRateLimit()
Gets the current rate limit from the server.
|
List<Flattr> |
getFlattrs(ThingId thingId)
Gets all
Flattr most recently posted for the given thing ID. |
List<Flattr> |
getFlattrs(ThingId thingId,
Integer count,
Integer page)
Gets all
Flattr most recently posted for the given thing ID. |
List<Flattr> |
getFlattrs(UserId user)
Gets all
Flattr most recently posted by the given user ID. |
List<Flattr> |
getFlattrs(UserId userId,
Integer count,
Integer page)
Gets all
Flattr most recently posted by the given user ID. |
List<Language> |
getLanguages()
Gets a list of all Flattr
Language . |
RateLimit |
getLastRateLimit()
Gets a
RateLimit instance that reflects the rate limit and remaining rate
returned by the last API call. |
List<Activity> |
getMyActivities(Activity.Type type)
Returns all
Activity of the associated user. |
List<Flattr> |
getMyFlattrs()
Returns all
Flattr submitted by the associated user. |
List<Flattr> |
getMyFlattrs(Integer count,
Integer page)
Returns all
Flattr submitted by the associated user. |
User |
getMyself()
Gets the
User profile of the associated user. |
List<Subscription> |
getMySubscriptions()
Returns all
Subscription of the associated user. |
List<Thing> |
getMyThings()
Returns all
Thing submitted by the associated user. |
List<Thing> |
getMyThings(Integer count,
Integer page)
Returns all
Thing submitted by the associated user. |
Subscription |
getSubscription(ThingId thingId)
Returns the
Subscription of the given Thing . |
Thing |
getThing(ThingId thingId)
|
Thing |
getThingBySubmission(AutoSubmission submission)
Gets a
Thing by its autosubmit URL. |
Thing |
getThingByUrl(String url)
Gets a
Thing by its registered URL. |
List<Thing> |
getThings(Collection<? extends ThingId> thingIds)
Gets a list of
Thing by a collection of thing IDs. |
List<Thing> |
getThings(UserId user)
Gets a list of
Thing most recently submitted by the given user. |
List<Thing> |
getThings(UserId user,
Integer count,
Integer page)
Gets a list of
Thing most recently submitted by the given user. |
User |
getUser(UserId user)
Gets the
User profile of the given user ID. |
boolean |
isFullMode()
Is the full mode currently enabled?
|
void |
pauseSubscription(ThingId thingId,
boolean paused)
Pauses or resumes a
Subscription . |
SearchResult |
searchThings(SearchQuery query,
Integer count,
Integer page)
Searches for
Thing . |
void |
setFullMode(boolean full)
Sets the full mode.
|
protected void |
setupFullMode(Connection conn)
Sets the
Connection according to the current full mode. |
void |
subscribe(ThingId thingId)
Subscribes a
Thing . |
boolean |
toggleSubscription(ThingId thingId)
Toggles the pause state of the subscription of the given
Thing . |
void |
unsubscribe(ThingId thingId)
Cancels subscription of a
Thing . |
void |
update(Thing thing)
Updates a Thing.
|
public FlattrServiceImpl(Connector connector)
protected Connector getConnector()
Connector
used for calling the API.Connector
public void setFullMode(boolean full)
FlattrService
false
.setFullMode
in interface FlattrService
full
- true
: use full requests, false
: use standard requestspublic boolean isFullMode()
FlattrService
isFullMode
in interface FlattrService
true
: full requests, false
: standard requestspublic ThingId create(Submission thing) throws FlattrException
FlattrService
create
in interface FlattrService
thing
- Submission
to be submittedThingId
of the Thing
that was createdFlattrException
public void update(Thing thing) throws FlattrException
FlattrService
update
in interface FlattrService
thing
- Thing
to be modifiedFlattrException
public void delete(ThingId thingId) throws FlattrException
FlattrService
delete
in interface FlattrService
thingId
- ThingId
to deleteFlattrException
public MiniThing flattr(AutoSubmission submission) throws FlattrException
FlattrService
AutoSubmission
. If the submission has not been submitted to
Flattr yet, it will automatically be submitted before.flattr
in interface FlattrService
submission
- AutoSubmission
to flattrMiniThing
of the flattr-ed thing (containing an updated click
count)FlattrException
public MiniThing flattr(String url) throws FlattrException
FlattrService
flattr
in interface FlattrService
url
- URL to flattrMiniThing
of the flattr-ed thing (containing an updated click
count)FlattrException
public MiniThing flattr(ThingId thingId) throws FlattrException
FlattrService
flattr
in interface FlattrService
thingId
- ThingId
to flattrMiniThing
of the flattr-ed thing (containing an updated click
count)FlattrException
public User getMyself() throws FlattrException
FlattrService
User
profile of the associated user.getMyself
in interface FlattrService
User
profile of oneselfFlattrException
public List<Thing> getMyThings() throws FlattrException
FlattrService
Thing
submitted by the associated user. Limited to 30 entries.getMyThings
in interface FlattrService
Thing
FlattrException
public List<Thing> getMyThings(Integer count, Integer page) throws FlattrException
FlattrService
Thing
submitted by the associated user.getMyThings
in interface FlattrService
count
- Number of entries per page, null
defaults to 30 entriespage
- Page number (counted from 1), or null
to turn off pagingThing
FlattrException
public List<Flattr> getMyFlattrs() throws FlattrException
FlattrService
Flattr
submitted by the associated user. Limited to 30 entries.getMyFlattrs
in interface FlattrService
Flattr
FlattrException
public List<Flattr> getMyFlattrs(Integer count, Integer page) throws FlattrException
FlattrService
Flattr
submitted by the associated user.getMyFlattrs
in interface FlattrService
count
- Number of entries per page, null
defaults to 30 entriespage
- Page number (counted from 1), or null
to turn off pagingFlattr
FlattrException
public Thing getThing(ThingId thingId) throws FlattrException
FlattrService
getThing
in interface FlattrService
thingId
- ThingId
of the Thing to be fetchedThing
FlattrException
public Thing getThingByUrl(String url) throws FlattrException
FlattrService
Thing
by its registered URL.getThingByUrl
in interface FlattrService
url
- Thing's URLThing
of the URL that was found, null
if nothing was foundFlattrException
public Thing getThingBySubmission(AutoSubmission submission) throws FlattrException
FlattrService
Thing
by its autosubmit URL.
Uses two rates!
getThingBySubmission
in interface FlattrService
submission
- AutoSubmission
to check forThing
of the submission if found, null
if nothing was foundFlattrException
public List<Thing> getThings(UserId user) throws FlattrException
FlattrService
Thing
most recently submitted by the given user. This list
is limited to 30 entries.getThings
in interface FlattrService
user
- UserId
to find the Things ofThing
submitted by the userFlattrException
public List<Thing> getThings(UserId user, Integer count, Integer page) throws FlattrException
FlattrService
Thing
most recently submitted by the given user.getThings
in interface FlattrService
user
- UserId
to find the Things ofcount
- Number of entries per page, null
defaults to 30 entriespage
- Page number (counted from 1), or null
to turn off pagingThing
submitted by the userFlattrException
public List<Thing> getThings(Collection<? extends ThingId> thingIds) throws FlattrException
FlattrService
Thing
by a collection of thing IDs.getThings
in interface FlattrService
thingIds
- Collection of ThingId
. The order of Thing
returned may
not match the order of the provided IDs.Thing
fetchedFlattrException
public SearchResult searchThings(SearchQuery query, Integer count, Integer page) throws FlattrException
FlattrService
Thing
.searchThings
in interface FlattrService
query
- SearchQuery
, or null
to search for everythingcount
- Number of entries per page, null
defaults to 30 entriespage
- Page number (counted from 1), or null
to turn off pagingSearchResult
FlattrException
public User getUser(UserId user) throws FlattrException
FlattrService
User
profile of the given user ID.getUser
in interface FlattrService
user
- UserId
to get a profile forUser
profile of that userFlattrException
public List<Flattr> getFlattrs(UserId user) throws FlattrException
FlattrService
Flattr
most recently posted by the given user ID. Limited to 30
results.getFlattrs
in interface FlattrService
user
- UserId
to get the result forFlattr
posted by the userFlattrException
public List<Flattr> getFlattrs(UserId userId, Integer count, Integer page) throws FlattrException
FlattrService
Flattr
most recently posted by the given user ID.getFlattrs
in interface FlattrService
userId
- UserId
to get the result forcount
- Number of entries per page, null
defaults to 30 entriespage
- Page number (counted from 1), or null
to turn off pagingFlattr
posted by the userFlattrException
public List<Flattr> getFlattrs(ThingId thingId) throws FlattrException
FlattrService
Flattr
most recently posted for the given thing ID.getFlattrs
in interface FlattrService
thingId
- ThingId
to get the result forFlattr
posted by the userFlattrException
public List<Flattr> getFlattrs(ThingId thingId, Integer count, Integer page) throws FlattrException
FlattrService
Flattr
most recently posted for the given thing ID.getFlattrs
in interface FlattrService
thingId
- ThingId
to get the result forcount
- Number of entries per page, null
defaults to 30 entriespage
- Page number (counted from 1), or null
to turn off pagingFlattr
posted by the userFlattrException
public List<Activity> getActivities(UserId user, Activity.Type type) throws FlattrException
FlattrService
Activity
of the given user ID.getActivities
in interface FlattrService
user
- UserId
to get the result fortype
- activity type. null
defaults to Activity.Type#OUTGOING
.Activity
FlattrException
public List<Activity> getMyActivities(Activity.Type type) throws FlattrException
FlattrService
Activity
of the associated user.getMyActivities
in interface FlattrService
type
- activity type. null
defaults to Activity.Type#OUTGOING
.Activity
FlattrException
public List<Subscription> getMySubscriptions() throws FlattrException
FlattrService
Subscription
of the associated user.getMySubscriptions
in interface FlattrService
Subscription
FlattrException
public Subscription getSubscription(ThingId thingId) throws FlattrException
FlattrService
Subscription
of the given Thing
. Only the subscriptions
of the associated user are accessible.
Note: This call is emulated by flattr4j. Depending on the number of subscriptions of the associated user, this call may take some time and cause increased network traffic. It may also increment the rate counter by more than 1.
getSubscription
in interface FlattrService
thingId
- ThingId
to get the subscription ofSubscription
of this thing, or null
if there is no such
subscriptionFlattrException
public void subscribe(ThingId thingId) throws FlattrException
FlattrService
Thing
.subscribe
in interface FlattrService
thingId
- ThingId
to subscribeFlattrException
public void unsubscribe(ThingId thingId) throws FlattrException
FlattrService
Thing
.unsubscribe
in interface FlattrService
thingId
- ThingId
to unsubscribedFlattrException
public boolean toggleSubscription(ThingId thingId) throws FlattrException
FlattrService
Thing
.toggleSubscription
in interface FlattrService
thingId
- ThingId
of the thing to toggle the pause state oftrue
if the subscription is now paused, false
if the
subscription was resumed.FlattrException
public void pauseSubscription(ThingId thingId, boolean paused) throws FlattrException
FlattrService
Subscription
. If the subscription is already in the
desired state, nothing will happen.
Note: There is currently no way to explicitely set the pause state of a subscription via Flattr API. flattr4j emulates this call by toggling the pause state to get the current state, and if necessary, toggling it again to set the subscription to the desired state (which means that the rate counter is incremented by 2). This call is not atomic. If the second toggle call should fail, it will leave the subscription in the opposite state.
pauseSubscription
in interface FlattrService
thingId
- ThingId
of the thing to set the pause statepaused
- true
: pause subscription, false
: resume subscriptionFlattrException
public List<Category> getCategories() throws FlattrException
FlattrService
Category
.
Note: The result is not cached.
getCategories
in interface FlattrService
Category
.FlattrException
public List<Language> getLanguages() throws FlattrException
FlattrService
Language
.
Note: The result is not cached.
getLanguages
in interface FlattrService
Language
.FlattrException
public RateLimit getCurrentRateLimit() throws FlattrException
FlattrService
Unlike FlattrService.getLastRateLimit()
, this call actively queries the current rate
limits from the server.
FlattrService.getLastRateLimit()
is untouched by this call.
getCurrentRateLimit
in interface FlattrService
FlattrException
public RateLimit getLastRateLimit()
FlattrService
RateLimit
instance that reflects the rate limit and remaining rate
returned by the last API call.
This method does not block and does not connect to the network.
getLastRateLimit
in interface FlattrService
protected void setupFullMode(Connection conn)
Connection
according to the current full mode.conn
- Connection
to setCopyright © 2010–2017. All rights reserved.