fellowshipone 3.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fellowshipone.gemspec +1 -2
- data/lib/fellowshipone/bingbong_hash.rb +22 -0
- data/lib/fellowshipone/bingbong_oauth.rb +66 -0
- data/lib/fellowshipone/client.rb +2 -3
- data/lib/fellowshipone/error.rb +1 -2
- data/lib/fellowshipone/resources/person.rb +2 -0
- data/lib/fellowshipone.rb +2 -0
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f65041c1559c6071155f13215045388bbe76cdcfd7927dbbef72a5e0d13d8861
|
4
|
+
data.tar.gz: 61e05bc05fb89f7e99f118c6ff44f62b7bc02c48e5bfc31cbd250e6822703f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ef3eb05566a9adecc665d0a5b70eb7b2d75146eef3bb3a0c8c742a75de6ce61c8b7b26a735969782f45d8e03c8bdfe019b288d0ea2f10f576d36395def17a4d
|
7
|
+
data.tar.gz: ee2769693fbfce6c467806fb60bb94c33db3b1d1fa60976a150d02732587257e8a84edc951d0582e13569e3ba4290338c541a1c1a2b3e7496eed312b7d048d2a
|
data/fellowshipone.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'fellowshipone'
|
5
|
-
s.version = '
|
5
|
+
s.version = '4.0.0'
|
6
6
|
s.authors = ['Taylor Brooks']
|
7
7
|
s.email = ['tbrooks@gmail.com']
|
8
8
|
s.homepage = 'https://github.com/taylorbrooks/fellowshipone'
|
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_runtime_dependency 'addressable'
|
21
21
|
s.add_runtime_dependency 'faraday'
|
22
|
-
s.add_runtime_dependency 'faraday_middleware'
|
23
22
|
s.add_runtime_dependency 'hashie'
|
24
23
|
s.add_runtime_dependency 'json'
|
25
24
|
s.add_runtime_dependency 'oauth'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
3
|
+
module FaradayMiddleware
|
4
|
+
class BingbongHash < Faraday::Middleware
|
5
|
+
def on_complete(env)
|
6
|
+
env[:body] = parse(env[:body])
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def parse(body)
|
12
|
+
case body
|
13
|
+
when Hash
|
14
|
+
::Hashie::Mash.new(body)
|
15
|
+
when Array
|
16
|
+
body.map { |item| parse(item) }
|
17
|
+
else
|
18
|
+
body
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'simple_oauth'
|
2
|
+
|
3
|
+
module FaradayMiddleware
|
4
|
+
class BingbongOAuth < Faraday::Middleware
|
5
|
+
AUTH_HEADER = 'Authorization'
|
6
|
+
CONTENT_TYPE = 'Content-Type'
|
7
|
+
TYPE_URLENCODED = 'application/x-www-form-urlencoded'
|
8
|
+
|
9
|
+
extend Forwardable
|
10
|
+
def_delegator :'Faraday::Utils', :parse_nested_query
|
11
|
+
|
12
|
+
def initialize(app, options)
|
13
|
+
super(app)
|
14
|
+
@options = options
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
env[:request_headers][AUTH_HEADER] ||= oauth_header(env).to_s if sign_request?(env)
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
|
22
|
+
def oauth_header(env)
|
23
|
+
SimpleOAuth::Header.new(
|
24
|
+
env[:method],
|
25
|
+
env[:url].to_s,
|
26
|
+
signature_params(body_params(env)),
|
27
|
+
oauth_options(env)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def sign_request?(env)
|
32
|
+
!!env[:request].fetch(:oauth, true)
|
33
|
+
end
|
34
|
+
|
35
|
+
def oauth_options(env)
|
36
|
+
if (extra = env[:request][:oauth]) && extra.is_a?(Hash) && !extra.empty?
|
37
|
+
@options.merge extra
|
38
|
+
else
|
39
|
+
@options
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def body_params(env)
|
44
|
+
if include_body_params?(env)
|
45
|
+
if env[:body].respond_to?(:to_str)
|
46
|
+
parse_nested_query env[:body]
|
47
|
+
else
|
48
|
+
env[:body]
|
49
|
+
end
|
50
|
+
end || {}
|
51
|
+
end
|
52
|
+
|
53
|
+
def include_body_params?(env)
|
54
|
+
# see RFC 5849, section 3.4.1.3.1 for details
|
55
|
+
!(type = env[:request_headers][CONTENT_TYPE]) || (type == TYPE_URLENCODED)
|
56
|
+
end
|
57
|
+
|
58
|
+
def signature_params(params)
|
59
|
+
if params.empty?
|
60
|
+
params
|
61
|
+
else
|
62
|
+
params.reject { |_k, v| v.respond_to?(:content_type) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/fellowshipone/client.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
2
|
require 'simple_oauth'
|
4
3
|
require 'json'
|
5
4
|
|
@@ -51,9 +50,9 @@ module Fellowshipone
|
|
51
50
|
def connection
|
52
51
|
Faraday.new(url: "https://#{church_code}.fellowshiponeapi.com", headers: { accept: 'application/json' }) do |connection|
|
53
52
|
connection.request :json
|
54
|
-
connection.
|
53
|
+
connection.use FaradayMiddleware::BingbongOAuth, oauth_data
|
55
54
|
connection.response :logger if logger
|
56
|
-
connection.use FaradayMiddleware::
|
55
|
+
connection.use FaradayMiddleware::BingbongHash
|
57
56
|
connection.use FaradayMiddleware::FellowshiponeErrorHandler
|
58
57
|
connection.response :json
|
59
58
|
connection.adapter Faraday.default_adapter
|
data/lib/fellowshipone/error.rb
CHANGED
@@ -9,9 +9,8 @@ module Fellowshipone
|
|
9
9
|
class Unauthorized < Error; end
|
10
10
|
end
|
11
11
|
|
12
|
-
require 'faraday'
|
13
12
|
module FaradayMiddleware
|
14
|
-
class FellowshiponeErrorHandler < Faraday::
|
13
|
+
class FellowshiponeErrorHandler < Faraday::Middleware
|
15
14
|
ERROR_STATUSES = 400..600
|
16
15
|
|
17
16
|
def on_complete(env)
|
data/lib/fellowshipone.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fellowshipone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Brooks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: faraday_middleware
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: hashie
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +178,8 @@ files:
|
|
192
178
|
- Rakefile
|
193
179
|
- fellowshipone.gemspec
|
194
180
|
- lib/fellowshipone.rb
|
181
|
+
- lib/fellowshipone/bingbong_hash.rb
|
182
|
+
- lib/fellowshipone/bingbong_oauth.rb
|
195
183
|
- lib/fellowshipone/client.rb
|
196
184
|
- lib/fellowshipone/connection.rb
|
197
185
|
- lib/fellowshipone/error.rb
|