gibbon 3.3.3 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gibbon might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbdff62baa93bc714bc199105fa84691067cec6650a1a5c06dbde64da52c8bd6
4
- data.tar.gz: 5e115ce632e5e3229692f3975c0819cc165eec6a2ef41ab0fa76704ce9c83955
3
+ metadata.gz: cbf98318183318809515680772c41112c958c6bbe179cca742be0ede39a7ff00
4
+ data.tar.gz: b5ef43d8313654cd65cc57da8698189cf559200e89da98cd269b9e3973d02b9e
5
5
  SHA512:
6
- metadata.gz: dec423c9924c775b88110218b948f2685daa949f03ea3ee7eef7bafd4c9b97ed5db201167cb9aae66edfb9be964e227c864c2536f9ab6407e1f50b14ec2061c3
7
- data.tar.gz: dfca56671affd0cffc57cb19b4292eed8f70e7a8de60b5a8524660cb2fe44ae947f794c540781039a1de77cf2ca5918c4bb0f6cbaadfe375bd5ed916e3d84c1a
6
+ metadata.gz: 6c4534f315ae5d1bdf712bbdb56414ba2e96170af76c6e70dde47f1d01157e2d3707d4473be60f3a38b9cfa3ab8780694bcde7b007d5dc0919c103d5b7f69598
7
+ data.tar.gz: fe7e4f3f2c55b289ee93c8f72ce28204a55ad013c3f997f287a734e0cb7e07b2ec5ce635a9c5534f2be11e25eda8ed291365d6c7579f6fb5cbfcf2a1287f1bdf
data/.travis.yml CHANGED
@@ -4,8 +4,9 @@ cache: bundler
4
4
  before_install:
5
5
  - gem install bundler # -v 1.7.14 if a specific version is needed
6
6
  rvm:
7
- - 2.3.8
8
7
  - 2.4.5
9
8
  - 2.5.7
10
9
  - 2.6.5
11
10
  - 2.7
11
+ - 3.0.0
12
+
data/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  ## [Unreleased][unreleased]
2
2
 
3
- ## [3.3.3] - 2020-02-7
3
+
4
+ ## [3.4.3] - 2022-01-19
5
+ - Support for Faraday 2.0, which requires new syntax for basic auth
6
+
7
+ ## [3.4.2] - 2021-09-21
8
+ - Fixing the deprecation warning in version 3.4.2 requires moving to a minimum version of Faraday 1.0.0 (more than 2 years old).
9
+
10
+ ## [3.4.1] - 2021-09-12
11
+ - Fix deprecation warning for upcoming versions of Faraday (2.x.x)
12
+
13
+ ## [3.4.0] - 2021-03-12
14
+ - Support for Faraday 1.x.x and higer
15
+
16
+ ## [3.3.4] - 2020-04-01
17
+ - Added support for setting API key via environment variable for Export API
18
+ - Updated webmock
19
+
20
+ ## [3.3.3] - 2020-02-07
4
21
  - Removes bit of extra conditional logic that was part of supporting older versions of Faraday
5
22
 
6
23
  ## [3.3.2] - 2020-01-19
data/Gemfile CHANGED
@@ -1,12 +1,11 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  platforms :rbx do
4
- gem 'rubysl', '~> 2.2.0'
5
4
  gem 'rubinius-developer_tools'
6
5
  end
7
6
 
8
7
  group :development, :test do
9
- gem 'webmock', '~>1.24.0'
8
+ gem 'webmock', '~> 3.8'
10
9
  end
11
10
 
12
11
  gemspec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2020 Amro Mousa
