|
1 |
| -class Services::MailingList |
2 |
| - attr_reader :list_id |
| 1 | +module Services |
| 2 | + class MailingList |
| 3 | + attr_reader :list_id |
3 | 4 |
|
4 |
| - def initialize(list_id) |
5 |
| - @list_id = list_id |
6 |
| - end |
| 5 | + def initialize(list_id) |
| 6 | + @list_id = list_id |
| 7 | + end |
7 | 8 |
|
8 |
| - def subscribe(email, first_name, last_name) |
9 |
| - return if client.disabled? |
| 9 | + def subscribe(email, first_name, last_name) |
| 10 | + return if client.disabled? |
10 | 11 |
|
11 |
| - client.subscribe(email:, first_name:, last_name:, segment_ids: [@list_id]) |
12 |
| - rescue Flodesk::FlodeskError |
13 |
| - false |
14 |
| - end |
15 |
| - handle_asynchronously :subscribe |
| 12 | + client.subscribe(email:, first_name:, last_name:, segment_ids: [@list_id]) |
| 13 | + rescue Flodesk::FlodeskError |
| 14 | + false |
| 15 | + end |
| 16 | + handle_asynchronously :subscribe |
16 | 17 |
|
17 |
| - def unsubscribe(email) |
18 |
| - return if client.disabled? |
| 18 | + def unsubscribe(email) |
| 19 | + return if client.disabled? |
19 | 20 |
|
20 |
| - client.unsubscribe(email:, segment_ids: [@list_id]) |
21 |
| - rescue Flodesk::FlodeskError |
22 |
| - false |
23 |
| - end |
24 |
| - handle_asynchronously :unsubscribe |
| 21 | + client.unsubscribe(email:, segment_ids: [@list_id]) |
| 22 | + rescue Flodesk::FlodeskError |
| 23 | + false |
| 24 | + end |
| 25 | + handle_asynchronously :unsubscribe |
25 | 26 |
|
26 |
| - def subscribed?(email) |
27 |
| - return if client.disabled? |
| 27 | + def subscribed?(email) |
| 28 | + return if client.disabled? |
28 | 29 |
|
29 |
| - client.subscribed?(email:, segment_ids: [@list_id]) |
30 |
| - rescue Flodesk::FlodeskError |
31 |
| - false |
32 |
| - end |
| 30 | + client.subscribed?(email:, segment_ids: [@list_id]) |
| 31 | + rescue Flodesk::FlodeskError |
| 32 | + false |
| 33 | + end |
33 | 34 |
|
34 |
| - private |
| 35 | + private |
35 | 36 |
|
36 |
| - def client |
37 |
| - @client ||= Flodesk::Client.new |
| 37 | + def client |
| 38 | + @client ||= Flodesk::Client.new |
| 39 | + end |
38 | 40 | end
|
39 | 41 | end
|
0 commit comments