Class: Talknote::Client
- Inherits:
-
Object
- Object
- Talknote::Client
- Defined in:
- lib/talknote/client.rb
Instance Method Summary collapse
- #dm ⇒ Object
- #dm_list(id) ⇒ Object
- #dm_post(id, message, options = {}) ⇒ Object
- #dm_unread(id) ⇒ Object
-
#group ⇒ Object
Group-related methods.
- #group_list(id) ⇒ Object
- #group_post(id, message, options = {}) ⇒ Object
- #group_unread(id) ⇒ Object
Instance Method Details
#dm ⇒ Object
9 10 11 |
# File 'lib/talknote/client.rb', line 9 def dm handle_response(conn.get('api/v1/dm')) end |
#dm_list(id) ⇒ Object
13 14 15 |
# File 'lib/talknote/client.rb', line 13 def dm_list(id) handle_response(conn.get("api/v1/dm/list/#{id}")) end |
#dm_post(id, message, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/talknote/client.rb', line 21 def dm_post(id, , = {}) # Let's try form-encoded data instead of JSON data = { message: } data.merge!() if .any? response = conn.post("api/v1/dm/post/#{id}") do |req| req.headers['Content-Type'] = 'application/x-www-form-urlencoded' req.body = URI.encode_www_form(data) end handle_response(response) end |
#dm_unread(id) ⇒ Object
17 18 19 |
# File 'lib/talknote/client.rb', line 17 def dm_unread(id) handle_response(conn.get("api/v1/dm/unread/#{id}")) end |
#group ⇒ Object
Group-related methods
34 35 36 |
# File 'lib/talknote/client.rb', line 34 def group handle_response(conn.get('api/v1/group')) end |
#group_list(id) ⇒ Object
38 39 40 |
# File 'lib/talknote/client.rb', line 38 def group_list(id) handle_response(conn.get("api/v1/group/list/#{id}")) end |
#group_post(id, message, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/talknote/client.rb', line 46 def group_post(id, , = {}) data = { message: } data.merge!() if .any? response = conn.post("api/v1/group/post/#{id}") do |req| req.headers['Content-Type'] = 'application/x-www-form-urlencoded' req.body = URI.encode_www_form(data) end handle_response(response) end |
#group_unread(id) ⇒ Object
42 43 44 |
# File 'lib/talknote/client.rb', line 42 def group_unread(id) handle_response(conn.get("api/v1/group/unread/#{id}")) end |