fellowshipone 2.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 62cb24583d770d51d4bbcaa1da51bd4b3385d99a
4
- data.tar.gz: 0857cfb2ce47912d9459c0761c827d5e99245902
2
+ SHA256:
3
+ metadata.gz: c7b6892a399d21c72712f35fb4b780fc5f0a67375b53dfcb0ed212c6d826c72b
4
+ data.tar.gz: b9ce0b52ad3365cf93ad0e839fb6ff4b23de93a7365b4db0f4f346f69a3e7ff0
5
5
  SHA512:
6
- metadata.gz: a5aa25ee6e43cc373d013907147fd1644a2f29bf3075c9ae09d723235372977d7d4f98d9f49796862a9a2e88f7e9eb195ebed9e31627a01c684a261c2094663c
7
- data.tar.gz: a06e43e12c702a214e8fd7932f70cc991af8818eb1a30d4a9f42584d2bc8f9c3be7407e5f5999dfde10cc85889bbfb1b4637c006628c293abecf26c858434421
6
+ metadata.gz: f4fc4e55888f426e7cc6335f8cb3a73f47d6c992b8101b315f758b1efffc8505fa2ac9495316c9c58017d70e17d483eb7ccaf676a4c788b331f75aff29d314cc
7
+ data.tar.gz: 89638f38f54f34d29da9758a846a6f30de15c795c161a5665247f029ca5ba3a5b2ebc7f8609a5fe370df7f816b312403222f30314ef5442272fadba9adb6f883
data/Gemfile.lock CHANGED
@@ -1,29 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fellowshipone (1.3.0)
4
+ fellowshipone (2.3.0)
5
5
  addressable
6
6
  faraday
7
7
  faraday_middleware
8
8
  hashie
9
9
  json
10
+ oauth
10
11
  simple_oauth
11
12
 
12
13
  GEM
13
14
  remote: http://rubygems.org/
14
15
  specs:
15
- addressable (2.3.7)
16
+ addressable (2.8.0)
17
+ public_suffix (>= 2.0.2, < 5.0)
16
18
  crack (0.4.2)
17
19
  safe_yaml (~> 1.0.0)
18
- faraday (0.9.2)
20
+ faraday (1.0.1)
19
21
  multipart-post (>= 1.2, < 3)
20
- faraday_middleware (0.10.0)
21
- faraday (>= 0.7.4, < 0.10)
22
- hashie (3.4.3)
23
- json (1.8.3)
22
+ faraday_middleware (1.0.0)
23
+ faraday (~> 1.0)
24
+ hashie (4.1.0)
25
+ json (2.3.1)
24
26
  minitest (5.5.1)
25
- multipart-post (2.0.0)
26
- rake (10.4.2)
27
+ multipart-post (2.1.1)
28
+ oauth (0.5.6)
29
+ public_suffix (4.0.6)
30
+ rake (12.3.3)
27
31
  safe_yaml (1.0.4)
28
32
  simple_oauth (0.3.1)
29
33
  vcr (2.9.3)
@@ -43,4 +47,4 @@ DEPENDENCIES
43
47
  webmock
44
48
 
45
49
  BUNDLED WITH
46
- 1.10.6
50
+ 2.1.4
data/README.md CHANGED
@@ -12,7 +12,7 @@ Installing the gem
12
12
 
13
13
  To add it to your Gemfile
14
14
 
15
- gem 'fellowshipone', require: 'fellowshipone'
15
+ gem 'fellowshipone', '3.0.0'
16
16
 
17
17
  ## Additional resources
18
18
 
@@ -23,10 +23,9 @@ To add it to your Gemfile
23
23
  ## License
24
24
 
25
25
  This project is released under the MIT license (see LICENSE).
