Module: Easemob::Messages
- Included in:
- Easemob
- Defined in:
- lib/easemob/messages.rb
Instance Method Summary collapse
- #audio_to(target, target_type: :users, url:, filename:, length:, secret: nil, from: nil, ext: nil) ⇒ Object
- #command_to(target, target_type: :users, action:, from: nil, ext: nil) ⇒ Object
- #image_to(target, target_type: :users, url:, filename:, secret: nil, from: nil, image_size: nil, ext: nil) ⇒ Object
- #message_to(target, target_type: :users, text:, from: nil, ext: nil) ⇒ Object
- #video_to(target, target_type: :users, url:, filename:, length:, file_length:, thumb:, secret: nil, thumb_secret: nil, from: nil, ext: nil) ⇒ Object
Instance Method Details
#audio_to(target, target_type: :users, url:, filename:, length:, secret: nil, from: nil, ext: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/easemob/messages.rb', line 24 def audio_to(target, target_type: :users, url:, filename:, length:, secret: nil, from: nil, ext: nil) jd = { target_type: target_type, target: [*target], msg: { type: :audio, url: url, filename: filename, length: length } } jd[:msg][:secret] = secret unless secret.nil? jd[:from] = from unless from.nil? jd[:ext] = ext unless ext.nil? ChatMessage.new request :post, 'messages', json: jd end |
#command_to(target, target_type: :users, action:, from: nil, ext: nil) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/easemob/messages.rb', line 46 def command_to(target, target_type: :users, action:, from: nil, ext: nil) jd = { target_type: target_type, target: [*target], msg: { type: :cmd, action: action } } jd[:from] = from unless from.nil? jd[:ext] = ext unless ext.nil? ChatMessage.new request :post, 'messages', json: jd end |
#image_to(target, target_type: :users, url:, filename:, secret: nil, from: nil, image_size: nil, ext: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easemob/messages.rb', line 13 def image_to(target, target_type: :users, url:, filename:, secret: nil, from: nil, image_size: nil, ext: nil) jd = { target_type: target_type, target: [*target], msg: { type: :img, filename: filename, url: url } } jd[:msg][:secret] = secret unless secret.nil? jd[:from] = from unless from.nil? jd[:size] = image_size unless image_size.nil? jd[:ext] = ext unless ext.nil? ChatMessage.new request :post, 'messages', json: jd end |
#message_to(target, target_type: :users, text:, from: nil, ext: nil) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/easemob/messages.rb', line 4 def (target, target_type: :users, text:, from: nil, ext: nil) jd = { target_type: target_type, target: [*target], msg: { type: :txt, msg: text } } jd[:from] = from unless from.nil? jd[:ext] = ext unless ext.nil? ChatMessage.new request :post, 'messages', json: jd end |
#video_to(target, target_type: :users, url:, filename:, length:, file_length:, thumb:, secret: nil, thumb_secret: nil, from: nil, ext: nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/easemob/messages.rb', line 34 def video_to(target, target_type: :users, url:, filename:, length:, file_length:, thumb:, secret: nil, thumb_secret: nil, from: nil, ext: nil) jd = { target_type: target_type, target: [*target], msg: { type: :video, filename: filename, thumb: thumb, length: length, file_length: file_length, url: url } } jd[:msg][:secret] = secret unless secret.nil? jd[:msg][:thumb_secret] = thumb_secret unless thumb_secret.nil? jd[:from] = from unless from.nil? jd[:ext] = ext unless ext.nil? ChatMessage.new request :post, 'messages', json: jd end |