-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
78 lines (67 loc) · 2 KB
/
app.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'message_media_messages.rb' # This gem contains all the logic for dealing with the MessageMedia Messages API
require 'pp' # This gem is for displaying 'pretty' JSON
def setup
# The API credentials needed to access the Messages API
auth_user_name = 'API_KEY'
auth_password = 'API_SECRET'
use_hmac = false # Change this to true if you are using HMAC keys
# Instantiating the client
client = MessageMediaMessages::MessageMediaMessagesClient.new(
auth_user_name: auth_user_name,
auth_password: auth_password,
use_hmac: use_hmac
)
return client
end
def send_message
# Setup authentication and instantiate client
client = setup();
# Creating the message structure
messages = client.messages
body_value = '{
"messages":[
{
"content":"Appointment Reminder",
"destination_number":"+61491570156",
"metadata": {
"name": "Ibrahim"
},
"delivery_report": "true",
"callback_url": "https://www.mycallbackurl.com"
}
]
}';
# Parsing the message body and converting it into a Ruby object
body = JSON.parse(body_value);
# Finally, sending the message
result = messages.create_send_messages(body)
# Displaying the response in the console
pp result
end
# Function to check message status
def check_status
# Setup authentication and instantiate client
client = setup()
messages = client.messages
message_id = 'MESSAGE_ID'
result = messages.get_message_status(message_id)
pp result
end
# Function to check replies
def check_replies
# Setup authentication and instantiate client
client = setup()
replies = client.replies
result = replies.get_check_replies()
pp result
end
# Function to check delivery reports
def check_delivery_reports
# Setup authentication and instantiate client
client = setup()
deliveryReports = client.delivery_reports
result = deliveryReports.get_check_delivery_reports()
pp result
end
# Add your function calls over here
send_message