Class: Kato::Room
Instance Method Summary collapse
-
#initialize(room_id, options = {}) ⇒ Room
constructor
A new instance of Room.
- #post(from, message, options = {}) ⇒ Object
Constructor Details
#initialize(room_id, options = {}) ⇒ Room
Returns a new instance of Room.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kato.rb', line 10 def initialize(room_id, = {}) = { :api_url => 'https://api.kato.im', :integration => 'simple' } = .merge url = [:api_url] + '/rooms/' + room_id + '/' + [:integration] url = [:full_url] if [:full_url] self.class.base_uri url end |
Instance Method Details
#post(from, message, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kato.rb', line 21 def post(from, , = {}) body = { :from => from, :text => }.merge response = self.class.post('', :headers => { 'Content-Type' => 'application/json' }, :body => body.to_json ) case response.code when 200,204 true else raise "#{response.} (#{response.code})" end end |