fellowshipone 0.0.1 → 1.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: 822ce7ceb639df2c03e7ccf15689fd5aadd9b7df
4
- data.tar.gz: d7028edcff998f520f9a49b8f5bc7fc91b22ca41
3
+ metadata.gz: 25789b93d29e2e2ff020d0d59416f2fbdb4170ce
4
+ data.tar.gz: 611838d2c6c8012bc1347f225bd72a7fd8f23205
5
5
  SHA512:
6
- metadata.gz: 5b35f52dcc3084e68ab668b28601dd9d15b6a960d40da35327ccafdaf132f4cd1f76fd7f3758b039c16f3e14854fd9a0edcde509a4c5f6e814c80a4ca56dc5fe
7
- data.tar.gz: f9b7c0972077b9b1274ac33b2534d9c62040d7efbf47188fca5ec756d94f2740271eae25a98bc3dd414b5ba992fd4ec70acba5005d883361e5bdf6ddf073d9d2
6
+ metadata.gz: 62946546cdaf3b85f1dc0b09f2865ae1db64db0597ad6a5b41a39f2e91364654f78035bbaeb383d8bcdfbee889ee8375d122ea4aaa2c3f2855393278238c3433
7
+ data.tar.gz: 7db31d942950435790a4c7a93e4ef809a59402cca592be9948e45a20f0a1ab2bea13a0524026478b0960b7a15ab1b97e3f37a148e79cb30ab1567042ef81d808
@@ -0,0 +1 @@
1
+ fellowshipone-*.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fellowshipone (1.0.0)
5
+ faraday
6
+ faraday_middleware
7
+ json
8
+ simple_oauth
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ addressable (2.3.7)
14
+ crack (0.4.2)
15
+ safe_yaml (~> 1.0.0)
16
+ faraday (0.9.1)
17
+ multipart-post (>= 1.2, < 3)
18
+ faraday_middleware (0.9.1)
19
+ faraday (>= 0.7.4, < 0.10)
20
+ json (1.8.2)
21
+ minitest (5.5.1)
22
+ multipart-post (2.0.0)
23
+ rake (10.4.2)
24
+ safe_yaml (1.0.4)
25
+ simple_oauth (0.3.1)
26
+ vcr (2.9.3)
27
+ webmock (1.20.4)
28
+ addressable (>= 2.3.6)
29
+ crack (>= 0.3.2)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler
36
+ fellowshipone!
37
+ minitest
38
+ rake
39
+ vcr
40
+ webmock
@@ -0,0 +1,32 @@
1
+ # FellowshipOne API
2
+
3
+ A Ruby wrapper for the FellowshipOne API (https://developer.fellowshipone.com/)
4
+
5
+
6
+ ## Install / Setup
7
+
8
+ Installing the gem
9
+
10
+ gem install fellowshipone
11
+
12
+
13
+ To add it to your Gemfile
14
+
15
+ gem 'fellowshipone', require: 'fellowshipone'
16
+
17
+ ## Additional resources
18
+
19
+ * FellowshipOne API: https://developer.fellowshipone.com/docs/
20
+ * FellowshipOne Forum: https://developer.fellowshipone.com/forum/
21
+
22
+
23
+ ## License
24
+
25
+ This project is released under the MIT license (see LICENSE).
26
+
27
+ This project is maintained by Taylor Brooks (https://github.com/taylorbrooks).
28
+
29
+
30
+ ## Want to Contribute?
31
+
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.
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/**/*_test.rb"
6
+ end
7
+
8
+ task default: :test
@@ -0,0 +1,29 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'fellowshipone'
5
+ s.version = '1.0.0'
6
+ s.authors = ['Taylor Brooks']
7
+ s.email = ['tbrooks@gmail.com']
8
+ s.homepage = 'https://github.com/taylorbrooks/fellowshipone'
9
+
10
+ s.summary = 'Ruby gem/plugin to interact with the FellowshipOne API (https://developer.fellowshipone.com/).'
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
+ s.license = 'MIT'
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"
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 "json"
24
+
25
+ s.files = `git ls-files`.split("\n").delete_if { |f| !(f =~ /^examples/).nil? }
26
+ s.test_files = `git ls-files -- {test,features}/*`.split("\n")
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
+ s.require_paths = ["lib"]
29
+ end
@@ -0,0 +1 @@
1
+ require_relative 'fellowshipone/client.rb'
@@ -0,0 +1,79 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'simple_oauth'
4
+ require 'json'
5
+
6
+ Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
7
+
8
+ module Fellowshipone
9
+ class Client
10
+ include Fellowshipone::Client::Communication
11
+ include Fellowshipone::Client::Contribution
12
+ include Fellowshipone::Client::Fund
13
+ include Fellowshipone::Client::Household
14
+ include Fellowshipone::Client::Person
15
+
16
+ attr_reader :church_code, :consumer_key, :consumer_secret, :token, :secret
17
+
18
+ def initialize(church_code, consumer_key, consumer_secret, token, secret)
19
+ @church_code = church_code
20
+ @consumer_key = consumer_key
21
+ @consumer_secret = consumer_secret
22
+ @token = token
23
+ @secret = secret
24
+ end
25
+
26
+ def get(path, options={})
27
+ connection.get do |req|
28
+ req.url(path, options)
29
+ end.body
30
+ end
31
+
32
+ def post(path, req_body)
33
+ connection.post do |req|
34
+ req.url(path)
35
+ req.body = req_body
36
+ end.body
37
+ end
38
+
39
+ def put(url, options = {})
40
+ connection.put do |req|
41
+ req.url path
42
+ end.body
43
+ end
44
+
45
+ def delete(url, options = {})
46
+ connection.delete do |req|
47
+ req.url path
48
+ end.body
49
+ end
50
+
51
+ def save
52
+ connection.put do |req|
53
+ req.url path
54
+ end.body
55
+ end
56
+
57
+ private
58
+
59
+ def connection
60
+ Faraday.new(url: "https://#{church_code}.fellowshiponeapi.com", headers: { accept: 'application/json' }) do |connection|
61
+ connection.request :json
62
+ connection.request :oauth, oauth_data
63
+ connection.response :logger
64
+ connection.use FaradayMiddleware::Mashify
65
+ connection.response :json
66
+ connection.adapter Faraday.default_adapter
67
+ end
68
+ end
69
+
70
+ def oauth_data
71
+ {
72
+ consumer_key: consumer_key,
73
+ consumer_secret: consumer_secret,
74
+ token: token,
75
+ token_secret: secret
76
+ }
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,15 @@
1
+ module Fellowshipone
2
+ class Client
3
+ module Communication
4
+
5
+ def new_communication(person_id)
6
+ get("/v1/People/#{person_id}/Communications/new.json")
7
+ end
8
+
9
+ def create_communication(person_id, json_body)
10
+ post("/v1/People/#{person_id}/Communications.json", json_body)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Fellowshipone
2
+ class Client
3
+ module Contribution
4
+
5
+ def contributions
6
+
7
+ end
8
+
9
+ def get_contribution(id)
10
+ get("/giving/v1/contributionreceipts/#{id}.json")
11
+ end
12
+
13
+ def new_contribution
14
+ get("/giving/v1/contributionreceipts/new.json")
15
+ end
16
+
17
+ def create_contribution(contribution_params)
18
+ post("/giving/v1/contributionreceipts.json", contribution_params)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ module Fellowshipone
2
+ class Client
3
+ module Fund
4
+
5
+ def funds
6
+ get('/giving/v1/funds')
7
+ end
8
+
9
+ def fund(id)
10
+ get("/giving/v1/fund/#{id}.json")
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Fellowshipone
2
+ class Client
3
+ module Household
4
+
5
+ def new_household
6
+ get("/v1/Households/new.json")
7
+ end
8
+
9
+ def create_household(household_params)
10
+ post("/v1/Households.json", household_params)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module Fellowshipone
2
+ class Client
3
+ module Person
4
+
5
+ def list_people(attrs={})
6
+ get('/v1/People/Search.json', attrs)
7
+ end
8
+
9
+ def find_person(id)
10
+ get("/v1/People/#{id}")
11
+ end
12
+
13
+ def new_person
14
+ get("/v1/People/new.json")
15
+ end
16
+
17
+ def create_person(person_params)
18
+ post("/v1/People.json", person_params.to_json)
19
+ end
20
+
21
+ def search_for_person(name, email)
22
+ get("/v1/People/Search.json?searchfor=#{name}&communication=#{email}").results
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ require './test/test_helper'
2
+
3
+ class FellowshipOnePersonTest < Minitest::Test
4
+ def test_exists
5
+ assert FellowshipOne::Person
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require './lib/fellowship_one'
2
+ require 'minitest/autorun'
3
+ require 'webmock/minitest'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = "test/fixtures"
8
+ c.hook_into :webmock
9
+ end
@@ -0,0 +1,65 @@
1
+ token = ""
2
+ secret = ""
3
+ church_code = ""
4
+
5
+ @client ||= FellowshipOne::Client.new(token, secret, church_code)
6
+
7
+ find_or_create_fellowship_person
8
+ contribution = build_fellowship_contribution
9
+
10
+ @donation.refs = {"f1_id" => contribution.id}
11
+ raise
12
+ @donation.save
13
+
14
+ def find_or_create_fellowship_person
15
+ people = @client.search_for_person({name: "taylor", email: "tbrooks@gmail"})
16
+
17
+ if people.count == 0
18
+ @donor = build_fellowship_person
19
+ build_fellowship_email
20
+ else
21
+ @donor = people.first
22
+ end
23
+ end
24
+
25
+ def build_fellowship_person
26
+ household = @client.new_household
27
+ household.household_name = "Taylor Brooks"
28
+ @client.save_household(household)
29
+
30
+ donor = @client.new_person
31
+ donor.household_id = household.id.to_s
32
+ donor.id = ''
33
+ donor.household_member_type['@id'] = '1'
34
+ donor.status['@id'] = '6' # Contributor Only
35
+ donor.first_name = "Taylor"
36
+ donor.last_name = "Brooks"
37
+ @client.create_person(donor)
38
+ end
39
+
40
+ def build_fellowship_email
41
+ communication = @client.new_communication(@donor.id)
42
+ communication.communication_type['@id'] = '4'
43
+ communication.communication_type['name'] = 'Email'
44
+ communication.communication_general_type = 'Email'
45
+ communication.preferred = 'true'
46
+ communication.communication_value = @customer.email
47
+ communication.search_communication_value = @customer.email
48
+ @client.create_communicate(@donor.id, communication.id, communication)
49
+ end
50
+
51
+ def build_fellowship_contribution
52
+ contribution = @client.new_contribution
53
+ contribution.amount = @donation.gross_amount/100.00
54
+
55
+ contribution.fund['@id'] = @donation.fund.settings['fellowship_fund_id']
56
+
57
+ contribution.household['@id'] = @donor.household_id
58
+ contribution.received_date = @donation.created_at.iso8601 # Needs to be this format
59
+ contribution.contribution_type['@id'] = @donation.payment_type == 'bank account' ? 5 : 3 # 3 - Credit Card, 5 - ACH
60
+
61
+ contribution.memo = "Simple Donation - #{@donation.id}"
62
+
63
+ contribution.address_verification = false
64
+ @client.create_contribution(contribution)
65
+ end
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: 0.0.1
4
+ version: 1.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: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2015-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,7 +143,23 @@ email:
143
143
  executables: []
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
- files: []
146
+ files:
147
+ - .gitignore
148
+ - Gemfile
149
+ - Gemfile.lock
150
+ - README.md
151
+ - Rakefile
152
+ - fellowshipone.gemspec
153
+ - lib/fellowshipone.rb
154
+ - lib/fellowshipone/client.rb
155
+ - lib/fellowshipone/resources/communication.rb
156
+ - lib/fellowshipone/resources/contribution.rb
157
+ - lib/fellowshipone/resources/fund.rb
158
+ - lib/fellowshipone/resources/household.rb
159
+ - lib/fellowshipone/resources/person.rb
160
+ - test/person/person_test.rb
161
+ - test/test_helper.rb
162
+ - tester.rb
147
163
  homepage: https://github.com/taylorbrooks/fellowshipone
148
164
  licenses:
149
165
  - MIT
@@ -168,4 +184,6 @@ rubygems_version: 2.0.14
168
184
  signing_key:
169
185
  specification_version: 4
170
186
  summary: Ruby gem/plugin to interact with the FellowshipOne API (https://developer.fellowshipone.com/).
171
- test_files: []
187
+ test_files:
188
+ - test/person/person_test.rb
189
+ - test/test_helper.rb