fellowshipone 1.3.4 → 2.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
  SHA1:
3
- metadata.gz: 7b7cb75f07e493516ff3716e6dd4725340869957
4
- data.tar.gz: 5e12892e3050d5eb3fe4faa667ccd9a23a633031
3
+ metadata.gz: 62cb24583d770d51d4bbcaa1da51bd4b3385d99a
4
+ data.tar.gz: 0857cfb2ce47912d9459c0761c827d5e99245902
5
5
  SHA512:
6
- metadata.gz: 397d4e6af0184f3cc8032025b3f0334b4fc8b3791c83b28ad9e814f70a7161506bc84be4504cdab15387f428cfa635f163dd8f2b8472f3f787585d426f323c01
7
- data.tar.gz: c4865b3ba9cbf3c695c9932b40feb55278a8ff8a5ba9dc88f51f2b9956c02aedb51c213a6d801c31fd90780a61c574039723170d91b8ce3cbbf5d5dced344fea
6
+ metadata.gz: a5aa25ee6e43cc373d013907147fd1644a2f29bf3075c9ae09d723235372977d7d4f98d9f49796862a9a2e88f7e9eb195ebed9e31627a01c684a261c2094663c
7
+ data.tar.gz: a06e43e12c702a214e8fd7932f70cc991af8818eb1a30d4a9f42584d2bc8f9c3be7407e5f5999dfde10cc85889bbfb1b4637c006628c293abecf26c858434421
@@ -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 = '1.3.4'
5
+ s.version = '2.0.0'
6
6
  s.authors = ['Taylor Brooks']
7
7
  s.email = ['tbrooks@gmail.com']
8
8
  s.homepage = 'https://github.com/taylorbrooks/fellowshipone'
@@ -4,6 +4,7 @@ require 'simple_oauth'
4
4
  require 'json'
5
5
 
6
6
  Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
7
+ Dir[File.expand_path('../responses/*.rb', __FILE__)].each{|f| require f}
7
8
 
8
9
  module Fellowshipone
9
10
  class Client
@@ -16,7 +17,7 @@ module Fellowshipone
16
17
 
17
18
  attr_reader :church_code, :consumer_key, :consumer_secret, :token, :secret, :logger
18
19
 
19
- def initialize(church_code, consumer_key, consumer_secret, token, secret, logger = false)
20
+ def initialize(church_code:, consumer_key:, consumer_secret:, token:, secret:, logger: false)
20
21
  @church_code = church_code
21
22
  @consumer_key = consumer_key
22
23
  @consumer_secret = consumer_secret
@@ -28,7 +28,8 @@ module Fellowshipone
28
28
  options.merge!(endReceivedDate: end_date) if end_date
29
29
 
30
30
  params = Addressable::URI.form_encode(options)
31
- get("/giving/v1/contributionreceipts/search.json?#{params}").results
31
+ response = get("/giving/v1/contributionreceipts/search.json?#{params}").results
32
+ Fellowshipone::Contribution.format(response)
32
33
  end
33
34
 
34
35
  end
@@ -3,7 +3,8 @@ module Fellowshipone
3
3
  module Fund
4
4
 
5
5
  def funds
6
- get('/giving/v1/funds')
6
+ response = get('/giving/v1/funds')
7
+ Fellowshipone::Fund.format(response)
7
8
  end
8
9
 
9
10
  def fund(id)
@@ -0,0 +1,23 @@
1
+ module Fellowshipone
2
+ class Contribution
3
+
4
+ def self.format(res)
5
+ response = res["contributionReceipt"]
6
+ if response.is_a?(Array)
7
+ response.map{|contribution| format_contribution(contribution) }
8
+ else
9
+ format_contribution(response)
10
+ end
11
+ end
12
+
13
+ def self.format_contribution(contribution)
14
+ 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"]
20
+ )
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module Fellowshipone
2
+ class Fund
3
+
4
+ def self.format(res)
5
+ response = res["funds"]["fund"]
6
+ if response.is_a?(Array)
7
+ response.map{|fund| format_fund(fund) }
8
+ else
9
+ format_fund(response)
10
+ end
11
+ end
12
+
13
+ def self.format_fund(fund)
14
+ OpenStruct.new(
15
+ id: fund["@id"],
16
+ name: fund["name"],
17
+ )
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fellowshipone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
@@ -186,6 +186,8 @@ files:
186
186
  - lib/fellowshipone/resources/household.rb
187
187
  - lib/fellowshipone/resources/person.rb
188
188
  - lib/fellowshipone/resources/pledge_drive.rb
189
+ - lib/fellowshipone/responses/contribution.rb
190
+ - lib/fellowshipone/responses/fund.rb
189
191
  - test/person/person_test.rb
190
192
  - test/test_helper.rb
191
193
  - tester.rb
@@ -209,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
211
  version: '0'
210
212
  requirements: []
211
213
  rubyforge_project:
212
- rubygems_version: 2.5.1
214
+ rubygems_version: 2.4.8
213
215
  signing_key:
214
216
  specification_version: 4
215
217
  summary: Ruby gem/plugin to interact with the FellowshipOne API (https://developer.fellowshipone.com/).