Class: Textmagic::REST::Sessions
- Inherits:
-
ListResource
- Object
- ListResource
- Textmagic::REST::Sessions
- Defined in:
- lib/textmagic-ruby/rest/sessions.rb
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
Creating is not supported.
-
#delete(uid) ⇒ Object
Delete session by ID.
-
#get(uid) ⇒ Object
Get session by ID.
-
#list(params = {}) ⇒ Object
Get all user message sessions.
-
#messages(uid, params = {}) ⇒ Object
Fetch messages by given session id.
-
#update(uid, params = {}) ⇒ Object
Updating is not supported.
Methods inherited from ListResource
Methods included from Utils
#key_map, #resource, #to_camel_case, #to_underscore_case
Constructor Details
This class inherits a constructor from Textmagic::REST::ListResource
Instance Method Details
#create(params = {}) ⇒ Object
Creating is not supported.
72 73 74 |
# File 'lib/textmagic-ruby/rest/sessions.rb', line 72 def create(params={}) raise '`create` method is not supported for this resource.' end |
#delete(uid) ⇒ Object
Delete session by ID. Returns true if success.
- uid
-
Session ID. Required.
Example:
r = client.sessions.delete 123123
85 86 87 |
# File 'lib/textmagic-ruby/rest/sessions.rb', line 85 def delete(uid) super uid end |
#get(uid) ⇒ Object
Get session by ID. Returns Session object.
- uid
-
Session ID. Required.
Example:
@session = client.sessions.get 123131
36 37 38 |
# File 'lib/textmagic-ruby/rest/sessions.rb', line 36 def get(uid) super uid end |
#list(params = {}) ⇒ Object
Get all user message sessions. Returns PaginateResource object, contains array of Session objects.
The following params keys are supported:
- page
-
Fetch specified results page. Defaults 1
- limit
-
How many results on page. Defaults 10
Example:
@sessions = client.sessions.list
19 20 21 22 23 24 |
# File 'lib/textmagic-ruby/rest/sessions.rb', line 19 def list(params={}) [:search, 'search'].each do |search| params.delete search end super params end |
#messages(uid, params = {}) ⇒ Object
Fetch messages by given session id. An useful synonym for “messages/search” command with provided ‘session_id` parameter. Returns PaginateResource object, contains array of Message objects.
- uid
-
Session ID. Required.
The following params keys are supported:
- page
-
Fetch specified results page. Defaults 1
- limit
-
How many results on page. Defaults 10
Example:
@messages = client.sessions. 123
57 58 59 60 |
# File 'lib/textmagic-ruby/rest/sessions.rb', line 57 def (uid, params={}) response = @client.get "#{@path}/#{uid}/messages", params PaginateResource.new "#{@path}", @client, response, Textmagic::REST::Message end |
#update(uid, params = {}) ⇒ Object
Updating is not supported.
65 66 67 |
# File 'lib/textmagic-ruby/rest/sessions.rb', line 65 def update(uid, params={}) raise '`update` method is not supported for this resource.' end |