Sha256: bc40d6ab4078a6175d15328df678254628b1c58b0cb24b171e67fa7324ec7318

Contents?: true

Size: 769 Bytes

Versions: 4

Compression:

Stored size: 769 Bytes

Contents

require 'restful_model'

module Inbox
  class Event < RestfulModel

    parameter :title
    parameter :description
    parameter :location
    parameter :read_only
    parameter :participants
    parameter :when
    parameter :calendar_id
    parameter :namespace_id
    parameter :recurrence
    parameter :cancelled
    parameter :master_event_id
    parameter :original_start_time

    def as_json(options = {})
      hash = super(options)

      # 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

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
nylas-0.15.5 lib/event.rb
inbox-0.15.4 lib/event.rb
inbox-0.15.3 lib/event.rb
inbox-0.15.2 lib/event.rb