org.springframework.social.twitter.api
Interface DirectMessageOperations


public interface DirectMessageOperations

Interface defining the Twitter operations for working with direct messages.


Method Summary
 void deleteDirectMessage(long messageId)
          Deletes a direct message for the authenticated user.
 DirectMessage getDirectMessage(long id)
          Gets a direct message by its ID.
 List<DirectMessage> getDirectMessagesReceived()
          Retrieve the 20 most recently received direct messages for the authenticating user.
 List<DirectMessage> getDirectMessagesReceived(int page, int pageSize)
          Retrieve received direct messages for the authenticating user.
 List<DirectMessage> getDirectMessagesReceived(int page, int pageSize, long sinceId, long maxId)
          Retrieve received direct messages for the authenticating user.
 List<DirectMessage> getDirectMessagesSent()
          Retrieve the 20 most recent direct messages sent by the authenticating user.
 List<DirectMessage> getDirectMessagesSent(int page, int pageSize)
          Retrieve direct messages sent by the authenticating user.
 List<DirectMessage> getDirectMessagesSent(int page, int pageSize, long sinceId, long maxId)
          Retrieve direct messages sent by the authenticating user.
 DirectMessage sendDirectMessage(long toUserId, String text)
          Sends a direct message to another Twitter user.
 DirectMessage sendDirectMessage(String toScreenName, String text)
          Sends a direct message to another Twitter user.
 

Method Detail

getDirectMessagesReceived

List<DirectMessage> getDirectMessagesReceived()
Retrieve the 20 most recently received direct messages for the authenticating user. The most recently received messages are listed first.

Returns:
a collection of DirectMessage with the authenticating user as the recipient.
Throws:
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.
org.springframework.social.ApiException - if there is an error while communicating with Twitter.

getDirectMessagesReceived

List<DirectMessage> getDirectMessagesReceived(int page,
                                              int pageSize)
Retrieve received direct messages for the authenticating user. The most recently received messages are listed first.

Parameters:
page - The page to return
pageSize - The number of DirectMessages per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of DirectMessage with the authenticating user as the recipient.
Throws:
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.
org.springframework.social.ApiException - if there is an error while communicating with Twitter.

getDirectMessagesReceived

List<DirectMessage> getDirectMessagesReceived(int page,
                                              int pageSize,
                                              long sinceId,
                                              long maxId)
Retrieve received direct messages for the authenticating user. The most recently received messages are listed first.

Parameters:
page - The page to return
pageSize - The number of DirectMessages per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum DirectMessage ID to return in the results
maxId - The maximum DirectMessage ID to return in the results
Returns:
a collection of DirectMessage with the authenticating user as the recipient.
Throws:
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.
org.springframework.social.ApiException - if there is an error while communicating with Twitter.

getDirectMessagesSent

List<DirectMessage> getDirectMessagesSent()
Retrieve the 20 most recent direct messages sent by the authenticating user. The most recently sent messages are listed first.

Returns:
a collection of DirectMessage with the authenticating user as the sender.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getDirectMessagesSent

List<DirectMessage> getDirectMessagesSent(int page,
                                          int pageSize)
Retrieve direct messages sent by the authenticating user. The most recently sent messages are listed first.

Parameters:
page - The page to return
pageSize - The number of DirectMessages per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of DirectMessage with the authenticating user as the sender.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getDirectMessagesSent

List<DirectMessage> getDirectMessagesSent(int page,
                                          int pageSize,
                                          long sinceId,
                                          long maxId)
Retrieve direct messages sent by the authenticating user. The most recently sent messages are listed first.

Parameters:
page - The page to return
pageSize - The number of DirectMessages per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum DirectMessage ID to return in the results
maxId - The maximum DirectMessage ID to return in the results
Returns:
a collection of DirectMessage with the authenticating user as the sender.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getDirectMessage

DirectMessage getDirectMessage(long id)
Gets a direct message by its ID. The message must be readable by the authenticating user.

Parameters:
id - the message ID
Returns:
the direct message
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

sendDirectMessage

DirectMessage sendDirectMessage(String toScreenName,
                                String text)
Sends a direct message to another Twitter user. The recipient of the message must follow the authenticated user in order for the message to be delivered. If the recipient is not following the authenticated user, an InvalidMessageRecipientException will be thrown.

Parameters:
toScreenName - the screen name of the recipient of the messages.
text - the message text.
Returns:
the DirectMessage
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
InvalidMessageRecipientException - if the recipient is not following the authenticating user.
DuplicateTweetException - if the message duplicates a previously sent message.
MessageTooLongException - if the message length exceeds Twitter's 140 character limit.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

sendDirectMessage

DirectMessage sendDirectMessage(long toUserId,
                                String text)
Sends a direct message to another Twitter user. The recipient of the message must follow the authenticated user in order for the message to be delivered. If the recipient is not following the authenticated user, an InvalidMessageRecipientException will be thrown.

Parameters:
toUserId - the Twitter user ID of the recipient of the messages.
text - the message text.
Returns:
the DirectMessage
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
InvalidMessageRecipientException - if the recipient is not following the authenticating user.
DuplicateTweetException - if the message duplicates a previously sent message.
MessageTooLongException - if the message length exceeds Twitter's 140 character limit.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

deleteDirectMessage

void deleteDirectMessage(long messageId)
Deletes a direct message for the authenticated user.

Parameters:
messageId - the ID of the message to be removed.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.