Class: MicrosoftGraphMailer::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/microsoft_graph_mailer/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id:, tenant:, client_id:, client_secret:, azure_ad_endpoint:, graph_endpoint:) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
# File 'lib/microsoft_graph_mailer/client.rb', line 9

def initialize(user_id:, tenant:, client_id:, client_secret:, azure_ad_endpoint:, graph_endpoint:)
  @user_id = user_id
  @tenant = tenant
  @client_id = client_id
  @client_secret = client_secret
  @azure_ad_endpoint = azure_ad_endpoint
  @graph_endpoint = graph_endpoint
end

Instance Attribute Details

#azure_ad_endpointObject

Returns the value of attribute azure_ad_endpoint.



7
8
9
# File 'lib/microsoft_graph_mailer/client.rb', line 7

def azure_ad_endpoint
  @azure_ad_endpoint
end

#client_idObject

Returns the value of attribute client_id.



7
8
9
# File 'lib/microsoft_graph_mailer/client.rb', line 7

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



7
8
9
# File 'lib/microsoft_graph_mailer/client.rb', line 7

def client_secret
  @client_secret
end

#graph_endpointObject

Returns the value of attribute graph_endpoint.



7
8
9
# File 'lib/microsoft_graph_mailer/client.rb', line 7

def graph_endpoint
  @graph_endpoint
end

#tenantObject

Returns the value of attribute tenant.



7
8
9
# File 'lib/microsoft_graph_mailer/client.rb', line 7

def tenant
  @tenant
end

#user_idObject

Returns the value of attribute user_id.



7
8
9
# File 'lib/microsoft_graph_mailer/client.rb', line 7

def user_id
  @user_id
end

Instance Method Details

#send_mail(message_in_mime_format) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/microsoft_graph_mailer/client.rb', line 18

def send_mail(message_in_mime_format)
  # https://docs.microsoft.com/en-us/graph/api/user-sendmail
  token.post(
    send_mail_url,
    headers: { "Content-type" => "text/plain" },
    body: Base64.encode64(message_in_mime_format)
  )
end