nationbuilder-rb 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5dbf155a35ce3dc4e6e6a589a2e21ee3cc72c8a
4
- data.tar.gz: fa021eae289bd54ce766f9830c8209d9945fbf86
3
+ metadata.gz: 14a29218206ac57d5dfab65c415aa96556baafab
4
+ data.tar.gz: 458e780eab970154448bf04728c91f8013074bd2
5
5
  SHA512:
6
- metadata.gz: 2c52251b51f1f8e525d18bfd7bf3875a480a525a32176441c6770bbe300ac5e532aa5d84aecb0cdacb2dde1f6aca278482f74a99c797b8877183e985e9d7f7df
7
- data.tar.gz: 5391541f46bc04bad1e0e7eab1332094b52c917f3d2b7c4d30a4bca22aca0591b8c770e9266c52fa03e3445e92e9c2c48a7165a9ccb3189ec292dcb9a4e0de33
6
+ metadata.gz: e6ee8bea7f26f66286e207800beb8b9e86e206ee0fdc7c92d281319246f20f19d57594cd6639639f8e7065a2c2473df5a66898a1d2f0bf0c17810d07f8e1108f
7
+ data.tar.gz: 50712c5c46c8da59efafb3313a7bfbef67d6524b869d1f70a39bfee91cf62ddc3bb4744aa305620f7c1efeb1dfb48f2e98f55b71e6b40177929c0e2d36a3caaa
@@ -1,5 +1,9 @@
1
+ # 1.6.0
2
+ - [#40] Remove appending `status_code` to the parsed response and ensure
3
+ the `response` for the last request is always accessible via the client
4
+
1
5
  # 1.5.0
2
- - [#31] Allow for a user provided HTTPClient
6
+ - [#31] Allow for a user provided HTTPClient
3
7
 
4
8
  # 1.4.3
5
9
  - [#34] Fix `Content-Type` header check
@@ -76,14 +76,13 @@ class NationBuilder::Client
76
76
  end
77
77
 
78
78
  def perform_request_with_retries(method, url, request_args)
79
- raw_response = nil
80
79
  parsed_response = nil
81
80
  exception_to_reraise = nil
82
81
 
83
82
  (@retries + 1).times do |i|
84
83
  begin
85
- raw_response = @http_client.send(method, url, request_args)
86
- parsed_response = parse_response_body(raw_response)
84
+ set_response(@http_client.send(method, url, request_args))
85
+ parsed_response = parse_response_body(response)
87
86
  rescue NationBuilder::RateLimitedError => e
88
87
  exception_to_reraise = e
89
88
  Kernel.sleep(RETRY_DELAY * 2**i)
@@ -96,11 +95,8 @@ class NationBuilder::Client
96
95
  end
97
96
 
98
97
  # If the retry cycle ended with an error, reraise it
99
- if exception_to_reraise
100
- raise exception_to_reraise
101
- end
98
+ raise exception_to_reraise if exception_to_reraise
102
99
 
103
- set_response(raw_response)
104
100
  parsed_response
105
101
  end
106
102
 
@@ -133,7 +129,7 @@ class NationBuilder::Client
133
129
  return true
134
130
  end
135
131
 
136
- parsed_body(response.body).merge('status_code' => response.code)
132
+ parsed_body(response.body)
137
133
  end
138
134
 
139
135
  def print_all_descriptions
@@ -1,5 +1,5 @@
1
1
  module NationBuilder
2
2
 
3
- VERSION = '1.5.0'.freeze
3
+ VERSION = '1.6.0'.freeze
4
4
 
5
5
  end
@@ -7,7 +7,7 @@ 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 = "2016-12-06"
10
+ s.date = "2017-03-27"
11
11
  s.description = "A Ruby client to the NationBuilder API"
12
12
  s.email = "schmitt@nationbuilder.com"
13
13
  s.executables = ["nbdoc"]
@@ -63,7 +63,7 @@ describe NationBuilder::Client do
63
63
  it 'should handle a parametered GET' do
64
64
  VCR.use_cassette('parametered_get') do
65
65
  response = client.call(:basic_pages, :index, site_slug: 'organizeralexandreschmitt', limit: 11)
66
- expect(response['status_code']).to eq(200)
66
+ expect(client.response.status).to eq(200)
67
67
  response['results'].each do |result|
68
68
  expect(result['site_slug']).to eq('organizeralexandreschmitt')
69
69
  end
@@ -83,10 +83,21 @@ describe NationBuilder::Client do
83
83
  client.call(:people, :create, params)
84
84
  end
85
85
 
86
- expect(response['status_code']).to eq(201)
86
+ expect(client.response.status).to eq(201)
87
87
  expect(response['person']['first_name']).to eq('Bob')
88
88
  end
89
89
 
90
+ context 'errored request' do
91
+ it 'sets the response on the client' do
92
+ VCR.use_cassette('errored_get') do
93
+ expect do
94
+ client.call(:people, :show, id: 0)
95
+ end.to raise_error(NationBuilder::ClientError)
96
+ expect(client.response.status).to eq(404)
97
+ end
98
+ end
99
+ end
100
+
90
101
  context 'fire_webhooks' do
91
102
 
92
103
  it 'should disable webhooks' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nationbuilder-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Huie
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-06 00:00:00.000000000 Z
12
+ date: 2017-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.5.2
191
+ rubygems_version: 2.6.11
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: A Ruby client to the NationBuilder API