-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsend_mms.rb
32 lines (23 loc) · 1.01 KB
/
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
require_relative '../scgapi/scgapi.rb'
def send_mms(senderid, mdn, attachment, url_arg = {})
factory = Scg::Factory.new(url_arg);
authenticator = factory.buildAuthenticator(json_config: 'auth.json' )
api_client = factory.buildApiClient(authenticator)
att_res = api_client.attachments
att_id = att_res.create({'name' => 'test_upload',
'type' => 'image/jpeg',
'filename' => 'cutecat.jpg'})['id']
att_res.upload att_id, attachment
mrq_res = api_client.message_requests
request_id = mrq_res.create({'from' => 'sender_id:' + senderid,
'to' =>[mdn],
'attachments' => [att_id],
'body' => 'Hello World'})['id']
puts "Created message request #{request_id}"
end
if !ARGV[0] || !ARGV[1] || !ARGV[2]
puts 'Usage: send_mms.rb senderid receipient attachment [api-url]'
exit -1
end
url_arg = ARGV[2] ? {'api_addr' => ARGV[3]} : {}
send_mms ARGV[0], ARGV[1], ARGV[2], url_arg