rock_rms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +49 -0
- data/lib/rock_rms.rb +4 -0
- data/lib/rock_rms/client.rb +74 -0
- data/lib/rock_rms/resources/donation.rb +50 -0
- data/lib/rock_rms/resources/fund.rb +18 -0
- data/lib/rock_rms/resources/payment_method.rb +16 -0
- data/lib/rock_rms/resources/person.rb +35 -0
- data/lib/rock_rms/responses/donation.rb +21 -0
- data/lib/rock_rms/responses/fund.rb +18 -0
- data/lib/rock_rms/responses/person.rb +23 -0
- data/lib/rock_rms/version.rb +3 -0
- data/rock_rms.gemspec +27 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 04dbe2c1ddc46b1ec79763a420fcbb97cd2ef247
|
4
|
+
data.tar.gz: 02a707ba95cf6cd74d462c01fc071ab32639f027
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1533f754cc4cd88a2ad823b786e409a2320e596032d8f2d5ca5b7b692b27d87dfa2ae19fdc538ba66ba9cad9efd26e35dae950dddf1576e3d9fa6fe6d43bd9c3
|
7
|
+
data.tar.gz: 25fccae0a610b7f4254ba2f983820521134ebd068d00bff1282ed1e29cdb73d768e4ce0f68aee9ec596ac604bdaa89f947c75841ddc0c91e7661992368ba36d5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Taylor Brooks
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
⚠️ Code is highly subject to change. Consider this an alpha release.
|
2
|
+
|
3
|
+
### A Ruby wrapper for the Rock RMS API
|
4
|
+
|
5
|
+
To get a general overview of Rock RMS: https://www.rockrms.com
|
6
|
+
|
7
|
+
To stay up-to-date with the code changes of Rock RMS: https://github.com/SparkDevNetwork/Rock
|
8
|
+
|
9
|
+
I'm a big fan of Rock so if you have problems using the gem or would like to see support for new endpoints, please open a GitHub issue -- I'll get it resolved as quick as I can.
|
10
|
+
|
11
|
+
### Installation
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
````ruby
|
14
|
+
# in your Gemfile
|
15
|
+
gem 'rock_rms', '~> 0.1'
|
16
|
+
|
17
|
+
# then...
|
18
|
+
bundle install
|
19
|
+
````
|
20
|
+
|
21
|
+
### Usage
|
22
|
+
````ruby
|
23
|
+
client = RockRMS::Client.new(
|
24
|
+
url: ...,
|
25
|
+
username: ...,
|
26
|
+
password: ...,
|
27
|
+
)
|
28
|
+
|
29
|
+
# Find a specific person
|
30
|
+
client.find_person_by_email('gob@bluthco.com')
|
31
|
+
client.find_person_by_name('Tobias Funke')
|
32
|
+
````
|
33
|
+
|
34
|
+
### History
|
35
|
+
|
36
|
+
View the [changelog](https://github.com/taylorbrooks/rock_rms/blob/master/CHANGELOG.md)
|
37
|
+
This gem follows [Semantic Versioning](http://semver.org/)
|
38
|
+
|
39
|
+
### Contributing
|
40
|
+
|
41
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
42
|
+
|
43
|
+
- [Report bugs](https://github.com/taylorbrooks/rock_rms/issues)
|
44
|
+
- Fix bugs and [submit pull requests](https://github.com/taylorbrooks/rock_rms/pulls)
|
45
|
+
- Write, clarify, or fix documentation
|
46
|
+
- Suggest or add new features
|
47
|
+
|
48
|
+
### Copyright
|
49
|
+
Copyright (c) 2017 Taylor Brooks. See LICENSE for details.
|
data/lib/rock_rms.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require_relative 'version'
|
4
|
+
|
5
|
+
Dir[File.expand_path('../resources/*.rb', __FILE__)].each{|f| require f}
|
6
|
+
Dir[File.expand_path('../responses/*.rb', __FILE__)].each{|f| require f}
|
7
|
+
|
8
|
+
module RockRMS
|
9
|
+
class Client
|
10
|
+
include RockRMS::Client::Donation
|
11
|
+
include RockRMS::Client::Fund
|
12
|
+
include RockRMS::Client::PaymentMethod
|
13
|
+
include RockRMS::Client::Person
|
14
|
+
|
15
|
+
attr_reader :url, :username, :password, :logger, :cookie, :connection
|
16
|
+
|
17
|
+
def initialize(url:, username:, password:, logger: true)
|
18
|
+
@url = url
|
19
|
+
@username = username
|
20
|
+
@password = password
|
21
|
+
@logger = logger
|
22
|
+
@cookie = auth['set-cookie']
|
23
|
+
end
|
24
|
+
|
25
|
+
def auth
|
26
|
+
connection.post("Auth/Login", {
|
27
|
+
'Username' => username,
|
28
|
+
'Password' => password,
|
29
|
+
'Persisted' => true
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
def get(path, options)
|
34
|
+
connection.get(path, options).body
|
35
|
+
end
|
36
|
+
|
37
|
+
def post(path, req_body)
|
38
|
+
connection.post do |req|
|
39
|
+
req.url(path)
|
40
|
+
req.body = req_body
|
41
|
+
end.body
|
42
|
+
end
|
43
|
+
|
44
|
+
def patch(path, options)
|
45
|
+
connection.patch(path, options).body
|
46
|
+
end
|
47
|
+
|
48
|
+
def put(path, options)
|
49
|
+
connection.put(path, options).body
|
50
|
+
end
|
51
|
+
|
52
|
+
def delete(path, options)
|
53
|
+
connection.delete(path, options).body
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def connection
|
59
|
+
headers = {
|
60
|
+
accept: 'application/json',
|
61
|
+
'User-Agent' => "rock-rms-ruby-gem/v#{RockRMS::VERSION}"
|
62
|
+
}
|
63
|
+
|
64
|
+
headers.merge!('Cookie' => cookie) if cookie
|
65
|
+
|
66
|
+
Faraday.new(url: url, headers: headers) do |conn|
|
67
|
+
conn.request :json
|
68
|
+
conn.response :logger if logger
|
69
|
+
conn.response :json
|
70
|
+
conn.adapter Faraday.default_adapter
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module Donation
|
4
|
+
|
5
|
+
def list_donations(options={})
|
6
|
+
res = get(transaction_path, options)
|
7
|
+
RockRMS::Donation.format(res)
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_donations_by_giving_id(id, raw = false)
|
11
|
+
res = get("FinancialTransactions/GetByGivingId/#{id}?$expand=TransactionDetails")
|
12
|
+
raw ? res : RockRMS::Donation.format(res)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_donations(id)
|
16
|
+
res = get(transaction_path(id))
|
17
|
+
RockRMS::Donation.format(res)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_donation(authorized_person_id:, amount:, date:, fund_id:)
|
21
|
+
options = {
|
22
|
+
"TransactionDateTime" => date,
|
23
|
+
"AuthorizedPersonAliasId" => authorized_person_id,
|
24
|
+
"TransactionDetails" => [{
|
25
|
+
"Amount" => amount,
|
26
|
+
"AccountId" => fund_id
|
27
|
+
}],
|
28
|
+
"TransactionTypeValueId" => 53, # transaction type "contribution", "registration"
|
29
|
+
"FinancialPaymentDetailId" => 1
|
30
|
+
}
|
31
|
+
post(transaction_path, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def update_transaction(id, options={})
|
35
|
+
put(transaction_path(id), options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete_transaction(id)
|
39
|
+
delete(transaction_path(id))
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def transaction_path(id = nil)
|
45
|
+
id ? "FinancialTransactions/#{id}" : "FinancialTransactions"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module Fund
|
4
|
+
|
5
|
+
def list_funds(options={})
|
6
|
+
res = get(fund_path, options)
|
7
|
+
RockRMS::Fund.format(res)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def fund_path(id = nil)
|
13
|
+
id ? "FinancialAccounts/#{id}" : "FinancialAccounts"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module PaymentMethod
|
4
|
+
|
5
|
+
def list_payment_methods(options={})
|
6
|
+
get(payment_method_path, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def payment_method_path(id = nil)
|
12
|
+
id ? "FinancialPaymentDetails/#{id}" : "FinancialPaymentDetails"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module Person
|
4
|
+
def list_people(options={})
|
5
|
+
res = get(people_path, options)
|
6
|
+
RockRMS::Person.format(res)
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_person(id)
|
10
|
+
res = get(people_path(id))
|
11
|
+
RockRMS::Person.format(res)
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_person_by_email(email)
|
15
|
+
res = get("People/GetByEmail/#{email}")
|
16
|
+
RockRMS::Person.format(res)
|
17
|
+
end
|
18
|
+
|
19
|
+
def find_person_by_name(full_name)
|
20
|
+
res = get("People/Search?name=#{full_name}&includeHtml=false&includeDetails=false&includeBusinesses=false&includeDeceased=false")
|
21
|
+
RockRMS::Person.format(res)
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_person(id, options = {})
|
25
|
+
put(people_path(id), options)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def people_path(id = nil)
|
31
|
+
id ? "People/#{id}" : "People"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Donation
|
3
|
+
def self.format(response)
|
4
|
+
if response.is_a?(Array)
|
5
|
+
response.map{|donation| format_donation(donation) }
|
6
|
+
else
|
7
|
+
format_donation(response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.format_donation(donation)
|
12
|
+
{
|
13
|
+
id: donation["Id"],
|
14
|
+
date: donation["TransactionDateTime"],
|
15
|
+
amount: donation["TransactionDetails"].reduce(0){|sum, td| sum + td["Amount"]},
|
16
|
+
person_id: donation["AuthorizedPersonAliasId"],
|
17
|
+
fund: ""
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Fund
|
3
|
+
def self.format(response)
|
4
|
+
if response.is_a?(Array)
|
5
|
+
response.map{|fund| format_fund(fund) }
|
6
|
+
else
|
7
|
+
format_fund(response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.format_fund(fund)
|
12
|
+
{
|
13
|
+
id: fund["Id"],
|
14
|
+
name: fund["Name"]
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Person
|
3
|
+
def self.format(response)
|
4
|
+
if response.is_a?(Array)
|
5
|
+
response.map{|person| format_person(person) }
|
6
|
+
else
|
7
|
+
format_person(response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.format_person(person)
|
12
|
+
{
|
13
|
+
id: person["Id"],
|
14
|
+
name: person["FullName"],
|
15
|
+
email: person["Email"],
|
16
|
+
first_name: person["FirstName"],
|
17
|
+
last_name: person["LastName"],
|
18
|
+
giving_id: person["GivingId"],
|
19
|
+
alias_id: person["PrimaryAliasId"]
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/rock_rms.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rock_rms/version"
|
4
|
+
require "base64"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rock_rms"
|
8
|
+
s.version = RockRMS::VERSION
|
9
|
+
s.authors = ["Taylor Brooks"]
|
10
|
+
s.email = ["dGJyb29rc0BnbWFpbC5jb20="].map{ |e| Base64.decode64(e) }
|
11
|
+
s.homepage = "https://github.com/taylorbrooks/rock_rms"
|
12
|
+
s.summary = %q{A Ruby wrapper for the Rock RMS API}
|
13
|
+
s.description = %q{A Ruby wrapper for the Rock RMS API -- a church management platform, simplified.}
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split($/)
|
17
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test)/})
|
19
|
+
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'faraday'
|
23
|
+
s.add_runtime_dependency 'faraday_middleware'
|
24
|
+
s.add_runtime_dependency 'json'
|
25
|
+
|
26
|
+
s.add_development_dependency 'bundler'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rock_rms
|
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: 2017-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: bundler
|
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
|
+
description: A Ruby wrapper for the Rock RMS API -- a church management platform,
|
70
|
+
simplified.
|
71
|
+
email:
|
72
|
+
- tbrooks@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- lib/rock_rms.rb
|
82
|
+
- lib/rock_rms/client.rb
|
83
|
+
- lib/rock_rms/resources/donation.rb
|
84
|
+
- lib/rock_rms/resources/fund.rb
|
85
|
+
- lib/rock_rms/resources/payment_method.rb
|
86
|
+
- lib/rock_rms/resources/person.rb
|
87
|
+
- lib/rock_rms/responses/donation.rb
|
88
|
+
- lib/rock_rms/responses/fund.rb
|
89
|
+
- lib/rock_rms/responses/person.rb
|
90
|
+
- lib/rock_rms/version.rb
|
91
|
+
- rock_rms.gemspec
|
92
|
+
homepage: https://github.com/taylorbrooks/rock_rms
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.6.8
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: A Ruby wrapper for the Rock RMS API
|
116
|
+
test_files: []
|