Sha256: 7699e2ae3c45e360d92c4aba3f98d5cc06dfe51c22c16a7d6580702c2e94643e

Contents?: true

Size: 1.16 KB

Versions: 35

Compression:

Stored size: 1.16 KB

Contents

require 'restful_model'
require 'time_attr_accessor'

module Inbox
  class Thread < RestfulModel
    extend TimeAttrAccessor

    parameter :subject
    parameter :participants
    parameter :snippet
    parameter :tags
    parameter :message_ids
    parameter :draft_ids
    time_attr_accessor :last_message_timestamp
    time_attr_accessor :first_message_timestamp

    def messages
      @messages ||= RestfulModelCollection.new(Message, @_api, @namespace_id, {:thread_id=>@id})
    end

    def drafts
      @drafts ||= RestfulModelCollection.new(Draft, @_api, @namespace_id, {:thread_id=>@id})
    end

    def update_tags!(tags_to_add = [], tags_to_remove = [])
      update('PUT', '', {
        :add_tags => tags_to_add,
        :remove_tags => tags_to_remove
      })
    end

    def mark_as_read!
      update_tags!([], ['unread'])
    end

    def mark_as_seen!
      update_tags!([], ['unseen'])
    end

    def archive!
      update_tags!(['archive'], ['inbox'])
    end

    def unarchive!
      update_tags!(['inbox'], ['archive'])
    end

    def star!
      update_tags!(['starred'], [''])
    end

    def unstar!
      update_tags!([], ['starred'])
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
nylas-0.17.4 lib/api_thread.rb
inbox-0.17.4 lib/api_thread.rb
inbox-0.17.2 lib/api_thread.rb
nylas-0.17.2 lib/api_thread.rb
inbox-0.17.1 lib/api_thread.rb
nylas-0.17.1 lib/api_thread.rb
nylas-0.17.0 lib/api_thread.rb
inbox-0.17.0 lib/api_thread.rb
inbox-0.16.1 lib/api_thread.rb
nylas-0.16.1 lib/api_thread.rb
nylas-0.16.0 lib/api_thread.rb
inbox-0.16.0 lib/api_thread.rb
inbox-0.15.8 lib/api_thread.rb
nylas-0.15.7d lib/api_thread.rb
inbox-0.15.7d lib/api_thread.rb
nylas-0.15.7c lib/api_thread.rb
nylas-0.15.7b lib/api_thread.rb
nylas-0.15.7 lib/api_thread.rb
nylas-0.15.6 lib/api_thread.rb
nylas-0.15.5 lib/api_thread.rb