Class: Inbox::Event
- Inherits:
-
RestfulModel
- Object
- RestfulModel
- Inbox::Event
- Defined in:
- lib/event.rb
Instance Attribute Summary
Attributes inherited from RestfulModel
Instance Method Summary collapse
Methods inherited from RestfulModel
#==, collection_name, #destroy, #inflate, #initialize, #save!, #update, #url
Methods included from TimeAttrAccessor
Methods included from Parameters
Constructor Details
This class inherits a constructor from Inbox::RestfulModel
Instance Method Details
#as_json(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/event.rb', line 19 def as_json( = {}) hash = super() # Delete nil values from the hash hash.delete_if { |key, value| value.nil? } # The API doesn't like to receive: "object": "timespan" in the when block. if hash.has_key?('when') and hash['when'].has_key?('object') hash['when'].delete('object') end return hash end |
#rsvp!(status, comment) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/event.rb', line 33 def rsvp!(status, comment) url = @_api.url_for_path("/send-rsvp") data = {:event_id => @id, :status => status, :comment => comment} ::RestClient.post(url, data.to_json, :content_type => :json) do |response, request, result| json = Inbox.interpret_response(result, response, :expected_class => Object) self.inflate(json) end self end |