Class: HipChat::ApiVersion::Room
- Inherits:
-
HipChat::ApiVersion
- Object
- HipChat::ApiVersion
- HipChat::ApiVersion::Room
- Defined in:
- lib/hipchat/api_version.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#room_id ⇒ Object
readonly
Returns the value of attribute room_id.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #add_member_config ⇒ Object
- #delete_room_config ⇒ Object
- #get_id_attribute ⇒ Object
- #get_room_config ⇒ Object
- #history_config ⇒ Object
-
#initialize(options = {}) ⇒ Room
constructor
A new instance of Room.
- #invite_config ⇒ Object
- #reply_config ⇒ Object
- #send_config ⇒ Object
- #send_file_config ⇒ Object
- #send_message_config ⇒ Object
- #share_link_config ⇒ Object
- #statistics_config ⇒ Object
- #topic_config ⇒ Object
- #update_room_config ⇒ Object
- #webhook_config ⇒ Object
Methods inherited from HipChat::ApiVersion
Constructor Details
#initialize(options = {}) ⇒ Room
Returns a new instance of Room.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/hipchat/api_version.rb', line 99 def initialize( = {}) @version = [:api_version] [:room_id] ||= [get_id_attribute] @room_id = [:room_id] if @version.eql?('v1') @base_uri = "#{[:server_url]}/v1/rooms" @headers = {'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'} else @base_uri = "#{[:server_url]}/v2/room" @headers = {'Accept' => 'application/json', 'Content-Type' => 'application/json'} end end |
Instance Attribute Details
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
114 115 116 |
# File 'lib/hipchat/api_version.rb', line 114 def base_uri @base_uri end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
114 115 116 |
# File 'lib/hipchat/api_version.rb', line 114 def headers @headers end |
#room_id ⇒ Object (readonly)
Returns the value of attribute room_id.
114 115 116 |
# File 'lib/hipchat/api_version.rb', line 114 def room_id @room_id end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
114 115 116 |
# File 'lib/hipchat/api_version.rb', line 114 def version @version end |
Instance Method Details
#add_member_config ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'lib/hipchat/api_version.rb', line 167 def add_member_config { 'v2' => { :url => URI::escape("/#{room_id}/member"), :body_format => :to_json } }[version] end |
#delete_room_config ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/hipchat/api_version.rb', line 143 def delete_room_config { 'v1' => { :url => URI::escape("/delete"), :method => :post, :query_params => { :room_id => room_id } }, 'v2' => { :url => URI::escape("/#{room_id}"), :method => :delete, :query_params => {} } }[version] end |
#get_id_attribute ⇒ Object
116 117 118 |
# File 'lib/hipchat/api_version.rb', line 116 def get_id_attribute version.eql?('v1') ? 'room_id' : 'id' end |
#get_room_config ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/hipchat/api_version.rb', line 120 def get_room_config { 'v1' => { :url => URI::escape('/show'), :query_params => { :room_id => room_id } }, 'v2' => { :url => URI::escape("/#{room_id}"), :query_params => { } } }[version] end |
#history_config ⇒ Object
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/hipchat/api_version.rb', line 242 def history_config { 'v1' => { :url => '/history' }, 'v2' => { :url => URI::escape("/#{room_id}/history") } }[version] end |
#invite_config ⇒ Object
158 159 160 161 162 163 164 165 |
# File 'lib/hipchat/api_version.rb', line 158 def invite_config { 'v2' => { :url => URI::escape("/#{room_id}/invite"), :body_format => :to_json } }[version] end |
#reply_config ⇒ Object
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/hipchat/api_version.rb', line 198 def reply_config { 'v2' => { :url => URI::escape("/#{room_id}/reply"), :method => :post, :query_params => { }, :body_format => :to_json } }[version] end |
#send_config ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/hipchat/api_version.rb', line 185 def send_config { 'v1' => { :url => "/message", :body_format => :to_hash }, 'v2' => { :url => URI::escape("/#{room_id}/notification"), :body_format => :to_json } }[version] end |
#send_file_config ⇒ Object
209 210 211 212 213 214 215 216 |
# File 'lib/hipchat/api_version.rb', line 209 def send_file_config { 'v2' => { :url => URI::escape("/#{room_id}/share/file"), :body_format => :to_json } }[version] end |
#send_message_config ⇒ Object
176 177 178 179 180 181 182 183 |
# File 'lib/hipchat/api_version.rb', line 176 def { 'v2' => { :url => URI::escape("/#{room_id}/message"), :body_format => :to_json } }[version] end |
#share_link_config ⇒ Object
218 219 220 221 222 223 224 225 |
# File 'lib/hipchat/api_version.rb', line 218 def share_link_config { 'v2' => { :url => URI::escape("/#{room_id}/share/link"), :body_format => :to_json } }[version] end |
#statistics_config ⇒ Object
253 254 255 256 257 258 259 |
# File 'lib/hipchat/api_version.rb', line 253 def statistics_config { 'v2' => { :url => URI::escape("/#{room_id}/statistics") } }[version] end |
#topic_config ⇒ Object
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/hipchat/api_version.rb', line 227 def topic_config { 'v1' => { :url => '/topic', :method => :post, :body_format => :to_hash }, 'v2' => { :url => URI::escape("/#{room_id}/topic"), :method => :put, :body_format => :to_json } }[version] end |
#update_room_config ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'lib/hipchat/api_version.rb', line 133 def update_room_config { 'v2' => { :url => URI::escape("/#{room_id}"), :method => :put, :body_format => :to_json } }[version] end |
#webhook_config ⇒ Object
261 262 263 264 265 266 267 268 |
# File 'lib/hipchat/api_version.rb', line 261 def webhook_config raise InvalidApiVersion, 'This functionality is not supported in API v1' unless version.eql?('v2') { 'v2' => { :url => URI::escape("/#{room_id}/webhook") } }[version] end |