slack-ruby-bot-server-mailchimp 0.1.0 → 0.2.0

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: 40656585b497e172f926371881eaf7e72c41fcda402abcf878df85902922f3f5
4
- data.tar.gz: c7c09b96b872061811ee730d5ca76100e0f22ed5da25e546f7a6921aef6f953a
3
+ metadata.gz: eeebcc779ee9d49dcd06717bd9f4c559fad159b5d731c1af3f2bb6a466ace27e
4
+ data.tar.gz: a362d30421360f06cd8cc666a5b604bb6f42ac52046a0c01615841551c79aee2
5
5
  SHA512:
6
- metadata.gz: 359aa967108d4a5761aeffd70250a06854b617092b21369faf63d14262179a82e2df7eafc801f32ece6d94748ab7c95586a54505e12bf1c80630208221592aa5
7
- data.tar.gz: b697c374b469e6f18cbd804b2edd60b5045aea3f4ba4698106e78d9cbc32ad6d8c2747be1e15191d553983f7a9dc06d59b77383dbdd29d40db43d89aecb37ecf
6
+ metadata.gz: 447dbb00d03066e3af0fb651fcdd15c5bd526e8d50abf95101dd52f442e7ac379beecdcf0ec2d3e5f4967cd00756a687db8aa9481a1f006a794da98c0c90189f
7
+ data.tar.gz: 0d1e2bcaf746bc67d74cd2aeb7d1c453b205f8630637c68b2aadd15a01fb21317bfaa57ea1dd87618019d38c774a3c557cfd64c31f31bb67976fb118145a47f0
@@ -1,5 +1,9 @@
1
1
  ### Changelog
2
2
 
3
+ #### 0.2.0 (2019/4/6)
4
+
5
+ * [#2](https://github.com/slack-ruby/slack-ruby-bot-server-mailchimp/pull/2): Configuration options `member_tags` and `additional_merge_fields` can now be `Proc` - [@dblock](https://github.com/dblock).
6
+
3
7
  #### 0.1.0 (2019/3/23)
4
8
 
5
9
  * Initial public release - [@dblock](https://github.com/dblock).
data/README.md CHANGED
@@ -33,6 +33,12 @@ If your `Team` model responds to `.tags`, those will be attached to new subscrip
33
33
  SlackRubyBotServer::Mailchimp.config.member_tags = ['my_bot']
34
34
  ```
35
35
 
36
+ This can be a function that accepts a team and callback options.
37
+
38
+ ```ruby
39
+ SlackRubyBotServer::Mailchimp.config.member_tags = ->(team, options) { [team.tags] }
40
+ ```
41
+
36
42
  ### Additional Profile Information
37
43
 
38
44
  The default member profile information that appears in Mailchimp under "Profile Information" for each new subscriber contains the user's email address, first and last name from Slack. You can supplement this data with `additional_merge_fields`.
@@ -41,6 +47,12 @@ The default member profile information that appears in Mailchimp under "Profile
41
47
  SlackRubyBotServer::Mailchimp.config.additional_merge_fields = { 'BOT' => 'MyBot' }
42
48
  ```
43
49
 
50
+ This can be a function that accepts a team and callback options.
51
+
52
+ ```ruby
53
+ SlackRubyBotServer::Mailchimp.config.additional_merge_fields = ->(team, options) { { 'TEAM' => team.name } }
54
+ ```
55
+
44
56
  ### Double Opt-In
45
57
 
46
58
  This integration subscribes users with double opt-in by default. Configure `member_status` to disable double opt-in. See [this doc](https://developer.mailchimp.com/documentation/mailchimp/guides/manage-subscribers-with-the-mailchimp-api) for more details.
@@ -1,4 +1,4 @@
1
- SlackRubyBotServer::Config.service_class.instance.on :created do |team, _error, _options|
1
+ SlackRubyBotServer::Config.service_class.instance.on :created do |team, _error, options|
2
2
  raise 'missing ENV["MAILCHIMP_API_KEY"]' unless SlackRubyBotServer::Mailchimp.config.mailchimp_api_key
3
3
  raise 'missing ENV["MAILCHIMP_LIST_ID"]' unless SlackRubyBotServer::Mailchimp.config.mailchimp_list_id
4
4
 
@@ -15,6 +15,7 @@ SlackRubyBotServer::Config.service_class.instance.on :created do |team, _error,
15
15
 
16
16
  # fetch and merge member tags
17
17
  tags = SlackRubyBotServer::Mailchimp.config.additional_member_tags
18
+ tags = tags.call(team, options) if tags.respond_to?(:call)
18
19
  tags = (tags + team.tags).uniq if team.respond_to?(:tags)
19
20
 
20
21
  member = mailchimp_list.members.where(email_address: profile.email).first
@@ -28,7 +29,9 @@ SlackRubyBotServer::Config.service_class.instance.on :created do |team, _error,
28
29
  end
29
30
 
30
31
  # merge fields
31
- merge_fields = SlackRubyBotServer::Mailchimp.config.additional_merge_fields.merge(
32
+ merge_fields = SlackRubyBotServer::Mailchimp.config.additional_merge_fields
33
+ merge_fields = merge_fields.call(team, options) if merge_fields.respond_to?(:call)
34
+ merge_fields = merge_fields.merge(
32
35
  'FNAME' => profile.first_name.to_s,
33
36
  'LNAME' => profile.last_name.to_s
34
37
  )
@@ -1,5 +1,5 @@
1
1
  module SlackRubyBotServer
2
2
  module Mailchimp
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-bot-server-mailchimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-24 00:00:00.000000000 Z
11
+ date: 2019-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mailchimp_api_v3