drip-ruby 3.1.1 → 3.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
  SHA1:
3
- metadata.gz: 34ab6a491e2d7b0bdf33b525a11c7d5499bd0e2f
4
- data.tar.gz: d5b703ea0a8f113be93b5c19bbf13849f7fbb6b7
3
+ metadata.gz: 70f3d91d9c2443f74403c190edb0cf38e67f6659
4
+ data.tar.gz: '0759cfde4ef6ed2361b909c6f765a9cec2579a14'
5
5
  SHA512:
6
- metadata.gz: ffb4cacb8da55651f34b33c9377de84104fa5913eb520f7437a2b0cf045eba8da1743043538c10ee00be64b562697128d22e35225307d5f4dee1c318c5022bdc
7
- data.tar.gz: 3bce36166a411416f7258939b2283c403ec35903b882144538f95b893f56a61bd7bb3f90503ae61f7c318a834356ca073b594555fbc62f6185f4d8d6fa29908c
6
+ metadata.gz: cad33578769c6b1e0d45dec91e9f4fd691eb32f36df440b82b41649ea723bf5906c3bc4fa0a5341920e17e2720857c94e6da1459ebe18df023a12c1fc28686f7
7
+ data.tar.gz: c03a67601a4d2cd13154002460576ffe475049d00e5beadb84b49a7b9ba263c6806624aa847767473cf6caaa972d8d46c43edbddf2a7b4f3be55919e680237dc
data/.rubocop.yml CHANGED
@@ -28,3 +28,7 @@ Layout/MultilineOperationIndentation:
28
28
 
29
29
  Layout/MultilineMethodCallIndentation:
30
30
  EnforcedStyle: 'indented'
31
+
32
+ Metrics/ClassLength:
33
+ Exclude:
34
+ - 'test/**/*'
data/.rubocop_todo.yml CHANGED
@@ -23,11 +23,6 @@ Metrics/AbcSize:
23
23
  Metrics/BlockLength:
24
24
  Max: 46
25
25
 
26
- # Offense count: 3
27
- # Configuration parameters: CountComments.
28
- Metrics/ClassLength:
29
- Max: 173
30
-
31
26
  # Offense count: 4
32
27
  # Configuration parameters: CountComments.
33
28
  Metrics/MethodLength:
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.0.0...HEAD
9
+ [master]: https://github.com/DripEmail/drip-ruby/compare/v3.2.0...HEAD
10
10
 
11
11
  - Your contribution here!
12
12
 
13
+ ## [3.2.0] - 2018-08-15
14
+
15
+ [3.2.0]: https://github.com/DripEmail/drip-ruby/compare/v3.1.1...v3.2.0
16
+
17
+ - Allow `#create_or_update_subscriber` to work with Drip id. Fixes [#50](https://github.com/DripEmail/drip-ruby/issues/50)
18
+ - [#52](https://github.com/DripEmail/drip-ruby/pull/52): Fix `#custom_fields` to accept the API response without error. Fixes [#30](https://github.com/DripEmail/drip-ruby/issues/30)
19
+
13
20
  ## [3.1.1] - 2018-06-06
14
21
 
15
22
  [3.1.1]: https://github.com/DripEmail/drip-ruby/compare/v3.1.0...v3.1.1
@@ -31,8 +31,10 @@ module Drip
31
31
 
32
32
  # Public: Create or update a subscriber.
33
33
  #
34
- # email - Required. The String subscriber email address.
34
+ # email - Optional. The String subscriber email address. (Deprecated in favor of a hash argument)
35
35
  # options - A Hash of options.
36
+ # - email - Required (or id). Lookup the subscriber by email.
37
+ # - id - Required (or email). Lookup the subscriber by Drip ID.
36
38
  # - new_email - Optional. A new email address for the subscriber.
37
39
  # If provided and a subscriber with the email above
38
40
  # does not exist, this address will be used to
@@ -44,8 +46,11 @@ module Drip
44
46
  #
45
47
  # Returns a Drip::Response.
46
48
  # See https://www.getdrip.com/docs/rest-api#create_or_update_subscriber
47
- def create_or_update_subscriber(email, options = {})
48
- data = options.merge(email: email)
49
+ def create_or_update_subscriber(*args)
50
+ data = {}
51
+ data[:email] = args[0] if args[0].is_a? String
52
+ data.merge!(args.last) if args.last.is_a? Hash
53
+ raise ArgumentError, 'email: or id: parameter required' if !data.key?(:email) && !data.key?(:id)
49
54
  post "#{account_id}/subscribers", generate_resource("subscribers", data)
50
55
  end
51
56
 
@@ -24,7 +24,7 @@ module Drip
24
24
 
25
25
  def parse_items
26
26
  raw_items.map do |raw_item|
27
- item_class.new(raw_item)
27
+ raw_item.is_a?(String) ? raw_item : item_class.new(raw_item)
28
28
  end
29
29
  end
30
30
 
data/lib/drip/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Drip
2
- VERSION = "3.1.1".freeze
2
+ VERSION = "3.2.0".freeze
3
3
  end
@@ -8,7 +8,15 @@ class Drip::Client::CustomFieldsTest < Drip::TestCase
8
8
  context "#custom_fields" do
9
9
  setup do
10
10
  @response_status = 200
11
- @response_body = "{}"
11
+ @response_body = <<-JSON
12
+ {
13
+ "custom_field_identifiers":[
14
+ "custom_field_1",
15
+ "custom_field_2",
16
+ "custom_field_3"
17
+ ]
18
+ }
19
+ JSON
12
20
 
13
21
  stub_request(:get, "https://api.getdrip.com/v2/12345/custom_field_identifiers").
14
22
  to_return(status: @response_status, body: @response_body, headers: {})
@@ -65,9 +65,22 @@ class Drip::Client::SubscribersTest < Drip::TestCase
65
65
  to_return(status: @response_status, body: @response_body, headers: {})
66
66
  end
67
67
 
68
- should "send the right request" do
68
+ should "allow request with legacy email argument" do
69
69
  expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
70
70
  assert_equal expected, @client.create_or_update_subscriber(@email, @data)
71
+ assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"email":"derrick@getdrip.com","time_zone":"America/Los_Angeles"}]}', times: 1
72
+ end
73
+
74
+ should "allow request with email keyword argument" do
75
+ expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
76
+ assert_equal expected, @client.create_or_update_subscriber(email: @email)
77
+ assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"email":"derrick@getdrip.com"}]}', times: 1
78
+ end
79
+
80
+ should "allow request with drip id keyword argument" do
81
+ expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
82
+ assert_equal expected, @client.create_or_update_subscriber(id: 123456)
83
+ assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"id":123456}]}', times: 1
71
84
  end
72
85
  end
73
86
 
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.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Reimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-06 00:00:00.000000000 Z
11
+ date: 2018-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler