pco_api 1.2.2 → 1.3.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 +5 -5
- data/README.md +8 -1
- data/lib/pco/api/endpoint.rb +9 -1
- data/lib/pco/api/errors.rb +3 -1
- data/lib/pco/api/version.rb +1 -1
- data/spec/pco/api/endpoint_spec.rb +2 -0
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb681a310a78eeb3ac455edc7ab2b4696a246e74a54077b1f0c5ce26e9a31c10
|
4
|
+
data.tar.gz: fe3398a9fd3c50f784e139fd65879a31cdf56d210a97e3e46e5f66309058b0f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41d1955114ffe087506d63c3907ebad24f9c0a34e9e3784d620bc2be8080bf309b3eb0fbed52a60b5805e1e2cf0ccfe07d6adcc0072a48f78336461d9e7ca14b
|
7
|
+
data.tar.gz: 1ead2832a8c2f62c13845b5c7c28254494efdbdedf404b6e70ccbd9791fd12ee9932acfad3ed9255dc9d3451eaf4dd4841cb2a1ed99721304a15fc5260c1301d
|
data/README.md
CHANGED
@@ -42,6 +42,13 @@ gem install pco_api
|
|
42
42
|
# GET /people/v2/households?order=name
|
43
43
|
```
|
44
44
|
|
45
|
+
5. To query dataset according to `can_query_by` variables:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
api.people.v2.people.get('where[membership]': 'Member')
|
49
|
+
# GET /people/v2/people?where[membership]=Member
|
50
|
+
```
|
51
|
+
|
45
52
|
## Example
|
46
53
|
|
47
54
|
```ruby
|
@@ -224,4 +231,4 @@ the status code returned by calling `error.status`.
|
|
224
231
|
|
225
232
|
## Copyright & License
|
226
233
|
|
227
|
-
Copyright
|
234
|
+
Copyright Ministry Centered Technologies. Licensed MIT.
|
data/lib/pco/api/endpoint.rb
CHANGED
@@ -5,6 +5,10 @@ module PCO
|
|
5
5
|
module API
|
6
6
|
URL = 'https://api.planningcenteronline.com'
|
7
7
|
|
8
|
+
class Response < Hash
|
9
|
+
attr_accessor :headers
|
10
|
+
end
|
11
|
+
|
8
12
|
class Endpoint
|
9
13
|
attr_reader :url, :last_result
|
10
14
|
|
@@ -69,7 +73,9 @@ module PCO
|
|
69
73
|
def _build_response(result)
|
70
74
|
case result.status
|
71
75
|
when 200..299
|
72
|
-
result.body
|
76
|
+
res = Response[result.body]
|
77
|
+
res.headers = result.headers
|
78
|
+
res
|
73
79
|
when 400
|
74
80
|
fail Errors::BadRequest, result
|
75
81
|
when 401
|
@@ -82,6 +88,8 @@ module PCO
|
|
82
88
|
fail Errors::MethodNotAllowed, result
|
83
89
|
when 422
|
84
90
|
fail Errors::UnprocessableEntity, result
|
91
|
+
when 429
|
92
|
+
fail Errors::TooManyRequests, result
|
85
93
|
when 400..499
|
86
94
|
fail Errors::ClientError, result
|
87
95
|
when 500
|
data/lib/pco/api/errors.rb
CHANGED
@@ -4,11 +4,12 @@ module PCO
|
|
4
4
|
class AuthRequiredError < StandardError; end
|
5
5
|
|
6
6
|
class BaseError < StandardError
|
7
|
-
attr_reader :status, :detail
|
7
|
+
attr_reader :status, :detail, :headers
|
8
8
|
|
9
9
|
def initialize(response)
|
10
10
|
@status = response.status
|
11
11
|
@detail = response.body
|
12
|
+
@headers = response.headers
|
12
13
|
end
|
13
14
|
|
14
15
|
def to_s
|
@@ -52,6 +53,7 @@ module PCO
|
|
52
53
|
class NotFound < ClientError; end # 404
|
53
54
|
class MethodNotAllowed < ClientError; end # 405
|
54
55
|
class UnprocessableEntity < ClientError; end # 422
|
56
|
+
class TooManyRequests < ClientError; end # 429
|
55
57
|
|
56
58
|
class ServerError < BaseError; end # 500..599
|
57
59
|
class InternalServerError < ServerError; end # 500
|
data/lib/pco/api/version.rb
CHANGED
@@ -50,6 +50,7 @@ describe PCO::API::Endpoint do
|
|
50
50
|
it 'returns the result of making a GET request to the endpoint' do
|
51
51
|
expect(@result).to be_a(Hash)
|
52
52
|
expect(@result['data']).to eq(result)
|
53
|
+
expect(@result.headers).to eq('Content-Type' => 'application/vnd.api+json')
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
@@ -76,6 +77,7 @@ describe PCO::API::Endpoint do
|
|
76
77
|
end
|
77
78
|
expect(error.status).to eq(404)
|
78
79
|
expect(error.message).to eq('Resource Not Found')
|
80
|
+
expect(error.headers).to eq('Content-Type' => 'application/vnd.api+json')
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
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: 1.
|
4
|
+
version: 1.3.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: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: excon
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.71.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.71.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ homepage: https://github.com/planningcenter/pco_api_ruby
|
|
114
114
|
licenses:
|
115
115
|
- MIT
|
116
116
|
metadata: {}
|
117
|
-
post_install_message:
|
117
|
+
post_install_message:
|
118
118
|
rdoc_options: []
|
119
119
|
require_paths:
|
120
120
|
- lib
|
@@ -129,9 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
|
133
|
-
|
134
|
-
signing_key:
|
132
|
+
rubygems_version: 3.0.3
|
133
|
+
signing_key:
|
135
134
|
specification_version: 4
|
136
135
|
summary: API wrapper for api.planningcenteronline.com
|
137
136
|
test_files:
|