message_quickly 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/message_quickly/index.js.erb +15 -0
- data/app/assets/stylesheets/message_quickly/application.css +15 -0
- data/app/controllers/message_quickly/application_controller.rb +4 -0
- data/app/controllers/message_quickly/webhooks_controller.rb +23 -0
- data/app/helpers/message_quickly/application_helper.rb +25 -0
- data/app/views/layouts/message_quickly/application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/lib/generators/message_quickly/callbacks/USAGE +11 -0
- data/lib/generators/message_quickly/callbacks/callbacks_generator.rb +23 -0
- data/lib/generators/message_quickly/callbacks/templates/authentication_callback.rb +10 -0
- data/lib/generators/message_quickly/callbacks/templates/message_delivered_callback.rb +10 -0
- data/lib/generators/message_quickly/callbacks/templates/message_received_callback.rb +10 -0
- data/lib/generators/message_quickly/callbacks/templates/postback_callback.rb +10 -0
- data/lib/generators/message_quickly/callbacks/templates/process_messenger_callback_job.rb +13 -0
- data/lib/generators/message_quickly/callbacks/templates/send_messenger_delivery_job.rb +20 -0
- data/lib/generators/message_quickly/callbacks/templates/webhooks.rb +5 -0
- data/lib/message_quickly/api/base.rb +20 -0
- data/lib/message_quickly/api/client.rb +62 -0
- data/lib/message_quickly/api/facebook_api_exception.rb +31 -0
- data/lib/message_quickly/api/graph_method_exception.rb +20 -0
- data/lib/message_quickly/api/messages.rb +46 -0
- data/lib/message_quickly/api/no_matching_user_exception.rb +6 -0
- data/lib/message_quickly/api/not_permitted_exception.rb +6 -0
- data/lib/message_quickly/api/oauth_exception.rb +20 -0
- data/lib/message_quickly/api/send_message_exception.rb +6 -0
- data/lib/message_quickly/api/thread_settings.rb +43 -0
- data/lib/message_quickly/api/user_profile.rb +22 -0
- data/lib/message_quickly/callback.rb +4 -0
- data/lib/message_quickly/callback_parser.rb +86 -0
- data/lib/message_quickly/callback_registry.rb +28 -0
- data/lib/message_quickly/engine.rb +20 -0
- data/lib/message_quickly/messaging/attachment.rb +14 -0
- data/lib/message_quickly/messaging/base.rb +12 -0
- data/lib/message_quickly/messaging/button.rb +9 -0
- data/lib/message_quickly/messaging/button_template_attachment.rb +56 -0
- data/lib/message_quickly/messaging/delivery.rb +29 -0
- data/lib/message_quickly/messaging/delivery_event.rb +47 -0
- data/lib/message_quickly/messaging/element.rb +33 -0
- data/lib/message_quickly/messaging/entry.rb +14 -0
- data/lib/message_quickly/messaging/event.rb +21 -0
- data/lib/message_quickly/messaging/generic_template_attachment.rb +82 -0
- data/lib/message_quickly/messaging/image_attachment.rb +41 -0
- data/lib/message_quickly/messaging/message.rb +36 -0
- data/lib/message_quickly/messaging/message_event.rb +60 -0
- data/lib/message_quickly/messaging/optin_event.rb +44 -0
- data/lib/message_quickly/messaging/postback_button.rb +24 -0
- data/lib/message_quickly/messaging/postback_event.rb +44 -0
- data/lib/message_quickly/messaging/receipt/address.rb +31 -0
- data/lib/message_quickly/messaging/receipt/adjustment.rb +23 -0
- data/lib/message_quickly/messaging/receipt/element.rb +22 -0
- data/lib/message_quickly/messaging/receipt/summary.rb +27 -0
- data/lib/message_quickly/messaging/receipt_template_attachment.rb +108 -0
- data/lib/message_quickly/messaging/recipient.rb +17 -0
- data/lib/message_quickly/messaging/sender.rb +6 -0
- data/lib/message_quickly/messaging/template_attachment.rb +14 -0
- data/lib/message_quickly/messaging/user.rb +23 -0
- data/lib/message_quickly/messaging/web_url_button.rb +24 -0
- data/lib/message_quickly/version.rb +4 -0
- data/lib/message_quickly.rb +22 -0
- data/spec/callback_parser_spec.rb +53 -0
- data/spec/callback_registry_spec.rb +7 -0
- data/spec/controllers/webhooks_controller_spec.rb +95 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/process_messenger_callback_job.rb +13 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/webhooks/authentication_callback.rb +10 -0
- data/spec/dummy/app/webhooks/message_delivered_callback.rb +10 -0
- data/spec/dummy/app/webhooks/message_received_callback.rb +10 -0
- data/spec/dummy/app/webhooks/postback_callback.rb +10 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/webhooks.rb +5 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +18183 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fixtures/12057251_909506139117248_2059695706_n.png +0 -0
- data/spec/fixtures/delivery_request.json +26 -0
- data/spec/fixtures/message_request.json +25 -0
- data/spec/fixtures/message_request_with_attachment.json +32 -0
- data/spec/fixtures/optin_request.json +23 -0
- data/spec/fixtures/postback_request.json +23 -0
- data/spec/helpers/application_helper_spec.rb +13 -0
- data/spec/message_quickly/api/messages_spec.rb +251 -0
- data/spec/message_quickly/api/thread_settings_spec.rb +31 -0
- data/spec/message_quickly/api/user_profile_spec.rb +29 -0
- data/spec/message_quickly/messaging/user_spec.rb +10 -0
- data/spec/spec_helper.rb +24 -0
- metadata +318 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/404.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/422.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/500.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
62
|
+
</div>
|
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
64
|
+
</div>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object":"page",
|
|
3
|
+
"entry":[
|
|
4
|
+
{
|
|
5
|
+
"id":"PAGE_ID",
|
|
6
|
+
"time":1458668856451,
|
|
7
|
+
"messaging":[
|
|
8
|
+
{
|
|
9
|
+
"sender":{
|
|
10
|
+
"id":"USER_ID"
|
|
11
|
+
},
|
|
12
|
+
"recipient":{
|
|
13
|
+
"id":"PAGE_ID"
|
|
14
|
+
},
|
|
15
|
+
"delivery":{
|
|
16
|
+
"mids":[
|
|
17
|
+
"mid.1458668856218:ed81099e15d3f4f233"
|
|
18
|
+
],
|
|
19
|
+
"watermark":1458668856253,
|
|
20
|
+
"seq":37
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object":"page",
|
|
3
|
+
"entry":[
|
|
4
|
+
{
|
|
5
|
+
"id":"PAGE_ID",
|
|
6
|
+
"time":1457764198246,
|
|
7
|
+
"messaging":[
|
|
8
|
+
{
|
|
9
|
+
"sender":{
|
|
10
|
+
"id":"USER_ID"
|
|
11
|
+
},
|
|
12
|
+
"recipient":{
|
|
13
|
+
"id":"PAGE_ID"
|
|
14
|
+
},
|
|
15
|
+
"timestamp":1457764197627,
|
|
16
|
+
"message":{
|
|
17
|
+
"mid":"mid.1457764197618:41d102a3e1ae206a38",
|
|
18
|
+
"seq":73,
|
|
19
|
+
"text":"hello, world!"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object":"page",
|
|
3
|
+
"entry":[
|
|
4
|
+
{
|
|
5
|
+
"id":"PAGE_ID",
|
|
6
|
+
"time":1458696618911,
|
|
7
|
+
"messaging":[
|
|
8
|
+
{
|
|
9
|
+
"sender":{
|
|
10
|
+
"id":"USER_ID"
|
|
11
|
+
},
|
|
12
|
+
"recipient":{
|
|
13
|
+
"id":"PAGE_ID"
|
|
14
|
+
},
|
|
15
|
+
"timestamp":1458696618268,
|
|
16
|
+
"message":{
|
|
17
|
+
"mid":"mid.1458696618141:b4ef9d19ec21086067",
|
|
18
|
+
"seq":51,
|
|
19
|
+
"attachments":[
|
|
20
|
+
{
|
|
21
|
+
"type":"image",
|
|
22
|
+
"payload":{
|
|
23
|
+
"url":"IMAGE_URL"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object":"page",
|
|
3
|
+
"entry":[
|
|
4
|
+
{
|
|
5
|
+
"id":"PAGE_ID",
|
|
6
|
+
"time":12341,
|
|
7
|
+
"messaging":[
|
|
8
|
+
{
|
|
9
|
+
"sender":{
|
|
10
|
+
"id":"USER_ID"
|
|
11
|
+
},
|
|
12
|
+
"recipient":{
|
|
13
|
+
"id":"PAGE_ID"
|
|
14
|
+
},
|
|
15
|
+
"timestamp":1234567890,
|
|
16
|
+
"optin":{
|
|
17
|
+
"ref":"PASS_THROUGH_PARAM"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object":"page",
|
|
3
|
+
"entry":[
|
|
4
|
+
{
|
|
5
|
+
"id":"PAGE_ID",
|
|
6
|
+
"time":1458692752478,
|
|
7
|
+
"messaging":[
|
|
8
|
+
{
|
|
9
|
+
"sender":{
|
|
10
|
+
"id":"USER_ID"
|
|
11
|
+
},
|
|
12
|
+
"recipient":{
|
|
13
|
+
"id":"PAGE_ID"
|
|
14
|
+
},
|
|
15
|
+
"timestamp":1458692752478,
|
|
16
|
+
"postback":{
|
|
17
|
+
"payload":"USER_DEFINED_PAYLOAD"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe ApplicationHelper, :type => :helper do
|
|
4
|
+
|
|
5
|
+
describe "#send_to_messenger" do
|
|
6
|
+
it { expect(helper.send_to_messenger).to eq("<div class=\"fb-send-to-messenger\" messenger_app_id=\"#{ENV['FACEBOOK_APP_ID']}\" data-ref=\"PASS_THROUGH_PARAM\" color=\"blue\" size=\"standard\"></div>") }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#message_us" do
|
|
10
|
+
it { expect(helper.message_us).to eq("<div class=\"fb-messengermessageus\" messenger_app_id=\"#{ENV['FACEBOOK_APP_ID']}\" color=\"blue\" size=\"standard\"></div>") }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe MessageQuickly::Api::Messages do
|
|
4
|
+
|
|
5
|
+
subject { MessageQuickly::Api::Messages }
|
|
6
|
+
|
|
7
|
+
let(:recipient) { MessageQuickly::Messaging::Recipient.new(id: ENV['FACEBOOK_MESSENGER_USER_ID']) }
|
|
8
|
+
|
|
9
|
+
describe '#create' do
|
|
10
|
+
|
|
11
|
+
context 'with own client' do
|
|
12
|
+
|
|
13
|
+
let(:client) { MessageQuickly::Api::Client.new(page_access_token: ENV['FACEBOOK_MESSENGER_PAGE_ACCESS_TOKEN'], page_id: ENV['FACEBOOK_MESSENGER_PAGE_ID']) }
|
|
14
|
+
|
|
15
|
+
it 'should be able to send text' do
|
|
16
|
+
delivery = subject.new(client).create(recipient) do |message|
|
|
17
|
+
message.text = 'Hello'
|
|
18
|
+
end
|
|
19
|
+
expect(delivery.id).not_to be_nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'with invalid recipient' do
|
|
25
|
+
|
|
26
|
+
let(:recipient) { MessageQuickly::Messaging::Recipient.new(id: 'invalid') }
|
|
27
|
+
|
|
28
|
+
it 'should raise an exception' do
|
|
29
|
+
expect do
|
|
30
|
+
subject.create(recipient) do |message|
|
|
31
|
+
message.text = 'Hello'
|
|
32
|
+
end
|
|
33
|
+
end.to raise_exception(MessageQuickly::Api::OauthException)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'with a phone number recipient' do
|
|
39
|
+
|
|
40
|
+
context "that's valid" do
|
|
41
|
+
let(:recipient) { MessageQuickly::Messaging::Recipient.new(phone: '+1(212)555-2368') }
|
|
42
|
+
|
|
43
|
+
# it 'should be able to send text' do
|
|
44
|
+
# pending
|
|
45
|
+
# delivery = subject.create(recipient) do |message|
|
|
46
|
+
# message.text = 'Hello'
|
|
47
|
+
# end
|
|
48
|
+
# expect(delivery.id).not_to be_nil
|
|
49
|
+
# end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "that's invalid" do
|
|
53
|
+
let(:recipient) { MessageQuickly::Messaging::Recipient.new(phone: '+1(212)555-2368') }
|
|
54
|
+
|
|
55
|
+
it 'should raise an exception' do
|
|
56
|
+
expect do
|
|
57
|
+
subject.create(recipient) do |message|
|
|
58
|
+
message.text = 'Hello'
|
|
59
|
+
end
|
|
60
|
+
end.to raise_exception(MessageQuickly::Api::OauthException)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context 'with a valid recipient' do
|
|
67
|
+
|
|
68
|
+
it 'should be able to send text' do
|
|
69
|
+
delivery = subject.create(recipient) do |message|
|
|
70
|
+
message.text = 'Hello'
|
|
71
|
+
end
|
|
72
|
+
expect(delivery.id).not_to be_nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'should be able to send with an image url attachment' do
|
|
76
|
+
delivery = subject.create(recipient) do |message|
|
|
77
|
+
message.build_attachment(:image) { |attachment| attachment.url = 'http://placehold.it/350x150' }
|
|
78
|
+
end
|
|
79
|
+
expect(delivery.id).not_to be_nil
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'should be able to send with an image file attachment' do
|
|
83
|
+
delivery = subject.create(recipient) do |message|
|
|
84
|
+
message.build_attachment(:image) do |attachment|
|
|
85
|
+
attachment.file = "spec/fixtures/12057251_909506139117248_2059695706_n.png"
|
|
86
|
+
attachment.file_type = 'image/png'
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
expect(delivery.id).not_to be_nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should be able to send with a generic template attachment' do
|
|
93
|
+
delivery = subject.create(recipient) do |message|
|
|
94
|
+
message.build_attachment(:generic_template) do |template|
|
|
95
|
+
|
|
96
|
+
template.build_element do |element|
|
|
97
|
+
|
|
98
|
+
element.title = "Classic White T-Shirt"
|
|
99
|
+
element.image_url = 'http://petersapparel.parseapp.com/img/item100-thumb.png'
|
|
100
|
+
element.subtitle = 'Soft white cotton t-shirt is back in style'
|
|
101
|
+
|
|
102
|
+
element.build_button(:web_url) do |button|
|
|
103
|
+
button.url = "https://petersapparel.parseapp.com/view_item?item_id=100"
|
|
104
|
+
button.title = "View Item"
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
element.build_button(:web_url) do |button|
|
|
108
|
+
button.url = "https://petersapparel.parseapp.com/buy_item?item_id=100"
|
|
109
|
+
button.title = "Buy Item"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
element.build_button(:postback) do |button|
|
|
113
|
+
button.payload = "USER_DEFINED_PAYLOAD_FOR_ITEM100"
|
|
114
|
+
button.title = "Bookmark Item"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
template.build_element do |element|
|
|
120
|
+
|
|
121
|
+
element.title = "Classic Grey T-Shirt"
|
|
122
|
+
element.image_url = 'http://petersapparel.parseapp.com/img/item101-thumb.png'
|
|
123
|
+
element.subtitle = 'Soft gray cotton t-shirt is back in style'
|
|
124
|
+
|
|
125
|
+
element.build_button(:web_url) do |button|
|
|
126
|
+
button.url = "https://petersapparel.parseapp.com/view_item?item_id=101"
|
|
127
|
+
button.title = "View Item"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
element.build_button(:web_url) do |button|
|
|
131
|
+
button.url = "https://petersapparel.parseapp.com/buy_item?item_id=101"
|
|
132
|
+
button.title = "Buy Item"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
element.build_button(:postback) do |button|
|
|
136
|
+
button.payload = "USER_DEFINED_PAYLOAD_FOR_ITEM101"
|
|
137
|
+
button.title = "Bookmark Item"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
expect(delivery.id).not_to be_nil
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'should be able to send with a button template attachment' do
|
|
148
|
+
delivery = subject.create(recipient) do |message|
|
|
149
|
+
message.build_attachment(:button_template) do |template|
|
|
150
|
+
|
|
151
|
+
template.text = 'How are you doing today?'
|
|
152
|
+
|
|
153
|
+
template.build_button(:web_url) do |button|
|
|
154
|
+
button.url = 'https://petersapparel.parseapp.com'
|
|
155
|
+
button.title = 'Show Website'
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
template.build_button(:postback) do |button|
|
|
159
|
+
button.payload = 'USER_DEFINED_PAYLOAD'
|
|
160
|
+
button.title = 'Start Chatting'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
expect(delivery.id).not_to be_nil
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'should be able to send with a receipt template attachment' do
|
|
169
|
+
delivery = subject.create(recipient) do |message|
|
|
170
|
+
message.build_attachment(:receipt_template) do |template|
|
|
171
|
+
|
|
172
|
+
template.recipient_name = 'Stephane Crozatier'
|
|
173
|
+
template.order_number = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
|
174
|
+
template.currency = 'USD'
|
|
175
|
+
template.payment_method = 'Visa 2345'
|
|
176
|
+
template.order_url = 'http://petersapparel.parseapp.com/order?order_id=123456'
|
|
177
|
+
template.timestamp = '1428444852'
|
|
178
|
+
|
|
179
|
+
template.build_element do |element|
|
|
180
|
+
element.title = 'Classic White T-Shirt'
|
|
181
|
+
element.subtitle = '100% Soft and Luxurious Cotton'
|
|
182
|
+
element.quantity = 2
|
|
183
|
+
element.price = 50
|
|
184
|
+
element.currency = 'USD'
|
|
185
|
+
element.image_url = 'http://petersapparel.parseapp.com/img/whiteshirt.png'
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
template.build_element do |element|
|
|
189
|
+
element.title = 'Classic Gray T-Shirt'
|
|
190
|
+
element.subtitle = '100% Soft and Luxurious Cotton'
|
|
191
|
+
element.quantity = 1
|
|
192
|
+
element.price = 25
|
|
193
|
+
element.currency = 'USD'
|
|
194
|
+
element.image_url = 'http://petersapparel.parseapp.com/img/grayshirt.png'
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
template.build_address do |address|
|
|
198
|
+
address.street_1 = "1 Hacker Way"
|
|
199
|
+
address.street_2 = ""
|
|
200
|
+
address.city = "Menlo Park"
|
|
201
|
+
address.postal_code = "94025"
|
|
202
|
+
address.state = "CA"
|
|
203
|
+
address.country = "US"
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
template.build_summary do |summary|
|
|
207
|
+
summary.subtotal = 75.00
|
|
208
|
+
summary.shipping_cost = 4.95
|
|
209
|
+
summary.total_tax = 6.19
|
|
210
|
+
summary.total_cost = 56.14
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
template.build_adjustment do |adjustment|
|
|
214
|
+
adjustment.name = "New Customer Discount"
|
|
215
|
+
adjustment.amount = 20
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
template.build_adjustment do |adjustment|
|
|
219
|
+
adjustment.name = "$10 Off Coupon"
|
|
220
|
+
adjustment.amount = 10
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
expect(delivery.id).not_to be_nil
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
describe '#create_from_hash' do
|
|
233
|
+
|
|
234
|
+
let(:client) { MessageQuickly::Api::Client.new(page_access_token: ENV['FACEBOOK_MESSENGER_PAGE_ACCESS_TOKEN'], page_id: ENV['FACEBOOK_MESSENGER_PAGE_ID']) }
|
|
235
|
+
let(:recipient) { MessageQuickly::Messaging::Recipient.new(id: ENV['FACEBOOK_MESSENGER_USER_ID']) }
|
|
236
|
+
|
|
237
|
+
let(:hash) do
|
|
238
|
+
MessageQuickly::Messaging::Delivery.new(recipient: recipient) do |delivery|
|
|
239
|
+
delivery.build_message do |message|
|
|
240
|
+
message.text = 'Hello'
|
|
241
|
+
end
|
|
242
|
+
end.to_hash
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'should be able to send text' do
|
|
246
|
+
expect(subject.new(client).create_from_hash(hash)).not_to be_nil
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe MessageQuickly::Api::ThreadSettings do
|
|
4
|
+
|
|
5
|
+
subject { MessageQuickly::Api::ThreadSettings }
|
|
6
|
+
|
|
7
|
+
describe '#create' do
|
|
8
|
+
|
|
9
|
+
let(:message) { MessageQuickly::Messaging::Message.new(text: 'Hello') }
|
|
10
|
+
|
|
11
|
+
context 'with own client' do
|
|
12
|
+
let(:client) { MessageQuickly::Api::Client.new(page_access_token: ENV['FACEBOOK_MESSENGER_PAGE_ACCESS_TOKEN'], page_id: ENV['FACEBOOK_MESSENGER_PAGE_ID']) }
|
|
13
|
+
it { expect(subject.new(client).create(message)).to eq(true) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context 'with valid params' do
|
|
17
|
+
it { expect(subject.create(message)).to eq(true) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'with invalid params' do
|
|
21
|
+
before { stub_const('ENV', ENV.to_hash.merge('FACEBOOK_MESSENGER_PAGE_ID' => 'invalid')) }
|
|
22
|
+
it { expect { subject.create(message) }.to raise_exception(MessageQuickly::Api::OauthException) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#delete' do
|
|
28
|
+
it { expect(subject.delete).to eq(true) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe MessageQuickly::Api::UserProfile do
|
|
4
|
+
|
|
5
|
+
subject { MessageQuickly::Api::UserProfile }
|
|
6
|
+
|
|
7
|
+
describe '#find' do
|
|
8
|
+
|
|
9
|
+
let(:fbid) { ENV['FACEBOOK_MESSENGER_USER_ID'] }
|
|
10
|
+
let(:fbid_invalid) { '091283908123' }
|
|
11
|
+
|
|
12
|
+
context 'with own client' do
|
|
13
|
+
let(:client) { MessageQuickly::Api::Client.new(page_access_token: ENV['FACEBOOK_MESSENGER_PAGE_ACCESS_TOKEN'], page_id: ENV['FACEBOOK_MESSENGER_PAGE_ID']) }
|
|
14
|
+
it { expect(subject.new(client).find(fbid)).to be_kind_of(MessageQuickly::Messaging::User) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'with matching user' do
|
|
18
|
+
it { expect(subject.find(fbid)).to be_kind_of(MessageQuickly::Messaging::User) }
|
|
19
|
+
it { expect(subject.find(fbid).first_name).to eq(ENV['FACEBOOK_MESSENGER_USER_FIRST_NAME']) }
|
|
20
|
+
it { expect(subject.find(fbid).last_name).to eq(ENV['FACEBOOK_MESSENGER_USER_LAST_NAME']) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'with no matching user' do
|
|
24
|
+
it { expect { subject.find(fbid_invalid) }.to raise_exception(MessageQuickly::Api::GraphMethodException) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe MessageQuickly::Messaging::User do
|
|
4
|
+
|
|
5
|
+
subject { MessageQuickly::Messaging::User.new(id: ENV['FACEBOOK_MESSENGER_USER_ID']) }
|
|
6
|
+
|
|
7
|
+
it { expect(subject.first_name).to eq(ENV['FACEBOOK_MESSENGER_USER_FIRST_NAME']) }
|
|
8
|
+
it { expect(subject.last_name).to eq(ENV['FACEBOOK_MESSENGER_USER_LAST_NAME']) }
|
|
9
|
+
|
|
10
|
+
end
|