public class UsersResource extends AbstractResource
UsersResource
provides the functionality
to access the /users
endpoints of the Twitch API.AbstractResource.TwitchHttpResponseHandler
http, objectMapper
Constructor and Description |
---|
UsersResource(java.lang.String baseUrl,
int apiVersion)
Construct the resource using the Twitch API base URL and specified API version.
|
Modifier and Type | Method and Description |
---|---|
void |
deleteBlock(java.lang.String user,
java.lang.String target,
UnblockResponseHandler handler)
|
void |
follow(java.lang.String user,
java.lang.String channel,
boolean enableNotifications,
UserFollowResponseHandler handler)
Follow a channel.
|
void |
follow(java.lang.String user,
java.lang.String channel,
UserFollowResponseHandler handler)
Follow a channel.
|
void |
get(java.lang.String user,
UserResponseHandler handler)
Returns a
User object. |
void |
get(UserResponseHandler handler)
Returns the authenticated
User object. |
void |
getBlocks(java.lang.String user,
BlocksResponseHandler handler)
Returns a list of
Block objects on User 's block list. |
void |
getBlocks(java.lang.String user,
com.mb3364.http.RequestParams params,
BlocksResponseHandler handler)
Returns a list of
Block objects on User 's block list. |
void |
getFollow(java.lang.String user,
java.lang.String channel,
UserFollowResponseHandler handler)
Returns a
UserFollow object representing a channel follow. |
void |
getFollows(java.lang.String user,
com.mb3364.http.RequestParams params,
UserFollowsResponseHandler handler)
Returns a
UserFollows object that contains a list of UserFollow
objects representing channels the user is following. |
void |
getFollows(java.lang.String user,
UserFollowsResponseHandler handler)
Returns a
UserFollows object that contains a list of UserFollow
objects representing channels the user is following. |
void |
getSubscription(java.lang.String user,
java.lang.String channel,
UserSubscriptionResponseHandler handler)
Returns the channel subscription that the user subscribes to.
|
void |
putBlock(java.lang.String user,
java.lang.String target,
BlockResponseHandler handler)
Blocks a
target for the authenticated user . |
void |
unfollow(java.lang.String user,
java.lang.String channel,
UserUnfollowResponseHandler handler)
Unfollow a channel.
|
getBaseUrl, setAuthAccessToken, setClientId
public UsersResource(java.lang.String baseUrl, int apiVersion)
baseUrl
- the base URL of the Twitch APIapiVersion
- the requested version of the Twitch APIpublic void get(java.lang.String user, UserResponseHandler handler)
User
object.user
- the user to requesthandler
- the response handlerpublic void get(UserResponseHandler handler)
User
object.
Authenticated, required scope: Scopes.USER_READ
handler
- the response handlerpublic void getSubscription(java.lang.String user, java.lang.String channel, UserSubscriptionResponseHandler handler)
Scopes.USER_SUBSCRIPTIONS
user
- the authenticated user's namechannel
- the channel name of the subscriptionhandler
- the response handlerpublic void getFollows(java.lang.String user, com.mb3364.http.RequestParams params, UserFollowsResponseHandler handler)
UserFollows
object that contains a list of UserFollow
objects representing channels the user is following.user
- the user's nameparams
- the optional request parameters:
limit
: Maximum number of objects in array. Default is 25. Maximum is 100.offset
: Object offset for pagination. Default is 0.direction
: Sorting direction. Default is desc
.
Valid values are asc
and desc
.sortby
: Sort key. Default is created_at
.
Valid values are created_at
and last_broadcast
.handler
- the response handlerpublic void getFollows(java.lang.String user, UserFollowsResponseHandler handler)
UserFollows
object that contains a list of UserFollow
objects representing channels the user is following.user
- the user's namehandler
- the response handlerpublic void getFollow(java.lang.String user, java.lang.String channel, UserFollowResponseHandler handler)
UserFollow
object representing a channel follow.user
- the userchannel
- the channelhandler
- the response handlerpublic void follow(java.lang.String user, java.lang.String channel, boolean enableNotifications, UserFollowResponseHandler handler)
user
.
Authenticated, required scope: Scopes.USER_FOLLOWS_EDIT
user
- the authenticated userchannel
- the channel to followenableNotifications
- receive email/push notifications when channel goes live. Default is false
.handler
- the response handlerpublic void follow(java.lang.String user, java.lang.String channel, UserFollowResponseHandler handler)
user
.
Authenticated, required scope: Scopes.USER_FOLLOWS_EDIT
user
- the authenticated userchannel
- the channel to followhandler
- the response handlerpublic void unfollow(java.lang.String user, java.lang.String channel, UserUnfollowResponseHandler handler)
user
.
Authenticated, required scope: Scopes.USER_FOLLOWS_EDIT
user
- the authenticated userchannel
- the channel to unfollowhandler
- the response handlerpublic void getBlocks(java.lang.String user, com.mb3364.http.RequestParams params, BlocksResponseHandler handler)
Block
objects on User
's block list.
List sorted by recency, newest first.
Authenticated, required scope: Scopes.USER_BLOCKS_READ
user
- the authenticated userparams
- the optional request parameters:
limit
: Maximum number of objects in array. Default is 25. Maximum is 100.offset
: Object offset for pagination. Default is 0.handler
- the response handlerpublic void getBlocks(java.lang.String user, BlocksResponseHandler handler)
Block
objects on User
's block list.
List sorted by recency, newest first.
Authenticated, required scope: Scopes.USER_BLOCKS_READ
user
- the authenticated userhandler
- the response handlerpublic void putBlock(java.lang.String user, java.lang.String target, BlockResponseHandler handler)
user
- the authenticated usertarget
- the user to blockhandler
- the response handlerpublic void deleteBlock(java.lang.String user, java.lang.String target, UnblockResponseHandler handler)
Block
of target
for the authenticated user
.
Authenticated, required scope: Scopes.USER_FOLLOWS_EDIT
user
- the authenticated usertarget
- the user to unblockhandler
- the response handler