Class: WhenHub::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/whenhub/schedule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client.



21
22
23
# File 'lib/whenhub/schedule.rb', line 21

def client
  @client
end

Class Method Details

.build(client, attributes) ⇒ Object



23
24
25
26
27
# File 'lib/whenhub/schedule.rb', line 23

def self.build(client, attributes)
  new(attributes).tap do |schedule|
    schedule.client = client
  end
end

Instance Method Details

#deleteObject



44
45
46
# File 'lib/whenhub/schedule.rb', line 44

def delete
  @client.delete("/api/schedules/#{id}")
end

#eventsObject



48
49
50
# File 'lib/whenhub/schedule.rb', line 48

def events
  EventsCollection.new(client, self)
end

#saveObject



29
30
31
32
33
34
# File 'lib/whenhub/schedule.rb', line 29

def save
  self.attributes = @client.post(
    '/api/users/me/schedules',
    writeable_attributes
  )
end

#writeable_attributesObject



36
37
38
39
40
41
42
# File 'lib/whenhub/schedule.rb', line 36

def writeable_attributes
  {
    name: name,
    description: description,
    scope: scope
  }
end