fellowshipone 2.2.0 → 3.0.1

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
- SHA1:
3
- metadata.gz: f4e11ab742f6434a9fdbad47eb2ad76ff6a541d7
4
- data.tar.gz: 0ea42375b6bdadc9d1a33eeca8dd4d9bad9ef928
2
+ SHA256:
3
+ metadata.gz: c69eb8b606e665f01ab90b205c6051253817de2458b848deb38ff1c28de75073
4
+ data.tar.gz: 1184d6a8f2d5ccf3710f5f13940e77ef16c3c45fd1f1a79e86f174c32596e7e2
5
5
  SHA512:
6
- metadata.gz: '08e01e74f88a62afacd80d646293e0dfbb626a16f106fec26d00de022fda3bd2ec60daebc39182df420dfd2beac87276d26ca5f22ad4c130dd2c9c50973fd214'
7
- data.tar.gz: fd72fbf2ef5a1535486de53b524c8805e24898d09e104582325b2b22f5ad34add06312855597601dcfdda4f5a7e0f87af112f7822aa96782899e32372d160a6f
6
+ metadata.gz: a33038de82fbcb6cfa4f6ed9b46ab54ce4b0c2225469edb8f9b8b0f30641ea6af55ef7b1dc3d977212662186fab8fe82e4d175c75d3034cddade9d91a509d7cf
7
+ data.tar.gz: b796f9e3cec78268eba4fc86c2be47361b5cfff62ccbd4862235b0f5cfe88e61ddfbc34e4d857ae058911d1ccdb4a703e7048db9867a318ecb5d13e17ab342f8
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  fellowshipone-*.gem
2
+ Gemfile.lock
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.
@@ -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 = '2.2.0'
5
+ s.version = '3.0.1'
6
6
  s.authors = ['Taylor Brooks']
7
7
  s.email = ['tbrooks@gmail.com']
8
8
  s.homepage = 'https://github.com/taylorbrooks/fellowshipone'
@@ -54,6 +54,7 @@ module Fellowshipone
54
54
  connection.request :oauth, oauth_data
55
55
  connection.response :logger if logger
56
56
  connection.use FaradayMiddleware::Mashify
57
+ connection.use FaradayMiddleware::FellowshiponeErrorHandler
57
58
  connection.response :json
58
59
  connection.adapter Faraday.default_adapter
59
60
  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
@@ -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
data/lib/fellowshipone.rb CHANGED
@@ -1,2 +1,3 @@
1
- require_relative 'fellowshipone/client.rb'
2
- require_relative 'fellowshipone/connection.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.2.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-07 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -188,13 +188,13 @@ extra_rdoc_files: []
188
188
  files:
189
189
  - ".gitignore"
190
190
  - Gemfile
191
- - Gemfile.lock
192
191
  - README.md
193
192
  - Rakefile
194
193
  - fellowshipone.gemspec
195
194
  - lib/fellowshipone.rb
196
195
  - lib/fellowshipone/client.rb
197
196
  - lib/fellowshipone/connection.rb
197
+ - lib/fellowshipone/error.rb
198
198
  - lib/fellowshipone/resources/communication.rb
199
199
  - lib/fellowshipone/resources/contribution.rb
200
200
  - lib/fellowshipone/resources/fund.rb
@@ -226,8 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  - !ruby/object:Gem::Version
227
227
  version: '0'
228
228
  requirements: []
229
- rubyforge_project:
230
- rubygems_version: 2.6.13
229
+ rubygems_version: 3.1.6
231
230
  signing_key:
232
231
  specification_version: 4
233
232
  summary: Ruby gem/plugin to interact with the FellowshipOne API (https://developer.fellowshipone.com/).
data/Gemfile.lock DELETED
@@ -1,46 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- fellowshipone (1.3.0)
5
- addressable
6
- faraday
7
- faraday_middleware
8
- hashie
9
- json
10
- simple_oauth
11
-
12
- GEM
13
- remote: http://rubygems.org/
14
- specs:
15
- addressable (2.3.7)
16
- crack (0.4.2)
17
- safe_yaml (~> 1.0.0)
18
- faraday (0.9.2)
19
- 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)
24
- minitest (5.5.1)
25
- multipart-post (2.0.0)
26
- rake (10.4.2)
27
- safe_yaml (1.0.4)
28
- simple_oauth (0.3.1)
29
- vcr (2.9.3)
30
- webmock (1.20.4)
31
- addressable (>= 2.3.6)
32
- crack (>= 0.3.2)
33
-
34
- PLATFORMS
35
- ruby
36
-
37
- DEPENDENCIES
38
- bundler
39
- fellowshipone!
40
- minitest
41
- rake
42
- vcr
43
- webmock
44
-
45
- BUNDLED WITH
46
- 1.10.6