fellowshipone 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7b6892a399d21c72712f35fb4b780fc5f0a67375b53dfcb0ed212c6d826c72b
4
- data.tar.gz: b9ce0b52ad3365cf93ad0e839fb6ff4b23de93a7365b4db0f4f346f69a3e7ff0
3
+ metadata.gz: f65041c1559c6071155f13215045388bbe76cdcfd7927dbbef72a5e0d13d8861
4
+ data.tar.gz: 61e05bc05fb89f7e99f118c6ff44f62b7bc02c48e5bfc31cbd250e6822703f71
5
5
  SHA512:
6
- metadata.gz: f4fc4e55888f426e7cc6335f8cb3a73f47d6c992b8101b315f758b1efffc8505fa2ac9495316c9c58017d70e17d483eb7ccaf676a4c788b331f75aff29d314cc
7
- data.tar.gz: 89638f38f54f34d29da9758a846a6f30de15c795c161a5665247f029ca5ba3a5b2ebc7f8609a5fe370df7f816b312403222f30314ef5442272fadba9adb6f883
6
+ metadata.gz: 4ef3eb05566a9adecc665d0a5b70eb7b2d75146eef3bb3a0c8c742a75de6ce61c8b7b26a735969782f45d8e03c8bdfe019b288d0ea2f10f576d36395def17a4d
7
+ data.tar.gz: ee2769693fbfce6c467806fb60bb94c33db3b1d1fa60976a150d02732587257e8a84edc951d0582e13569e3ba4290338c541a1c1a2b3e7496eed312b7d048d2a
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  fellowshipone-*.gem
2
+ Gemfile.lock
@@ -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 = '3.0.0'
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
@@ -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.request :oauth, oauth_data
53
+ connection.use FaradayMiddleware::BingbongOAuth, oauth_data
55
54
  connection.response :logger if logger
56
- connection.use FaradayMiddleware::Mashify
55
+ connection.use FaradayMiddleware::BingbongHash
57
56
  connection.use FaradayMiddleware::FellowshiponeErrorHandler
58
57
  connection.response :json
59
58
  connection.adapter Faraday.default_adapter
@@ -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::Response::Middleware
13
+ class FellowshiponeErrorHandler < Faraday::Middleware
15
14
  ERROR_STATUSES = 400..600
16
15
 
17
16
  def on_complete(env)
@@ -1,3 +1,5 @@
1
+ require 'addressable/uri'
2
+
1
3
  module Fellowshipone
2
4
  class Client
3
5
  module Person
data/lib/fellowshipone.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  require_relative 'fellowshipone/client'
2
2
  require_relative 'fellowshipone/connection'
3
3
  require_relative 'fellowshipone/error'
4
+ require_relative 'fellowshipone/bingbong_oauth'
5
+ require_relative 'fellowshipone/bingbong_hash'
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: 3.0.0
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: 2022-02-01 00:00:00.000000000 Z
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
@@ -188,11 +174,12 @@ extra_rdoc_files: []
188
174
  files:
189
175
  - ".gitignore"
190
176
  - Gemfile
191
- - Gemfile.lock
192
177
  - README.md
193
178
  - Rakefile
194
179
  - fellowshipone.gemspec
195
180
  - lib/fellowshipone.rb
181
+ - lib/fellowshipone/bingbong_hash.rb
182
+ - lib/fellowshipone/bingbong_oauth.rb
196
183
  - lib/fellowshipone/client.rb
197
184
  - lib/fellowshipone/connection.rb
198
185
  - lib/fellowshipone/error.rb
data/Gemfile.lock DELETED
@@ -1,50 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- fellowshipone (2.3.0)
5
- addressable
6
- faraday
7
- faraday_middleware
8
- hashie
9
- json
10
- oauth
11
- simple_oauth
12
-
13
- GEM
14
- remote: http://rubygems.org/
15
- specs:
16
- addressable (2.8.0)
17
- public_suffix (>= 2.0.2, < 5.0)
18
- crack (0.4.2)
19
- safe_yaml (~> 1.0.0)
20
- faraday (1.0.1)
21
- multipart-post (>= 1.2, < 3)
22
- faraday_middleware (1.0.0)
23
- faraday (~> 1.0)
24
- hashie (4.1.0)
25
- json (2.3.1)
26
- minitest (5.5.1)
27
- multipart-post (2.1.1)
28
- oauth (0.5.6)
29
- public_suffix (4.0.6)
30
- rake (12.3.3)
31
- safe_yaml (1.0.4)
32
- simple_oauth (0.3.1)
33
- vcr (2.9.3)
34
- webmock (1.20.4)
35
- addressable (>= 2.3.6)
36
- crack (>= 0.3.2)
37
-
38
- PLATFORMS
39
- ruby
40
-
41
- DEPENDENCIES
42
- bundler
43
- fellowshipone!
44
- minitest
45
- rake
46
- vcr
47
- webmock
48
-
49
- BUNDLED WITH
50
- 2.1.4