Class: Msgraph::Api::Resource::Message

Inherits:
Base
  • Object
show all
Defined in:
lib/msgraph/api/resource/message.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #parent, #resource_name

Instance Method Summary collapse

Methods inherited from Base

#client, #initialize, lists, #method_missing, resource_name, #resource_path, #user

Constructor Details

This class inherits a constructor from Msgraph::Api::Resource::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Msgraph::Api::Resource::Base

Instance Method Details

#move(parent_or_id) ⇒ Object



18
19
20
21
22
# File 'lib/msgraph/api/resource/message.rb', line 18

def move(parent_or_id)
  id = parent_or_id
  id = id.id unless id.is_a?(String)
  self.attributes = post(path: resource_path.join_path("move"), body: {destination_id: id})
end

#read!Object



14
15
16
# File 'lib/msgraph/api/resource/message.rb', line 14

def read!
  self.attributes = patch(body: {is_read: true})
end

#read?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/msgraph/api/resource/message.rb', line 6

def read?
  self.is_read
end

#to_rfc822Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/msgraph/api/resource/message.rb', line 24

def to_rfc822
  if self.attributes[:rfc822].nil?
    # plain format request won't work within nested folder scope,
    # so we need to crawl up to the parent user and request the
    # message from there.
    path = user.messages.find(id).resource_path.join_path("$value")
    self.attributes[:rfc822] = get(path: path, format: :plain)
  end
  self.attributes[:rfc822]
end

#unread?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/msgraph/api/resource/message.rb', line 10

def unread?
  !read?
end