Class: Vine::Client
- Inherits:
-
Object
- Object
- Vine::Client
- Includes:
- Request
- Defined in:
- lib/vine_client/client.rb
Instance Method Summary collapse
- #get_popular ⇒ Object
- #get_post(post_id = nil) ⇒ Object
-
#initialize(name, pass) ⇒ Client
constructor
A new instance of Client.
- #like(post_id = nil) ⇒ Object
- #login(name, pass) ⇒ Object
- #logout ⇒ Object
- #notifications(user_id = @userId) ⇒ Object
- #search(keyword, page = nil) ⇒ Object
- #tag(tag = nil, page = nil) ⇒ Object
- #timelines(page = nil, user_id = @userId) ⇒ Object
- #user_info(user_id = @userId) ⇒ Object
Methods included from Request
Constructor Details
#initialize(name, pass) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/vine_client/client.rb', line 6 def initialize(name, pass) result = login(name,pass) @key = result['key'] @userId = result['userId'] end |
Instance Method Details
#get_popular ⇒ Object
20 21 22 |
# File 'lib/vine_client/client.rb', line 20 def get_popular get('/timelines/popular') end |
#get_post(post_id = nil) ⇒ Object
55 56 57 |
# File 'lib/vine_client/client.rb', line 55 def get_post(post_id=nil) get("/timelines/posts/#{post_id}") if post_id end |
#like(post_id = nil) ⇒ Object
51 52 53 |
# File 'lib/vine_client/client.rb', line 51 def like(post_id=nil) post("/posts/#{post_id}/likes") if post_id end |
#login(name, pass) ⇒ Object
12 13 14 |
# File 'lib/vine_client/client.rb', line 12 def login(name, pass) post('/users/authenticate',{:username =>name, :password=>pass}) end |
#logout ⇒ Object
16 17 18 |
# File 'lib/vine_client/client.rb', line 16 def logout delete('/users/authenticate') end |
#notifications(user_id = @userId) ⇒ Object
47 48 49 |
# File 'lib/vine_client/client.rb', line 47 def notifications(user_id=@userId) get("/users/#{user_id}/pendingNotificationsCount") end |
#search(keyword, page = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/vine_client/client.rb', line 28 def search(keyword, page = nil) result = get("/users/search/#{keyword}?page=#{page}") method = lambda{|keyword, page| get("/users/search/#{keyword}?page=#{page}")} ResultSet.new(result, keyword, method) end |
#tag(tag = nil, page = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/vine_client/client.rb', line 41 def tag(tag=nil, page=nil) result = get("/timelines/tags/#{tag}?page=#{page}") method = lambda{|tag, page| get("/timelines/tags/#{tag}?page=#{page}")} ResultSet.new(result, tag, method) end |
#timelines(page = nil, user_id = @userId) ⇒ Object
35 36 37 38 39 |
# File 'lib/vine_client/client.rb', line 35 def timelines(page = nil, user_id=@userId) result = get("/timelines/users/#{user_id}?page=#{page}") method = lambda{|user_id, page| get("/timelines/users/#{user_id}?page=#{page}")} ResultSet.new(result, user_id, method) end |
#user_info(user_id = @userId) ⇒ Object
24 25 26 |
# File 'lib/vine_client/client.rb', line 24 def user_info(user_id=@userId) get("/users/profiles/#{user_id}") end |