effective_mailchimp 0.5.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aeb420fedb9cb1cd9ef0454773d4daf4e1b738e472ad5154226bb3ba299f7010
4
- data.tar.gz: 35faa4bdbd56036558bf3ebf5c3bce35a8eb37eb3eab17b123449fc56f60dd16
3
+ metadata.gz: 57f2e87a71e74c97178552f620fa255eb992d7ba6329681f283c140205c7b991
4
+ data.tar.gz: 0b4a7b098353735f7aae1dbf7cb857477fdd780f1fef3f15ea1318f4383ff434
5
5
  SHA512:
6
- metadata.gz: 6c888569b99ed7d9474706235698af874c54edca6a3b13a53e449f0a03ca9d2e64099b642b640959ad5100b5964ef06f873739c853f6e11daeb05a33b99ef93f
7
- data.tar.gz: f50fc3d24091a2f58a2361b015e4329c21be5846081f9d660b9e6c00c017171952324a3e7f37c56b00f49b012e80ea97a1127f5ae7c26bd51c64d6cf7f6534e8
6
+ metadata.gz: ac169326fba074be7af97f386d93edb215220bce91750fa8e410487d601ae7f91e496aa7b4bdcda0a290d216a0cf0ef0e80639cdd8176d2f62c7fc7690891e1f
7
+ data.tar.gz: 06edb4d4261b098133462d263fe1ec6f12d327668eba7d81a8eb765d2b8dc53352d4e71ebd5317c08a7f3d5c95c0c67ebefd5d95c08279550ad0e51063820cf0
@@ -50,18 +50,21 @@ module EffectiveMailchimpUser
50
50
 
51
51
  # Api method to just subscribe this user to this list right now
52
52
  # Pass one list or an Array of lists
53
- def mailchimp_subscribe!(mailchimp_list)
53
+ def mailchimp_subscribe!(mailchimp_list, subscribed: true, now: false)
54
54
  mailchimp_lists = Array(mailchimp_list)
55
55
  raise('expected a MailchimpList') unless mailchimp_lists.all? { |list| list.kind_of?(Effective::MailchimpList) }
56
56
 
57
57
  mailchimp_lists.each do |mailchimp_list|
58
58
  member = build_mailchimp_list_member(mailchimp_list: mailchimp_list)
59
- member.assign_attributes(subscribed: true)
59
+ member.assign_attributes(subscribed: subscribed)
60
60
  end
61
61
 
62
62
  # This sets up the after_commit to run the mailchimp_update! job
63
63
  assign_attributes(mailchimp_user_form_action: true)
64
64
 
65
+ # For use in a rake task. Run the update right now
66
+ mailchimp_update! if now
67
+
65
68
  save!
66
69
  end
67
70
 
@@ -113,6 +116,8 @@ module EffectiveMailchimpUser
113
116
  end
114
117
 
115
118
  if respond_to?(:membership)
119
+ membership = memberships.first() # Individual or organization membership
120
+
116
121
  atts.merge!(
117
122
  'CATEGORY': membership&.categories&.to_sentence,
118
123
  'STATUS': membership&.statuses&.to_sentence,
@@ -121,6 +126,13 @@ module EffectiveMailchimpUser
121
126
  )
122
127
  end
123
128
 
129
+ if self.class.respond_to?(:effective_memberships_organization_user?)
130
+ atts.merge!(
131
+ 'COMPANY': representatives.map { |rep| rep.organization.to_s }.join(', ').presence,
132
+ 'ROLES': representatives.flat_map { |rep| rep.roles }.compact.join(', ').presence,
133
+ )
134
+ end
135
+
124
136
  atts
125
137
  end
126
138
 
@@ -197,7 +209,7 @@ module EffectiveMailchimpUser
197
209
 
198
210
  member.assign_mailchimp_attributes(list_member) if list_member.present?
199
211
  rescue MailchimpMarketing::ApiError => e
200
- if e.to_s.downcase.include?("cannot be subscribed")
212
+ if e.to_s.downcase.include?("cannot be subscribed") || e.to_s.downcase.include?('deleted')
201
213
  member.assign_mailchimp_cannot_be_subscribed
202
214
  else
203
215
  raise(e)
@@ -1,3 +1,3 @@
1
1
  module EffectiveMailchimp
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.2'.freeze
3
3
  end
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.5.0
4
+ version: 0.5.2
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: 2024-02-15 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails