church_community_builder 0.0.16 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/Rakefile +5 -3
- data/church_community_builder.gemspec +29 -25
- 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/lib/church_community_builder.rb +3 -0
- data/test/test_helper.rb +1 -1
- metadata +8 -24
- data/Gemfile.lock +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e573525f18e1ba8736878d42c25d4c2e7ea42f6b25758441bc9a583bf09c38ad
|
4
|
+
data.tar.gz: 55519ee1be6a6c5e7e891cff02d20bd184a6cf1666c3182b1819dafceac09b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '085e1724dbb24a3ac217eb52ecafd95e8fd2bf3c29ff7f441342e8fb8b166fd10fd66d4ef8918b4f7f6923c6ae82fdbb380b25e69f323ffe5aae921896895139'
|
7
|
+
data.tar.gz: ea04892b8e5d6693e3b5ca7aa36c634e09bfdb4a72b5db635a60782a9742ac7ed723b8501d2a244f2f4c734aa5d3669d9c95f7017288c7c1645b530f088475cd
|
data/.gitignore
CHANGED
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.19'
|
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.19
|
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: 2022-08-05 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: []
|
@@ -146,12 +131,12 @@ extra_rdoc_files: []
|
|
146
131
|
files:
|
147
132
|
- ".gitignore"
|
148
133
|
- Gemfile
|
149
|
-
- Gemfile.lock
|
150
134
|
- README.md
|
151
135
|
- Rakefile
|
152
136
|
- church_community_builder.gemspec
|
153
137
|
- lib/church_community_builder.rb
|
154
138
|
- lib/church_community_builder/client.rb
|
139
|
+
- lib/church_community_builder/error.rb
|
155
140
|
- lib/church_community_builder/resources/campus.rb
|
156
141
|
- lib/church_community_builder/resources/contribution.rb
|
157
142
|
- lib/church_community_builder/resources/fund.rb
|
@@ -181,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
166
|
- !ruby/object:Gem::Version
|
182
167
|
version: '0'
|
183
168
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.4.8
|
169
|
+
rubygems_version: 3.1.6
|
186
170
|
signing_key:
|
187
171
|
specification_version: 4
|
188
172
|
summary: Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).
|
data/Gemfile.lock
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
church_community_builder (0.0.7)
|
5
|
-
addressable
|
6
|
-
faraday
|
7
|
-
faraday_middleware
|
8
|
-
multi_xml
|
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.2)
|
17
|
-
multipart-post (>= 1.2, < 3)
|
18
|
-
faraday_middleware (0.10.0)
|
19
|
-
faraday (>= 0.7.4, < 0.10)
|
20
|
-
minitest (5.5.1)
|
21
|
-
multi_xml (0.5.5)
|
22
|
-
multipart-post (2.0.0)
|
23
|
-
rake (10.4.2)
|
24
|
-
safe_yaml (1.0.4)
|
25
|
-
vcr (2.9.3)
|
26
|
-
webmock (1.20.4)
|
27
|
-
addressable (>= 2.3.6)
|
28
|
-
crack (>= 0.3.2)
|
29
|
-
|
30
|
-
PLATFORMS
|
31
|
-
ruby
|
32
|
-
|
33
|
-
DEPENDENCIES
|
34
|
-
bundler
|
35
|
-
church_community_builder!
|
36
|
-
minitest
|
37
|
-
rake
|
38
|
-
vcr
|
39
|
-
webmock
|
40
|
-
|
41
|
-
BUNDLED WITH
|
42
|
-
1.10.6
|