26
-
27
26
  This project is maintained by Taylor Brooks (https://github.com/taylorbrooks).
28
27
 
29
28
 
30
29
  ## Want to Contribute?
31
30
 
32
- If you would like to get involved in this project, then please fork the project. Make changes, add features, write some tests, and then send a pull request.
31
+ If you would like to get involved in this project, then please fork the project. Make changes, add features, write some tests, and then send a pull request.
@@ -1,8 +1,8 @@
1
- $:.push File.expand_path("../lib", __FILE__)
1
+ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'fellowshipone'
5
- s.version = '2.0.0'
5
+ s.version = '3.0.0'
6
6
  s.authors = ['Taylor Brooks']
7
7
  s.email = ['tbrooks@gmail.com']
8
8
  s.homepage = 'https://github.com/taylorbrooks/fellowshipone'
@@ -11,21 +11,22 @@ Gem::Specification.new do |s|
11
11
  s.description = 'Ruby gem/plugin to interact with the FellowshipOne API (https://developer.fellowshipone.com/). Checkout the project on github for more detail.'
12
12
  s.license = 'MIT'
13
13
 
14
- s.add_development_dependency "bundler"
15
- s.add_development_dependency "rake"
16
- s.add_development_dependency "minitest"
17
- s.add_development_dependency "vcr"
18
- s.add_development_dependency "webmock"
14
+ s.add_development_dependency 'bundler'
15
+ s.add_development_dependency 'minitest'
16
+ s.add_development_dependency 'rake'
17
+ s.add_development_dependency 'vcr'
18
+ s.add_development_dependency 'webmock'
19
19
 
20
- s.add_runtime_dependency "faraday"
21
- s.add_runtime_dependency "faraday_middleware"
22
- s.add_runtime_dependency "simple_oauth"
23
- s.add_runtime_dependency "hashie"
24
- s.add_runtime_dependency "json"
25
- s.add_runtime_dependency "addressable"
20
+ s.add_runtime_dependency 'addressable'
21
+ s.add_runtime_dependency 'faraday'
22
+ s.add_runtime_dependency 'faraday_middleware'
23
+ s.add_runtime_dependency 'hashie'
24
+ s.add_runtime_dependency 'json'
25
+ s.add_runtime_dependency 'oauth'
26
+ s.add_runtime_dependency 'simple_oauth'
26
27
 
27
28
  s.files = `git ls-files`.split("\n").delete_if { |f| !(f =~ /^examples/).nil? }
28
29
  s.test_files = `git ls-files -- {test,features}/*`.split("\n")
29
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
- s.require_paths = ["lib"]
30
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
31
+ s.require_paths = ['lib']
31
32
  end
@@ -26,36 +26,24 @@ module Fellowshipone
26
26
  @logger = logger
27
27
  end
28
28
 
29
- def get(path, options={})
30
- connection.get do |req|
31
- req.url(path, options)
32
- end.body
29
+ def get(path, options = {})
30
+ connection.get(path, options).body
33
31
  end
34
32
 
35
- def post(path, req_body)
36
- connection.post do |req|
37
- req.url(path)
38
- req.body = req_body
39
- end.body
33
+ def post(path, options = {})
34
+ connection.post(path, options).body
40
35
  end
41
36
 
42
- def put(path, req_body)
43
- connection.put do |req|
44
- req.url path
45
- req.body = req_body
46
- end
37
+ def put(path, options = {})
38
+ connection.put(path, options).body
47
39
  end
48
40
 
49
41
  def delete(path, options = {})
50
- connection.delete do |req|
51
- req.url path
52
- end.body
42
+ connection.delete(path, options).body
53
43
  end
54
44
 
55
45
  def save
56
- connection.put do |req|
57
- req.url path
58
- end.body
46
+ connection.put(path, {}).body
59
47
  end
60
48
 
61
49
  private
@@ -66,6 +54,7 @@ module Fellowshipone
66
54
  connection.request :oauth, oauth_data
67
55
  connection.response :logger if logger
68
56
  connection.use FaradayMiddleware::Mashify
57
+ connection.use FaradayMiddleware::FellowshiponeErrorHandler
69
58
  connection.response :json
70
59
  connection.adapter Faraday.default_adapter
71
60
  end
@@ -0,0 +1,18 @@
1
+ require 'oauth'
2
+
3
+ module Fellowshipone
4
+ class Connection
5
+ def self.connect(church_code:, consumer_key:, consumer_secret:, callback_url:)
6
+ consumer = OAuth::Consumer.new(
7
+ consumer_key,
8
+ consumer_secret,
9
+ site: "https://#{church_code}.fellowshiponeapi.com",
10
+ request_token_path: '/v1/Tokens/RequestToken',
11
+ authorize_path: '/v1/PortalUser/Login',
12
+ access_token_path: '/v1/Tokens/AccessToken'
13
+ )
14
+
15
+ consumer.get_request_token(oauth_callback: callback_url)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,44 @@
1
+ module Fellowshipone
2
+ class Error < StandardError; end
3
+ class BadRequest < Error; end
4
+ class Forbidden < Error; end
5
+ class GatewayTimeout < Error; end
6
+ class InternalServerError < Error; end
7
+ class NotFound < Error; end
8
+ class ServiceUnavailable < Error; end
9
+ class Unauthorized < Error; end
10
+ end
11
+
12
+ require 'faraday'
13
+ module FaradayMiddleware
14
+ class FellowshiponeErrorHandler < Faraday::Response::Middleware
15
+ ERROR_STATUSES = 400..600
16
+
17
+ def on_complete(env)
18
+ case env[:status]
19
+ when 400
20
+ raise Fellowshipone::BadRequest, error_message(env)
21
+ when 401
22
+ raise Fellowshipone::Unauthorized, error_message(env)
23
+ when 403
24
+ raise Fellowshipone::Forbidden, error_message(env)
25
+ when 404
26
+ raise Fellowshipone::NotFound, error_message(env)
27
+ when 500
28
+ raise Fellowshipone::InternalServerError, error_message(env)
29
+ when 503
30
+ raise Fellowshipone::ServiceUnavailable, error_message(env)
31
+ when 504
32
+ raise Fellowshipone::GatewayTimeout, error_message(env)
33
+ when ERROR_STATUSES
34
+ raise Fellowshipone::Error, error_message(env)
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def error_message(env)
41
+ "#{env[:status]}: #{env[:url]} #{env[:body]} #{env[:reason_phrase]}"
42
+ end
43
+ end
44
+ end
@@ -12,7 +12,8 @@ module Fellowshipone
12
12
  end
13
13
 
14
14
  def subfunds(fund_id)
15
- get("/giving/v1/funds/#{fund_id}/subfunds")
15
+ response = get("/giving/v1/funds/#{fund_id}/subfunds")
16
+ Fellowshipone::SubFund.format(response)
16
17
  end
17
18
 
18
19
  end
@@ -1,8 +1,7 @@
1
1
  module Fellowshipone
2
2
  class Contribution
3
-
4
3
  def self.format(res)
5
- response = res["contributionReceipt"]
4
+ response = res['contributionReceipt']
6
5
  if response.is_a?(Array)
7
6
  response.map{|contribution| format_contribution(contribution) }
8
7
  else
@@ -12,11 +11,12 @@ module Fellowshipone
12
11
 
13
12
  def self.format_contribution(contribution)
14
13
  OpenStruct.new(
15
- id: contribution["@id"],
16
- amount: contribution["amount"],
17
- fund: contribution["fund"]["name"],
18
- sub_fund: contribution["subFund"]["name"],
19
- date: contribution["receivedDate"]
14
+ id: contribution['@id'],
15
+ amount: contribution['amount'],
16
+ fund: contribution['fund']['name'],
17
+ sub_fund: contribution['subFund']['name'],
18
+ date: contribution['receivedDate'],
19
+ fund_type_id: contribution['fund']['fundTypeID']
20
20
  )
21
21
  end
22
22
  end
@@ -1,8 +1,7 @@
1
1
  module Fellowshipone
2
2
  class Fund
3
-
4
3
  def self.format(res)
5
- response = res["funds"]["fund"]
4
+ response = res['funds']['fund']
6
5
  if response.is_a?(Array)
7
6
  response.map{|fund| format_fund(fund) }
8
7
  else
@@ -0,0 +1,22 @@
1
+ module Fellowshipone
2
+ class SubFund
3
+ def self.format(res)
4
+ return nil if res['subFunds'].nil?
5
+
6
+ response = res['subFunds']['subFund']
7
+
8
+ if response.is_a?(Array)
9
+ response.map{|fund| format_fund(fund) }
10
+ else
11
+ format_fund(response)
12
+ end
13
+ end
14
+
15
+ def self.format_fund(fund)
16
+ OpenStruct.new(
17
+ id: fund['@id'],
18
+ name: fund['name'],
19
+ )
20
+ end
21
+ end
22
+ end
data/lib/fellowshipone.rb CHANGED
@@ -1 +1,3 @@
1
- require_relative 'fellowshipone/client.rb'
1
+ require_relative 'fellowshipone/client'
2
+ require_relative 'fellowshipone/connection'
3
+ require_relative 'fellowshipone/error'
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: 2.0.0
4
+ version: 3.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: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: faraday
84
+ name: addressable
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: faraday_middleware
98
+ name: faraday
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: simple_oauth
112
+ name: faraday_middleware
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -151,7 +151,21 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: addressable
154
+ name: oauth
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simple_oauth
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - ">="
@@ -180,6 +194,8 @@ files:
180
194
  - fellowshipone.gemspec
181
195
  - lib/fellowshipone.rb
182
196
  - lib/fellowshipone/client.rb
197
+ - lib/fellowshipone/connection.rb
198
+ - lib/fellowshipone/error.rb
183
199
  - lib/fellowshipone/resources/communication.rb
184
200
  - lib/fellowshipone/resources/contribution.rb
185
201
  - lib/fellowshipone/resources/fund.rb
@@ -188,6 +204,7 @@ files:
188
204
  - lib/fellowshipone/resources/pledge_drive.rb
189
205
  - lib/fellowshipone/responses/contribution.rb
190
206
  - lib/fellowshipone/responses/fund.rb
207
+ - lib/fellowshipone/responses/sub_fund.rb
191
208
  - test/person/person_test.rb
192
209
  - test/test_helper.rb
193
210
  - tester.rb
@@ -210,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
227
  - !ruby/object:Gem::Version
211
228
  version: '0'
212
229
  requirements: []
213
- rubyforge_project:
214
- rubygems_version: 2.4.8
230
+ rubygems_version: 3.1.6
215
231
  signing_key:
216
232
  specification_version: 4
217
233
  summary: Ruby gem/plugin to interact with the FellowshipOne API (https://developer.fellowshipone.com/).