nationbuilder-rb 1.6.1 → 1.6.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
- SHA1:
3
- metadata.gz: 7d90522e1da3706355c4384564ce4d013e5157c9
4
- data.tar.gz: 9b90174d74c34961e5c0182723c69f18c189be11
2
+ SHA256:
3
+ metadata.gz: fa19aac9206353be46c51cc1da4ffe85900ede423561f5088522cd87247deebd
4
+ data.tar.gz: 52de4115b379d3dd190c64e6d8caae4992cbaf66d68010790dc4f2d3e790ebff
5
5
  SHA512:
6
- metadata.gz: 74c9fe8815fbbe6b6c249701953995a5af9f82f3db7cde9fa925acea0d197d225f749518507523a7bd3aaebe226e6619db80e7c88bcf246ddb3340d7f01d707a
7
- data.tar.gz: 8058d962e097dc7a4353ca00bcdbc4fe7a7a58bf8cdb7422f97f0dbaa565c1694ac90f442f5dc3e9b2a494e631284b611f3a73bcbf1f51ea2ebbef3c29dcfbe0
6
+ metadata.gz: 8aa4e1c4ac464310c14e7f3e6c01d2ff1d8fd13cb2f759fff6cdba79e621e0fdc85a4e4a46029fd445d3ba638028d8aa8e4e7fc7a44cb31c901e2816b890a5fc
7
+ data.tar.gz: 2154343718733e691c2aa242b5603a4bcf94216c4b3ca6dc9b2de3ab1cab3f09fbcbb8a85a030615b1c0b9ac7d5853f0cdfa37f12867159dc67a8a2ca9335aa2
@@ -1 +1 @@
1
- ruby-2.1.6
1
+ ruby-2.5.3
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
4
- - 2.2.5
5
- - 2.3.1
3
+ - 2.2
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
6
7
  before_script: bundle install
7
8
  script: bundle exec rake
