Module: Tuiter::DirectMessageMethods
- Included in:
- Client
- Defined in:
- lib/tuiter/methods/direct_message.rb
Instance Method Summary collapse
- #direct_messages(options = {}) ⇒ Object
- #direct_messages_new(user, text) ⇒ Object
- #direct_messages_sent(options = {}) ⇒ Object
Instance Method Details
#direct_messages(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tuiter/methods/direct_message.rb', line 11 def ( = {}) url = '/direct_messages.json' params = () || "" if res = @request_handler.get(url+params).body data = JSON.parse(res) return data.map { |d| Tuiter::DirectMessage.new(d) } else return nil end end |
#direct_messages_new(user, text) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tuiter/methods/direct_message.rb', line 35 def (user, text) log("direct_new() sending: #{text} to #{user}") res = @request_handler.post('/direct_messages/new.json', {'user'=>user, 'text'=>text }) case res when Net::HTTPSuccess, Net::HTTPRedirection log("direct_new() success: OK") return res # OK else log("direct_new() error: #{res.error!}") res.error! end end |
#direct_messages_sent(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tuiter/methods/direct_message.rb', line 23 def ( = {}) url = '/direct_messages/sent.json' params = () || "" if res = @request_handler.get(url+params).body data = JSON.parse(res) return data.map { |d| Tuiter::DirectMessage.new(d) } else return nil end end |