Class: CiscoSpark::Team

Inherits:
Base
  • Object
show all
Defined in:
lib/team.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #delete, #refresh, #update

Constructor Details

#initialize(data) ⇒ Team

Returns a new instance of Team.



4
5
6
7
8
# File 'lib/team.rb', line 4

def initialize(data)
  @api_endpoint = 'teams'
  @update_fields = [:name]
  super
end

Instance Attribute Details

#createdObject

Returns the value of attribute created.



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

def created
  @created
end

#creatorIdObject

Returns the value of attribute creatorId.



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

def creatorId
  @creatorId
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.create(name, payload = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/team.rb', line 18

def create(name, payload = {})
  payload[:name] = name
  res = CiscoSpark.rest('POST', '/teams', payload: payload)
  if res.ok
    team = CiscoSpark::Team.new(JSON.parse(res.body))
    return team
  end
  nil
end

.get(id) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/team.rb', line 10

def get(id)
  res = CiscoSpark.rest('GET', "/teams/#{id}")
  if res.ok
    team = CiscoSpark::Team.new(JSON.parse(res.body))
    return team
  end
  nil
end