sm_sms_campaign_webhook 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +100 -6
- data/app/models/sm_sms_campaign_webhook/campaign_engagement.rb +31 -31
- data/app/models/sm_sms_campaign_webhook/campaign_engagement/answer.rb +18 -14
- data/app/operations/sm_sms_campaign_webhook/campaign_engagement_operation.rb +3 -3
- data/app/processors/sm_sms_campaign_webhook/processable.rb +1 -1
- data/lib/generators/sm_sms_campaign_webhook/install/install_generator.rb +2 -2
- data/lib/generators/sm_sms_campaign_webhook/install/templates/sms_payload_processor.rb.erb +1 -1
- data/lib/sm_sms_campaign_webhook.rb +3 -3
- data/lib/sm_sms_campaign_webhook/version.rb +1 -1
- data/sm_sms_campaign_webhook.gemspec +23 -17
- metadata +34 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c9e06fcd786b02a6ee242bd41008108826f55c777022449516dd1882c047797
|
4
|
+
data.tar.gz: 65c4a176a43566e112f0d6ca19f2a2fd79d9af9721d3b29b51b5dc89d220f9ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2d84c4ed5cd7cd5a14b10eb87903e6aacba85fbf310895299bca1afc1a95670f744a29bf7509a267982cb5cd134164ef42d471ce1ea357fbe2b0bae6630ab1f
|
7
|
+
data.tar.gz: 3c0e4704cbbc02ad28581e5230c0d0fbf8b074b50cdc4677638bab9a52ad0021fca7ef1944e4c9ba68fa29cd8a486bb7176d36ce29e64e556831a792dfb6d0ee
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.0.0] - 2020-12-31
|
10
|
+
### Added
|
11
|
+
- Campaign engagement payload example to README
|
12
|
+
- Support for Rails 6.1.x
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Required version of rake for development
|
16
|
+
- Standardize style/format of gem code with [StandardRB](https://github.com/testdouble/standard)
|
17
|
+
- CI to test against Ruby 2.7.x
|
18
|
+
- Required Ruby version to permit 3.0.x
|
19
|
+
- CI to test against Ruby 3.0.x
|
20
|
+
- CI to test against Rails 6.1.x
|
21
|
+
|
22
|
+
### Removed
|
23
|
+
- Rails 5.2.x support
|
24
|
+
|
9
25
|
## [1.0.0] - 2019-07-26
|
10
26
|
### Added
|
11
27
|
- Mountable Rails engine as API
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# SmSmsCampaignWebhook
|
2
2
|
|
3
|
-
![Southern Made - Galaxy Logo](https://raw.github.com/SouthernMade/sm_sms_campaign_webhook/develop/logo_galaxymark.png) by [Southern Made](https://www.southernmade.com/)
|
3
|
+
[![Southern Made - Galaxy Logo](https://raw.github.com/SouthernMade/sm_sms_campaign_webhook/develop/logo_galaxymark.png)](https://www.southernmade.com/) by [Southern Made](https://www.southernmade.com/)
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/sm_sms_campaign_webhook.svg)](https://
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/sm_sms_campaign_webhook.svg)](https://rubygems.org/gems/sm_sms_campaign_webhook)
|
6
6
|
[![Travis Build Status](https://travis-ci.org/SouthernMade/sm_sms_campaign_webhook.svg?branch=develop)](https://travis-ci.org/SouthernMade/sm_sms_campaign_webhook)
|
7
7
|
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/2298f12a7d6f31688c9c/maintainability)](https://codeclimate.com/github/SouthernMade/sm_sms_campaign_webhook/maintainability)
|
8
8
|
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/2298f12a7d6f31688c9c/test_coverage)](https://codeclimate.com/github/SouthernMade/sm_sms_campaign_webhook/test_coverage)
|
@@ -32,6 +32,7 @@ Work closely with your Southern Made project manager to gather details about wha
|
|
32
32
|
- [Processor Expections](#processor-expections)
|
33
33
|
- [Campaign Engagement Data Model](#campaign-engagement-data-model)
|
34
34
|
- [Campaign Engagement Answer Data Model](#campaign-engagement-answer-data-model)
|
35
|
+
- [Campaign Engagement Payload Example](#campaign-engagement-payload-example)
|
35
36
|
- [Development](#development)
|
36
37
|
- [Versioning](#versioning)
|
37
38
|
- [Testing](#testing)
|
@@ -41,12 +42,12 @@ Work closely with your Southern Made project manager to gather details about wha
|
|
41
42
|
|
42
43
|
## Installation
|
43
44
|
|
44
|
-
This gem is tested with Rails
|
45
|
+
This gem is tested with Rails 6.0.x, 6.1.x versions.
|
45
46
|
|
46
47
|
Add this line to your application's Gemfile:
|
47
48
|
|
48
49
|
```ruby
|
49
|
-
gem
|
50
|
+
gem "sm_sms_campaign_webhook", "~> 1.0"
|
50
51
|
```
|
51
52
|
|
52
53
|
And then execute:
|
@@ -101,6 +102,8 @@ SM_SMS_CAMPAIGN_WEBHOOK_AUTH_TOKEN="******"
|
|
101
102
|
|
102
103
|
Payloads will be dispatched and processed asynchronously using [ActiveJob](https://edgeguides.rubyonrails.org/active_job_basics.html). Southern Made prefers that the app be configured with [Sidekiq](https://github.com/mperham/sidekiq) as the queue adapter.
|
103
104
|
|
105
|
+
If you have already chosen another queue adapter then feel free to ignore this step!
|
106
|
+
|
104
107
|
You can set the adapter in `config/application.rb` with:
|
105
108
|
|
106
109
|
```ruby
|
@@ -109,6 +112,38 @@ class Application < Rails::Application
|
|
109
112
|
end
|
110
113
|
```
|
111
114
|
|
115
|
+
Add `config/sidekiq.yml` config with:
|
116
|
+
|
117
|
+
```yaml
|
118
|
+
---
|
119
|
+
:concurrency: <%= ENV.fetch("SIDEKIQ_CONCURRENCY") { 5 }.to_i %>
|
120
|
+
:timeout: <%= ENV.fetch("SIDEKIQ_TIMEOUT") { 25 }.to_i %>
|
121
|
+
:queues:
|
122
|
+
- default
|
123
|
+
- mailers
|
124
|
+
```
|
125
|
+
|
126
|
+
Add `config/initializers/sidekiq.rb` with:
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
# @note Sidekiq server + client must both be configured for Redis.
|
130
|
+
# @see https://github.com/mperham/sidekiq/wiki/Using-Redis
|
131
|
+
|
132
|
+
Sidekiq.configure_server do |config|
|
133
|
+
config.redis = {
|
134
|
+
url: ENV.fetch("REDIS_URL") { "redis://localhost:6379/0" },
|
135
|
+
network_timeout: ENV.fetch("REDIS_NETWORK_TIMEOUT") { 5 }.to_i
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
Sidekiq.configure_client do |config|
|
140
|
+
config.redis = {
|
141
|
+
url: ENV.fetch("REDIS_URL") { "redis://localhost:6379/0" },
|
142
|
+
network_timeout: ENV.fetch("REDIS_NETWORK_TIMEOUT") { 5 }.to_i
|
143
|
+
}
|
144
|
+
end
|
145
|
+
```
|
146
|
+
|
112
147
|
Update your Procfile or appropriate config to launch worker processes:
|
113
148
|
|
114
149
|
```
|
@@ -206,7 +241,7 @@ It is important that you work closely with your Southern Made project manager to
|
|
206
241
|
|
207
242
|
#### Processor Expections
|
208
243
|
|
209
|
-
You must behavior for this method to ingest campaign engagement data in your paylod processor:
|
244
|
+
You must implement behavior for this method to ingest campaign engagement data in your paylod processor:
|
210
245
|
|
211
246
|
```ruby
|
212
247
|
def self.process_campaign_engagement(campaign_engagement)
|
@@ -255,7 +290,7 @@ campaign_engagement.phone_campaign_state_answers? # TrueClass,FalseClass
|
|
255
290
|
# If a match is found it returns instance of
|
256
291
|
# SmSmsCampaignWebhook::CampaignEngagement::Answer data model.
|
257
292
|
# If a match is not found it return nil (NilClass).
|
258
|
-
|
293
|
+
campaign_engagement.answer_for(field: "email") # Returned type answer specific
|
259
294
|
```
|
260
295
|
|
261
296
|
#### Campaign Engagement Answer Data Model
|
@@ -275,10 +310,69 @@ The value data types could be one of the following:
|
|
275
310
|
- boolean (`TrueClass`, `FalseClass`)
|
276
311
|
- us_state (`String`)
|
277
312
|
|
313
|
+
#### Campaign Engagement Payload Example
|
314
|
+
|
315
|
+
Here is an example payload for campaign engagement that could come through to the payload processor. Be sure to check with your Southern Made project manager to gather details about the answer fields and data types:
|
316
|
+
|
317
|
+
```json
|
318
|
+
{
|
319
|
+
"uuid": "99aaafe3-b52b-413f-a9cd-db52fa13b77a",
|
320
|
+
"object": "event",
|
321
|
+
"type": "campaign.engagement",
|
322
|
+
"created_at": "2019-08-09T18:29:05.052Z",
|
323
|
+
"data": {
|
324
|
+
"campaign": {
|
325
|
+
"id": 55,
|
326
|
+
"keyword": "KEYWORD"
|
327
|
+
},
|
328
|
+
"phone": {
|
329
|
+
"id": 80,
|
330
|
+
"number": "3335557777"
|
331
|
+
},
|
332
|
+
"phone_campaign_state": {
|
333
|
+
"id": 95,
|
334
|
+
"answers": {
|
335
|
+
"DOB": {
|
336
|
+
"value": "2001-07-04",
|
337
|
+
"collected_at": "2019-08-09T18:26:59.052Z"
|
338
|
+
},
|
339
|
+
"email": {
|
340
|
+
"value": "email@example.com",
|
341
|
+
"collected_at": "2019-08-09T18:27:59.052Z"
|
342
|
+
},
|
343
|
+
"vote-september": {
|
344
|
+
"value": 1,
|
345
|
+
"collected_at": "2019-08-09T18:28:59.052Z"
|
346
|
+
}
|
347
|
+
},
|
348
|
+
"completed": true,
|
349
|
+
"completed_at": "2019-08-09T18:28:59.052Z"
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
```
|
354
|
+
|
355
|
+
[cURL](https://curl.haxx.se) example assuming the payload file path is `tmp/sms_campaign_payload.json`, app is running running with mount point `sms_campaign`, web server uses port `3000`, and that you use your app's webhook auth token:
|
356
|
+
|
357
|
+
```bash
|
358
|
+
$ curl \
|
359
|
+
--header "Authorization: Bearer WEBHOOKAUTHTOKEN" \
|
360
|
+
--header "Content-Type: application/json" \
|
361
|
+
--header "Accept: application/json" \
|
362
|
+
--data @tmp/sms_campaign_payload.json \
|
363
|
+
http://localhost:3000/sms_campaign/api/webhook
|
364
|
+
```
|
365
|
+
|
278
366
|
## Development
|
279
367
|
|
280
368
|
This gem uses [git-flow](https://github.com/nvie/gitflow) to manage deployments. The default branches are used to manage development and production code.
|
281
369
|
|
370
|
+
### StandardRB
|
371
|
+
|
372
|
+
This project uses [StandardRB](https://github.com/testdouble/standard), a hands-off wrapper around [Rubocop](https://docs.rubocop.org/en/stable/), to manage style/formatting/etc. Please apply changes before submitting pull requests:
|
373
|
+
|
374
|
+
$ bundle exec standardrb --fix
|
375
|
+
|
282
376
|
### Versioning
|
283
377
|
|
284
378
|
Gem versioning follows [Semantic Versioning](https://semver.org).
|
@@ -16,9 +16,9 @@ module SmSmsCampaignWebhook
|
|
16
16
|
# @raise [InvalidPayload] when uuid missing from payload
|
17
17
|
def event_uuid
|
18
18
|
@event_uuid ||= String(
|
19
|
-
payload.fetch("uuid")
|
19
|
+
payload.fetch("uuid") {
|
20
20
|
raise_invalid_payload_for("uuid")
|
21
|
-
|
21
|
+
}.freeze
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
@@ -26,9 +26,9 @@ module SmSmsCampaignWebhook
|
|
26
26
|
# @raise [InvalidPayload] when type missing from payload
|
27
27
|
def event_type
|
28
28
|
@event_type ||= String(
|
29
|
-
payload.fetch("type")
|
29
|
+
payload.fetch("type") {
|
30
30
|
raise_invalid_payload_for("type")
|
31
|
-
|
31
|
+
}.freeze
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
@@ -37,14 +37,14 @@ module SmSmsCampaignWebhook
|
|
37
37
|
# @raise [InvalidPayloadValue] when created_at not datetime
|
38
38
|
def event_created_at
|
39
39
|
@event_created_at ||= begin
|
40
|
-
raw_created_at = payload.fetch("created_at")
|
40
|
+
raw_created_at = payload.fetch("created_at") {
|
41
41
|
raise_invalid_payload_for("created_at")
|
42
|
-
|
42
|
+
}
|
43
43
|
DateTime.parse(raw_created_at).freeze
|
44
44
|
end
|
45
45
|
rescue ArgumentError
|
46
46
|
raise InvalidPayloadValue,
|
47
|
-
|
47
|
+
"created_at has invalid datetime value #{payload.inspect}"
|
48
48
|
end
|
49
49
|
|
50
50
|
# @return [Integer] ID of the engaged campaign
|
@@ -52,22 +52,22 @@ module SmSmsCampaignWebhook
|
|
52
52
|
# @raise [InvalidPayloadValue] when campaign id not numeric
|
53
53
|
def campaign_id
|
54
54
|
@campaign_id ||= Integer(
|
55
|
-
campaign_hash.fetch("id")
|
55
|
+
campaign_hash.fetch("id") {
|
56
56
|
raise_invalid_payload_for("campaign id")
|
57
|
-
|
57
|
+
}
|
58
58
|
)
|
59
59
|
rescue ArgumentError
|
60
60
|
raise InvalidPayloadValue,
|
61
|
-
|
61
|
+
"campaign id has invalid integer value #{payload.inspect}"
|
62
62
|
end
|
63
63
|
|
64
64
|
# @return [String] Keyword of the engaged campaign
|
65
65
|
# @raise [InvalidPayload] when campaign keyword missing from payload
|
66
66
|
def campaign_keyword
|
67
67
|
@campaign_keyword ||= String(
|
68
|
-
campaign_hash.fetch("keyword")
|
68
|
+
campaign_hash.fetch("keyword") {
|
69
69
|
raise_invalid_payload_for("campaign keyword")
|
70
|
-
|
70
|
+
}.freeze
|
71
71
|
)
|
72
72
|
end
|
73
73
|
|
@@ -76,22 +76,22 @@ module SmSmsCampaignWebhook
|
|
76
76
|
# @raise [InvalidPayloadValue] when phone id not numeric
|
77
77
|
def phone_id
|
78
78
|
@phone_id ||= Integer(
|
79
|
-
phone_hash.fetch("id")
|
79
|
+
phone_hash.fetch("id") {
|
80
80
|
raise_invalid_payload_for("phone id")
|
81
|
-
|
81
|
+
}
|
82
82
|
)
|
83
83
|
rescue ArgumentError
|
84
84
|
raise InvalidPayloadValue,
|
85
|
-
|
85
|
+
"phone id has invalid integer value #{payload.inspect}"
|
86
86
|
end
|
87
87
|
|
88
88
|
# @return [String] Phone number engaging the campaign
|
89
89
|
# @raise [InvalidPayload] when phone number missing from payload
|
90
90
|
def phone_number
|
91
91
|
@phone_number ||= String(
|
92
|
-
phone_hash.fetch("number")
|
92
|
+
phone_hash.fetch("number") {
|
93
93
|
raise_invalid_payload_for("phone number")
|
94
|
-
|
94
|
+
}.freeze
|
95
95
|
)
|
96
96
|
end
|
97
97
|
|
@@ -100,13 +100,13 @@ module SmSmsCampaignWebhook
|
|
100
100
|
# @raise [InvalidPayloadValue] when phone_campaign_state id not numeric
|
101
101
|
def phone_campaign_state_id
|
102
102
|
@phone_campaign_state_id ||= Integer(
|
103
|
-
phone_campaign_state_hash.fetch("id")
|
103
|
+
phone_campaign_state_hash.fetch("id") {
|
104
104
|
raise_invalid_payload_for("phone_campaign_state id")
|
105
|
-
|
105
|
+
}
|
106
106
|
)
|
107
107
|
rescue ArgumentError
|
108
108
|
raise InvalidPayloadValue,
|
109
|
-
|
109
|
+
"phone_campaign_state id has invalid integer value #{payload.inspect}"
|
110
110
|
end
|
111
111
|
|
112
112
|
# @return [TrueClass,FalseClass] Has campaign engagement completed?
|
@@ -114,21 +114,21 @@ module SmSmsCampaignWebhook
|
|
114
114
|
# @raise [InvalidPayloadValue] when phone_campaign_state completed is not boolean
|
115
115
|
def phone_campaign_state_completed?
|
116
116
|
# Has the boolean value already been assigned?
|
117
|
-
|
117
|
+
unless @phone_campaign_state_completed.nil?
|
118
118
|
return @phone_campaign_state_completed
|
119
119
|
end
|
120
120
|
|
121
121
|
# Extract the value and memoize it.
|
122
122
|
@phone_campaign_state_completed = begin
|
123
123
|
completed = phone_campaign_state_hash
|
124
|
-
.fetch("completed")
|
124
|
+
.fetch("completed") {
|
125
125
|
raise_invalid_payload_for("phone_campaign_state completed")
|
126
|
-
|
126
|
+
}
|
127
127
|
|
128
128
|
# Is this a boolean value?
|
129
129
|
if [true, false].none?(completed)
|
130
130
|
raise InvalidPayloadValue,
|
131
|
-
|
131
|
+
"phone_campaign_state completed has invalid boolean value #{payload.inspect}"
|
132
132
|
end
|
133
133
|
|
134
134
|
completed
|
@@ -140,14 +140,14 @@ module SmSmsCampaignWebhook
|
|
140
140
|
# @raise [InvalidPayloadValue] when phone_campaign_state completed_at not datetime
|
141
141
|
def phone_campaign_state_completed_at
|
142
142
|
@phone_campaign_state_completed_at ||= begin
|
143
|
-
raw_completed_at = phone_campaign_state_hash.fetch("completed_at")
|
143
|
+
raw_completed_at = phone_campaign_state_hash.fetch("completed_at") {
|
144
144
|
raise_invalid_payload_for("phone_campaign_state completed_at")
|
145
|
-
|
145
|
+
}
|
146
146
|
DateTime.parse(raw_completed_at).freeze if raw_completed_at
|
147
147
|
end
|
148
148
|
rescue ArgumentError
|
149
149
|
raise InvalidPayloadValue,
|
150
|
-
|
150
|
+
"phone_campaign_state completed_at has invalid datetime value #{payload.inspect}"
|
151
151
|
end
|
152
152
|
|
153
153
|
# @return [Array<Answer>] Modeled campaign engagement answers
|
@@ -156,12 +156,12 @@ module SmSmsCampaignWebhook
|
|
156
156
|
def phone_campaign_state_answers
|
157
157
|
@phone_campaign_state_answers ||= begin
|
158
158
|
# Extract answers data from payload.
|
159
|
-
data = phone_campaign_state_hash.fetch("answers")
|
159
|
+
data = phone_campaign_state_hash.fetch("answers") {
|
160
160
|
raise_invalid_payload_for("phone_campaign_state answers")
|
161
|
-
|
162
|
-
|
161
|
+
}
|
162
|
+
|
163
163
|
# Is this hash data?
|
164
|
-
|
164
|
+
unless data.is_a?(Hash)
|
165
165
|
raise InvalidPayloadValue,
|
166
166
|
"phone_campaign_state answers has invalid hash value #{payload.inspect}"
|
167
167
|
end
|
@@ -9,13 +9,13 @@ module SmSmsCampaignWebhook
|
|
9
9
|
# @param data [Hash] Answers from payload
|
10
10
|
# @return [Array<Answer>] Modeled answer data sorted by collected_at
|
11
11
|
def self.cast(data:)
|
12
|
-
data.map
|
12
|
+
data.map { |field, answer_hash|
|
13
13
|
new(field: field, answer_hash: answer_hash)
|
14
|
-
|
14
|
+
}.sort_by(&:collected_at)
|
15
15
|
end
|
16
16
|
|
17
17
|
attr_reader :field,
|
18
|
-
|
18
|
+
:answer_hash
|
19
19
|
|
20
20
|
# @param field [String] Field describing the answer
|
21
21
|
# @param answer_hash [Hash] Answer data from payload
|
@@ -36,19 +36,23 @@ module SmSmsCampaignWebhook
|
|
36
36
|
# @raise [InvalidPayload] when value is missing from answer_hash
|
37
37
|
def value
|
38
38
|
# Could be boolean so cannot rely on double pipe assignment guard.
|
39
|
-
|
39
|
+
unless @value.nil?
|
40
40
|
return @value
|
41
41
|
end
|
42
42
|
|
43
43
|
# Extract the value and memoize it.
|
44
44
|
@value = begin
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
raw_value = answer_hash.fetch("value") {
|
46
|
+
raise InvalidPayload,
|
47
|
+
"value missing from answer_hash #{answer_hash.inspect}"
|
48
|
+
}.freeze
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
# Attempt to parse date value falling back to raw value.
|
51
|
+
begin
|
52
|
+
Date.strptime(raw_value, "%Y-%m-%d").freeze
|
53
|
+
rescue
|
54
|
+
raw_value
|
55
|
+
end
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
@@ -57,15 +61,15 @@ module SmSmsCampaignWebhook
|
|
57
61
|
# @raise [InvalidPayloadValue] when collected_at not datetime
|
58
62
|
def collected_at
|
59
63
|
@collected_at ||= begin
|
60
|
-
raw_collected_at = answer_hash.fetch("collected_at")
|
64
|
+
raw_collected_at = answer_hash.fetch("collected_at") {
|
61
65
|
raise InvalidPayload,
|
62
|
-
|
63
|
-
|
66
|
+
"collected_at missing from answer_hash #{answer_hash.inspect}"
|
67
|
+
}
|
64
68
|
DateTime.parse(raw_collected_at).freeze
|
65
69
|
end
|
66
70
|
rescue ArgumentError
|
67
71
|
raise InvalidPayloadValue,
|
68
|
-
|
72
|
+
"collected_at has invalid datetime value #{answer_hash.inspect}"
|
69
73
|
end
|
70
74
|
end
|
71
75
|
end
|
@@ -14,11 +14,11 @@ module SmSmsCampaignWebhook
|
|
14
14
|
|
15
15
|
if payload.fetch("type") != "campaign.engagement"
|
16
16
|
raise PayloadDispatchError,
|
17
|
-
|
17
|
+
"dispatched payload different from campaign.engagement #{payload.inspect}"
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
processor.process_campaign_engagement(
|
20
|
+
campaign_engagement = CampaignEngagement.new(payload: payload)
|
21
|
+
processor.process_campaign_engagement(campaign_engagement)
|
22
22
|
end
|
23
23
|
|
24
24
|
# @return [Processable] Configured SMS campaign payload processor
|
@@ -14,7 +14,7 @@ module SmSmsCampaignWebhook
|
|
14
14
|
# @raise [NotImplementedError] requiring implementing class to define behavior
|
15
15
|
def process_campaign_engagement(campaign_engagement)
|
16
16
|
raise NotImplementedError,
|
17
|
-
|
17
|
+
"#{self.class} must implement .process_campaign_engagement receiving campaign_engagement param"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -22,8 +22,8 @@ module SmSmsCampaignWebhook
|
|
22
22
|
# Mount engine to path in config/routes.rb
|
23
23
|
def add_mount_path
|
24
24
|
insert_into_file "config/routes.rb",
|
25
|
-
|
26
|
-
|
25
|
+
" mount SmSmsCampaignWebhook::Engine => \"/sms_campaign\"\n",
|
26
|
+
after: "Rails.application.routes.draw do\n"
|
27
27
|
end
|
28
28
|
|
29
29
|
# Dump the README for the app developer
|
@@ -5,7 +5,7 @@
|
|
5
5
|
class SmsPayloadProcessor
|
6
6
|
include SmSmsCampaignWebhook::Processable
|
7
7
|
|
8
|
-
# @param
|
8
|
+
# @param campaign_engagement [SmSmsCampaignWebhook::CampaignEngagement]
|
9
9
|
# @see https://github.com/SouthernMade/sm_sms_campaign_webhook/blob/v<%= SmSmsCampaignWebhook::VERSION %>/app/models/sm_sms_campaign_webhook/campaign_engagement.rb SmSmsCampaignWebhook::CampaignEngagement
|
10
10
|
# @todo Implement business logic to process campaign engagement.
|
11
11
|
# def self.process_campaign_engagement(campaign_engagement)
|
@@ -13,10 +13,10 @@ module SmSmsCampaignWebhook
|
|
13
13
|
# @return [String] SMS campaign webhook auth token
|
14
14
|
# @raise [MissingConfigError] when ENV does not contain SM_SMS_CAMPAIGN_WEBHOOK_AUTH_TOKEN value
|
15
15
|
def self.auth_token
|
16
|
-
@auth_token ||= ENV.fetch("SM_SMS_CAMPAIGN_WEBHOOK_AUTH_TOKEN")
|
16
|
+
@auth_token ||= ENV.fetch("SM_SMS_CAMPAIGN_WEBHOOK_AUTH_TOKEN") {
|
17
17
|
raise MissingConfigError,
|
18
|
-
|
19
|
-
|
18
|
+
"ENV does not contain SM_SMS_CAMPAIGN_WEBHOOK_AUTH_TOKEN value"
|
19
|
+
}
|
20
20
|
end
|
21
21
|
|
22
22
|
# @return [Processable] SMS campaign payload processor used by operations
|
@@ -1,21 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path("lib", __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "sm_sms_campaign_webhook/version"
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.license
|
9
|
-
spec.summary
|
10
|
-
spec.description =
|
11
|
-
spec.homepage
|
12
|
-
spec.authors
|
13
|
-
spec.email
|
8
|
+
spec.name = "sm_sms_campaign_webhook"
|
9
|
+
spec.version = SmSmsCampaignWebhook::VERSION
|
10
|
+
spec.license = "MIT"
|
11
|
+
spec.summary = "Middleware providing webhook for Southern Made SMS Campaign Engagement."
|
12
|
+
spec.description = "Middleware providing webhook for Southern Made SMS Campaign Engagement."
|
13
|
+
spec.homepage = "https://github.com/SouthernMade/sm_sms_campaign_webhook"
|
14
|
+
spec.authors = ["Cameron Dykes", "Matt Mueller"]
|
15
|
+
spec.email = ["cameron@southernmade.com", "matt@southernmade.com"]
|
14
16
|
|
15
|
-
spec.metadata
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
spec.metadata = {
|
18
|
+
"allowed_push_host" => "https://rubygems.org",
|
19
|
+
"changelog_uri" => "#{spec.homepage}/blob/develop/CHANGELOG.md",
|
20
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/sm_sms_campaign_webhook/#{spec.version}",
|
21
|
+
"homepage_uri" => spec.homepage,
|
22
|
+
"source_code_uri" => spec.homepage
|
23
|
+
}
|
19
24
|
|
20
25
|
# Specify which files should be added to the gem when it is released.
|
21
26
|
spec.files = Dir[
|
@@ -28,15 +33,16 @@ Gem::Specification.new do |spec|
|
|
28
33
|
spec.require_paths = ["lib"]
|
29
34
|
|
30
35
|
# Required version of Ruby guided by Rails.
|
31
|
-
spec.required_ruby_version = "
|
36
|
+
spec.required_ruby_version = ">= 2.5.8"
|
32
37
|
|
33
38
|
# Runtime dependencies.
|
34
|
-
spec.add_dependency "rails", [">=
|
39
|
+
spec.add_dependency "rails", [">= 6.0", "< 6.2"]
|
35
40
|
|
36
41
|
# Development + test dependencies.
|
37
42
|
spec.add_development_dependency "bundler", "~> 2.0"
|
38
|
-
spec.add_development_dependency "rake", "~>
|
39
|
-
spec.add_development_dependency "rspec-rails", "~>
|
40
|
-
spec.add_development_dependency "simplecov", "~> 0.
|
43
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
44
|
+
spec.add_development_dependency "rspec-rails", "~> 4.0"
|
45
|
+
spec.add_development_dependency "simplecov", "~> 0.20"
|
46
|
+
spec.add_development_dependency "standard"
|
41
47
|
spec.add_development_dependency "yard", "~> 0.9"
|
42
48
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sm_sms_campaign_webhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dykes
|
8
8
|
- Matt Mueller
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,20 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '6.0'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '6.
|
23
|
+
version: '6.2'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: '6.0'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '6.
|
33
|
+
version: '6.2'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: bundler
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,42 +51,56 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rspec-rails
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.0'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: simplecov
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.20'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.20'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: standard
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
90
104
|
- !ruby/object:Gem::Dependency
|
91
105
|
name: yard
|
92
106
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,26 +157,27 @@ licenses:
|
|
143
157
|
- MIT
|
144
158
|
metadata:
|
145
159
|
allowed_push_host: https://rubygems.org
|
160
|
+
changelog_uri: https://github.com/SouthernMade/sm_sms_campaign_webhook/blob/develop/CHANGELOG.md
|
161
|
+
documentation_uri: https://www.rubydoc.info/gems/sm_sms_campaign_webhook/2.0.0
|
146
162
|
homepage_uri: https://github.com/SouthernMade/sm_sms_campaign_webhook
|
147
163
|
source_code_uri: https://github.com/SouthernMade/sm_sms_campaign_webhook
|
148
|
-
|
149
|
-
post_install_message:
|
164
|
+
post_install_message:
|
150
165
|
rdoc_options: []
|
151
166
|
require_paths:
|
152
167
|
- lib
|
153
168
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
169
|
requirements:
|
155
|
-
- - "
|
170
|
+
- - ">="
|
156
171
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
172
|
+
version: 2.5.8
|
158
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
174
|
requirements:
|
160
175
|
- - ">="
|
161
176
|
- !ruby/object:Gem::Version
|
162
177
|
version: '0'
|
163
178
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
-
signing_key:
|
179
|
+
rubygems_version: 3.2.3
|
180
|
+
signing_key:
|
166
181
|
specification_version: 4
|
167
182
|
summary: Middleware providing webhook for Southern Made SMS Campaign Engagement.
|
168
183
|
test_files: []
|