drip-ruby 3.4.1 → 3.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +39 -0
- data/CHANGELOG.md +8 -1
- data/lib/drip/client/subscribers.rb +15 -3
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/subscribers_test.rb +6 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a315464f308426c87063f971108b2861cc7f6beacf9320fdf16af17bed73fc16
|
4
|
+
data.tar.gz: 70cd96e4f9ea7a463f73ae83990e8cfda6519563bbcaec9b4942d1862d7613b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d9dba42336127f9cfc9269ab57ff0f7af9fac620fb735d0749cb40ecf76a96175e25bee9b2a55ef94fd4ba038d10ae0fa371c9b0b0d7ded6f09f4169bbcb93
|
7
|
+
data.tar.gz: 1991082152cbf1bfc5748a37e6108418313871ea5272e8ad42b33a2be4081174b282601deedd027f8187df2e513071ea80636423f77168fffe2d2f42dba82af2
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Addresses: [ECI-XXXX](https://dripcom.atlassian.net/browse/ECI-XXXX)
|
2
|
+
|
3
|
+
plus links to any other relevant tickets, PRs, JIRAs, wikis, e.g.:
|
4
|
+
|
5
|
+
Followup to: https://github.com/DripEmail/drip-ruby/12437
|
6
|
+
|
7
|
+
Also any pair partners that worked on this code:
|
8
|
+
|
9
|
+
Co-authored-by: Jesse Developer <jesse.developer@drip.com>
|
10
|
+
|
11
|
+
## Background
|
12
|
+
|
13
|
+
Explain the context and why you're making that change. What is the
|
14
|
+
problem you're trying to solve? In some cases there is not a problem
|
15
|
+
and this can be thought of being the motivation for your change.
|
16
|
+
|
17
|
+
## Modification
|
18
|
+
|
19
|
+
Describe the modifications you've done.
|
20
|
+
|
21
|
+
## Result
|
22
|
+
|
23
|
+
What will change as a result of your pull request? Note that sometimes
|
24
|
+
this section is unnecessary because it is self-explanatory based on
|
25
|
+
the solution.
|
26
|
+
|
27
|
+
## Additional Context
|
28
|
+
|
29
|
+
Does the PR title contain the JIRA key if using JIRA?
|
30
|
+
|
31
|
+
## How to verify/test
|
32
|
+
|
33
|
+
Aside from automated tests that should be part of every PR,
|
34
|
+
what are the steps necessary to independently confirm that the PR
|
35
|
+
is correct in staging or production? Describe here the steps did you do
|
36
|
+
to manually smoke test or verify the functionality from the point of
|
37
|
+
view of a non-developer.
|
38
|
+
|
39
|
+
This section may not apply to all PRs.
|
data/CHANGELOG.md
CHANGED
@@ -6,10 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
[master]: https://github.com/DripEmail/drip-ruby/compare/v3.4.
|
9
|
+
[master]: https://github.com/DripEmail/drip-ruby/compare/v3.4.2...HEAD
|
10
10
|
|
11
11
|
- Your contribution here!
|
12
12
|
|
13
|
+
## [3.4.2] - 2021-04-25
|
14
|
+
|
15
|
+
[3.4.2]: https://github.com/DripEmail/drip-ruby/compare/v3.4.1...v3.4.2
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- `Drip::Client#create_or_update_subscriber` can be used with a BigCommerce Subscriber ID as the required key
|
19
|
+
|
13
20
|
## [3.4.1] - 2020-04-21
|
14
21
|
|
15
22
|
[3.4.1]: https://github.com/DripEmail/drip-ruby/compare/v3.4.0...v3.4.1
|
@@ -35,8 +35,10 @@ module Drip
|
|
35
35
|
#
|
36
36
|
# email - Optional. The String subscriber email address. (Deprecated in favor of a hash argument)
|
37
37
|
# options - A Hash of options.
|
38
|
-
# - email - Required (or id
|
39
|
-
#
|
38
|
+
# - email - Required (or id, or bigcommerce_subscriber_id).
|
39
|
+
# Lookup the subscriber by email.
|
40
|
+
# - id - Required (or email, or bigcommerce_subscriber_id).
|
41
|
+
# Lookup the subscriber by Drip ID.
|
40
42
|
# - new_email - Optional. A new email address for the subscriber.
|
41
43
|
# If provided and a subscriber with the email above
|
42
44
|
# does not exist, this address will be used to
|
@@ -45,6 +47,9 @@ module Drip
|
|
45
47
|
# format). Defaults to Etc/UTC.
|
46
48
|
# - custom_fields - Optional. A Hash of custom field data.
|
47
49
|
# - tags - Optional. An Array of tags.
|
50
|
+
# - external_ids - Optional. A hash of relevant ids for other integrations.
|
51
|
+
# For unsubscribing BigCommerce subscribers, a bigcommerce_subscriber_id
|
52
|
+
# can be provided in external_ids rather than email or id as the required field.
|
48
53
|
#
|
49
54
|
# Returns a Drip::Response.
|
50
55
|
# See https://www.getdrip.com/docs/rest-api#create_or_update_subscriber
|
@@ -52,7 +57,7 @@ module Drip
|
|
52
57
|
data = {}
|
53
58
|
data[:email] = args[0] if args[0].is_a? String
|
54
59
|
data.merge!(args.last) if args.last.is_a? Hash
|
55
|
-
raise ArgumentError, 'email: or id: parameter required' if
|
60
|
+
raise ArgumentError, 'email: or id: or bigcommerce_subscriber_id: parameter required' if missing_subscriber_identifier(data)
|
56
61
|
make_json_api_request :post, "v2/#{account_id}/subscribers", private_generate_resource("subscribers", data)
|
57
62
|
end
|
58
63
|
|
@@ -152,5 +157,12 @@ module Drip
|
|
152
157
|
make_json_api_request :post, "v2/#{account_id}/subscribers/#{CGI.escape id_or_email}/unsubscribe_all"
|
153
158
|
end
|
154
159
|
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def missing_subscriber_identifier(data)
|
164
|
+
external_ids = data[:external_ids] || {}
|
165
|
+
!data.key?(:email) && !data.key?(:id) && !external_ids.key?("bigcommerce_subscriber_id")
|
166
|
+
end
|
155
167
|
end
|
156
168
|
end
|
data/lib/drip/version.rb
CHANGED
@@ -84,6 +84,12 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
84
84
|
assert_equal expected, @client.create_or_update_subscriber(id: 123456)
|
85
85
|
assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"id":123456}]}', times: 1
|
86
86
|
end
|
87
|
+
|
88
|
+
should "allow request with bigcommerce_subscriber_id keyword argument" do
|
89
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
90
|
+
assert_equal expected, @client.create_or_update_subscriber(external_ids: { "bigcommerce_subscriber_id" => "2" })
|
91
|
+
assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"external_ids":{"bigcommerce_subscriber_id":"2"}}]}', times: 1
|
92
|
+
end
|
87
93
|
end
|
88
94
|
|
89
95
|
context "#create_or_update_subscribers" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drip-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drip
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple wrapper for the Drip API
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/pull_request_template.md"
|
20
21
|
- ".gitignore"
|
21
22
|
- ".rubocop.yml"
|
22
23
|
- ".rubocop_todo.yml"
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
rubygems_version: 3.1.
|
145
|
+
rubygems_version: 3.1.4
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: A Ruby gem for interacting with the Drip API
|