com.twitterapime.rest
Class UserAccountManager

java.lang.Object
  extended by com.twitterapime.rest.UserAccountManager

public final class UserAccountManager
extends java.lang.Object

This class is responsible for managing the user account.

 Credential c = new Credential(...);
 UserAccountManager uam = UserAccountManager.getInstance(c)
 if (uam.verifyCredential()) {
   System.out.println("User logged in...");
 }
 uam.signOut();
 

Since:
1.1
Version:
1.2
Author:
Ernandes Mourao Junior (ernandes@gmail.com)

Field Summary
static java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS
           Key for Twitter API URL service account rate limit status.
static java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_UPDATE_PROFILE
           Key for Twitter API URL service account update profile.
static java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_VERIFY_CREDENTIALS
           Key for Twitter API URL service account verify credentials.
static java.lang.String TWITTER_API_URL_SERVICE_OAUTH_ACCESS_TOKEN
           Key for Twitter API URL service OAuth access token.
static java.lang.String TWITTER_API_URL_SERVICE_USERS_SHOW
           Key for Twitter API URL service users show.
 
Method Summary
 UserAccount block(UserAccount ua)
          FriendshipManager.block(UserAccount)
 boolean equals(java.lang.Object o)
           
 UserAccount follow(UserAccount ua)
          FriendshipManager.follow(UserAccount)
 java.lang.String[] getFollowersID(Query query)
          FriendshipManager.getFollowersID(Query)
 java.lang.String[] getFriendsID(Query query)
          FriendshipManager.getFriendsID(Query)
static UserAccountManager getInstance(Credential c)
           Get an instance of UserAccountManager class and associate it to a given user credential.
 RateLimitStatus getRateLimitStatus()
           Returns a set of info about the number of API requests available to the requesting user before the REST API limit is reached for the current hour.
 UserAccount getUserAccount()
           Get the logged user's account.
 UserAccount getUserAccount(UserAccount user)
           Get the account of a given user.
 int hashCode()
           
 boolean isBlocking(UserAccount ua)
          FriendshipManager.isBlocking(UserAccount)
 boolean isFollowing(UserAccount ua)
          FriendshipManager.isFollowing(UserAccount)
 boolean isVerified()
           Return whether it is properly verified.
 void setServiceURL(java.lang.String serviceKey, java.lang.String url)
           Set a new URL to a given Twitter API service.
 void signOut()
           Ends the session of the authenticating user.
 UserAccount unblock(UserAccount ua)
          FriendshipManager.unblock(UserAccount)
 UserAccount unfollow(UserAccount ua)
          FriendshipManager.unfollow(UserAccount)
 UserAccount updateProfile(UserAccount newUserInfo)
           Update account information of authenticated user.
 boolean verifyCredential()
           Verify whether the given user's credential are valid.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TWITTER_API_URL_SERVICE_ACCOUNT_VERIFY_CREDENTIALS

public static final java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_VERIFY_CREDENTIALS

Key for Twitter API URL service account verify credentials.

See Also:
setServiceURL(String, String), verifyCredential(), Constant Field Values

TWITTER_API_URL_SERVICE_OAUTH_ACCESS_TOKEN

public static final java.lang.String TWITTER_API_URL_SERVICE_OAUTH_ACCESS_TOKEN

Key for Twitter API URL service OAuth access token.

See Also:
setServiceURL(String, String), verifyCredential(), Constant Field Values

TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS

public static final java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS

Key for Twitter API URL service account rate limit status.

See Also:
setServiceURL(String, String), getRateLimitStatus(), Constant Field Values

TWITTER_API_URL_SERVICE_USERS_SHOW

public static final java.lang.String TWITTER_API_URL_SERVICE_USERS_SHOW

Key for Twitter API URL service users show.

See Also:
setServiceURL(String, String), getUserAccount(), Constant Field Values

TWITTER_API_URL_SERVICE_ACCOUNT_UPDATE_PROFILE

public static final java.lang.String TWITTER_API_URL_SERVICE_ACCOUNT_UPDATE_PROFILE

Key for Twitter API URL service account update profile.

See Also:
setServiceURL(String, String), getUserAccount(), Constant Field Values
Method Detail

setServiceURL

public void setServiceURL(java.lang.String serviceKey,
                          java.lang.String url)

Set a new URL to a given Twitter API service. This method is very useful in case Twitter API decides to change a service's URL. So there is no need to wait for a new version of this API to get it working back.

Be careful about using this method, since it can cause unexpected results, case you enter an invalid URL.

Parameters:
serviceKey - Service key.
url - New URL.
See Also:
TWITTER_API_URL_SERVICE_ACCOUNT_RATE_LIMIT_STATUS, TWITTER_API_URL_SERVICE_ACCOUNT_VERIFY_CREDENTIALS, TWITTER_API_URL_SERVICE_OAUTH_ACCESS_TOKEN, TWITTER_API_URL_SERVICE_USERS_SHOW

