Class: WhenHub::SchedulesCollection
- Inherits:
-
Object
- Object
- WhenHub::SchedulesCollection
- Defined in:
- lib/whenhub/schedules_collection.rb
Instance Method Summary collapse
- #all ⇒ Object
- #build(attributes = {}) ⇒ Object
- #create(attributes = {}) ⇒ Object
- #find(schedule_id, media: false) ⇒ Object
-
#initialize(client) ⇒ SchedulesCollection
constructor
A new instance of SchedulesCollection.
Constructor Details
#initialize(client) ⇒ SchedulesCollection
Returns a new instance of SchedulesCollection.
3 4 5 |
# File 'lib/whenhub/schedules_collection.rb', line 3 def initialize(client) @client = client end |
Instance Method Details
#all ⇒ Object
7 8 9 10 11 |
# File 'lib/whenhub/schedules_collection.rb', line 7 def all @client.get('/api/users/me/schedules').map do |attributes| Schedule.build(@client, attributes) end end |
#build(attributes = {}) ⇒ Object
23 24 25 |
# File 'lib/whenhub/schedules_collection.rb', line 23 def build(attributes = {}) Schedule.build(@client, attributes) end |
#create(attributes = {}) ⇒ Object
27 28 29 |
# File 'lib/whenhub/schedules_collection.rb', line 27 def create(attributes = {}) build(attributes).tap(&:save) end |
#find(schedule_id, media: false) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/whenhub/schedules_collection.rb', line 13 def find(schedule_id, media: false) params = { 'filter[include][events]' => ['media'], 'filter[include]' => ['media'] } attributes = @client.get("/api/users/me/schedules/#{schedule_id}", params) Schedule.build(@client, attributes) end |