pco_api 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pco/api/endpoint.rb +7 -3
- data/lib/pco/api/version.rb +1 -1
- data/lib/pco/api.rb +1 -0
- data/spec/pco/api/endpoint_spec.rb +40 -23
- metadata +14 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24edea66c936c4da9459fdaa5a575c53f5ce412382536626524d5ad6891bbc70
|
4
|
+
data.tar.gz: 85d8c1dc776d5f1b00aa69e5505f2d5227062ad69ae7c24c4a4d1834a2760098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 449d3b4f74b5aa220911116292ee0bfd70964a04d82f483db71dbbe9e796b87bf376a9c45925ce45debbec5d08fdc160b9179cfa7e47afc991cb4090c77f8a70
|
7
|
+
data.tar.gz: 7f4ea90c3e61e1f28d58197ea3f2c09932a8f950df1f09705497d50972a331fb035b07bcbca2d89c09c89f0243b23a439bbafefed767c9d4624094839b728b6d
|
data/lib/pco/api/endpoint.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'faraday'
|
2
|
-
require '
|
2
|
+
require 'faraday/excon'
|
3
3
|
|
4
4
|
module PCO
|
5
5
|
module API
|
@@ -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,7 +141,7 @@ 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.request :
|
144
|
+
faraday.request :authorization, :basic, @basic_auth_token, @basic_auth_secret
|
141
145
|
elsif @oauth_access_token
|
142
146
|
faraday.request :authorization, 'Bearer', @oauth_access_token
|
143
147
|
else
|
@@ -158,4 +162,4 @@ module PCO
|
|
158
162
|
end
|
159
163
|
end
|
160
164
|
end
|
161
|
-
end
|
165
|
+
end
|
data/lib/pco/api/version.rb
CHANGED
data/lib/pco/api.rb
CHANGED
@@ -169,34 +169,51 @@ describe PCO::API::Endpoint do
|
|
169
169
|
end
|
170
170
|
|
171
171
|
describe '#post' do
|
172
|
-
|
172
|
+
context do
|
173
|
+
subject { base.people.v2.people }
|
173
174
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
175
|
+
let(:resource) do
|
176
|
+
{
|
177
|
+
'type' => 'Person',
|
178
|
+
'first_name' => 'Tim',
|
179
|
+
'last_name' => 'Morgan'
|
180
|
+
}
|
181
|
+
end
|
181
182
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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
|
-
|
198
|
-
|
199
|
-
|
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,57 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pco_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
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:
|
11
|
+
date: 2023-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.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: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: faraday-excon
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '2.1'
|
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: '1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: excon
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.71.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.71.0
|
40
|
+
version: '2.1'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +101,7 @@ homepage: https://github.com/planningcenter/pco_api_ruby
|
|
115
101
|
licenses:
|
116
102
|
- MIT
|
117
103
|
metadata: {}
|
118
|
-
post_install_message:
|
104
|
+
post_install_message:
|
119
105
|
rdoc_options: []
|
120
106
|
require_paths:
|
121
107
|
- lib
|
@@ -130,11 +116,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
116
|
- !ruby/object:Gem::Version
|
131
117
|
version: '0'
|
132
118
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
-
signing_key:
|
119
|
+
rubygems_version: 3.4.2
|
120
|
+
signing_key:
|
135
121
|
specification_version: 4
|
136
122
|
summary: API wrapper for api.planningcenteronline.com
|
137
123
|
test_files:
|
138
|
-
- spec/pco/api_spec.rb
|
139
124
|
- spec/pco/api/endpoint_spec.rb
|
125
|
+
- spec/pco/api_spec.rb
|
140
126
|
- spec/spec_helper.rb
|