1
+ Copyright (c) 2010-2022 Amro Mousa
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gibbon is an API wrapper for MailChimp's [API](http://kb.mailchimp.com/api/).
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/amro/gibbon.svg)](http://travis-ci.org/amro/gibbon)
5
+ [![Build Status](https://travis-ci.com/amro/gibbon.svg?branch=master)](https://app.travis-ci.com/github/amro/gibbon)
6
6
 
7
7
  ## Important Notes
8
8
 
@@ -38,7 +38,7 @@ gibbon.open_timeout = 30
38
38
  You can read about `timeout` and `open_timeout` in the [Net::HTTP](https://ruby-doc.org/stdlib-2.3.3/libdoc/net/http/rdoc/Net/HTTP.html) doc.
39
39
 
40
40
  Now you can make requests using the resources defined in [MailChimp's docs](http://kb.mailchimp.com/api/resources). Resource IDs
41
- are specified inline and a `CRUD` (`create`, `retrieve`, `update`, `upsert`, or `delete`) verb initiates the request. `upsert` lets you update a record, if it exists, or insert it otherwise where supported by MailChimp's API.
41
+ are specified inline and a `CRUD` (`create`, `retrieve` (or `get`), `update`, `upsert`, or `delete`) verb initiates the request. `upsert` lets you update a record, if it exists, or insert it otherwise where supported by MailChimp's API.
42
42
 
43
43
  ***Note*** `upsert` requires Gibbon version 2.1.0 or newer!
44
44
 
@@ -48,6 +48,8 @@ You can specify `headers`, `params`, and `body` when calling a `CRUD` method. Fo
48
48
  gibbon.lists.retrieve(headers: {"SomeHeader": "SomeHeaderValue"}, params: {"query_param": "query_param_value"})
49
49
  ```
50
50
 
51
+ ***Note*** `get` can be substituted for `retrieve` as of Gibbon version 3.4.1 or newer!
52
+
51
53
  Of course, `body` is only supported on `create`, `update`, and `upsert` calls. Those map to HTTP `POST`, `PATCH`, and `PUT` verbs respectively.
52
54
 
53
55
  You can set `api_key`, `timeout`, `open_timeout`, `faraday_adapter`, `proxy`, `symbolize_keys`, `logger`, and `debug` globally:
@@ -506,5 +508,5 @@ Thanks to everyone who has [contributed](https://github.com/amro/gibbon/contribu
506
508
 
507
509
  ## Copyright
508
510
 
509
- * Copyright (c) 2010-2020 Amro Mousa. See LICENSE.txt for details.
510
- * MailChimp (c) 2001-2020 The Rocket Science Group.
511
+ * Copyright (c) 2010-2022 Amro Mousa. See LICENSE.txt for details.
512
+ * MailChimp (c) 2001-2022 The Rocket Science Group.
data/gibbon.gemspec CHANGED
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
- s.required_ruby_version = '>= 2.3.8'
20
+ s.required_ruby_version = '>= 2.4.0'
21
21
 
22
- s.add_dependency('faraday', '>= 0.16.0')
22
+ s.add_dependency('faraday', '>= 1.0')
23
23
  s.add_dependency('multi_json', '>= 1.11.0')
24
24
 
25
25
  s.add_development_dependency 'rake'
26
26
  s.add_development_dependency "rspec", "3.5.0"
27
- s.add_development_dependency 'webmock', '~> 1.21.0'
27
+ s.add_development_dependency 'webmock', '~> 3.8'
28
28
 
29
29
  end
@@ -109,7 +109,7 @@ module Gibbon
109
109
  error_params = {}
110
110
 
111
111
  begin
112
- if error.is_a?(Faraday::ClientError) && error.response
112
+ if (error.is_a?(Faraday::ClientError) || error.is_a?(Faraday::ServerError)) && error.response
113
113
  error_params[:status_code] = error.response[:status]
114
114
  error_params[:raw_body] = error.response[:body]
115
115
 
@@ -152,8 +152,14 @@ module Gibbon
152
152
  if @request_builder.debug
153
153
  faraday.response :logger, @request_builder.logger, bodies: true
154
154
  end
155
+
156
+ if Faraday::VERSION.to_i >= 2
157
+ faraday.request :authorization, :basic, 'apikey', self.api_key
158
+ else
159
+ faraday.request :basic_auth, 'apikey', self.api_key
160
+ end
155
161
  end
156
- client.basic_auth('apikey', self.api_key)
162
+
157
163
  client
158
164
  end
159
165
 
data/lib/gibbon/export.rb CHANGED
@@ -7,7 +7,7 @@ module Gibbon
7
7
  attr_accessor :api_key, :timeout
8
8
 
9
9
  def initialize(api_key: nil, timeout: nil)
10
- @api_key = api_key || self.class.api_key
10
+ @api_key = api_key || self.class.api_key || ENV['MAILCHIMP_API_KEY']
11
11
  @timeout = timeout || self.class.timeout || 600
12
12
  end
13
13
 
@@ -61,6 +61,10 @@ module Gibbon
61
61
  reset
62
62
  end
63
63
 
64
+ def get(params: nil, headers: nil)
65
+ retrieve(params: params, headers: headers)
66
+ end
67
+
64
68
  def retrieve(params: nil, headers: nil)
65
69
  APIRequest.new(builder: self).get(params: params, headers: headers)
66
70
  ensure
@@ -1,3 +1,3 @@
1
1
  module Gibbon
2
- VERSION = "3.3.3"
2
+ VERSION = "3.4.3"
3
3
  end
@@ -6,20 +6,21 @@ describe Gibbon::APIRequest do
6
6
 
7
7
  before do
8
8
  @gibbon = Gibbon::Request.new(api_key: api_key)
9
- @api_root = "https://apikey:#{api_key}@us1.api.mailchimp.com/3.0"
9
+ @api_root = "https://us1.api.mailchimp.com/3.0"
10
+ @basic_auth_credentials = ['apikey', api_key]
10
11
  end
11
12
 
12
13
  shared_examples_for 'client error handling' do
13
14
  it "surfaces client request exceptions as a Gibbon::MailChimpError" do
14
15
  exception = error_class.new("the server responded with status 503")
15
- stub_request(:get, "#{@api_root}/lists").to_raise(exception)
16
+ stub_request(:get, "#{@api_root}/lists").with(basic_auth: @basic_auth_credentials).to_raise(exception)
16
17
  expect { @gibbon.lists.retrieve }.to raise_error(Gibbon::MailChimpError)
17
18
  end
18
19
 
19
20
  it "surfaces an unparseable client request exception as a Gibbon::MailChimpError" do
20
21
  exception = error_class.new(
21
22
  "the server responded with status 503")
22
- stub_request(:get, "#{@api_root}/lists").to_raise(exception)
23
+ stub_request(:get, "#{@api_root}/lists").with(basic_auth: @basic_auth_credentials).to_raise(exception)
23
24
  expect { @gibbon.lists.retrieve }.to raise_error(Gibbon::MailChimpError)
24
25
  end
25
26
 
@@ -27,7 +28,7 @@ describe Gibbon::APIRequest do
27
28
  response_values = {:status => 503, :headers => {}, :body => '[foo]'}
28
29
  exception = error_class.new("the server responded with status 503", response_values)
29
30
 
30
- stub_request(:get, "#{@api_root}/lists").to_raise(exception)
31
+ stub_request(:get, "#{@api_root}/lists").with(basic_auth: @basic_auth_credentials).to_raise(exception)
31
32
  expect { @gibbon.lists.retrieve }.to raise_error(Gibbon::MailChimpError)
32
33
  end
33
34
 
@@ -17,6 +17,13 @@ describe Gibbon::Export do
17
17
  expect {@export.list(id: "123456")}.to raise_error(Gibbon::GibbonError)
18
18
  end
19
19
 
20
+ it "sets an API key from the 'MAILCHIMP_API_KEY' ENV variable" do
21
+ ENV['MAILCHIMP_API_KEY'] = 'TESTKEY-us1'
22
+ @export = Gibbon::Export.new
23
+ expect(@export.api_key).to eq('TESTKEY-us1')
24
+ ENV.delete('MAILCHIMP_API_KEY')
25
+ end
26
+
20
27
  it "sets correct endpoint from api key" do
21
28
  @api_key = "TESTKEY-us1"
22
29
  @export.api_key = @api_key
@@ -17,8 +17,8 @@ describe Gibbon do
17
17
  end
18
18
 
19
19
  it 'supports upsert request' do
20
- stub_request(:put, "https://apikey:1234-us1@us1.api.mailchimp.com/3.0/lists/#{list_id}/members/#{member_id}")
21
- .with(body: MultiJson.dump(request_body))
20
+ stub_request(:put, "https://us1.api.mailchimp.com/3.0/lists/#{list_id}/members/#{member_id}")
21
+ .with(body: MultiJson.dump(request_body), basic_auth: ['apikey', '1234-us1'])
22
22
  .to_return(status: 200)
23
23
 
24
24
  Gibbon::Request.new(api_key: api_key)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amro Mousa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.16.0
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.16.0
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.21.0
75
+ version: '3.8'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.21.0
82
+ version: '3.8'
83
83
  description: A wrapper for MailChimp API 3.0 and Export API
84
84
  email:
85
85
  - amromousa@gmail.com
@@ -116,7 +116,7 @@ homepage: http://github.com/amro/gibbon
116
116
  licenses:
117
117
  - MIT
118
118
  metadata: {}
119
- post_install_message:
119
+ post_install_message:
120
120
  rdoc_options: []
121
121
  require_paths:
122
122
  - lib
@@ -124,15 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: 2.3.8
127
+ version: 2.4.0
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.0.6
135
- signing_key:
134
+ rubygems_version: 3.2.27
135
+ signing_key:
136
136
  specification_version: 4
137
137
  summary: A wrapper for MailChimp API 3.0 and Export API
138
138
  test_files: