Class: Textmagic::REST::Chats
- Inherits:
-
ListResource
- Object
- ListResource
- Textmagic::REST::Chats
- Defined in:
- lib/textmagic-ruby/rest/chats.rb
Instance Method Summary collapse
-
#create(params = {}) ⇒ Object
Creating is not supported.
-
#delete(uid) ⇒ Object
Deleting is not supported.
-
#get(uid) ⇒ Object
Getting by ID is not supported.
-
#get_by_phone(phone, params = {}) ⇒ Object
Fetch messages from chat with specified phone number.
-
#list(params = {}) ⇒ Object
Get all user chats.
-
#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.
47 48 49 |
# File 'lib/textmagic-ruby/rest/chats.rb', line 47 def create(params={}) raise '`create` method is not supported for this resource.' end |
#delete(uid) ⇒ Object
Deleting is not supported.
68 69 70 |
# File 'lib/textmagic-ruby/rest/chats.rb', line 68 def delete(uid) raise '`delete` method is not supported for this resource.' end |
#get(uid) ⇒ Object
Getting by ID is not supported. Try get_by_phone instead.
54 55 56 |
# File 'lib/textmagic-ruby/rest/chats.rb', line 54 def get(uid) raise '`get` method by ID is not supported for this resource, use `get_by_phone`.' end |
#get_by_phone(phone, params = {}) ⇒ Object
Fetch messages from chat with specified phone number.
- phone
-
Phone number in E.164 format. Required.
The following params keys are supported:
- page
-
Fetch specified results page. Defaults 1
- limit
-
How many results on page. Defaults 10
Example:
= client.chats.get_by_phone 99990000
39 40 41 42 |
# File 'lib/textmagic-ruby/rest/chats.rb', line 39 def get_by_phone(phone, params={}) response = @client.get "#{@path}/#{phone}", params PaginateResource.new "#{@path}", @client, response, Textmagic::REST::ChatMessage end |
#list(params = {}) ⇒ Object
Get all user chats.
The following params keys are supported:
- page
-
Fetch specified results page. Defaults 1
- limit
-
How many results on page. Defaults 10
Example:
@chats = client.chats.list
17 18 19 20 21 22 |
# File 'lib/textmagic-ruby/rest/chats.rb', line 17 def list(params={}) [:search, 'search'].each do |search| params.delete search end super params end |
#update(uid, params = {}) ⇒ Object
Updating is not supported.
61 62 63 |
# File 'lib/textmagic-ruby/rest/chats.rb', line 61 def update(uid, params={}) raise '`update` method is not supported for this resource.' end |