Class: Convore::Topic
Instance Attribute Summary
Attributes inherited from Base
#attributes, #password, #username
Class Method Summary collapse
Instance Method Summary collapse
-
#create_message(topic_id, hash) ⇒ Object
Post a new message.
-
#delete_topic(topic_id) ⇒ Object
Delete a topic.
-
#edit_topic(topic_id, hash) ⇒ Object
Edit a topic.
-
#get_topic(topic_id) ⇒ Object
Get detailed information about the topic.
-
#get_topic_messages(topic_id, *hash) ⇒ Object
Get the latest messages in a topic.
-
#initialize(username, password) ⇒ Topic
constructor
A new instance of Topic.
-
#mark_read(topic_id) ⇒ Object
Mark all messages in a topic as read.
Methods inherited from Base
find, from_json, get_class, #method_missing
Constructor Details
#initialize(username, password) ⇒ Topic
Returns a new instance of Topic.
4 5 6 7 |
# File 'lib/convore/topic.rb', line 4 def initialize(username, password) @username = username @password = password end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Convore::Base
Class Method Details
.api ⇒ Object
60 61 62 |
# File 'lib/convore/topic.rb', line 60 def self.api 'topic' end |
Instance Method Details
#create_message(topic_id, hash) ⇒ Object
Post a new message
30 31 32 33 34 35 |
# File 'lib/convore/topic.rb', line 30 def (topic_id, hash) if topic_id.integer? RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/messages/create.json", {:message => hash[:message]} end end |
#delete_topic(topic_id) ⇒ Object
Delete a topic. You must be the creator of the topic or a group admin in order to delete the topic.
39 40 41 42 43 |
# File 'lib/convore/topic.rb', line 39 def delete_topic(topic_id) if topic_id.integer? RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/delete.json", {} end end |
#edit_topic(topic_id, hash) ⇒ Object
Edit a topic. You must be the creator of the topic or a group admin in order to edit the topic.
46 47 48 49 50 51 |
# File 'lib/convore/topic.rb', line 46 def edit_topic(topic_id, hash) if topic_id.integer? RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/edit.json", {:name => hash[:name]} end end |
#get_topic(topic_id) ⇒ Object
Get detailed information about the topic
10 11 12 13 14 |
# File 'lib/convore/topic.rb', line 10 def get_topic(topic_id) if topic_id.integer? RestClient.get "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}.json" end end |
#get_topic_messages(topic_id, *hash) ⇒ Object
Get the latest messages in a topic. Use the optional until_id parameter to paginate and get prior messages. Set the optional mark_read parameter to false to leave the messages as unread
19 20 21 22 23 24 25 26 27 |
# File 'lib/convore/topic.rb', line 19 def (topic_id, *hash) if topic_id.integer? RestClient.get "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/messages.json", #Optional Parms #until_id #mark_read hash[0] end end |
#mark_read(topic_id) ⇒ Object
Mark all messages in a topic as read
54 55 56 57 58 |
# File 'lib/convore/topic.rb', line 54 def mark_read(topic_id) if topic_id.integer? RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/mark_read.json", {} end end |