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.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +29 -0
  4. data/app/assets/javascripts/message_quickly/index.js.erb +15 -0
  5. data/app/assets/stylesheets/message_quickly/application.css +15 -0
  6. data/app/controllers/message_quickly/application_controller.rb +4 -0
  7. data/app/controllers/message_quickly/webhooks_controller.rb +23 -0
  8. data/app/helpers/message_quickly/application_helper.rb +25 -0
  9. data/app/views/layouts/message_quickly/application.html.erb +14 -0
  10. data/config/routes.rb +4 -0
  11. data/lib/generators/message_quickly/callbacks/USAGE +11 -0
  12. data/lib/generators/message_quickly/callbacks/callbacks_generator.rb +23 -0
  13. data/lib/generators/message_quickly/callbacks/templates/authentication_callback.rb +10 -0
  14. data/lib/generators/message_quickly/callbacks/templates/message_delivered_callback.rb +10 -0
  15. data/lib/generators/message_quickly/callbacks/templates/message_received_callback.rb +10 -0
  16. data/lib/generators/message_quickly/callbacks/templates/postback_callback.rb +10 -0
  17. data/lib/generators/message_quickly/callbacks/templates/process_messenger_callback_job.rb +13 -0
  18. data/lib/generators/message_quickly/callbacks/templates/send_messenger_delivery_job.rb +20 -0
  19. data/lib/generators/message_quickly/callbacks/templates/webhooks.rb +5 -0
  20. data/lib/message_quickly/api/base.rb +20 -0
  21. data/lib/message_quickly/api/client.rb +62 -0
  22. data/lib/message_quickly/api/facebook_api_exception.rb +31 -0
  23. data/lib/message_quickly/api/graph_method_exception.rb +20 -0
  24. data/lib/message_quickly/api/messages.rb +46 -0
  25. data/lib/message_quickly/api/no_matching_user_exception.rb +6 -0
  26. data/lib/message_quickly/api/not_permitted_exception.rb +6 -0
  27. data/lib/message_quickly/api/oauth_exception.rb +20 -0
  28. data/lib/message_quickly/api/send_message_exception.rb +6 -0
  29. data/lib/message_quickly/api/thread_settings.rb +43 -0
  30. data/lib/message_quickly/api/user_profile.rb +22 -0
  31. data/lib/message_quickly/callback.rb +4 -0
  32. data/lib/message_quickly/callback_parser.rb +86 -0
  33. data/lib/message_quickly/callback_registry.rb +28 -0
  34. data/lib/message_quickly/engine.rb +20 -0
  35. data/lib/message_quickly/messaging/attachment.rb +14 -0
  36. data/lib/message_quickly/messaging/base.rb +12 -0
  37. data/lib/message_quickly/messaging/button.rb +9 -0
  38. data/lib/message_quickly/messaging/button_template_attachment.rb +56 -0
  39. data/lib/message_quickly/messaging/delivery.rb +29 -0
  40. data/lib/message_quickly/messaging/delivery_event.rb +47 -0
  41. data/lib/message_quickly/messaging/element.rb +33 -0
  42. data/lib/message_quickly/messaging/entry.rb +14 -0
  43. data/lib/message_quickly/messaging/event.rb +21 -0
  44. data/lib/message_quickly/messaging/generic_template_attachment.rb +82 -0
  45. data/lib/message_quickly/messaging/image_attachment.rb +41 -0
  46. data/lib/message_quickly/messaging/message.rb +36 -0
  47. data/lib/message_quickly/messaging/message_event.rb +60 -0
  48. data/lib/message_quickly/messaging/optin_event.rb +44 -0
  49. data/lib/message_quickly/messaging/postback_button.rb +24 -0
  50. data/lib/message_quickly/messaging/postback_event.rb +44 -0
  51. data/lib/message_quickly/messaging/receipt/address.rb +31 -0
  52. data/lib/message_quickly/messaging/receipt/adjustment.rb +23 -0
  53. data/lib/message_quickly/messaging/receipt/element.rb +22 -0
  54. data/lib/message_quickly/messaging/receipt/summary.rb +27 -0
  55. data/lib/message_quickly/messaging/receipt_template_attachment.rb +108 -0
  56. data/lib/message_quickly/messaging/recipient.rb +17 -0
  57. data/lib/message_quickly/messaging/sender.rb +6 -0
  58. data/lib/message_quickly/messaging/template_attachment.rb +14 -0
  59. data/lib/message_quickly/messaging/user.rb +23 -0
  60. data/lib/message_quickly/messaging/web_url_button.rb +24 -0
  61. data/lib/message_quickly/version.rb +4 -0
  62. data/lib/message_quickly.rb +22 -0
  63. data/spec/callback_parser_spec.rb +53 -0
  64. data/spec/callback_registry_spec.rb +7 -0
  65. data/spec/controllers/webhooks_controller_spec.rb +95 -0
  66. data/spec/dummy/README.rdoc +28 -0
  67. data/spec/dummy/Rakefile +6 -0
  68. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  69. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  70. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  71. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  72. data/spec/dummy/app/jobs/process_messenger_callback_job.rb +13 -0
  73. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  74. data/spec/dummy/app/webhooks/authentication_callback.rb +10 -0
  75. data/spec/dummy/app/webhooks/message_delivered_callback.rb +10 -0
  76. data/spec/dummy/app/webhooks/message_received_callback.rb +10 -0
  77. data/spec/dummy/app/webhooks/postback_callback.rb +10 -0
  78. data/spec/dummy/bin/bundle +3 -0
  79. data/spec/dummy/bin/rails +4 -0
  80. data/spec/dummy/bin/rake +4 -0
  81. data/spec/dummy/bin/setup +29 -0
  82. data/spec/dummy/config/application.rb +31 -0
  83. data/spec/dummy/config/boot.rb +5 -0
  84. data/spec/dummy/config/database.yml +25 -0
  85. data/spec/dummy/config/environment.rb +5 -0
  86. data/spec/dummy/config/environments/development.rb +41 -0
  87. data/spec/dummy/config/environments/production.rb +79 -0
  88. data/spec/dummy/config/environments/test.rb +42 -0
  89. data/spec/dummy/config/initializers/assets.rb +11 -0
  90. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  91. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  92. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  93. data/spec/dummy/config/initializers/inflections.rb +16 -0
  94. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  95. data/spec/dummy/config/initializers/session_store.rb +3 -0
  96. data/spec/dummy/config/initializers/webhooks.rb +5 -0
  97. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  98. data/spec/dummy/config/locales/en.yml +23 -0
  99. data/spec/dummy/config/routes.rb +4 -0
  100. data/spec/dummy/config/secrets.yml +22 -0
  101. data/spec/dummy/config.ru +4 -0
  102. data/spec/dummy/db/test.sqlite3 +0 -0
  103. data/spec/dummy/log/test.log +18183 -0
  104. data/spec/dummy/public/404.html +67 -0
  105. data/spec/dummy/public/422.html +67 -0
  106. data/spec/dummy/public/500.html +66 -0
  107. data/spec/dummy/public/favicon.ico +0 -0
  108. data/spec/fixtures/12057251_909506139117248_2059695706_n.png +0 -0
  109. data/spec/fixtures/delivery_request.json +26 -0
  110. data/spec/fixtures/message_request.json +25 -0
  111. data/spec/fixtures/message_request_with_attachment.json +32 -0
  112. data/spec/fixtures/optin_request.json +23 -0
  113. data/spec/fixtures/postback_request.json +23 -0
  114. data/spec/helpers/application_helper_spec.rb +13 -0
  115. data/spec/message_quickly/api/messages_spec.rb +251 -0
  116. data/spec/message_quickly/api/thread_settings_spec.rb +31 -0
  117. data/spec/message_quickly/api/user_profile_spec.rb +29 -0
  118. data/spec/message_quickly/messaging/user_spec.rb +10 -0
  119. data/spec/spec_helper.rb +24 -0
  120. metadata +318 -0
