church_community_builder 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +2 -0
- data/Rakefile +5 -3
- data/church_community_builder.gemspec +29 -25
- data/lib/church_community_builder.rb +3 -0
- data/lib/church_community_builder/client.rb +18 -21
- data/lib/church_community_builder/error.rb +19 -0
- data/lib/church_community_builder/resources/campus.rb +3 -3
- data/lib/church_community_builder/resources/contribution.rb +2 -2
- data/lib/church_community_builder/resources/fund.rb +3 -3
- data/lib/church_community_builder/resources/person.rb +7 -2
- data/lib/church_community_builder/response/campus.rb +6 -5
- data/lib/church_community_builder/response/contribution.rb +14 -13
- data/lib/church_community_builder/response/fund.rb +6 -4
- data/lib/church_community_builder/response/person.rb +14 -13
- data/test/test_helper.rb +1 -1
- metadata +8 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 401251c8b4bc9de5d2ae50bd6b472f1c568e4770655917ece1773e0ad3354b88
|
4
|
+
data.tar.gz: aae254e82e100a10110797a849399a0d05b681c60f76676a14e810a07fbbe9b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc6489dea6ce7ec3f60bd2fbed429dfe158d551b85e97d32223bb0320596cd491b98c086be0d0c3720845a50afd217859c70fdd1f2f9aa2ae10f6be05fe9f103
|
7
|
+
data.tar.gz: 180ab9d7e5e1ad9ff02feed638d90eeeb1cb8ff85044d5f1080ba678e29c25e818cd69b8db9a3beeb052057b4eefd7532c4de4622ac4f615154f0581ef884f58
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
3
5
|
|
4
6
|
Rake::TestTask.new do |t|
|
5
|
-
t.pattern =
|
7
|
+
t.pattern = 'test/**/*_test.rb'
|
6
8
|
end
|
7
9
|
|
8
10
|
task default: :test
|
@@ -1,30 +1,34 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$:.push File.expand_path('../lib', __FILE__)
|
4
|
+
require 'base64'
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
6
|
-
s.version
|
7
|
-
s.authors
|
8
|
-
s.email
|
9
|
-
s.homepage
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
s.name = 'church_community_builder'
|
8
|
+
s.version = '0.0.18'
|
9
|
+
s.authors = ['Taylor Brooks']
|
10
|
+
s.email = ['dGJyb29rc0BnbWFpbC5jb20='].map { |e| Base64.decode64(e) }
|
11
|
+
s.homepage = 'https://github.com/taylorbrooks/church_community_builder'
|
12
|
+
|
13
|
+
SUMMARY = 'Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).'
|
14
|
+
|
15
|
+
s.summary = SUMMARY
|
16
|
+
s.description = SUMMARY
|
13
17
|
s.license = 'MIT'
|
14
18
|
|
15
|
-
s.add_development_dependency
|
16
|
-
s.add_development_dependency
|
17
|
-
s.add_development_dependency
|
18
|
-
s.add_development_dependency
|
19
|
-
|
20
|
-
|
21
|
-
s.add_runtime_dependency
|
22
|
-
s.add_runtime_dependency
|
23
|
-
s.add_runtime_dependency
|
24
|
-
|
25
|
-
|
26
|
-
s.
|
27
|
-
s.
|
28
|
-
|
29
|
-
s.require_paths = [
|
19
|
+
s.add_development_dependency 'bundler'
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
s.add_development_dependency 'vcr'
|
22
|
+
s.add_development_dependency 'webmock'
|
23
|
+
|
24
|
+
s.add_runtime_dependency 'addressable'
|
25
|
+
s.add_runtime_dependency 'faraday'
|
26
|
+
s.add_runtime_dependency 'faraday_middleware'
|
27
|
+
s.add_runtime_dependency 'multi_xml'
|
28
|
+
|
29
|
+
s.files = `git ls-files`.split($/)
|
30
|
+
s.test_files = s.files.grep(%r{^(test)/})
|
31
|
+
s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
32
|
+
|
33
|
+
s.require_paths = ['lib']
|
30
34
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
2
|
-
require "faraday_middleware"
|
3
|
-
require "addressable/uri"
|
4
|
-
require "json"
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
|
7
|
-
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
|
+
require 'addressable/uri'
|
6
|
+
require 'json'
|
8
7
|
|
8
|
+
Dir[File.expand_path('../resources/*.rb', __FILE__)].each { |f| require f }
|
9
|
+
Dir[File.expand_path('../response/*.rb', __FILE__)].each { |f| require f }
|
9
10
|
|
10
11
|
module ChurchCommunityBuilder
|
11
12
|
class Client
|
@@ -22,29 +23,25 @@ module ChurchCommunityBuilder
|
|
22
23
|
@logger = logger
|
23
24
|
end
|
24
25
|
|
25
|
-
def get(path)
|
26
|
-
connection.get
|
27
|
-
req.url(path)
|
28
|
-
end.body
|
26
|
+
def get(path, options = {})
|
27
|
+
connection.get(path, options).body
|
29
28
|
end
|
30
29
|
|
31
|
-
def post(path,
|
32
|
-
connection.post
|
33
|
-
|
34
|
-
req.body = body if body
|
35
|
-
end.body
|
30
|
+
def post(path, options = {})
|
31
|
+
res = connection.post(path, options).body
|
32
|
+
res
|
36
33
|
end
|
37
34
|
|
38
35
|
private
|
39
36
|
|
40
37
|
def connection
|
41
|
-
Faraday.new(url: "https://#{subdomain}.ccbchurch.com/api.php") do |
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
Faraday.new(url: "https://#{subdomain}.ccbchurch.com/api.php") do |conn|
|
39
|
+
conn.basic_auth username, password
|
40
|
+
conn.response :logger if logger
|
41
|
+
conn.response :xml
|
42
|
+
conn.use FaradayMiddleware::ChurchCommunityBuilderErrorHandler
|
43
|
+
conn.adapter Faraday.default_adapter
|
46
44
|
end
|
47
45
|
end
|
48
|
-
|
49
46
|
end
|
50
47
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ChurchCommunityBuilder
|
4
|
+
class Error < StandardError; end
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'faraday'
|
8
|
+
module FaradayMiddleware
|
9
|
+
class ChurchCommunityBuilderErrorHandler < Faraday::Response::Middleware
|
10
|
+
ERROR_STATUSES = 400..600
|
11
|
+
|
12
|
+
def on_complete(env)
|
13
|
+
case env[:status]
|
14
|
+
when ERROR_STATUSES
|
15
|
+
raise ChurchCommunityBuilder::Error, "#{env[:status]} #{env[:body]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Client
|
3
5
|
module Campus
|
4
|
-
|
5
6
|
def list_campuses
|
6
|
-
response = get(
|
7
|
+
response = get('?srv=campus_list')
|
7
8
|
ChurchCommunityBuilder::Campus.new(response).parse
|
8
9
|
end
|
9
|
-
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Client
|
3
5
|
module Contribution
|
4
|
-
|
5
6
|
def create_contribution(contribution_params)
|
6
7
|
response = post("?srv=online_giving_insert_gift&#{Addressable::URI.form_encode(contribution_params)}", nil)
|
7
8
|
ChurchCommunityBuilder::Contribution.new(response).parse
|
@@ -11,7 +12,6 @@ module ChurchCommunityBuilder
|
|
11
12
|
response = get("?srv=transactions_by_family&family_id=#{family_id}")
|
12
13
|
ChurchCommunityBuilder::FamilyContributions.new(response).parse
|
13
14
|
end
|
14
|
-
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Client
|
3
5
|
module Fund
|
4
|
-
|
5
6
|
def list_funds
|
6
|
-
response = get(
|
7
|
+
response = get('?srv=transaction_detail_type_list')
|
7
8
|
ChurchCommunityBuilder::Fund.new(response).parse
|
8
9
|
end
|
9
|
-
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Client
|
3
5
|
module Person
|
4
|
-
|
5
6
|
def create_person(person_params)
|
6
|
-
response = post(
|
7
|
+
response = post('?srv=create_individual', Addressable::URI.form_encode(person_params))
|
7
8
|
ChurchCommunityBuilder::Person.new(response).parse
|
8
9
|
end
|
9
10
|
|
@@ -12,6 +13,10 @@ module ChurchCommunityBuilder
|
|
12
13
|
ChurchCommunityBuilder::Person.new(response).parse
|
13
14
|
end
|
14
15
|
|
16
|
+
def search_for_person_by_id(id)
|
17
|
+
response = get("?srv=individual_profile_from_id&individual_id=#{id}")
|
18
|
+
ChurchCommunityBuilder::Person.new(response).parse
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -1,20 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Campus
|
3
5
|
attr_reader :response, :campuses
|
4
6
|
|
5
7
|
def initialize(response)
|
6
|
-
@response = response[
|
7
|
-
@campuses = @response[
|
8
|
+
@response = response['ccb_api']['response']
|
9
|
+
@campuses = @response['campuses']['campus']
|
8
10
|
end
|
9
11
|
|
10
12
|
def parse
|
11
13
|
@campuses.map do |campus|
|
12
14
|
OpenStruct.new(
|
13
|
-
id: campus[
|
14
|
-
name: campus[
|
15
|
+
id: campus['id'],
|
16
|
+
name: campus['name']
|
15
17
|
)
|
16
18
|
end
|
17
19
|
end
|
18
|
-
|
19
20
|
end
|
20
21
|
end
|
@@ -1,38 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Contribution
|
3
5
|
attr_reader :response, :contribution
|
4
6
|
|
5
7
|
def initialize(response)
|
6
|
-
@response = response[
|
7
|
-
@contribution = @response[
|
8
|
+
@response = response['ccb_api']['response']
|
9
|
+
@contribution = @response['items']['item']
|
8
10
|
end
|
9
11
|
|
10
12
|
def parse
|
11
13
|
OpenStruct.new(
|
12
|
-
id: contribution[
|
13
|
-
amount: contribution[
|
14
|
+
id: contribution['gift_id'],
|
15
|
+
amount: contribution['amount']
|
14
16
|
)
|
15
17
|
end
|
16
|
-
|
17
18
|
end
|
18
19
|
|
19
20
|
class FamilyContributions
|
20
21
|
attr :transactions
|
21
22
|
|
22
23
|
def initialize(response)
|
23
|
-
@transactions = response[
|
24
|
+
@transactions = response['ccb_api']['response']['transactions']['transaction']
|
24
25
|
end
|
25
26
|
|
26
27
|
def parse
|
27
28
|
@transactions.map do |t|
|
28
29
|
OpenStruct.new(
|
29
|
-
id: t[
|
30
|
-
date: t[
|
31
|
-
amount: t[
|
32
|
-
fund: t[
|
33
|
-
note: t[
|
34
|
-
person: t[
|
35
|
-
person_id: t[
|
30
|
+
id: t['id'],
|
31
|
+
date: t['date'],
|
32
|
+
amount: t['transaction_details']['transaction_detail']['amount'],
|
33
|
+
fund: t['transaction_details']['transaction_detail']['coa']['__content__'],
|
34
|
+
note: t['transaction_details']['transaction_detail']['note'],
|
35
|
+
person: t['individual']['__content__'],
|
36
|
+
person_id: t['individual']['id']
|
36
37
|
)
|
37
38
|
end
|
38
39
|
end
|
@@ -1,17 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Fund
|
3
5
|
attr_reader :response, :funds
|
4
6
|
|
5
7
|
def initialize(response)
|
6
|
-
@response = response[
|
7
|
-
@funds = @response[
|
8
|
+
@response = response['ccb_api']['response']
|
9
|
+
@funds = @response['transaction_detail_types']['transaction_detail_type']
|
8
10
|
end
|
9
11
|
|
10
12
|
def parse
|
11
13
|
@funds.map do |fund|
|
12
14
|
OpenStruct.new(
|
13
|
-
id: fund[
|
14
|
-
name: fund[
|
15
|
+
id: fund['id'],
|
16
|
+
name: fund['name']
|
15
17
|
)
|
16
18
|
end
|
17
19
|
end
|
@@ -1,32 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ChurchCommunityBuilder
|
2
4
|
class Person
|
3
5
|
attr_reader :response, :people, :count
|
4
6
|
|
5
7
|
def initialize(response)
|
6
|
-
@response = response[
|
7
|
-
@people = @response[
|
8
|
-
@count = @people[
|
8
|
+
@response = response['ccb_api']['response']
|
9
|
+
@people = @response['individuals']
|
10
|
+
@count = @people['count'].to_i
|
9
11
|
end
|
10
12
|
|
11
13
|
def parse
|
12
|
-
return [] if count
|
14
|
+
return [] if count.zero? || people['individual'].nil?
|
13
15
|
|
14
|
-
if count == 1 || people[
|
15
|
-
[hydrate(people[
|
16
|
+
if count == 1 || people['individual'].is_a?(Hash)
|
17
|
+
[hydrate(people['individual'])]
|
16
18
|
else
|
17
|
-
people[
|
19
|
+
people['individual'].map { |p| hydrate(p) }
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
def hydrate(person)
|
22
24
|
OpenStruct.new(
|
23
|
-
id: person[
|
24
|
-
family_id: person[
|
25
|
-
first_name: person[
|
26
|
-
last_name: person[
|
27
|
-
email: person[
|
25
|
+
id: person['id'],
|
26
|
+
family_id: person['family']['id'],
|
27
|
+
first_name: person['first_name'],
|
28
|
+
last_name: person['last_name'],
|
29
|
+
email: person['email']
|
28
30
|
)
|
29
31
|
end
|
30
|
-
|
31
32
|
end
|
32
33
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: church_community_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Brooks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: vcr
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: addressable
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
@@ -95,7 +81,7 @@ dependencies:
|
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: faraday
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ">="
|
@@ -109,7 +95,7 @@ dependencies:
|
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: faraday_middleware
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
@@ -123,7 +109,7 @@ dependencies:
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: multi_xml
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - ">="
|
@@ -137,7 +123,6 @@ dependencies:
|
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '0'
|
139
125
|
description: Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).
|
140
|
-
Checkout the project on github for more detail.
|
141
126
|
email:
|
142
127
|
- tbrooks@gmail.com
|
143
128
|
executables: []
|
@@ -152,6 +137,7 @@ files:
|
|
152
137
|
- church_community_builder.gemspec
|
153
138
|
- lib/church_community_builder.rb
|
154
139
|
- lib/church_community_builder/client.rb
|
140
|
+
- lib/church_community_builder/error.rb
|
155
141
|
- lib/church_community_builder/resources/campus.rb
|
156
142
|
- lib/church_community_builder/resources/contribution.rb
|
157
143
|
- lib/church_community_builder/resources/fund.rb
|
@@ -181,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
167
|
- !ruby/object:Gem::Version
|
182
168
|
version: '0'
|
183
169
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.6.8
|
170
|
+
rubygems_version: 3.0.3
|
186
171
|
signing_key:
|
187
172
|
specification_version: 4
|
188
173
|
summary: Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).
|