Module: Firering::Requests
- Included in:
- Connection
- Defined in:
- lib/firering/requests.rb
Instance Method Summary (collapse)
-
- (Object) authenticate(&callback)
Calls /users/me route on campfire to get the authenticated user information, including token.
-
- (Object) room(id, &callback)
returns a room by id.
-
- (Object) rooms(&callback)
Returns all rooms.
-
- (Object) search_messages(query, &callback)
Returns all the messages containing the supplied term.
-
- (Object) star_message(id, yes_or_no = true, &callback)
Toggles the star next to a message.
-
- (Object) user(id, &callback)
returns a user by id.
Instance Method Details
- (Object) authenticate(&callback)
Calls /users/me route on campfire to get the authenticated user information, including token
5 6 7 8 9 10 |
# File 'lib/firering/requests.rb', line 5 def authenticate(&callback) user("me") do |user| self.token = user.token callback.call(user) end end |
- (Object) room(id, &callback)
returns a room by id
20 21 22 23 24 |
# File 'lib/firering/requests.rb', line 20 def room(id, &callback) http(:get, "/room/#{id}.json") do |data, http| Firering::Room.instantiate(self, data, :room, &callback) end end |
- (Object) rooms(&callback)
Returns all rooms. For getting the users, each specific room must be queries with Firering.room multi: if true, gets all the users from each room as Firering::User objects
28 29 30 31 32 |
# File 'lib/firering/requests.rb', line 28 def rooms(&callback) http(:get, "/rooms.json") do |data, http| callback.call(data[:rooms].map{|room| Firering::Room.instantiate(self, room)}) if callback end end |
- (Object) search_messages(query, &callback)
Returns all the messages containing the supplied term.
35 36 37 38 39 |
# File 'lib/firering/requests.rb', line 35 def (query, &callback) http(:get, "/search/#{query}.json") do |data, http| callback.call(data[:messages].map { |msg| Firering::Message.instantiate(self, msg) }) if callback end end |
- (Object) star_message(id, yes_or_no = true, &callback)
Toggles the star next to a message
42 43 44 45 46 |
# File 'lib/firering/requests.rb', line 42 def (id, yes_or_no = true, &callback) http(yes_or_no ? :post : :delete, "/messages/#{id}/star.json") do |data, http| callback.call(data) if callback end end |
- (Object) user(id, &callback)
returns a user by id
13 14 15 16 17 |
# File 'lib/firering/requests.rb', line 13 def user(id, &callback) http(:get, "/users/#{id}.json") do |data, http| Firering::User.instantiate(self, data, :user, &callback) end end |