getInstance

public static UserAccountManager getInstance(Credential c)

Get an instance of UserAccountManager class and associate it to a given user credential.

Parameters:
c - Credentials.
Returns:
AccountManager object.
Throws:
java.lang.IllegalArgumentException - If credential is null.

getRateLimitStatus

public RateLimitStatus getRateLimitStatus()
                                   throws java.io.IOException,
                                          LimitExceededException

Returns a set of info about the number of API requests available to the requesting user before the REST API limit is reached for the current hour.

Stay aware of these limits, since it can impact the usage of some methods of this API.

Returns:
Rate limiting status info.
Throws:
java.io.IOException - If an I/O error occurs.
java.lang.SecurityException - If it is not properly logged in.
LimitExceededException - If limit has been hit.

isVerified

public boolean isVerified()

Return whether it is properly verified.

Returns:
Verified (true).

verifyCredential

public boolean verifyCredential()
                         throws java.io.IOException,
                                LimitExceededException

Verify whether the given user's credential are valid. This method authenticates the API to Twitter REST API.

Returns:
Valid credentials (true).
Throws:
java.io.IOException - If an I/O error occurs.
LimitExceededException - If limit has been hit.

signOut

public void signOut()
             throws java.io.IOException,
                    LimitExceededException

Ends the session of the authenticating user.

Once signed out, this instance is no longer valid for use as well as another one dependent of it. Dump them!

Throws:
java.io.IOException - If an I/O error occurs.
java.lang.SecurityException - If it is not properly logged in.
LimitExceededException - If limit has been hit.

getUserAccount

public UserAccount getUserAccount()
                           throws java.io.IOException,
                                  LimitExceededException

Get the logged user's account.

Returns:
User account object.
Throws:
java.lang.SecurityException - If it is not properly logged in.
java.io.IOException - If an I/O error occurs.
LimitExceededException - If limit has been hit.

getUserAccount

public UserAccount getUserAccount(UserAccount user)
                           throws java.io.IOException,
                                  LimitExceededException

Get the account of a given user.

Parameters:
user - User.
Returns:
Username/id.
Throws:
java.lang.SecurityException - If it is not properly logged in.
java.io.IOException - If an I/O error occurs.
LimitExceededException - If limit has been hit.
java.lang.IllegalArgumentException - If user/id/username is null/empty.

follow

public UserAccount follow(UserAccount ua)
                   throws java.io.IOException,
                          LimitExceededException
FriendshipManager.follow(UserAccount)

Throws:
java.io.IOException
LimitExceededException

unfollow

public UserAccount unfollow(UserAccount ua)
                     throws java.io.IOException,
                            LimitExceededException
FriendshipManager.unfollow(UserAccount)

Throws:
java.io.IOException
LimitExceededException

isFollowing

public boolean isFollowing(UserAccount ua)
                    throws java.io.IOException,
                           LimitExceededException
FriendshipManager.isFollowing(UserAccount)

Throws:
java.io.IOException
LimitExceededException

block

public UserAccount block(UserAccount ua)
                  throws java.io.IOException,
                         LimitExceededException
FriendshipManager.block(UserAccount)

Throws:
java.io.IOException
LimitExceededException

unblock

public UserAccount unblock(UserAccount ua)
                    throws java.io.IOException,
                           LimitExceededException
FriendshipManager.unblock(UserAccount)

Throws:
java.io.IOException
LimitExceededException

isBlocking

public boolean isBlocking(UserAccount ua)
                   throws java.io.IOException,
                          LimitExceededException
FriendshipManager.isBlocking(UserAccount)

Throws:
java.io.IOException
LimitExceededException

getFriendsID

public java.lang.String[] getFriendsID(Query query)
                                throws java.io.IOException,
                                       LimitExceededException
FriendshipManager.getFriendsID(Query)

Throws:
java.io.IOException
LimitExceededException

getFollowersID

public java.lang.String[] getFollowersID(Query query)
                                  throws java.io.IOException,
                                         LimitExceededException
FriendshipManager.getFollowersID(Query)

Throws:
java.io.IOException
LimitExceededException

updateProfile

public UserAccount updateProfile(UserAccount newUserInfo)
                          throws java.io.IOException,
                                 LimitExceededException

Update account information of authenticated user. Only name, description, URL and location can be changed.

Parameters:
newUserInfo -
Returns:
New user account info.
Throws:
java.io.IOException - If an I/O error occurs.
LimitExceededException - If limit has been hit.
java.lang.SecurityException - If it is not authenticated.
java.lang.IllegalArgumentException - If user info is null/empty.
See Also:
MetadataSet.USERACCOUNT_USER_NAME, MetadataSet.USERACCOUNT_DESCRIPTION, MetadataSet.USERACCOUNT_URL, MetadataSet.USERACCOUNT_LOCATION

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()


Copyright © 2010 Twitter API ME Team. All Rights Reserved.