Class: DistributionWrappers::Office365
- Inherits:
-
Email
- Object
- Base
- Email
- DistributionWrappers::Office365
show all
- Defined in:
- lib/distribution_wrappers/office365/office365.rb
Instance Attribute Summary
Attributes inherited from Base
#params
Instance Method Summary
collapse
Methods inherited from Email
#prepare
Methods inherited from Base
#initialize
Instance Method Details
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/distribution_wrappers/office365/office365.rb', line 33
def get_contacts
key = @auth[:key]
results = []
response = RestClient.get('https://graph.microsoft.com/v1.0/me/contacts', {"Authorization" => "Bearer #{key}"})
contacts = JSON.parse(response.body)
csv_string = ""
contacts['value'].each do |contact|
csv_string += CSV.generate_line [contact['displayName'], contact['emailAddresses'].first['address'], '{"url": null}', 'email', @params[:channel_id]]
end
@params[:temp_file].write(csv_string)
return true
end
|
#send_message(email) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/distribution_wrappers/office365/office365.rb', line 4
def send_message(email)
super
key = @auth[:key]
recipients = []
recipients << {'emailAddress' => {"address" => email['identifier']}}
message = {
'subject' => @params[:subject],
'body' => {
'contentType' => 'HTML',
'content' => @message
},
"toRecipients" => recipients,
"sender" => {
"emailAddress" => {
"address" => @params[:custom_opts]['send_from']
}
}
}
send_response = Curl.post('https://graph.microsoft.com/v1.0/me/sendMail', {"Message" => message}.to_json) do |http|
http.['Authorization'] = "Bearer #{key}"
http.['Content-Type'] = 'application/json'
end
end
|