Class: WhenHub::Event

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/whenhub/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client.



11
12
13
# File 'lib/whenhub/event.rb', line 11

def client
  @client
end

#createdAtObject

Returns the value of attribute createdAt.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def createdAt
  @createdAt
end

#createdByObject

Returns the value of attribute createdBy.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def createdBy
  @createdBy
end

#customFieldDataObject

Returns the value of attribute customFieldData.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def customFieldData
  @customFieldData
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def description
  @description
end

#draftObject

Returns the value of attribute draft.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def draft
  @draft
end

#iconObject

Returns the value of attribute icon.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def icon
  @icon
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def id
  @id
end

#locationObject

Returns the value of attribute location.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def location
  @location
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def name
  @name
end

#orderObject

Returns the value of attribute order.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def order
  @order
end

#priorityObject

Returns the value of attribute priority.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def priority
  @priority
end

#resourcesObject

Returns the value of attribute resources.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def resources
  @resources
end

#scheduleIdObject

Returns the value of attribute scheduleId.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def scheduleId
  @scheduleId
end

#tagsObject

Returns the value of attribute tags.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def tags
  @tags
end

#updatedAtObject

Returns the value of attribute updatedAt.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def updatedAt
  @updatedAt
end

#updatedByObject

Returns the value of attribute updatedBy.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def updatedBy
  @updatedBy
end

#userIdObject

Returns the value of attribute userId.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def userId
  @userId
end

#whenObject

Returns the value of attribute when.



7
8
9
# File 'lib/whenhub/event.rb', line 7

def when
  @when
end

Class Method Details

.build(client, schedule, attributes) ⇒ Object



13
14
15
16
17
18
# File 'lib/whenhub/event.rb', line 13

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

Instance Method Details

#deleteObject



38
39
40
# File 'lib/whenhub/event.rb', line 38

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

#saveObject



20
21
22
23
24
25
26
27
# File 'lib/whenhub/event.rb', line 20

def save
  assign_attributes(
    @client.post(
      "/api/users/me/schedules/#{scheduleId}/events",
      writeable_attributes
    ).first
  )
end

#writeable_attributesObject



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

def writeable_attributes
  {
    when: self.when,
    name: name,
    description: description,
    scheduleId: scheduleId
  }
end