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.Connectorpublic void setFullMode(boolean full)
FlattrServicefalse.setFullMode in interface FlattrServicefull - true: use full requests, false: use standard requestspublic boolean isFullMode()
FlattrServiceisFullMode in interface FlattrServicetrue: full requests, false: standard requestspublic ThingId create(Submission thing) throws FlattrException
FlattrServicecreate in interface FlattrServicething - Submission to be submittedThingId of the Thing that was createdFlattrExceptionpublic void update(Thing thing) throws FlattrException
FlattrServiceupdate in interface FlattrServicething - Thing to be modifiedFlattrExceptionpublic void delete(ThingId thingId) throws FlattrException
FlattrServicedelete in interface FlattrServicethingId - ThingId to deleteFlattrExceptionpublic MiniThing flattr(AutoSubmission submission) throws FlattrException
FlattrServiceAutoSubmission. If the submission has not been submitted to
Flattr yet, it will automatically be submitted before.flattr in interface FlattrServicesubmission - AutoSubmission to flattrMiniThing of the flattr-ed thing (containing an updated click
count)FlattrExceptionpublic MiniThing flattr(String url) throws FlattrException
FlattrServiceflattr in interface FlattrServiceurl - URL to flattrMiniThing of the flattr-ed thing (containing an updated click
count)FlattrExceptionpublic MiniThing flattr(ThingId thingId) throws FlattrException
FlattrServiceflattr in interface FlattrServicethingId - ThingId to flattrMiniThing of the flattr-ed thing (containing an updated click
count)FlattrExceptionpublic User getMyself() throws FlattrException
FlattrServiceUser profile of the associated user.getMyself in interface FlattrServiceUser profile of oneselfFlattrExceptionpublic List<Thing> getMyThings() throws FlattrException
FlattrServiceThing submitted by the associated user. Limited to 30 entries.getMyThings in interface FlattrServiceThingFlattrExceptionpublic List<Thing> getMyThings(Integer count, Integer page) throws FlattrException
FlattrServiceThing submitted by the associated user.getMyThings in interface FlattrServicecount - Number of entries per page, null defaults to 30 entriespage - Page number (counted from 1), or null to turn off pagingThingFlattrExceptionpublic List<Flattr> getMyFlattrs() throws FlattrException
FlattrServiceFlattr submitted by the associated user. Limited to 30 entries.getMyFlattrs in interface FlattrServiceFlattrFlattrExceptionpublic List<Flattr> getMyFlattrs(Integer count, Integer page) throws FlattrException
FlattrServiceFlattr submitted by the associated user.getMyFlattrs in interface FlattrServicecount - Number of entries per page, null defaults to 30 entriespage - Page number (counted from 1), or null to turn off pagingFlattrFlattrExceptionpublic Thing getThing(ThingId thingId) throws FlattrException
FlattrServicegetThing in interface FlattrServicethingId - ThingId of the Thing to be fetchedThingFlattrExceptionpublic Thing getThingByUrl(String url) throws FlattrException
FlattrServiceThing by its registered URL.getThingByUrl in interface FlattrServiceurl - Thing's URLThing of the URL that was found, null if nothing was foundFlattrExceptionpublic Thing getThingBySubmission(AutoSubmission submission) throws FlattrException
FlattrServiceThing by its autosubmit URL.
Uses two rates!
getThingBySubmission in interface FlattrServicesubmission - AutoSubmission to check forThing of the submission if found, null if nothing was foundFlattrExceptionpublic List<Thing> getThings(UserId user) throws FlattrException
FlattrServiceThing most recently submitted by the given user. This list
is limited to 30 entries.getThings in interface FlattrServiceuser - UserId to find the Things ofThing submitted by the userFlattrExceptionpublic List<Thing> getThings(UserId user, Integer count, Integer page) throws FlattrException
FlattrServiceThing most recently submitted by the given user.getThings in interface FlattrServiceuser - 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 userFlattrExceptionpublic List<Thing> getThings(Collection<? extends ThingId> thingIds) throws FlattrException
FlattrServiceThing by a collection of thing IDs.getThings in interface FlattrServicethingIds - Collection of ThingId. The order of Thing returned may
not match the order of the provided IDs.Thing fetchedFlattrExceptionpublic SearchResult searchThings(SearchQuery query, Integer count, Integer page) throws FlattrException
FlattrServiceThing.searchThings in interface FlattrServicequery - 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 pagingSearchResultFlattrExceptionpublic User getUser(UserId user) throws FlattrException
FlattrServiceUser profile of the given user ID.getUser in interface FlattrServiceuser - UserId to get a profile forUser profile of that userFlattrExceptionpublic List<Flattr> getFlattrs(UserId user) throws FlattrException
FlattrServiceFlattr most recently posted by the given user ID. Limited to 30
results.getFlattrs in interface FlattrServiceuser - UserId to get the result forFlattr posted by the userFlattrExceptionpublic List<Flattr> getFlattrs(UserId userId, Integer count, Integer page) throws FlattrException
FlattrServiceFlattr most recently posted by the given user ID.getFlattrs in interface FlattrServiceuserId - 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 userFlattrExceptionpublic List<Flattr> getFlattrs(ThingId thingId) throws FlattrException
FlattrServiceFlattr most recently posted for the given thing ID.getFlattrs in interface FlattrServicethingId - ThingId to get the result forFlattr posted by the userFlattrExceptionpublic List<Flattr> getFlattrs(ThingId thingId, Integer count, Integer page) throws FlattrException
FlattrServiceFlattr most recently posted for the given thing ID.getFlattrs in interface FlattrServicethingId - 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 userFlattrExceptionpublic List<Activity> getActivities(UserId user, Activity.Type type) throws FlattrException
FlattrServiceActivity of the given user ID.getActivities in interface FlattrServiceuser - UserId to get the result fortype - activity type. null defaults to Activity.Type#OUTGOING.ActivityFlattrExceptionpublic List<Activity> getMyActivities(Activity.Type type) throws FlattrException
FlattrServiceActivity of the associated user.getMyActivities in interface FlattrServicetype - activity type. null defaults to Activity.Type#OUTGOING.ActivityFlattrExceptionpublic List<Subscription> getMySubscriptions() throws FlattrException
FlattrServiceSubscription of the associated user.getMySubscriptions in interface FlattrServiceSubscriptionFlattrExceptionpublic Subscription getSubscription(ThingId thingId) throws FlattrException
FlattrServiceSubscription 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 FlattrServicethingId - ThingId to get the subscription ofSubscription of this thing, or null if there is no such
subscriptionFlattrExceptionpublic void subscribe(ThingId thingId) throws FlattrException
FlattrServiceThing.subscribe in interface FlattrServicethingId - ThingId to subscribeFlattrExceptionpublic void unsubscribe(ThingId thingId) throws FlattrException
FlattrServiceThing.unsubscribe in interface FlattrServicethingId - ThingId to unsubscribedFlattrExceptionpublic boolean toggleSubscription(ThingId thingId) throws FlattrException
FlattrServiceThing.toggleSubscription in interface FlattrServicethingId - ThingId of the thing to toggle the pause state oftrue if the subscription is now paused, false if the
subscription was resumed.FlattrExceptionpublic void pauseSubscription(ThingId thingId, boolean paused) throws FlattrException
FlattrServiceSubscription. 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 FlattrServicethingId - ThingId of the thing to set the pause statepaused - true: pause subscription, false: resume subscriptionFlattrExceptionpublic List<Category> getCategories() throws FlattrException
FlattrServiceCategory.
Note: The result is not cached.
getCategories in interface FlattrServiceCategory.FlattrExceptionpublic List<Language> getLanguages() throws FlattrException
FlattrServiceLanguage.
Note: The result is not cached.
getLanguages in interface FlattrServiceLanguage.FlattrExceptionpublic 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 FlattrServiceFlattrExceptionpublic RateLimit getLastRateLimit()
FlattrServiceRateLimit 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 FlattrServiceprotected void setupFullMode(Connection conn)
Connection according to the current full mode.conn - Connection to setCopyright © 2010–2017. All rights reserved.