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
- #help ⇒ Object
-
#initialize(client) ⇒ Base
constructor
A new instance of Base.
- #rate_limit_status ⇒ Object
-
#replies(query = {}) ⇒ Object
Options: since_id, max_id, since, page.
- #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_background_image(path_or_url_to_image) ⇒ Object
-
#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.
- #verify_credentials ⇒ Object
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/twitter/base.rb', line 11 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/twitter/base.rb', line 9 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
67 68 69 |
# File 'lib/twitter/base.rb', line 67 def (user, text) perform_post("/direct_messages/new.json", :body => {:user => user, :text => text}) end |
#direct_message_destroy(id) ⇒ Object
71 72 73 |
# File 'lib/twitter/base.rb', line 71 def (id) perform_post("/direct_messages/destroy/#{id}.json") end |
#direct_messages(query = {}) ⇒ Object
Options: since, since_id, page
58 59 60 |
# File 'lib/twitter/base.rb', line 58 def (query={}) perform_get("/direct_messages.json", :query => query) end |
#direct_messages_sent(query = {}) ⇒ Object
Options: since, since_id, page
63 64 65 |
# File 'lib/twitter/base.rb', line 63 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
95 96 97 |
# File 'lib/twitter/base.rb', line 95 def follower_ids(query={}) perform_get("/followers/ids.json", :query => query, :mash => false) end |
#followers(query = {}) ⇒ Object
Options: id, user_id, screen_name, page
49 50 51 |
# File 'lib/twitter/base.rb', line 49 def followers(query={}) perform_get('/statuses/followers.json', :query => query) end |
#friend_ids(query = {}) ⇒ Object
Options: id, user_id, screen_name
90 91 92 |
# File 'lib/twitter/base.rb', line 90 def friend_ids(query={}) perform_get("/friends/ids.json", :query => query, :mash => false) end |
#friends(query = {}) ⇒ Object
Options: id, user_id, screen_name, page
44 45 46 |
# File 'lib/twitter/base.rb', line 44 def friends(query={}) perform_get('/statuses/friends.json', :query => query) end |
#friends_timeline(query = {}) ⇒ Object
Options: since_id, max_id, count, page, since
16 17 18 |
# File 'lib/twitter/base.rb', line 16 def friends_timeline(query={}) perform_get('/statuses/friends_timeline.json', :query => query) end |
#friendship_create(id, follow = false) ⇒ Object
75 76 77 78 79 |
# File 'lib/twitter/base.rb', line 75 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
81 82 83 |
# File 'lib/twitter/base.rb', line 81 def friendship_destroy(id) perform_post("/friendships/destroy/#{id}.json") end |
#friendship_exists?(a, b) ⇒ Boolean
85 86 87 |
# File 'lib/twitter/base.rb', line 85 def friendship_exists?(a, b) perform_get("/friendships/exists.json", :query => {:user_a => a, :user_b => b}) end |
#help ⇒ Object
165 166 167 |
# File 'lib/twitter/base.rb', line 165 def help perform_get('/help/test.json') 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
Options: since_id, max_id, since, page
35 36 37 |
# File 'lib/twitter/base.rb', line 35 def replies(query={}) perform_get('/statuses/replies.json', :query => query) end |
#status(id) ⇒ Object
25 26 27 |
# File 'lib/twitter/base.rb', line 25 def status(id) perform_get("/statuses/show/#{id}.json") end |
#status_destroy(id) ⇒ Object
39 40 41 |
# File 'lib/twitter/base.rb', line 39 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
30 31 32 |
# File 'lib/twitter/base.rb', line 30 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
104 105 106 |
# File 'lib/twitter/base.rb', line 104 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_background_image(path_or_url_to_image) ⇒ Object
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/twitter/base.rb', line 115 def update_profile_background_image(path_or_url_to_image) file = open(path_or_url_to_image) url = URI.parse('http://twitter.com/account/update_profile_background_image.json') Net::HTTP.new(url.host, url.port).start do |http| req = Net::HTTP::Post.new(url.request_uri) add_multipart_data(req, :image => file) add_oauth(req) res = http.request(req) end 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
111 112 113 |
# File 'lib/twitter/base.rb', line 111 def update_profile_colors(colors={}) perform_post('/account/update_profile_colors.json', :body => colors) end |
#user(id, query = {}) ⇒ Object
53 54 55 |
# File 'lib/twitter/base.rb', line 53 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
21 22 23 |
# File 'lib/twitter/base.rb', line 21 def user_timeline(query={}) perform_get('/statuses/user_timeline.json', :query => query) end |
#verify_credentials ⇒ Object
99 100 101 |
# File 'lib/twitter/base.rb', line 99 def verify_credentials perform_get("/account/verify_credentials.json") end |