Implement requests #65

Merged
michaelhelmick merged 3 commits from implement_requests into master 2012-03-18 06:56:35 -07:00
Showing only changes of commit e3d9ed656b - Show all commits

View file

@ -1,330 +1,330 @@
""" """
A huge map of every Twitter API endpoint to a function definition in Twython. A huge map of every Twitter API endpoint to a function definition in Twython.
Parameters that need to be embedded in the URL are treated with mustaches, e.g: Parameters that need to be embedded in the URL are treated with mustaches, e.g:
{{version}}, etc {{version}}, etc
When creating new endpoint definitions, keep in mind that the name of the mustache When creating new endpoint definitions, keep in mind that the name of the mustache
will be replaced with the keyword that gets passed in to the function at call time. will be replaced with the keyword that gets passed in to the function at call time.
i.e, in this case, if I pass version = 47 to any function, {{version}} will be replaced i.e, in this case, if I pass version = 47 to any function, {{version}} will be replaced
with 47, instead of defaulting to 1 (said defaulting takes place at conversion time). with 47, instead of defaulting to 1 (said defaulting takes place at conversion time).
""" """
# Base Twitter API url, no need to repeat this junk... # Base Twitter API url, no need to repeat this junk...
base_url = 'http://api.twitter.com/{{version}}' base_url = 'http://api.twitter.com/{{version}}'
api_table = { api_table = {
'getRateLimitStatus': { 'getRateLimitStatus': {
'url': '/account/rate_limit_status.json', 'url': '/account/rate_limit_status.json',
'method': 'GET', 'method': 'GET',
}, },
'verifyCredentials': { 'verifyCredentials': {
'url': '/account/verify_credentials.json', 'url': '/account/verify_credentials.json',
'method': 'GET', 'method': 'GET',
}, },
'endSession' : { 'endSession': {
'url': '/account/end_session.json', 'url': '/account/end_session.json',
'method': 'POST', 'method': 'POST',
}, },
# Timeline methods # Timeline methods
'getPublicTimeline': { 'getPublicTimeline': {
'url': '/statuses/public_timeline.json', 'url': '/statuses/public_timeline.json',
'method': 'GET', 'method': 'GET',
}, },
'getHomeTimeline': { 'getHomeTimeline': {
'url': '/statuses/home_timeline.json', 'url': '/statuses/home_timeline.json',
'method': 'GET', 'method': 'GET',
}, },
'getUserTimeline': { 'getUserTimeline': {
'url': '/statuses/user_timeline.json', 'url': '/statuses/user_timeline.json',
'method': 'GET', 'method': 'GET',
}, },
'getFriendsTimeline': { 'getFriendsTimeline': {
'url': '/statuses/friends_timeline.json', 'url': '/statuses/friends_timeline.json',
'method': 'GET', 'method': 'GET',
}, },
# Interfacing with friends/followers # Interfacing with friends/followers
'getUserMentions': { 'getUserMentions': {
'url': '/statuses/mentions.json', 'url': '/statuses/mentions.json',
'method': 'GET', 'method': 'GET',
}, },
'getFriendsStatus': { 'getFriendsStatus': {
'url': '/statuses/friends.json', 'url': '/statuses/friends.json',
'method': 'GET', 'method': 'GET',
}, },
'getFollowersStatus': { 'getFollowersStatus': {
'url': '/statuses/followers.json', 'url': '/statuses/followers.json',
'method': 'GET', 'method': 'GET',
}, },
'createFriendship': { 'createFriendship': {
'url': '/friendships/create.json', 'url': '/friendships/create.json',
'method': 'POST', 'method': 'POST',
}, },
'destroyFriendship': { 'destroyFriendship': {
'url': '/friendships/destroy.json', 'url': '/friendships/destroy.json',
'method': 'POST', 'method': 'POST',
}, },
'getFriendsIDs': { 'getFriendsIDs': {
'url': '/friends/ids.json', 'url': '/friends/ids.json',
'method': 'GET', 'method': 'GET',
}, },
'getFollowersIDs': { 'getFollowersIDs': {
'url': '/followers/ids.json', 'url': '/followers/ids.json',
'method': 'GET', 'method': 'GET',
}, },
'getIncomingFriendshipIDs': { 'getIncomingFriendshipIDs': {
'url': '/friendships/incoming.json', 'url': '/friendships/incoming.json',
'method': 'GET', 'method': 'GET',
}, },
'getOutgoingFriendshipIDs': { 'getOutgoingFriendshipIDs': {
'url': '/friendships/outgoing.json', 'url': '/friendships/outgoing.json',
'method': 'GET', 'method': 'GET',
}, },
# Retweets # Retweets
'reTweet': { 'reTweet': {
'url': '/statuses/retweet/{{id}}.json', 'url': '/statuses/retweet/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
'getRetweets': { 'getRetweets': {
'url': '/statuses/retweets/{{id}}.json', 'url': '/statuses/retweets/{{id}}.json',
'method': 'GET', 'method': 'GET',
}, },
'retweetedOfMe': { 'retweetedOfMe': {
'url': '/statuses/retweets_of_me.json', 'url': '/statuses/retweets_of_me.json',
'method': 'GET', 'method': 'GET',
}, },
'retweetedByMe': { 'retweetedByMe': {
'url': '/statuses/retweeted_by_me.json', 'url': '/statuses/retweeted_by_me.json',
'method': 'GET', 'method': 'GET',
}, },
'retweetedToMe': { 'retweetedToMe': {
'url': '/statuses/retweeted_to_me.json', 'url': '/statuses/retweeted_to_me.json',
'method': 'GET', 'method': 'GET',
}, },
# User methods # User methods
'showUser': { 'showUser': {
'url': '/users/show.json', 'url': '/users/show.json',
'method': 'GET', 'method': 'GET',
}, },
'searchUsers': { 'searchUsers': {
'url': '/users/search.json', 'url': '/users/search.json',
'method': 'GET', 'method': 'GET',
}, },
'lookupUser': { 'lookupUser': {
'url': '/users/lookup.json', 'url': '/users/lookup.json',
'method': 'GET', 'method': 'GET',
}, },
# Status methods - showing, updating, destroying, etc. # Status methods - showing, updating, destroying, etc.
'showStatus': { 'showStatus': {
'url': '/statuses/show/{{id}}.json', 'url': '/statuses/show/{{id}}.json',
'method': 'GET', 'method': 'GET',
}, },
'updateStatus': { 'updateStatus': {
'url': '/statuses/update.json', 'url': '/statuses/update.json',
'method': 'POST', 'method': 'POST',
}, },
'destroyStatus': { 'destroyStatus': {
'url': '/statuses/destroy/{{id}}.json', 'url': '/statuses/destroy/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
# Direct Messages - getting, sending, effing, etc. # Direct Messages - getting, sending, effing, etc.
'getDirectMessages': { 'getDirectMessages': {
'url': '/direct_messages.json', 'url': '/direct_messages.json',
'method': 'GET', 'method': 'GET',
}, },
'getSentMessages': { 'getSentMessages': {
'url': '/direct_messages/sent.json', 'url': '/direct_messages/sent.json',
'method': 'GET', 'method': 'GET',
}, },
'sendDirectMessage': { 'sendDirectMessage': {
'url': '/direct_messages/new.json', 'url': '/direct_messages/new.json',
'method': 'POST', 'method': 'POST',
}, },
'destroyDirectMessage': { 'destroyDirectMessage': {
'url': '/direct_messages/destroy/{{id}}.json', 'url': '/direct_messages/destroy/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
# Friendship methods # Friendship methods
'checkIfFriendshipExists': { 'checkIfFriendshipExists': {
'url': '/friendships/exists.json', 'url': '/friendships/exists.json',
'method': 'GET', 'method': 'GET',
}, },
'showFriendship': { 'showFriendship': {
'url': '/friendships/show.json', 'url': '/friendships/show.json',
'method': 'GET', 'method': 'GET',
}, },
# Profile methods # Profile methods
'updateProfile': { 'updateProfile': {
'url': '/account/update_profile.json', 'url': '/account/update_profile.json',
'method': 'POST', 'method': 'POST',
}, },
'updateProfileColors': { 'updateProfileColors': {
'url': '/account/update_profile_colors.json', 'url': '/account/update_profile_colors.json',
'method': 'POST', 'method': 'POST',
}, },
# Favorites methods # Favorites methods
'getFavorites': { 'getFavorites': {
'url': '/favorites.json', 'url': '/favorites.json',
'method': 'GET', 'method': 'GET',
}, },
'createFavorite': { 'createFavorite': {
'url': '/favorites/create/{{id}}.json', 'url': '/favorites/create/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
'destroyFavorite': { 'destroyFavorite': {
'url': '/favorites/destroy/{{id}}.json', 'url': '/favorites/destroy/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
# Blocking methods # Blocking methods
'createBlock': { 'createBlock': {
'url': '/blocks/create/{{id}}.json', 'url': '/blocks/create/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
'destroyBlock': { 'destroyBlock': {
'url': '/blocks/destroy/{{id}}.json', 'url': '/blocks/destroy/{{id}}.json',
'method': 'POST', 'method': 'POST',
}, },
'getBlocking': { 'getBlocking': {
'url': '/blocks/blocking.json', 'url': '/blocks/blocking.json',
'method': 'GET', 'method': 'GET',
}, },
'getBlockedIDs': { 'getBlockedIDs': {
'url': '/blocks/blocking/ids.json', 'url': '/blocks/blocking/ids.json',
'method': 'GET', 'method': 'GET',
}, },
'checkIfBlockExists': { 'checkIfBlockExists': {
'url': '/blocks/exists.json', 'url': '/blocks/exists.json',
'method': 'GET', 'method': 'GET',
}, },
# Trending methods # Trending methods
'getCurrentTrends': { 'getCurrentTrends': {
'url': '/trends/current.json', 'url': '/trends/current.json',
'method': 'GET', 'method': 'GET',
}, },
'getDailyTrends': { 'getDailyTrends': {
'url': '/trends/daily.json', 'url': '/trends/daily.json',
'method': 'GET', 'method': 'GET',
}, },
'getWeeklyTrends': { 'getWeeklyTrends': {
'url': '/trends/weekly.json', 'url': '/trends/weekly.json',
'method': 'GET', 'method': 'GET',
}, },
'availableTrends': { 'availableTrends': {
'url': '/trends/available.json', 'url': '/trends/available.json',
'method': 'GET', 'method': 'GET',
}, },
'trendsByLocation': { 'trendsByLocation': {
'url': '/trends/{{woeid}}.json', 'url': '/trends/{{woeid}}.json',
'method': 'GET', 'method': 'GET',
}, },
# Saved Searches # Saved Searches
'getSavedSearches': { 'getSavedSearches': {
'url': '/saved_searches.json', 'url': '/saved_searches.json',
'method': 'GET', 'method': 'GET',
}, },
'showSavedSearch': { 'showSavedSearch': {
'url': '/saved_searches/show/{{id}}.json', 'url': '/saved_searches/show/{{id}}.json',
'method': 'GET', 'method': 'GET',
}, },
'createSavedSearch': { 'createSavedSearch': {
'url': '/saved_searches/create.json', 'url': '/saved_searches/create.json',
'method': 'GET', 'method': 'GET',
}, },
'destroySavedSearch': { 'destroySavedSearch': {
'url': '/saved_searches/destroy/{{id}}.json', 'url': '/saved_searches/destroy/{{id}}.json',
'method': 'GET', 'method': 'GET',
}, },
# List API methods/endpoints. Fairly exhaustive and annoying in general. ;P # List API methods/endpoints. Fairly exhaustive and annoying in general. ;P
'createList': { 'createList': {
'url': '/{{username}}/lists.json', 'url': '/{{username}}/lists.json',
'method': 'POST', 'method': 'POST',
}, },
'updateList': { 'updateList': {
'url': '/{{username}}/lists/{{list_id}}.json', 'url': '/{{username}}/lists/{{list_id}}.json',
'method': 'POST', 'method': 'POST',
}, },
'showLists': { 'showLists': {
'url': '/{{username}}/lists.json', 'url': '/{{username}}/lists.json',
'method': 'GET', 'method': 'GET',
}, },
'getListMemberships': { 'getListMemberships': {
'url': '/{{username}}/lists/memberships.json', 'url': '/{{username}}/lists/memberships.json',
'method': 'GET', 'method': 'GET',
}, },
'getListSubscriptions': { 'getListSubscriptions': {
'url': '/{{username}}/lists/subscriptions.json', 'url': '/{{username}}/lists/subscriptions.json',
'method': 'GET', 'method': 'GET',
}, },
'deleteList': { 'deleteList': {
'url': '/{{username}}/lists/{{list_id}}.json', 'url': '/{{username}}/lists/{{list_id}}.json',
'method': 'DELETE', 'method': 'DELETE',
}, },
'getListTimeline': { 'getListTimeline': {
'url': '/{{username}}/lists/{{list_id}}/statuses.json', 'url': '/{{username}}/lists/{{list_id}}/statuses.json',
'method': 'GET', 'method': 'GET',
}, },
'getSpecificList': { 'getSpecificList': {
'url': '/{{username}}/lists/{{list_id}}/statuses.json', 'url': '/{{username}}/lists/{{list_id}}/statuses.json',
'method': 'GET', 'method': 'GET',
}, },
'addListMember': { 'addListMember': {
'url': '/{{username}}/{{list_id}}/members.json', 'url': '/{{username}}/{{list_id}}/members.json',
'method': 'POST', 'method': 'POST',
}, },
'getListMembers': { 'getListMembers': {
'url': '/{{username}}/{{list_id}}/members.json', 'url': '/{{username}}/{{list_id}}/members.json',
'method': 'GET', 'method': 'GET',
}, },
'deleteListMember': { 'deleteListMember': {
'url': '/{{username}}/{{list_id}}/members.json', 'url': '/{{username}}/{{list_id}}/members.json',
'method': 'DELETE', 'method': 'DELETE',
}, },
'getListSubscribers': { 'getListSubscribers': {
'url': '/{{username}}/{{list_id}}/subscribers.json', 'url': '/{{username}}/{{list_id}}/subscribers.json',
'method': 'GET', 'method': 'GET',
}, },
'subscribeToList': { 'subscribeToList': {
'url': '/{{username}}/{{list_id}}/subscribers.json', 'url': '/{{username}}/{{list_id}}/subscribers.json',
'method': 'POST', 'method': 'POST',
}, },
'unsubscribeFromList': { 'unsubscribeFromList': {
'url': '/{{username}}/{{list_id}}/subscribers.json', 'url': '/{{username}}/{{list_id}}/subscribers.json',
'method': 'DELETE', 'method': 'DELETE',
}, },
# The one-offs # The one-offs
'notificationFollow': { 'notificationFollow': {
'url': '/notifications/follow/follow.json', 'url': '/notifications/follow/follow.json',
'method': 'POST', 'method': 'POST',
}, },
'notificationLeave': { 'notificationLeave': {
'url': '/notifications/leave/leave.json', 'url': '/notifications/leave/leave.json',
'method': 'POST', 'method': 'POST',
}, },
'updateDeliveryService': { 'updateDeliveryService': {
'url': '/account/update_delivery_device.json', 'url': '/account/update_delivery_device.json',
'method': 'POST', 'method': 'POST',
}, },
'reportSpam': { 'reportSpam': {
'url': '/report_spam.json', 'url': '/report_spam.json',
'method': 'POST', 'method': 'POST',
}, },
} }