Class: RubyDesk::TeamRoom

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_desk/team_room.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ TeamRoom

Create a new TeamRoom from a hash similar to the one in ActiveRecord::Base. The given hash maps each attribute name to its value



24
25
26
27
28
# File 'lib/ruby_desk/team_room.rb', line 24

def initialize(params={})
  params.each do |k, v|
    self.instance_variable_set("@#{k}", v)
  end
end

Instance Attribute Details

#company_nameObject (readonly)

Attribute readers for all attributes



3
4
5
# File 'lib/ruby_desk/team_room.rb', line 3

def company_name
  @company_name
end

#company_recnoObject (readonly)

Attribute readers for all attributes



3
4
5
# File 'lib/ruby_desk/team_room.rb', line 3

def company_recno
  @company_recno
end

#idObject (readonly)

Attribute readers for all attributes



3
4
5
# File 'lib/ruby_desk/team_room.rb', line 3

def id
  @id
end

#nameObject (readonly)

Attribute readers for all attributes



3
4
5
# File 'lib/ruby_desk/team_room.rb', line 3

def name
  @name
end

#recnoObject (readonly)

Attribute readers for all attributes



3
4
5
# File 'lib/ruby_desk/team_room.rb', line 3

def recno
  @recno
end

#teamroom_apiObject (readonly)

Attribute readers for all attributes



3
4
5
# File 'lib/ruby_desk/team_room.rb', line 3

def teamroom_api
  @teamroom_api
end

Class Method Details

.get_teamrooms(connector) ⇒ Object

Retrieves all team rooms for the currently logged in user



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby_desk/team_room.rb', line 7

def get_teamrooms(connector)
  json = connector.prepare_and_invoke_api_call 'team/v1/teamrooms',
      :method=>:get

  team_rooms = []
  [json['teamrooms']['teamroom']].flatten.each do |teamroom|
    # Append this TeamRoom to array
    team_rooms << self.new(teamroom)
  end
  # return the resulting array
  team_rooms
end

Instance Method Details

#snapshot(connector, online = 'now') ⇒ Object

Retrieves all snaphots for users currently connected to this team room



31
32
33
34
35
36
# File 'lib/ruby_desk/team_room.rb', line 31

def snapshot(connector, online='now')
  json = connector.prepare_and_invoke_api_call "team/v1/teamrooms/#{self.id}",
    :params=>{:online=>online}, :method=>:get

  RubyDesk::Snapshot.new(json['teamroom']['snapshot'])
end

#work_diary(connector, user_id, date = nil, timezone = "mine") ⇒ Object

Retrieves work diary for this team room



39
40
41
# File 'lib/ruby_desk/team_room.rb', line 39

def work_diary(connector, user_id, date = nil, timezone = "mine")
  RubyDesk::Snapshot.workdiary(connector, self.id, user_id, date, timezone)
end