rock_rms 0.0.10 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rock_rms/client.rb +7 -6
- data/lib/rock_rms/resources/donation.rb +12 -6
- data/lib/rock_rms/resources/recurring_donation.rb +21 -0
- data/lib/rock_rms/responses/recurring_donation.rb +27 -0
- data/lib/rock_rms/responses/recurring_donation_details.rb +22 -0
- data/lib/rock_rms/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65005100add8c42685fc4eae6afd72642d839b51
|
4
|
+
data.tar.gz: b177de895e8be5949aa3a1c3074479f873271594
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7122edcf512009eec7a9cc633c0cc087a1962ee1d533b0b47e03b179e19f8b26cb029e43fc846d31d6b81852928ebc674c3979692bbf395786f256359ea803c6
|
7
|
+
data.tar.gz: 74c27a4c0f3a1536a2ede5c220f1cd3584b0586c5b20e8787a224ab7f161641cc25965dc32bd91ad8b7e04d3c6d66c0faa028cf74f5a1cf2c543f137a79d99bc
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ I'm a big fan of Rock so if you have problems using the gem or would like to see
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
````ruby
|
14
14
|
# in your Gemfile
|
15
|
-
gem 'rock_rms', '~> 0
|
15
|
+
gem 'rock_rms', '~> 1.0'
|
16
16
|
|
17
17
|
# then...
|
18
18
|
bundle install
|
@@ -46,4 +46,4 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
46
46
|
- Suggest or add new features
|
47
47
|
|
48
48
|
### Copyright
|
49
|
-
Copyright (c)
|
49
|
+
Copyright (c) 2018 Taylor Brooks. See LICENSE for details.
|
data/lib/rock_rms/client.rb
CHANGED
@@ -12,6 +12,7 @@ module RockRMS
|
|
12
12
|
include RockRMS::Client::Fund
|
13
13
|
include RockRMS::Client::PaymentMethod
|
14
14
|
include RockRMS::Client::Person
|
15
|
+
include RockRMS::Client::RecurringDonation
|
15
16
|
include RockRMS::Client::TransactionDetail
|
16
17
|
|
17
18
|
attr_reader :url, :username, :password, :logger, :cookie, :connection
|
@@ -32,16 +33,16 @@ module RockRMS
|
|
32
33
|
connection.get(path, options).body
|
33
34
|
end
|
34
35
|
|
35
|
-
def patch(path,
|
36
|
-
connection.patch(path,
|
36
|
+
def patch(path, options = {})
|
37
|
+
connection.patch(path, options).body
|
37
38
|
end
|
38
39
|
|
39
|
-
def post(path,
|
40
|
-
connection.post(path,
|
40
|
+
def post(path, options = {})
|
41
|
+
connection.post(path, options).body
|
41
42
|
end
|
42
43
|
|
43
|
-
def put(path,
|
44
|
-
connection.put(path,
|
44
|
+
def put(path, options = {})
|
45
|
+
connection.put(path, options).body
|
45
46
|
end
|
46
47
|
|
47
48
|
private
|
@@ -17,25 +17,22 @@ module RockRMS
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def create_donation(
|
20
|
-
amount:,
|
21
20
|
authorized_person_id:,
|
22
21
|
batch_id:,
|
23
22
|
date:,
|
24
|
-
|
23
|
+
funds:,
|
25
24
|
payment_type:,
|
26
25
|
source_type_id: 10,
|
27
26
|
transaction_code: nil
|
28
27
|
)
|
28
|
+
|
29
29
|
options = {
|
30
30
|
'AuthorizedPersonAliasId' => authorized_person_id,
|
31
31
|
'BatchId' => batch_id,
|
32
32
|
'FinancialPaymentDetailId' => payment_type,
|
33
33
|
'TransactionCode' => transaction_code,
|
34
34
|
'TransactionDateTime' => date,
|
35
|
-
'TransactionDetails' =>
|
36
|
-
'Amount' => amount,
|
37
|
-
'AccountId' => fund_id
|
38
|
-
}],
|
35
|
+
'TransactionDetails' => translate_funds(funds),
|
39
36
|
'TransactionTypeValueId' => 53, # contribution, registration
|
40
37
|
'SourceTypeValueId' => source_type_id, # website, kiosk, mobile app
|
41
38
|
}
|
@@ -55,6 +52,15 @@ module RockRMS
|
|
55
52
|
|
56
53
|
private
|
57
54
|
|
55
|
+
def translate_funds(funds)
|
56
|
+
funds.map do |fund|
|
57
|
+
{
|
58
|
+
'Amount' => fund[:amount],
|
59
|
+
'AccountId' => fund[:fund_id]
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
58
64
|
def transaction_path(id = nil)
|
59
65
|
id ? "FinancialTransactions/#{id}" : 'FinancialTransactions'
|
60
66
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class Client
|
3
|
+
module RecurringDonation
|
4
|
+
def list_recurring_donations(options = {})
|
5
|
+
res = get(recurring_donation_path, options)
|
6
|
+
RockRMS::RecurringDonation.format(res)
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_recurring_donation(id)
|
10
|
+
res = get(recurring_donation_path(id))
|
11
|
+
RockRMS::RecurringDonation.format(res)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def recurring_donation_path(id = nil)
|
17
|
+
id ? "FinancialScheduledTransactions/#{id}" : 'FinancialScheduledTransactions'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class RecurringDonation
|
3
|
+
MAP = {
|
4
|
+
id: 'Id',
|
5
|
+
person_id: 'AuthorizedPersonAliasId',
|
6
|
+
transaction_details: 'ScheduledTransactionDetails'
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
def self.format(data)
|
10
|
+
if data.is_a?(Array)
|
11
|
+
data.map { |object| format_single(object) }
|
12
|
+
else
|
13
|
+
format_single(data)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.format_single(data)
|
18
|
+
MAP.each.with_object({}) do |(l, r), object|
|
19
|
+
object[l] = if l == :transaction_details
|
20
|
+
RockRMS::RecurringDonationDetails.format(data[r])
|
21
|
+
else
|
22
|
+
data[r]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RockRMS
|
2
|
+
class RecurringDonationDetails
|
3
|
+
MAP = {
|
4
|
+
fund_id: 'AccountId',
|
5
|
+
amount: 'Amount'
|
6
|
+
}.freeze
|
7
|
+
|
8
|
+
def self.format(data)
|
9
|
+
if data.is_a?(Array)
|
10
|
+
data.map { |object| format_single(object) }
|
11
|
+
else
|
12
|
+
format_single(data)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.format_single(data)
|
17
|
+
MAP.each.with_object({}) do |(l, r), object|
|
18
|
+
object[l] = data[r]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/rock_rms/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rock_rms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
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: 2017-12-
|
11
|
+
date: 2017-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -188,10 +188,13 @@ files:
|
|
188
188
|
- lib/rock_rms/resources/fund.rb
|
189
189
|
- lib/rock_rms/resources/payment_method.rb
|
190
190
|
- lib/rock_rms/resources/person.rb
|
191
|
+
- lib/rock_rms/resources/recurring_donation.rb
|
191
192
|
- lib/rock_rms/resources/transaction_detail.rb
|
192
193
|
- lib/rock_rms/responses/donation.rb
|
193
194
|
- lib/rock_rms/responses/fund.rb
|
194
195
|
- lib/rock_rms/responses/person.rb
|
196
|
+
- lib/rock_rms/responses/recurring_donation.rb
|
197
|
+
- lib/rock_rms/responses/recurring_donation_details.rb
|
195
198
|
- lib/rock_rms/version.rb
|
196
199
|
- rock_rms.gemspec
|
197
200
|
- spec/rock_rms/client_spec.rb
|