@@ -0,0 +1,44 @@
1
+ require "message_quickly/messaging/event"
2
+
3
+ module MessageQuickly
4
+ module Messaging
5
+ class PostbackEvent < Event
6
+
7
+ attr_reader :payload
8
+
9
+ def initialize(params = {})
10
+ initialize_params(params['postback'])
11
+ super(params)
12
+ end
13
+
14
+ def webhook_name
15
+ :messaging_postbacks
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+
22
+ # {
23
+ # "object":"page",
24
+ # "entry":[
25
+ # {
26
+ # "id":PAGE_ID,
27
+ # "time":1458692752478,
28
+ # "messaging":[
29
+ # {
30
+ # "sender":{
31
+ # "id":USER_ID
32
+ # },
33
+ # "recipient":{
34
+ # "id":PAGE_ID
35
+ # },
36
+ # "timestamp":1458692752478,
37
+ # "postback":{
38
+ # "payload":"USER_DEFINED_PAYLOAD"
39
+ # }
40
+ # }
41
+ # ]
42
+ # }
43
+ # ]
44
+ # }
@@ -0,0 +1,31 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ module Receipt
4
+ class Address < MessageQuickly::Messaging::Base
5
+
6
+ attr_accessor :street_1, :street_2, :city, :postal_code, :state, :country
7
+
8
+ def to_hash
9
+ {
10
+ street_1: street_1,
11
+ street_2: street_2,
12
+ city: city,
13
+ postal_code: postal_code,
14
+ state: state,
15
+ country: country
16
+ }
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ # "address":{
25
+ # "street_1":"1 Hacker Way",
26
+ # "street_2":"",
27
+ # "city":"Menlo Park",
28
+ # "postal_code":"94025",
29
+ # "state":"CA",
30
+ # "country":"US"
31
+ # }
@@ -0,0 +1,23 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ module Receipt
4
+ class Adjustment < MessageQuickly::Messaging::Base
5
+
6
+ attr_accessor :name, :amount
7
+
8
+ def to_hash
9
+ {
10
+ name: name,
11
+ amount: amount
12
+ }
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ # {
21
+ # "name":"New Customer Discount",
22
+ # "amount":20
23
+ # }
@@ -0,0 +1,22 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ module Receipt
4
+ class Element < MessageQuickly::Messaging::Element
5
+
6
+ attr_accessor :quantity, :price, :currency
7
+
8
+ def to_hash
9
+ {
10
+ title: title,
11
+ subtitle: subtitle,
12
+ quantity: quantity,
13
+ price: price,
14
+ currency: currency,
15
+ image_url: image_url
16
+ }
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ module Receipt
4
+ class Summary < MessageQuickly::Messaging::Base
5
+
6
+ attr_accessor :subtotal, :shipping_cost, :total_tax, :total_cost
7
+
8
+ def to_hash
9
+ {
10
+ subtotal: subtotal,
11
+ shipping_cost: shipping_cost,
12
+ total_tax: total_tax,
13
+ total_cost: total_cost
14
+ }
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ # "summary":{
23
+ # "subtotal":75.00,
24
+ # "shipping_cost":4.95,
25
+ # "total_tax":6.19,
26
+ # "total_cost":56.14
27
+ # }
@@ -0,0 +1,108 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ class ReceiptTemplateAttachment < TemplateAttachment
4
+
5
+ attr_accessor :recipient_name, :order_number, :currency, :payment_method, :order_url, :timestamp, :elements, :address, :summary, :adjustments
6
+
7
+ def initialize(params = {})
8
+ self.elements ||= []
9
+ self.address ||= Receipt::Address.new
10
+ self.summary ||= Receipt::Summary.new
11
+ self.adjustments ||= []
12
+ params['template_type'] ||= 'receipt'
13
+ super(params)
14
+ end
15
+
16
+ def build_element
17
+ elements << Receipt::Element.new.tap { |element| yield element }
18
+ end
19
+
20
+ def build_address
21
+ yield address
22
+ end
23
+
24
+ def build_summary
25
+ yield summary
26
+ end
27
+
28
+ def build_adjustment
29
+ adjustments << Receipt::Adjustment.new.tap { |adjustment| yield adjustment }
30
+ end
31
+
32
+ def to_hash
33
+ {
34
+ type: type,
35
+ payload: {
36
+ template_type: template_type,
37
+ recipient_name: recipient_name,
38
+ order_number: order_number,
39
+ currency: currency,
40
+ payment_method: payment_method,
41
+ order_url: order_url,
42
+ timestamp: timestamp,
43
+ elements: elements.collect { |element| element.to_hash },
44
+ address: address.to_hash,
45
+ summary: summary.to_hash,
46
+ adjustments: adjustments.collect { |adjustment| adjustment.to_hash }
47
+ }
48
+ }
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+
55
+ # "attachment":{
56
+ # "type":"template",
57
+ # "payload":{
58
+ # "template_type":"receipt",
59
+ # "recipient_name":"Stephane Crozatier",
60
+ # "order_number":"12345678902",
61
+ # "currency":"USD",
62
+ # "payment_method":"Visa 2345",
63
+ # "order_url":"http://petersapparel.parseapp.com/order?order_id=123456",
64
+ # "timestamp":"1428444852",
65
+ # "elements":[
66
+ # {
67
+ # "title":"Classic White T-Shirt",
68
+ # "subtitle":"100% Soft and Luxurious Cotton",
69
+ # "quantity":2,
70
+ # "price":50,
71
+ # "currency":"USD",
72
+ # "image_url":"http://petersapparel.parseapp.com/img/whiteshirt.png"
73
+ # },
74
+ # {
75
+ # "title":"Classic Gray T-Shirt",
76
+ # "subtitle":"100% Soft and Luxurious Cotton",
77
+ # "quantity":1,
78
+ # "price":25,
79
+ # "currency":"USD",
80
+ # "image_url":"http://petersapparel.parseapp.com/img/grayshirt.png"
81
+ # }
82
+ # ],
83
+ # "address":{
84
+ # "street_1":"1 Hacker Way",
85
+ # "street_2":"",
86
+ # "city":"Menlo Park",
87
+ # "postal_code":"94025",
88
+ # "state":"CA",
89
+ # "country":"US"
90
+ # },
91
+ # "summary":{
92
+ # "subtotal":75.00,
93
+ # "shipping_cost":4.95,
94
+ # "total_tax":6.19,
95
+ # "total_cost":56.14
96
+ # },
97
+ # "adjustments":[
98
+ # {
99
+ # "name":"New Customer Discount",
100
+ # "amount":20
101
+ # },
102
+ # {
103
+ # "name":"$10 Off Coupon",
104
+ # "amount":10
105
+ # }
106
+ # ]
107
+ # }
108
+ # }
@@ -0,0 +1,17 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ class Recipient < User
4
+
5
+ attr_accessor :phone_number
6
+
7
+ def to_hash
8
+ if id.present?
9
+ { id: id }
10
+ else
11
+ { phone_number: phone_number }
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ class Sender < User
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ class TemplateAttachment < Attachment
4
+
5
+ attr_accessor :template_type
6
+
7
+ def initialize(params = {})
8
+ params['type'] ||= 'template'
9
+ super(params)
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ class User < Base
4
+
5
+ attr_reader :id, :first_name, :last_name, :profile_pic
6
+
7
+ def first_name
8
+ @first_name || user_profile.first_name
9
+ end
10
+
11
+ def last_name
12
+ @last_name || user_profile.last_name
13
+ end
14
+
15
+ private
16
+
17
+ def user_profile
18
+ @user_profile ||= MessageQuickly::Api::UserProfile.find(id)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ module MessageQuickly
2
+ module Messaging
3
+ class WebUrlButton < Button
4
+
5
+ attr_accessor :url
6
+
7
+ def initialize(params = {})
8
+ params['type'] ||= 'web_url'
9
+ super(params)
10
+ end
11
+
12
+ def to_hash
13
+ { type: type, url: url, title: title }
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+
20
+ # {
21
+ # "type":"web_url",
22
+ # "url":"https://petersapparel.parseapp.com",
23
+ # "title":"Show Website"
24
+ # }
@@ -0,0 +1,4 @@
1
+ module MessageQuickly
2
+ VERSION = "1.0.0"
3
+ FB_MESSENGER_VERSION = "v2.6"
4
+ end
@@ -0,0 +1,22 @@
1
+ require "message_quickly/version"
2
+
3
+ require "message_quickly/api/client"
4
+ require "message_quickly/api/base"
5
+ require "message_quickly/api/messages"
6
+ require "message_quickly/api/facebook_api_exception"
7
+ require "message_quickly/api/oauth_exception"
8
+ require "message_quickly/api/graph_method_exception"
9
+ require "message_quickly/api/no_matching_user_exception"
10
+ require "message_quickly/api/not_permitted_exception"
11
+ require "message_quickly/api/send_message_exception"
12
+ require "message_quickly/api/thread_settings"
13
+ require "message_quickly/api/user_profile"
14
+
15
+ require "message_quickly/engine"
16
+
17
+ require "message_quickly/callback"
18
+ require "message_quickly/callback_parser"
19
+ require "message_quickly/callback_registry"
20
+
21
+ module MessageQuickly
22
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ module MessageQuickly
4
+
5
+ describe CallbackParser do
6
+
7
+ context 'with a optin request' do
8
+
9
+ let(:optin_json) { JSON.parse(File.read("spec/fixtures/optin_request.json")) }
10
+
11
+ subject { CallbackParser.new(optin_json) }
12
+
13
+ it { expect { |b| subject.parse(&b) }.to yield_with_args(Messaging::OptinEvent) }
14
+ it { expect(subject.parse).not_to be_empty }
15
+
16
+ end
17
+
18
+ context 'with a delivery request' do
19
+
20
+ let(:delivery_json) { JSON.parse(File.read("spec/fixtures/delivery_request.json")) }
21
+
22
+ subject { CallbackParser.new(delivery_json) }
23
+
24
+ it { expect { |b| subject.parse(&b) }.to yield_with_args(Messaging::DeliveryEvent) }
25
+ it { expect(subject.parse).not_to be_empty }
26
+
27
+ end
28
+
29
+ context 'with a message request' do
30
+
31
+ let(:message_json) { JSON.parse(File.read("spec/fixtures/message_request.json")) }
32
+
33
+ subject { CallbackParser.new(message_json) }
34
+
35
+ it { expect { |b| subject.parse(&b) }.to yield_with_args(Messaging::MessageEvent) }
36
+ it { expect(subject.parse).not_to be_empty }
37
+
38
+ end
39
+
40
+ context 'with a postback request' do
41
+
42
+ let(:postback_json) { JSON.parse(File.read("spec/fixtures/postback_request.json")) }
43
+
44
+ subject { CallbackParser.new(postback_json) }
45
+
46
+ it { expect { |b| subject.parse(&b) }.to yield_with_args(Messaging::PostbackEvent) }
47
+ it { expect(subject.parse).not_to be_empty }
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module MessageQuickly
4
+ describe CallbackRegistry do
5
+
6
+ end
7
+ end
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ describe MessageQuickly::WebhooksController, type: :controller do
4
+
5
+ routes { MessageQuickly::Engine.routes }
6
+
7
+ describe 'GET #verify' do
8
+
9
+ context 'with valid token' do
10
+ before { get :verify, 'hub.verify_token': ENV['FACEBOOK_MESSENGER_VERIFICATION_TOKEN'], 'hub.challenge': '123456' }
11
+ it { expect(response.body).to eq('123456') }
12
+ it { expect(response).to have_http_status(200) }
13
+ end
14
+
15
+ context 'with invalid token' do
16
+ before { get :verify, 'hub.verify_token': '<invalid token>', 'hub.challenge': '123456' }
17
+ it { expect(response.body).to eq('Wrong validation token') }
18
+ it { expect(response).to have_http_status(500) }
19
+ end
20
+
21
+ end
22
+
23
+ describe 'POST #callback' do
24
+
25
+ context 'with an optin request' do
26
+
27
+ let(:optin_json) { File.read("spec/fixtures/optin_request.json") }
28
+
29
+ context 'with valid params' do
30
+ before { post :callback, optin_json }
31
+ it { expect(response).to have_http_status(200) }
32
+ end
33
+
34
+ context 'with invalid params' do
35
+ before { post :callback, 'invalid json' }
36
+ it { expect(response.body).to eq('Error processing callback') }
37
+ it { expect(response).to have_http_status(500) }
38
+ end
39
+
40
+ end
41
+
42
+ context 'with a delivery request' do
43
+
44
+ let(:optin_json) { File.read("spec/fixtures/delivery_request.json") }
45
+
46
+ context 'with valid params' do
47
+ before { post :callback, optin_json }
48
+ it { expect(response).to have_http_status(200) }
49
+ end
50
+
51
+ context 'with invalid params' do
52
+ before { post :callback, 'invalid json' }
53
+ it { expect(response.body).to eq('Error processing callback') }
54
+ it { expect(response).to have_http_status(500) }
55
+ end
56
+
57
+ end
58
+
59
+ context 'with a message request' do
60
+
61
+ let(:optin_json) { File.read("spec/fixtures/message_request.json") }
62
+
63
+ context 'with valid params' do
64
+ before { post :callback, optin_json }
65
+ it { expect(response).to have_http_status(200) }
66
+ end
67
+
68
+ context 'with invalid params' do
69
+ before { post :callback, 'invalid json' }
70
+ it { expect(response.body).to eq('Error processing callback') }
71
+ it { expect(response).to have_http_status(500) }
72
+ end
73
+
74
+ end
75
+
76
+ context 'with a postback request' do
77
+
78
+ let(:optin_json) { File.read("spec/fixtures/postback_request.json") }
79
+
80
+ context 'with valid params' do
81
+ before { post :callback, optin_json }
82
+ it { expect(response).to have_http_status(200) }
83
+ end
84
+
85
+ context 'with invalid params' do
86
+ before { post :callback, 'invalid json' }
87
+ it { expect(response.body).to eq('Error processing callback') }
88
+ it { expect(response).to have_http_status(500) }
89
+ end
90
+
91
+ end
92
+
93
+ end
94
+
95
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,13 @@
1
+ class ProcessMessengerCallbackJob < ActiveJob::Base
2
+
3
+ queue_as :messaging
4
+
5
+ def perform(json)
6
+ MessageQuickly::CallbackParser.new(json.deep_dup).parse do |event|
7
+ callback_handler = MessageQuickly::CallbackRegistry.handler_for(event.webhook_name)
8
+ return unless callback_handler.present?
9
+ callback_handler.new.run(event, json)
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,10 @@
1
+ class AuthenticationCallback < MessageQuickly::Callback
2
+
3
+ def callback_name
4
+ :messaging_optins
5
+ end
6
+
7
+ def run(event, json)
8
+ end
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+ class MessageDeliveredCallback < MessageQuickly::Callback
2
+
3
+ def callback_name
4
+ :message_deliveries
5
+ end
6
+
7
+ def run(event, json)
8
+ end
9
+
10
+ end
@@ -0,0 +1,10 @@
1
+ class MessageReceivedCallback < MessageQuickly::Callback
2
+
3
+ def callback_name
4
+ :messages
5
+ end
6
+
7
+ def run(event, json)
8
+ end
9
+
10
+ end