class HipChat::ApiVersion::Room

Attributes

base_uri[R]
headers[R]
room_id[R]
version[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/hipchat/api_version.rb, line 69
def initialize(options = {})
  @room_id = options[:room_id]
  @version = options[:api_version]
  if @version.eql?('v1')
    @base_uri = "#{options[:server_url]}/v1/rooms"
    @headers = {'Accept' => 'application/json',
       'Content-Type' => 'application/x-www-form-urlencoded'}
  else
    @base_uri = "#{options[:server_url]}/v2/room"
    @headers = {'Accept' => 'application/json',
       'Content-Type' => 'application/json'}
  end
end

Public Instance Methods

get_room_config() click to toggle source
# File lib/hipchat/api_version.rb, line 85
def get_room_config
  {
    'v2' => {
      :url => URI::escape("/#{room_id}")
    }
  }[version]
end
history_config() click to toggle source
# File lib/hipchat/api_version.rb, line 140
def history_config
  {
    'v1' => {
      :url => '/history'
    },
    'v2' => {
      :url => URI::escape("/#{room_id}/history")
    }
  }[version]
end
invite_config() click to toggle source
# File lib/hipchat/api_version.rb, line 103
def invite_config
  {
    'v2' => {
      :url => URI::escape("/#{room_id}/invite"),
      :body_format => :to_json
    }
  }[version]
end
send_config() click to toggle source
# File lib/hipchat/api_version.rb, line 112
def send_config
  {
    'v1' => {
      :url => "/message",
      :body_format => :to_hash
    },
    'v2' => {
      :url => URI::escape("/#{room_id}/notification"),
      :body_format => :to_json
    }
  }[version]
end
statistics_config() click to toggle source
# File lib/hipchat/api_version.rb, line 151
def statistics_config
  {
    'v2' => {
      :url => URI::escape("/#{room_id}/statistics")
    }
  }[version]
end
topic_config() click to toggle source
# File lib/hipchat/api_version.rb, line 125
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() click to toggle source
# File lib/hipchat/api_version.rb, line 93
def update_room_config
  {
    "v2" => {
      :url => URI::escape("/#{room_id}"),
      :method => :put,
      :body_format => :to_json
    }
  }[version]
end