-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsms_send_mms.rb
52 lines (42 loc) · 1.44 KB
/
sms_send_mms.rb
1
2
3
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!ruby
require 'dotenv'
require 'ringcentral_sdk'
require 'pp'
# Set your credentials in the .env file
# Use the credentials_sample.env.txt file as a scaffold
envPath = ENV['ENV_PATH'] || '.env'
Dotenv.load envPath
client = RingCentralSdk::REST::Client.new do |config|
config.server_url = ENV['RINGCENTRAL_SERVER_URL']
config.client_id = ENV['RINGCENTRAL_CLIENT_ID']
config.client_secret = ENV['RINGCENTRAL_CLIENT_SECRET']
config.username = ENV['RINGCENTRAL_USERNAME']
config.extension = ENV['RINGCENTRAL_EXTENSION']
config.password = ENV['RINGCENTRAL_PASSWORD']
end
def send_mms_object(client)
req = RingCentralSdk::REST::Request::Multipart.new(
method: 'post',
url: '/restapi/v1.0/account/~/extension/~/sms'
).
add_json({
to: [{phoneNumber: ENV['RINGCENTRAL_DEMO_SMS_TO']}],
from: {phoneNumber: ENV['RINGCENTRAL_DEMO_SMS_FROM']},
text: ENV['RINGCENTRAL_DEMO_SMS_TEXT']
}).
add_file(ENV['RINGCENTRAL_DEMO_MMS_FILE'])
res = client.send_request req
end
def send_mms_quick(client)
client.messages.sms.create(
to: [ENV['RINGCENTRAL_DEMO_SMS_TO']],
from: ENV['RINGCENTRAL_DEMO_SMS_FROM'],
text: ENV['RINGCENTRAL_DEMO_SMS_TEXT'],
media: ENV['RINGCENTRAL_DEMO_MMS_FILE']
)
end
pp({ to: [ENV['RINGCENTRAL_DEMO_SMS_TO']], from: ENV['RINGCENTRAL_DEMO_SMS_FROM'], text: ENV['RINGCENTRAL_DEMO_SMS_TEXT'] })
res = send_mms_object client
pp res.body
puts res.status
puts 'DONE'