effective_mailchimp 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/effective_mailchimp_user.rb +13 -5
- data/app/models/effective/mailchimp_api.rb +1 -7
- data/app/models/effective/mailchimp_list_member.rb +14 -1
- data/app/views/effective/mailchimp_user/_fields.html.haml +5 -2
- data/db/migrate/101_create_effective_mailchimp.rb +2 -1
- data/lib/effective_mailchimp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42b138c379e2bef73c47ff7dfdf53ed004505b0e892ff407a16558cfa2deac4b
|
4
|
+
data.tar.gz: 199f1d58e6f32d182c80cfd5be9d4ca970bbf828944820563af7319126ce6ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55ffa0423f7a02d94d3f74113b9139f44e71943b9748a82106d54c3ddf93abf26057c86755fec0a1a058e1706052aad79e4100066e7cc8fe0c3c9560331c61d5
|
7
|
+
data.tar.gz: 6306b88940c840bf58f099436362e0c386e440ac1e511e42c088a163f8cdc322b8597e30c9554b95f54e0a93fccf0f639c7b63f323475a7a19e7e6ca63aaa412
|
@@ -188,12 +188,20 @@ module EffectiveMailchimpUser
|
|
188
188
|
assign_attributes(mailchimp_user_form_action: nil)
|
189
189
|
|
190
190
|
mailchimp_list_members.each do |member|
|
191
|
-
|
192
|
-
list_member =
|
193
|
-
|
194
|
-
|
195
|
-
|
191
|
+
begin
|
192
|
+
list_member = if member.mailchimp_id.blank? && member.subscribed?
|
193
|
+
api.list_member_add(member)
|
194
|
+
elsif member.mailchimp_id.present?
|
195
|
+
api.list_member_update(member)
|
196
|
+
end
|
197
|
+
|
196
198
|
member.assign_mailchimp_attributes(list_member) if list_member.present?
|
199
|
+
rescue MailchimpMarketing::ApiError => e
|
200
|
+
if e.to_s.downcase.include?("cannot be subscribed") || e.to_s.downcase.include?('deleted')
|
201
|
+
member.assign_mailchimp_cannot_be_subscribed
|
202
|
+
else
|
203
|
+
raise(e)
|
204
|
+
end
|
197
205
|
end
|
198
206
|
end
|
199
207
|
|
@@ -94,13 +94,7 @@ module Effective
|
|
94
94
|
merge_fields: merge_fields.delete_if { |k, v| v.blank? }
|
95
95
|
}
|
96
96
|
|
97
|
-
|
98
|
-
client.lists.add_list_member(member.mailchimp_list.mailchimp_id, payload)
|
99
|
-
rescue MailchimpMarketing::ApiError => e
|
100
|
-
return false if e.status == 400 && e.to_s.downcase.include?("member in compliance state")
|
101
|
-
raise(e)
|
102
|
-
end
|
103
|
-
|
97
|
+
client.lists.add_list_member(member.mailchimp_list.mailchimp_id, payload)
|
104
98
|
end
|
105
99
|
|
106
100
|
def list_member_update(member)
|
@@ -14,7 +14,12 @@ module Effective
|
|
14
14
|
email_address :string
|
15
15
|
full_name :string
|
16
16
|
|
17
|
-
|
17
|
+
# We set this on our side to update mailchimp and subscribe the user
|
18
|
+
subscribed :boolean
|
19
|
+
|
20
|
+
# This one is generated by the MailchimpMarketing::ApiError
|
21
|
+
# They unsubscribed and there's nothing we can do about it.
|
22
|
+
cannot_be_subscribed :boolean # Member is in Compliance State
|
18
23
|
|
19
24
|
last_synced_at :datetime
|
20
25
|
|
@@ -45,6 +50,14 @@ module Effective
|
|
45
50
|
)
|
46
51
|
end
|
47
52
|
|
53
|
+
def assign_mailchimp_cannot_be_subscribed
|
54
|
+
assign_attributes(
|
55
|
+
subscribed: false,
|
56
|
+
cannot_be_subscribed: true,
|
57
|
+
last_synced_at: Time.zone.now
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
48
61
|
def synced?
|
49
62
|
last_synced_at.present?
|
50
63
|
end
|
@@ -9,8 +9,11 @@
|
|
9
9
|
|
10
10
|
- if mailchimp_list.force_subscribe?
|
11
11
|
%p
|
12
|
-
|
13
|
-
|
12
|
+
- if fmlm.object.cannot_be_subscribed?
|
13
|
+
= fmlm.check_box :subscribed, label: fmlm.object.to_s, disabled: true, hint: 'required but unsubscribed', checked: false
|
14
|
+
- else
|
15
|
+
= fmlm.check_box :subscribed, label: fmlm.object.to_s, disabled: true, hint: 'required', checked: true
|
16
|
+
= fmlm.hidden_field :subscribed, value: true
|
14
17
|
|
15
18
|
- elsif mailchimp_list.can_subscribe?
|
16
19
|
%p
|
@@ -23,7 +23,8 @@ class CreateEffectiveMailchimp < ActiveRecord::Migration[6.0]
|
|
23
23
|
t.string :email_address
|
24
24
|
t.string :full_name
|
25
25
|
|
26
|
-
t.boolean :subscribed
|
26
|
+
t.boolean :subscribed, default: false
|
27
|
+
t.boolean :cannot_be_subscribed, default: false
|
27
28
|
|
28
29
|
t.datetime :last_synced_at
|
29
30
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_mailchimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
238
|
- !ruby/object:Gem::Version
|
239
239
|
version: '0'
|
240
240
|
requirements: []
|
241
|
-
rubygems_version: 3.
|
241
|
+
rubygems_version: 3.5.6
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
244
|
summary: Subscribe and unsubscribe to mailchimp lists.
|