@@ -1,3 +1,7 @@
1
+ # 1.6.2
2
+ - [#46] Pass access token via header instead of query params
3
+ - [#45] Fix query params for searching custom fields on people#search
4
+
1
5
  # 1.6.0
2
6
  - [#40] Remove appending `status_code` to the parsed response and ensure
3
7
  the `response` for the last request is always accessible via the client
data/Gemfile CHANGED
@@ -3,9 +3,9 @@ source 'https://rubygems.org'
3
3
  gem 'httpclient', '~> 2.7'
4
4
 
5
5
  group :development do
6
- gem 'rake', '~> 10.4'
7
- gem 'rspec', '~> 3.2'
8
- gem 'simplecov', '~> 0.8'
9
- gem 'vcr', '~> 2.9'
10
- gem 'webmock', '~> 1.18'
6
+ gem 'rake', '~> 12.3'
7
+ gem 'rspec', '~> 3.8'
8
+ gem 'simplecov', '~> 0.16'
9
+ gem 'vcr', '~> 4.0'
10
+ gem 'webmock', '~> 3.4'
11
11
  end
@@ -1,48 +1,52 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- addressable (2.3.7)
5
- crack (0.4.2)
4
+ addressable (2.5.2)
5
+ public_suffix (>= 2.0.2, < 4.0)
6
+ crack (0.4.3)
6
7
  safe_yaml (~> 1.0.0)
7
- diff-lcs (1.2.5)
8
- docile (1.1.5)
9
- httpclient (2.7.0.1)
10
- multi_json (1.10.1)
11
- rake (10.5.0)
12
- rspec (3.2.0)
13
- rspec-core (~> 3.2.0)
14
- rspec-expectations (~> 3.2.0)
15
- rspec-mocks (~> 3.2.0)
16
- rspec-core (3.2.0)
17
- rspec-support (~> 3.2.0)
18
- rspec-expectations (3.2.0)
8
+ diff-lcs (1.3)
9
+ docile (1.3.1)
10
+ hashdiff (0.3.7)
11
+ httpclient (2.8.3)
12
+ json (2.1.0)
13
+ public_suffix (3.0.3)
14
+ rake (12.3.1)
15
+ rspec (3.8.0)
16
+ rspec-core (~> 3.8.0)
17
+ rspec-expectations (~> 3.8.0)
18
+ rspec-mocks (~> 3.8.0)
19
+ rspec-core (3.8.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-expectations (3.8.2)
19
22
  diff-lcs (>= 1.2.0, < 2.0)
20
- rspec-support (~> 3.2.0)
21
- rspec-mocks (3.2.0)
23
+ rspec-support (~> 3.8.0)
24
+ rspec-mocks (3.8.0)
22
25
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.2.0)
24
- rspec-support (3.2.1)
26
+ rspec-support (~> 3.8.0)
27
+ rspec-support (3.8.0)
25
28
  safe_yaml (1.0.4)
26
- simplecov (0.9.1)
27
- docile (~> 1.1.0)
28
- multi_json (~> 1.0)
29
- simplecov-html (~> 0.8.0)
30
- simplecov-html (0.8.0)
31
- vcr (2.9.3)
32
- webmock (1.20.4)
29
+ simplecov (0.16.1)
30
+ docile (~> 1.1)
31
+ json (>= 1.8, < 3)
32
+ simplecov-html (~> 0.10.0)
33
+ simplecov-html (0.10.2)
34
+ vcr (4.0.0)
35
+ webmock (3.4.2)
33
36
  addressable (>= 2.3.6)
34
37
  crack (>= 0.3.2)
38
+ hashdiff
35
39
 
36
40
  PLATFORMS
37
41
  ruby
38
42
 
39
43
  DEPENDENCIES
40
44
  httpclient (~> 2.7)
41
- rake (~> 10.4)
42
- rspec (~> 3.2)
43
- simplecov (~> 0.8)
44
- vcr (~> 2.9)
45
- webmock (~> 1.18)
45
+ rake (~> 12.3)
46
+ rspec (~> 3.8)
47
+ simplecov (~> 0.16)
48
+ vcr (~> 4.0)
49
+ webmock (~> 3.4)
46
50
 
47
51
  BUNDLED WITH
48
- 1.13.6
52
+ 1.16.4
@@ -7,6 +7,7 @@ require 'uri'
7
7
  module NationBuilder; end
8
8
 
9
9
  require 'nationbuilder/version'
10
+ require 'nationbuilder/utils'
10
11
  require 'nationbuilder/client'
11
12
  require 'nationbuilder/endpoint'
12
13
  require 'nationbuilder/method'
@@ -45,18 +45,16 @@ class NationBuilder::Client
45
45
 
46
46
  request_args = {
47
47
  header: {
48
- 'Accept' => 'application/json',
49
- 'Content-Type' => 'application/json'
48
+ 'Accept' => 'application/json',
49
+ 'Content-Type' => 'application/json',
50
+ 'Authorization' => "Bearer #{@api_key}"
50
51
  },
51
- query: {
52
- access_token: @api_key
53
- }
52
+ query: {}
54
53
  }
55
54
 
56
55
  if method == :get
57
- request_args[:query].merge!(body)
56
+ request_args[:query].merge!(NationBuilder::Utils::QueryParams.encode(body))
58
57
  else
59
- body[:access_token] = @api_key
60
58
  if !body[:fire_webhooks].nil?
61
59
  request_args[:query][:fire_webhooks] = body[:fire_webhooks]
62
60
  end
@@ -30,19 +30,15 @@ class NationBuilder::Method
30
30
  end
31
31
 
32
32
  def method_args(args)
33
- a = {}
34
- args.each do |k, v|
35
- a[k] = v if parameters.include?(k)
33
+ args.each_with_object({}) do |(k, v), a|
34
+ a[k] = v if parameters.include?(k)
36
35
  end
37
- a
38
36
  end
39
37
 
40
38
  def nonmethod_args(args)
41
- a = {}
42
- args.each do |k, v|
43
- a[k] = v unless parameters.include?(k)
39
+ args.each_with_object({}) do |(k, v), a|
40
+ a[k] = v unless parameters.include?(k)
44
41
  end
45
- a
46
42
  end
47
43
 
48
44
  end
@@ -14,7 +14,7 @@ class NationBuilder::Paginator
14
14
  define_method(:"#{page_type}") do |call_body = {}|
15
15
  return nil unless send(:"#{page_type}?")
16
16
  path = send(:"#{page_type}?").split('/api/v1').last
17
- call_body[:limit] ||= CGI.parse(path)['limit']
17
+ call_body[:limit] ||= CGI.parse(path)['limit'][0]
18
18
  results = @client.raw_call(path, :get, call_body)
19
19
  return self.class.new(@client, results)
20
20
  end
@@ -2,9 +2,8 @@ class NationBuilder::SpecParser
2
2
 
3
3
  def self.parse(spec_path)
4
4
  spec = JSON.parse(File.read(spec_path))
5
- endpoints = []
6
5
 
7
- spec['endpoints'].each do |endpoint|
6
+ spec['endpoints'].each_with_object([]) do |endpoint, endpoints|
8
7
  nb_endpoint = NationBuilder::Endpoint.new(endpoint['name'])
9
8
  endpoints << nb_endpoint
10
9
  endpoint['methods'].each do |method|
@@ -22,7 +21,6 @@ class NationBuilder::SpecParser
22
21
  end
23
22
  end
24
23
 
25
- endpoints
26
24
  end
27
25
 
28
26
  end
@@ -0,0 +1,22 @@
1
+ module NationBuilder::Utils
2
+ module QueryParams
3
+ module_function
4
+
5
+ def encode(value, key = nil, output = {})
6
+ case value
7
+ when Hash then value.each { |k, v| encode(v, append_key(key, k), output) }
8
+ when Array then value.each { |v| encode(v, "#{key}[]", output) }
9
+ when nil then ''
10
+ else
11
+ output[key] = value
12
+ end
13
+ output
14
+ end
15
+
16
+ def append_key(root_key, key)
17
+ root_key.nil? ? "#{key}" : "#{root_key}[#{key}]"
18
+ end
19
+
20
+ private_class_method :append_key
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module NationBuilder
2
2
 
3
- VERSION = '1.6.1'.freeze
3
+ VERSION = '1.6.2'.freeze
4
4
 
5
5
  end
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.require_paths = ["lib"]
9
9
  s.authors = ["David Huie", "Alexandre Schmitt"]
10
- s.date = "2017-11-22"
10
+ s.date = "2018-12-27"
11
11
  s.description = "A Ruby client to the NationBuilder API"
12
- s.email = "schmitt@nationbuilder.com"
12
+ s.email = "api@nationbuilder.com"
13
13
  s.executables = ["nbdoc"]
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -68,9 +68,12 @@ Gem::Specification.new do |s|
68
68
  "lib/nationbuilder/parameter.rb",
69
69
  "lib/nationbuilder/spec_parser.rb",
70
70
  "lib/nationbuilder/url.rb",
71
+ "lib/nationbuilder/utils.rb",
71
72
  "lib/nationbuilder/version.rb",
72
73
  "nationbuilder-rb.gemspec",
73
74
  "spec/fixtures/delete.yml",
75
+ "spec/fixtures/errored_get.yml",
76
+ "spec/fixtures/paginated_get.yml",
74
77
  "spec/fixtures/paginated_get_page2.yml",
75
78
  "spec/fixtures/paginated_get_page2_with_limit.yml",
76
79
  "spec/fixtures/paginated_get_page3.yml",
@@ -78,6 +81,7 @@ Gem::Specification.new do |s|
78
81
  "spec/fixtures/parametered_post.yml",
79
82
  "spec/lib/nationbuilder/client_spec.rb",
80
83
  "spec/lib/nationbuilder/paginator_spec.rb",
84
+ "spec/lib/nationbuilder/utils_spec.rb",
81
85
  "spec/spec_helper.rb",
82
86
  "update_subtree.sh"
83
87
  ]
@@ -91,25 +95,25 @@ Gem::Specification.new do |s|
91
95
 
92
96
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
93
97
  s.add_runtime_dependency(%q<httpclient>, ["~> 2.7"])
94
- s.add_development_dependency(%q<rake>, ["~> 10.4"])
95
- s.add_development_dependency(%q<rspec>, ["~> 3.2"])
96
- s.add_development_dependency(%q<simplecov>, ["~> 0.8"])
97
- s.add_development_dependency(%q<vcr>, ["~> 2.9"])
98
- s.add_development_dependency(%q<webmock>, ["~> 1.18"])
98
+ s.add_development_dependency(%q<rake>, ["~> 12.3"])
99
+ s.add_development_dependency(%q<rspec>, ["~> 3.8"])
100
+ s.add_development_dependency(%q<simplecov>, ["~> 0.16"])
101
+ s.add_development_dependency(%q<vcr>, ["~> 4.0"])
102
+ s.add_development_dependency(%q<webmock>, ["~> 3.4"])
99
103
  else
100
104
  s.add_dependency(%q<httpclient>, ["~> 2.7"])
101
- s.add_dependency(%q<rake>, ["~> 10.4"])
102
- s.add_dependency(%q<rspec>, ["~> 3.2"])
103
- s.add_dependency(%q<simplecov>, ["~> 0.8"])
104
- s.add_dependency(%q<vcr>, ["~> 2.9"])
105
- s.add_dependency(%q<webmock>, ["~> 1.18"])
105
+ s.add_dependency(%q<rake>, ["~> 12.3"])
106
+ s.add_dependency(%q<rspec>, ["~> 3.8"])
107
+ s.add_dependency(%q<simplecov>, ["~> 0.16"])
108
+ s.add_dependency(%q<vcr>, ["~> 4.0"])
109
+ s.add_dependency(%q<webmock>, ["~> 3.4"])
106
110
  end
107
111
  else
108
112
  s.add_dependency(%q<httpclient>, ["~> 2.7"])
109
- s.add_dependency(%q<rake>, ["~> 10.4"])
110
- s.add_dependency(%q<rspec>, ["~> 3.2"])
111
- s.add_dependency(%q<simplecov>, ["~> 0.8"])
112
- s.add_dependency(%q<vcr>, ["~> 2.9"])
113
- s.add_dependency(%q<webmock>, ["~> 1.18"])
113
+ s.add_dependency(%q<rake>, ["~> 12.3"])
114
+ s.add_dependency(%q<rspec>, ["~> 3.8"])
115
+ s.add_dependency(%q<simplecov>, ["~> 0.16"])
116
+ s.add_dependency(%q<vcr>, ["~> 4.0"])
117
+ s.add_dependency(%q<webmock>, ["~> 3.4"])
114
118
  end
115
119
  end
@@ -2,38 +2,42 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: delete
5
- uri: https://organizeralexandreschmitt.nationbuilder.com/api/v1/people/278881?access_token=03c22256c06ed11f6bee83673addf26e02a86caa1a5127f4e0815be7223fe4a3
5
+ uri: https://testnation.nationbuilder.com/api/v1/people/278881
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"access_token":"03c22256c06ed11f6bee83673addf26e02a86caa1a5127f4e0815be7223fe4a3"}'
8
+ string: "{}"
9
9
  headers:
10
10
  User-Agent:
11
- - HTTPClient/1.0 (2.7.0.1, ruby 2.1.6 (2015-04-13))
11
+ - HTTPClient/1.0 (2.7.0.1, ruby 2.5.1 (2018-03-29))
12
12
  Accept:
13
13
  - application/json
14
14
  Date:
15
- - Wed, 23 Nov 2016 19:16:47 GMT
15
+ - Tue, 30 Oct 2018 20:21:54 GMT
16
16
  Content-Type:
17
17
  - application/json
18
+ Authorization:
19
+ - Bearer 03c22256c06ed11f6bee83673addf26e02a86caa1a5127f4e0815be7223fe4a3
18
20
  response:
19
21
  status:
20
22
  code: 204
21
23
  message: No Content
22
24
  headers:
23
- Server:
24
- - Apache/2.4.7 (Ubuntu)
25
25
  Nation-Ratelimit-Limit:
26
26
  - '999999'
27
27
  Nation-Ratelimit-Remaining:
28
28
  - '999999'
29
29
  Nation-Ratelimit-Reset:
30
- - '1479945600'
30
+ - '1540944000'
31
+ Server:
32
+ - Apache/2.4.7 (Ubuntu)
31
33
  Status:
32
34
  - 204 No Content
33
35
  X-Content-Type-Options:
34
36
  - nosniff
35
37
  X-Frame-Options:
36
- - SAMEORIGIN
38
+ - ALLOWALL
39
+ X-Middleware-Start:
40
+ - t=1540930915181995
37
41
  X-Powered-By:
38
42
  - Phusion Passenger Enterprise 5.0.28
39
43
  X-Pulse-Approved:
@@ -45,30 +49,28 @@ http_interactions:
45
49
  X-Ratelimit-Remaining:
46
50
  - '99'
47
51
  X-Ratelimit-Reset:
48
- - '1479928618'
52
+ - '1540930925'
49
53
  X-Request-Id:
50
- - 48920c47-e280-436b-9a98-36fa47402ce9
54
+ - eabac74f-2db5-4709-978c-bbf60720df1e
51
55
  X-Runtime:
52
- - '1.202383'
53
- X-Xss-Protection:
54
- - 1; mode=block
55
- Content-Length:
56
- - '0'
56
+ - '1.301545'
57
+ X-Served-By:
58
+ - api11
57
59
  Expires:
58
- - Wed, 23 Nov 2016 19:16:49 GMT
60
+ - Tue, 30 Oct 2018 20:21:56 GMT
59
61
  Cache-Control:
60
62
  - max-age=0, no-cache, no-store
61
63
  Pragma:
62
64
  - no-cache
63
65
  Date:
64
- - Wed, 23 Nov 2016 19:16:49 GMT
66
+ - Tue, 30 Oct 2018 20:21:56 GMT
65
67
  Connection:
66
68
  - keep-alive
67
- Set-Cookie:
68
- - _cookies_enabled=1479928609; path=/
69
+ Use-Proxy:
70
+ - 'True'
69
71
  body:
70
72
  encoding: UTF-8
71
73
  string: ''
72
- http_version:
73
- recorded_at: Wed, 23 Nov 2016 19:16:49 GMT
74
+ http_version:
75
+ recorded_at: Tue, 30 Oct 2018 20:21:56 GMT
74
76
  recorded_with: VCR 2.9.3
@@ -0,0 +1,80 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://testnation.nationbuilder.com/api/v1/people/0
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - HTTPClient/1.0 (2.7.0.1, ruby 2.5.1 (2018-03-29))
12
+ Accept:
13
+ - application/json
14
+ Date:
15
+ - Tue, 30 Oct 2018 20:20:39 GMT
16
+ Content-Type:
17
+ - application/json
18
+ Authorization:
19
+ - Bearer 03c22256c06ed11f6bee83673addf26e02a86caa1a5127f4e0815be7223fe4a3
20
+ response:
21
+ status:
22
+ code: 404
23
+ message: Not Found
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Nation-Ratelimit-Limit:
28
+ - '999999'
29
+ Nation-Ratelimit-Remaining:
30
+ - '999999'
31
+ Nation-Ratelimit-Reset:
32
+ - '1540944000'
33
+ Server:
34
+ - Apache/2.4.7 (Ubuntu)
35
+ Status:
36
+ - 404 Not Found
37
+ X-Content-Type-Options:
38
+ - nosniff
39
+ X-Frame-Options:
40
+ - ALLOWALL
41
+ X-Middleware-Start:
42
+ - t=1540930839625416
43
+ X-Powered-By:
44
+ - Phusion Passenger Enterprise 5.0.28
45
+ X-Pulse-Approved:
46
+ - 'true'
47
+ X-Rack-Cache:
48
+ - miss
49
+ X-Ratelimit-Limit:
50
+ - 10s
51
+ X-Ratelimit-Remaining:
52
+ - '98'
53
+ X-Ratelimit-Reset:
54
+ - '1540930848'
55
+ X-Request-Id:
56
+ - b89dc2fd-2a92-425c-9c60-228e3bf634c9
57
+ X-Runtime:
58
+ - '0.067800'
59
+ X-Served-By:
60
+ - api12
61
+ Content-Length:
62
+ - '49'
63
+ Expires:
64
+ - Tue, 30 Oct 2018 20:20:39 GMT
65
+ Cache-Control:
66
+ - max-age=0, no-cache, no-store
67
+ Pragma:
68
+ - no-cache
69
+ Date:
70
+ - Tue, 30 Oct 2018 20:20:39 GMT
71
+ Connection:
72
+ - keep-alive
73
+ Use-Proxy:
74
+ - 'True'
75
+ body:
76
+ encoding: UTF-8
77
+ string: '{"code":"not_found","message":"Record not found"}'
78
+ http_version:
79
+ recorded_at: Tue, 30 Oct 2018 20:20:39 GMT
80
+ recorded_with: VCR 2.9.3