church_community_builder 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +40 -0
- data/README.md +27 -0
- data/Rakefile +8 -0
- data/church_commmunity_builder.gemspec +31 -0
- data/lib/church_community_builder/client.rb +73 -0
- data/lib/church_community_builder/resources/contribution.rb +12 -0
- data/lib/church_community_builder/resources/person.rb +17 -0
- data/lib/church_community_builder/response/contribution.rb +16 -0
- data/lib/church_community_builder/response/person.rb +29 -0
- data/lib/church_community_builder.rb +1 -0
- data/test/person/person_test.rb +7 -0
- data/test/test_helper.rb +9 -0
- metadata +201 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 488cdc4117133a348475fb269f13e5e401d8d259
|
|
4
|
+
data.tar.gz: 06be55fbedc587942cb928028dd11b984de3db3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0f84479c3a181e04b4d7c759570e623970e46fcd88913affc9bb00c20d48612cd2179008b91ebb11586e6c3aa54287aa4c6a0a7dabebb1c8bc2c2b14328bc855
|
|
7
|
+
data.tar.gz: 986e3ef6133d5804bcb80f75cb61e29937e74b71ba8e99b764f423a420083d96f686c96650573e229c952db286c0aa46093968355d26897186450f5c4943501e
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fellowshipone-*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -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
|
data/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Church Community Builder API
|
|
2
|
+
|
|
3
|
+
A Ruby wrapper for the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Install / Setup
|
|
7
|
+
|
|
8
|
+
Installing the gem
|
|
9
|
+
|
|
10
|
+
gem install church_community_builder
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
To add it to your Gemfile
|
|
14
|
+
|
|
15
|
+
gem 'church_community_builder', require: 'church_community_builder'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
This project is released under the MIT license (see LICENSE).
|
|
21
|
+
|
|
22
|
+
This project is maintained by Taylor Brooks (https://github.com/taylorbrooks).
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Want to Contribute?
|
|
26
|
+
|
|
27
|
+
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.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
require "base64"
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "church_community_builder"
|
|
6
|
+
s.version = "0.0.1"
|
|
7
|
+
s.authors = ['Taylor Brooks']
|
|
8
|
+
s.email = ["dGJyb29rc0BnbWFpbC5jb20="].map{ |e| Base64.decode64(e) }
|
|
9
|
+
s.homepage = "https://github.com/taylorbrooks/church_community_builder"
|
|
10
|
+
|
|
11
|
+
s.summary = 'Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).'
|
|
12
|
+
s.description = 'Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation). Checkout the project on github for more detail.'
|
|
13
|
+
s.license = 'MIT'
|
|
14
|
+
|
|
15
|
+
s.add_development_dependency "bundler"
|
|
16
|
+
s.add_development_dependency "rake"
|
|
17
|
+
s.add_development_dependency "minitest"
|
|
18
|
+
s.add_development_dependency "vcr"
|
|
19
|
+
s.add_development_dependency "webmock"
|
|
20
|
+
|
|
21
|
+
s.add_runtime_dependency "faraday"
|
|
22
|
+
s.add_runtime_dependency "faraday_middleware"
|
|
23
|
+
s.add_runtime_dependency "simple_oauth"
|
|
24
|
+
s.add_runtime_dependency "hashie"
|
|
25
|
+
s.add_runtime_dependency "json"
|
|
26
|
+
|
|
27
|
+
s.files = `git ls-files`.split("\n").delete_if { |f| !(f =~ /^examples/).nil? }
|
|
28
|
+
s.test_files = `git ls-files -- {test,features}/*`.split("\n")
|
|
29
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
30
|
+
s.require_paths = ["lib"]
|
|
31
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'faraday'
|
|
2
|
+
require 'faraday_middleware'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
|
|
6
|
+
Dir[File.expand_path('../response/*.rb', __FILE__)].each{|f| require f}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module ChurchCommunityBuilder
|
|
10
|
+
class Client
|
|
11
|
+
include ChurchCommunityBuilder::Client::Contribution
|
|
12
|
+
include ChurchCommunityBuilder::Client::Fund
|
|
13
|
+
include ChurchCommunityBuilder::Client::Person
|
|
14
|
+
|
|
15
|
+
attr_reader :subdomain, :username, :password
|
|
16
|
+
|
|
17
|
+
def initialize(subdomain, username, password)
|
|
18
|
+
@subdomain = subdomain
|
|
19
|
+
@username = username
|
|
20
|
+
@password = password
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get(path, options={})
|
|
24
|
+
connection.get do |req|
|
|
25
|
+
req.url(path, options)
|
|
26
|
+
end.body
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def post(path, req_body)
|
|
30
|
+
connection.post do |req|
|
|
31
|
+
req.url(path)
|
|
32
|
+
req.body = req_body
|
|
33
|
+
end.body
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def put(path, req_body)
|
|
37
|
+
connection.put do |req|
|
|
38
|
+
req.url path
|
|
39
|
+
req.body = req_body
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def delete(path, options = {})
|
|
44
|
+
connection.delete do |req|
|
|
45
|
+
req.url path
|
|
46
|
+
end.body
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def save
|
|
50
|
+
connection.put do |req|
|
|
51
|
+
req.url path
|
|
52
|
+
end.body
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def to_url(hash)
|
|
56
|
+
hash.collect do |key,val|
|
|
57
|
+
"#{CGI.escape(key.to_s)}=#{CGI.escape(val)}"
|
|
58
|
+
end.join('&')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def connection
|
|
64
|
+
Faraday.new(url: "https://#{subdomain}.ccbchurch.com/api.php") do |connection|
|
|
65
|
+
connection.basic_auth username, password
|
|
66
|
+
connection.response :logger
|
|
67
|
+
connection.response :xml
|
|
68
|
+
connection.adapter Faraday.default_adapter
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module ChurchCommunityBuilder
|
|
2
|
+
class Client
|
|
3
|
+
module Contribution
|
|
4
|
+
|
|
5
|
+
def create_contribution(contribution_params)
|
|
6
|
+
response = post("?srv=online_giving_insert_gift&#{contribution_params.to_url}")
|
|
7
|
+
::Contribution.new(response).parse
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module ChurchCommunityBuilder
|
|
2
|
+
class Client
|
|
3
|
+
module Person
|
|
4
|
+
|
|
5
|
+
def create_person(person_params)
|
|
6
|
+
response = post("?srv=create_individual&#{person_params.to_url}")
|
|
7
|
+
::Person.new(response).parse
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def search_for_person_by_email(email)
|
|
11
|
+
response = get("?srv=individual_search&email=#{email}")
|
|
12
|
+
::Person.new(response).parse
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Contribution
|
|
2
|
+
attr_reader :response, :contribution
|
|
3
|
+
|
|
4
|
+
def initialize(response)
|
|
5
|
+
@response = response["ccb_api"]["response"]
|
|
6
|
+
@contribution = @response["items"]["item"]
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def parse
|
|
10
|
+
OpenStruct.new(
|
|
11
|
+
id: contribution["gift_id"],
|
|
12
|
+
amount: contribution["amount"]
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class Person
|
|
2
|
+
attr_reader :response, :people, :count
|
|
3
|
+
|
|
4
|
+
def initialize(response)
|
|
5
|
+
@response = response["ccb_api"]["response"]
|
|
6
|
+
@people = @response["individuals"]
|
|
7
|
+
@count = @people["count"].to_i
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def parse
|
|
11
|
+
return [] if count == 0
|
|
12
|
+
|
|
13
|
+
if count == 1
|
|
14
|
+
[hydrate(people["individual"])]
|
|
15
|
+
else
|
|
16
|
+
people["individual"].map{|p| hydrate(p) }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def hydrate(person)
|
|
21
|
+
OpenStruct.new(
|
|
22
|
+
id: person["id"],
|
|
23
|
+
first_name: person["first_name"],
|
|
24
|
+
last_name: person["last_name"],
|
|
25
|
+
email: person["email"]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative 'church_commmunity_builder/client.rb'
|
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: church_community_builder
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Taylor Brooks
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
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
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: vcr
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: webmock
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: faraday
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: faraday_middleware
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: simple_oauth
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: hashie
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: json
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - ">="
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0'
|
|
153
|
+
description: Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).
|
|
154
|
+
Checkout the project on github for more detail.
|
|
155
|
+
email:
|
|
156
|
+
- tbrooks@gmail.com
|
|
157
|
+
executables: []
|
|
158
|
+
extensions: []
|
|
159
|
+
extra_rdoc_files: []
|
|
160
|
+
files:
|
|
161
|
+
- ".gitignore"
|
|
162
|
+
- Gemfile
|
|
163
|
+
- Gemfile.lock
|
|
164
|
+
- README.md
|
|
165
|
+
- Rakefile
|
|
166
|
+
- church_commmunity_builder.gemspec
|
|
167
|
+
- lib/church_community_builder.rb
|
|
168
|
+
- lib/church_community_builder/client.rb
|
|
169
|
+
- lib/church_community_builder/resources/contribution.rb
|
|
170
|
+
- lib/church_community_builder/resources/person.rb
|
|
171
|
+
- lib/church_community_builder/response/contribution.rb
|
|
172
|
+
- lib/church_community_builder/response/person.rb
|
|
173
|
+
- test/person/person_test.rb
|
|
174
|
+
- test/test_helper.rb
|
|
175
|
+
homepage: https://github.com/taylorbrooks/church_community_builder
|
|
176
|
+
licenses:
|
|
177
|
+
- MIT
|
|
178
|
+
metadata: {}
|
|
179
|
+
post_install_message:
|
|
180
|
+
rdoc_options: []
|
|
181
|
+
require_paths:
|
|
182
|
+
- lib
|
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - ">="
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: '0'
|
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
|
+
requirements:
|
|
190
|
+
- - ">="
|
|
191
|
+
- !ruby/object:Gem::Version
|
|
192
|
+
version: '0'
|
|
193
|
+
requirements: []
|
|
194
|
+
rubyforge_project:
|
|
195
|
+
rubygems_version: 2.4.5
|
|
196
|
+
signing_key:
|
|
197
|
+
specification_version: 4
|
|
198
|
+
summary: Ruby gem/plugin to interact with the Church Community Builder API (https://support.churchcommunitybuilder.com/customer/portal/articles/640589-api-documentation).
|
|
199
|
+
test_files:
|
|
200
|
+
- test/person/person_test.rb
|
|
201
|
+
- test/test_helper.rb
|