Class: Twitter::Base
- Inherits:
-
Object
- Object
- Twitter::Base
- Extended by:
- Forwardable
- Defined in:
- lib/twitter/base.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #block(id) ⇒ Object
- #direct_message_create(user, text) ⇒ Object
- #direct_message_destroy(id) ⇒ Object
-
#direct_messages(query = {}) ⇒ Object
Options: since, since_id, page.
-
#direct_messages_sent(query = {}) ⇒ Object
Options: since, since_id, page.
- #disable_notifications(id) ⇒ Object
- #enable_notifications(id) ⇒ Object
- #favorite_create(id) ⇒ Object
- #favorite_destroy(id) ⇒ Object
-
#favorites(query = {}) ⇒ Object
Options: id, page.
-
#follower_ids(query = {}) ⇒ Object
Options: id, user_id, screen_name.
-
#followers(query = {}) ⇒ Object
Options: id, user_id, screen_name, page.
-
#friend_ids(query = {}) ⇒ Object
Options: id, user_id, screen_name.
-
#friends(query = {}) ⇒ Object
Options: id, user_id, screen_name, page.
-
#friends_timeline(query = {}) ⇒ Object
Options: since_id, max_id, count, page, since.
- #friendship_create(id, follow = false) ⇒ Object
- #friendship_destroy(id) ⇒ Object
- #friendship_exists?(a, b) ⇒ Boolean
- #friendship_show(query) ⇒ Object
- #help ⇒ Object
-
#initialize(client) ⇒ Base
constructor
A new instance of Base.
- #is_list_member?(list_owner_username, slug, id) ⇒ Boolean
- #list(list_owner_username, slug) ⇒ Object
- #list_add_member(list_owner_username, slug, new_id) ⇒ Object
- #list_create(list_owner_username, options) ⇒ Object
- #list_delete(list_owner_username, slug) ⇒ Object
- #list_members(list_owner_username, slug) ⇒ Object
- #list_remove_member(list_owner_username, slug, id) ⇒ Object
- #list_subscribe(list_owner_username, slug) ⇒ Object
- #list_subscribers(list_owner_username, slug) ⇒ Object
- #list_subscriptions(list_owner_username) ⇒ Object
- #list_timeline(list_owner_username, slug) ⇒ Object
- #list_unsubscribe(list_owner_username, slug) ⇒ Object
- #list_update(list_owner_username, slug, options) ⇒ Object
- #lists(list_owner_username = nil) ⇒ Object
- #memberships(list_owner_username) ⇒ Object
-
#mentions(query = {}) ⇒ Object
Options: since_id, max_id, count, page.
- #rate_limit_status ⇒ Object
-
#replies(query = {}) ⇒ Object
DEPRECATED: Use #mentions instead.
- #status(id) ⇒ Object
- #status_destroy(id) ⇒ Object
- #unblock(id) ⇒ Object
-
#update(status, query = {}) ⇒ Object
Options: in_reply_to_status_id.
-
#update_delivery_device(device) ⇒ Object
Device must be sms, im or none.
-
#update_profile(body = {}) ⇒ Object
One or more of the following must be present: name, email, url, location, description.
-
#update_profile_colors(colors = {}) ⇒ Object
One or more of the following must be present: profile_background_color, profile_text_color, profile_link_color, profile_sidebar_fill_color, profile_sidebar_border_color.
- #user(id, query = {}) ⇒ Object
-
#user_timeline(query = {}) ⇒ Object
Options: id, user_id, screen_name, since_id, max_id, page, since, count.
- #verify_credentials ⇒ Object
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/twitter/base.rb', line 9 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/twitter/base.rb', line 7 def client @client end |
Instance Method Details
#block(id) ⇒ Object
157 158 159 |
# File 'lib/twitter/base.rb', line 157 def block(id) perform_post("/blocks/create/#{id}.json") end |
#direct_message_create(user, text) ⇒ Object
74 75 76 |
# File 'lib/twitter/base.rb', line 74 def (user, text) perform_post("/direct_messages/new.json", :body => {:user => user, :text => text}) end |
#direct_message_destroy(id) ⇒ Object
78 79 80 |
# File 'lib/twitter/base.rb', line 78 def (id) perform_post("/direct_messages/destroy/#{id}.json") end |
#direct_messages(query = {}) ⇒ Object
Options: since, since_id, page
65 66 67 |
# File 'lib/twitter/base.rb', line 65 def (query={}) perform_get("/direct_messages.json", :query => query) end |
#direct_messages_sent(query = {}) ⇒ Object
Options: since, since_id, page
70 71 72 |
# File 'lib/twitter/base.rb', line 70 def (query={}) perform_get("/direct_messages/sent.json", :query => query) end |
#disable_notifications(id) ⇒ Object
153 154 155 |
# File 'lib/twitter/base.rb', line 153 def disable_notifications(id) perform_post("/notifications/leave/#{id}.json") end |
#enable_notifications(id) ⇒ Object
149 150 151 |
# File 'lib/twitter/base.rb', line 149 def enable_notifications(id) perform_post("/notifications/follow/#{id}.json") end |
#favorite_create(id) ⇒ Object
141 142 143 |
# File 'lib/twitter/base.rb', line 141 def favorite_create(id) perform_post("/favorites/create/#{id}.json") end |
#favorite_destroy(id) ⇒ Object
145 146 147 |
# File 'lib/twitter/base.rb', line 145 def favorite_destroy(id) perform_post("/favorites/destroy/#{id}.json") end |
#favorites(query = {}) ⇒ Object
Options: id, page
137 138 139 |
# File 'lib/twitter/base.rb', line 137 def favorites(query={}) perform_get('/favorites.json', :query => query) end |
#follower_ids(query = {}) ⇒ Object
Options: id, user_id, screen_name
106 107 108 |
# File 'lib/twitter/base.rb', line 106 def follower_ids(query={}) perform_get("/followers/ids.json", :query => query, :mash => false) end |
#followers(query = {}) ⇒ Object
Options: id, user_id, screen_name, page
56 57 58 |
# File 'lib/twitter/base.rb', line 56 def followers(query={}) perform_get('/statuses/followers.json', :query => query) end |
#friend_ids(query = {}) ⇒ Object
Options: id, user_id, screen_name
101 102 103 |
# File 'lib/twitter/base.rb', line 101 def friend_ids(query={}) perform_get("/friends/ids.json", :query => query, :mash => false) end |
#friends(query = {}) ⇒ Object
Options: id, user_id, screen_name, page
51 52 53 |
# File 'lib/twitter/base.rb', line 51 def friends(query={}) perform_get('/statuses/friends.json', :query => query) end |
#friends_timeline(query = {}) ⇒ Object
Options: since_id, max_id, count, page, since
14 15 16 |
# File 'lib/twitter/base.rb', line 14 def friends_timeline(query={}) perform_get('/statuses/friends_timeline.json', :query => query) end |
#friendship_create(id, follow = false) ⇒ Object
82 83 84 85 86 |
# File 'lib/twitter/base.rb', line 82 def friendship_create(id, follow=false) body = {} body.merge!(:follow => follow) if follow perform_post("/friendships/create/#{id}.json", :body => body) end |
#friendship_destroy(id) ⇒ Object
88 89 90 |
# File 'lib/twitter/base.rb', line 88 def friendship_destroy(id) perform_post("/friendships/destroy/#{id}.json") end |
#friendship_exists?(a, b) ⇒ Boolean
92 93 94 |
# File 'lib/twitter/base.rb', line 92 def friendship_exists?(a, b) perform_get("/friendships/exists.json", :query => {:user_a => a, :user_b => b}) end |
#friendship_show(query) ⇒ Object
96 97 98 |
# File 'lib/twitter/base.rb', line 96 def friendship_show(query) perform_get("/friendships/show.json", :query => query) end |
#help ⇒ Object
165 166 167 |
# File 'lib/twitter/base.rb', line 165 def help perform_get('/help/test.json') end |
#is_list_member?(list_owner_username, slug, id) ⇒ Boolean
212 213 214 |
# File 'lib/twitter/base.rb', line 212 def is_list_member?(list_owner_username, slug, id) perform_get("/#{list_owner_username}/#{slug}/members/#{id}.json").error.nil? end |
#list(list_owner_username, slug) ⇒ Object
188 189 190 |
# File 'lib/twitter/base.rb', line 188 def list(list_owner_username, slug) perform_get("/#{list_owner_username}/lists/#{slug}.json") end |
#list_add_member(list_owner_username, slug, new_id) ⇒ Object
204 205 206 |
# File 'lib/twitter/base.rb', line 204 def list_add_member(list_owner_username, slug, new_id) perform_post("/#{list_owner_username}/#{slug}/members.json", :body => {:id => new_id}) end |
#list_create(list_owner_username, options) ⇒ Object
169 170 171 |
# File 'lib/twitter/base.rb', line 169 def list_create(list_owner_username, ) perform_post("/#{list_owner_username}/lists.json", :body => {:user => list_owner_username}.merge()) end |
#list_delete(list_owner_username, slug) ⇒ Object
177 178 179 |
# File 'lib/twitter/base.rb', line 177 def list_delete(list_owner_username, slug) perform_delete("/#{list_owner_username}/lists/#{slug}.json") end |
#list_members(list_owner_username, slug) ⇒ Object
200 201 202 |
# File 'lib/twitter/base.rb', line 200 def list_members(list_owner_username, slug) perform_get("/#{list_owner_username}/#{slug}/members.json") end |
#list_remove_member(list_owner_username, slug, id) ⇒ Object
208 209 210 |
# File 'lib/twitter/base.rb', line 208 def list_remove_member(list_owner_username, slug, id) perform_delete("/#{list_owner_username}/#{slug}/members.json", :body => {:id => id}) end |
#list_subscribe(list_owner_username, slug) ⇒ Object
220 221 222 |
# File 'lib/twitter/base.rb', line 220 def list_subscribe(list_owner_username, slug) perform_post("/#{list_owner_username}/#{slug}/subscribers.json") end |
#list_subscribers(list_owner_username, slug) ⇒ Object
216 217 218 |
# File 'lib/twitter/base.rb', line 216 def list_subscribers(list_owner_username, slug) perform_get("/#{list_owner_username}/#{slug}/subscribers.json") end |
#list_subscriptions(list_owner_username) ⇒ Object
228 229 230 |
# File 'lib/twitter/base.rb', line 228 def list_subscriptions(list_owner_username) perform_get("/#{list_owner_username}/lists/subscriptions.json") end |
#list_timeline(list_owner_username, slug) ⇒ Object
192 193 194 |
# File 'lib/twitter/base.rb', line 192 def list_timeline(list_owner_username, slug) perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json") end |
#list_unsubscribe(list_owner_username, slug) ⇒ Object
224 225 226 |
# File 'lib/twitter/base.rb', line 224 def list_unsubscribe(list_owner_username, slug) perform_delete("/#{list_owner_username}/#{slug}/subscribers.json") end |
#list_update(list_owner_username, slug, options) ⇒ Object
173 174 175 |
# File 'lib/twitter/base.rb', line 173 def list_update(list_owner_username, slug, ) perform_put("/#{list_owner_username}/lists/#{slug}.json", :body => ) end |
#lists(list_owner_username = nil) ⇒ Object
181 182 183 184 185 186 |
# File 'lib/twitter/base.rb', line 181 def lists(list_owner_username=nil) path = "http://api.twitter.com/1" path += "/#{list_owner_username}" if list_owner_username path += "/lists.json" perform_get(path) end |
#memberships(list_owner_username) ⇒ Object
196 197 198 |
# File 'lib/twitter/base.rb', line 196 def memberships(list_owner_username) perform_get("/#{list_owner_username}/lists/memberships.json") end |
#mentions(query = {}) ⇒ Object
Options: since_id, max_id, count, page
42 43 44 |
# File 'lib/twitter/base.rb', line 42 def mentions(query={}) perform_get('/statuses/mentions.json', :query => query) end |
#rate_limit_status ⇒ Object
126 127 128 |
# File 'lib/twitter/base.rb', line 126 def rate_limit_status perform_get('/account/rate_limit_status.json') end |
#replies(query = {}) ⇒ Object
DEPRECATED: Use #mentions instead
Options: since_id, max_id, since, page
36 37 38 39 |
# File 'lib/twitter/base.rb', line 36 def replies(query={}) warn("DEPRECATED: #replies is deprecated by Twitter; use #mentions instead") perform_get('/statuses/replies.json', :query => query) end |
#status(id) ⇒ Object
24 25 26 |
# File 'lib/twitter/base.rb', line 24 def status(id) perform_get("/statuses/show/#{id}.json") end |
#status_destroy(id) ⇒ Object
46 47 48 |
# File 'lib/twitter/base.rb', line 46 def status_destroy(id) perform_post("/statuses/destroy/#{id}.json") end |
#unblock(id) ⇒ Object
161 162 163 |
# File 'lib/twitter/base.rb', line 161 def unblock(id) perform_post("/blocks/destroy/#{id}.json") end |
#update(status, query = {}) ⇒ Object
Options: in_reply_to_status_id
29 30 31 |
# File 'lib/twitter/base.rb', line 29 def update(status, query={}) perform_post("/statuses/update.json", :body => {:status => status}.merge(query)) end |
#update_delivery_device(device) ⇒ Object
Device must be sms, im or none
115 116 117 |
# File 'lib/twitter/base.rb', line 115 def update_delivery_device(device) perform_post('/account/update_delivery_device.json', :body => {:device => device}) end |
#update_profile(body = {}) ⇒ Object
One or more of the following must be present:
name, email, url, location, description
132 133 134 |
# File 'lib/twitter/base.rb', line 132 def update_profile(body={}) perform_post('/account/update_profile.json', :body => body) end |
#update_profile_colors(colors = {}) ⇒ Object
One or more of the following must be present:
profile_background_color, profile_text_color, profile_link_color,
profile_sidebar_fill_color, profile_sidebar_border_color
122 123 124 |
# File 'lib/twitter/base.rb', line 122 def update_profile_colors(colors={}) perform_post('/account/update_profile_colors.json', :body => colors) end |
#user(id, query = {}) ⇒ Object
60 61 62 |
# File 'lib/twitter/base.rb', line 60 def user(id, query={}) perform_get("/users/show/#{id}.json", :query => query) end |
#user_timeline(query = {}) ⇒ Object
Options: id, user_id, screen_name, since_id, max_id, page, since, count
20 21 22 |
# File 'lib/twitter/base.rb', line 20 def user_timeline(query={}) perform_get('/statuses/user_timeline.json', :query => query) end |
#verify_credentials ⇒ Object
110 111 112 |
# File 'lib/twitter/base.rb', line 110 def verify_credentials perform_get("/account/verify_credentials.json") end |