pco_api 2.0.0 → 2.0.2

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
  SHA256:
3
- metadata.gz: 6e9b56ec41159e601c1afb0b4fa004797f91d0ae845ba396e09617738f98cdea
4
- data.tar.gz: 931ed18a093f13ba313d6070b2307d888db9d38fe434308f76e6b0b5b0cf9715
3
+ metadata.gz: 7c46caaee5254ab6c2c26d7a80965686c4ca68bb5ac99218ffeb95fe957a1073
4
+ data.tar.gz: be7b6229238e9f837a7b5ae30b55f13d2eff235aa4b7505d189560860d3e65c4
5
5
  SHA512:
6
- metadata.gz: 21f690d99a0ea0896ab49a416d64ae802c7f993a6f63afa725b7e6ab098a2049a6d7aad3e1dc7b0f230eb2db4bb2faceba7760d054b0c8595138708438348a66
7
- data.tar.gz: cc5b2478ae1de0b2911594483573266d9f3447078b81529c97e9765c209d49af7b9c99f80a14a089d6c92d0c7d5be3e33cde7a17a4d25cfc4ad64e0f0d030e37
6
+ metadata.gz: 8a117d5e5efe71502b215b2eb5e81c94ceef9eafb3561d251b850a8762d55aa17e4cd976f632ce997fb062b95506089a62512c05669bef27318226ca7012fbb7
7
+ data.tar.gz: 3ef5696dbe26914aaa0cb58f78840386b44a70a82b07f17102c45cd1fc10f4ad9c9aee1beae65f806a852c42fd5b53e8fac20ed6806d158eefb9f490a0929dcc
@@ -83,6 +83,10 @@ module PCO
83
83
 
84
84
  def _build_response(result)
85
85
  case result.status
86
+ when 204
87
+ res = Response.new
88
+ res.headers = result.headers
89
+ res
86
90
  when 200..299
87
91
  res = Response[result.body]
88
92
  res.headers = result.headers
@@ -137,9 +141,9 @@ module PCO
137
141
  Faraday.new(url: url) do |faraday|
138
142
  faraday.response :json, content_type: /\bjson$/
139
143
  if @basic_auth_token && @basic_auth_secret
140
- faraday.basic_auth @basic_auth_token, @basic_auth_secret
144
+ faraday.request :basic_auth, @basic_auth_token, @basic_auth_secret
141
145
  elsif @oauth_access_token
142
- faraday.headers['Authorization'] = "Bearer #{@oauth_access_token}"
146
+ faraday.request :authorization, 'Bearer', @oauth_access_token
143
147
  else
144
148
  fail Errors::AuthRequiredError, "You must specify either HTTP basic auth credentials or an OAuth2 access token."
145
149
  end
@@ -1,5 +1,5 @@
1
1
  module PCO
2
2
  module API
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.2'
4
4
  end
5
5
  end
@@ -169,34 +169,51 @@ describe PCO::API::Endpoint do
169
169
  end
170
170
 
171
171
  describe '#post' do
172
- subject { base.people.v2.people }
172
+ context do
173
+ subject { base.people.v2.people }
173
174
 
174
- let(:resource) do
175
- {
176
- 'type' => 'Person',
177
- 'first_name' => 'Tim',
178
- 'last_name' => 'Morgan'
179
- }
180
- end
175
+ let(:resource) do
176
+ {
177
+ 'type' => 'Person',
178
+ 'first_name' => 'Tim',
179
+ 'last_name' => 'Morgan'
180
+ }
181
+ end
181
182
 
182
- let(:result) do
183
- {
184
- 'type' => 'Person',
185
- 'id' => '1',
186
- 'first_name' => 'Tim',
187
- 'last_name' => 'Morgan'
188
- }
189
- end
183
+ let(:result) do
184
+ {
185
+ 'type' => 'Person',
186
+ 'id' => '1',
187
+ 'first_name' => 'Tim',
188
+ 'last_name' => 'Morgan'
189
+ }
190
+ end
190
191
 
191
- before do
192
- stub_request(:post, 'https://api.planningcenteronline.com/people/v2/people')
193
- .to_return(status: 201, body: { data: result }.to_json, headers: { 'Content-Type' => 'application/vnd.api+json' })
194
- @result = subject.post(data: resource)
192
+ before do
193
+ stub_request(:post, 'https://api.planningcenteronline.com/people/v2/people')
194
+ .to_return(status: 201, body: { data: result }.to_json, headers: { 'Content-Type' => 'application/vnd.api+json' })
195
+ @result = subject.post(data: resource)
196
+ end
197
+
198
+ it 'returns the result of making a POST request to the endpoint' do
199
+ expect(@result).to be_a(Hash)
200
+ expect(@result['data']).to eq(result)
201
+ end
195
202
  end
196
203
 
197
- it 'returns the result of making a POST request to the endpoint' do
198
- expect(@result).to be_a(Hash)
199
- expect(@result['data']).to eq(result)
204
+ context 'given a 204 No Content response' do
205
+ subject { base.people.v2.some_action }
206
+
207
+ before do
208
+ stub_request(:post, 'https://api.planningcenteronline.com/people/v2/some_action')
209
+ .to_return(status: 204, body: '')
210
+ @result = subject.post
211
+ end
212
+
213
+ it 'returns an empty hash' do
214
+ expect(@result).to be_a(Hash)
215
+ expect(@result).to eq({})
216
+ end
200
217
  end
201
218
  end
202
219
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pco_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Planning Center Online
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
19
+ version: '1.8'
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.10'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.10'
33
+ version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.10'
40
+ version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: excon
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -115,7 +115,7 @@ homepage: https://github.com/planningcenter/pco_api_ruby
115
115
  licenses:
116
116
  - MIT
117
117
  metadata: {}
118
- post_install_message:
118
+ post_install_message:
119
119
  rdoc_options: []
120
120
  require_paths:
121
121
  - lib
@@ -130,11 +130,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.0.3
134
- signing_key:
133
+ rubygems_version: 3.4.2
134
+ signing_key:
135
135
  specification_version: 4
136
136
  summary: API wrapper for api.planningcenteronline.com
137
137
  test_files:
138
- - spec/pco/api_spec.rb
139
138
  - spec/pco/api/endpoint_spec.rb
139
+ - spec/pco/api_spec.rb
140
140
  - spec/spec_helper.rb