rock_rms 3.8.0 → 3.9.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d90a904297b23290523da3e063a61f5cbb76a8ed
|
4
|
+
data.tar.gz: '03943e2c02fb2ceab23a892798614a154a1c5a84'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686e3dc2fdfc3328eb324f5e028cea1fd6644b159942535b2d23df6ceda43d11b5fd45d9cf533dc1e3e94de253e752670f07b02e06abad3fac2e03fb6c7eb7f7
|
7
|
+
data.tar.gz: c06a373d5b5d7c09582cf7daec6e42ca06743f96dfef13f6c9b6a5401ed4660f361b1efe51b6a21c04f9449ddabd9c4c1f88b09c02ded477db38920ce703f914
|
@@ -11,6 +11,36 @@ module RockRMS
|
|
11
11
|
Response::RecurringDonation.format(res)
|
12
12
|
end
|
13
13
|
|
14
|
+
def create_recurring_donation(
|
15
|
+
active: true,
|
16
|
+
authorized_person_id:,
|
17
|
+
foreign_key: nil,
|
18
|
+
frequency:,
|
19
|
+
funds:,
|
20
|
+
gateway_id: nil,
|
21
|
+
gateway_schedule_id: nil,
|
22
|
+
next_payment_date:,
|
23
|
+
source_type_id: 10,
|
24
|
+
transaction_code: nil,
|
25
|
+
start_date:
|
26
|
+
)
|
27
|
+
|
28
|
+
options = {
|
29
|
+
'AuthorizedPersonAliasId' => authorized_person_id,
|
30
|
+
'TransactionFrequencyValueId' => RECURRING_FREQUENCIES[frequency],
|
31
|
+
'StartDate' => start_date,
|
32
|
+
'NextPaymentDate' => next_payment_date,
|
33
|
+
'IsActive' => active,
|
34
|
+
'FinancialGatewayId' => gateway_id,
|
35
|
+
'TransactionCode' => transaction_code,
|
36
|
+
'ScheduledTransactionDetails' => translate_funds(funds),
|
37
|
+
'GatewayScheduleId' => gateway_schedule_id,
|
38
|
+
'SourceTypeValueId' => source_type_id,
|
39
|
+
'ForeignKey' => foreign_key
|
40
|
+
}
|
41
|
+
post(recurring_donation_path, options)
|
42
|
+
end
|
43
|
+
|
14
44
|
def update_recurring_donation(
|
15
45
|
id,
|
16
46
|
next_payment_date:,
|
@@ -26,6 +56,24 @@ module RockRMS
|
|
26
56
|
|
27
57
|
private
|
28
58
|
|
59
|
+
RECURRING_FREQUENCIES = {
|
60
|
+
'one-time' => 130,
|
61
|
+
'weekly' => 132,
|
62
|
+
'bi-weekly' => 133,
|
63
|
+
'monthly' => 135,
|
64
|
+
'quarterly' => 153,
|
65
|
+
'yearly' => 155
|
66
|
+
}.freeze
|
67
|
+
|
68
|
+
def translate_funds(funds)
|
69
|
+
funds.map do |fund|
|
70
|
+
{
|
71
|
+
'Amount' => fund[:amount],
|
72
|
+
'AccountId' => fund[:fund_id]
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
29
77
|
def recurring_donation_path(id = nil)
|
30
78
|
id ? "FinancialScheduledTransactions/#{id}" : 'FinancialScheduledTransactions'
|
31
79
|
end
|
data/lib/rock_rms/version.rb
CHANGED
@@ -83,4 +83,68 @@ RSpec.describe RockRMS::Client::RecurringDonation, type: :model do
|
|
83
83
|
expect(resource).to be_nil
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
describe '#create_recurring_donation' do
|
88
|
+
context 'arguments' do
|
89
|
+
it 'require `authorized_person_id`' do
|
90
|
+
expect { client.create_recurring_donation }
|
91
|
+
.to raise_error(ArgumentError, /authorized_person_id/)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'require `frequency`' do
|
95
|
+
expect { client.create_recurring_donation }
|
96
|
+
.to raise_error(ArgumentError, /frequency/)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'require `next_payment_date`' do
|
100
|
+
expect { client.create_recurring_donation }
|
101
|
+
.to raise_error(ArgumentError, /next_payment_date/)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'require `start_date`' do
|
105
|
+
expect { client.create_recurring_donation }
|
106
|
+
.to raise_error(ArgumentError, /start_date/)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'require `funds`' do
|
110
|
+
expect { client.create_recurring_donation }
|
111
|
+
.to raise_error(ArgumentError, /funds/)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
subject(:resource) do
|
116
|
+
client.create_recurring_donation(
|
117
|
+
authorized_person_id: 1,
|
118
|
+
funds: [{ amount: 450, fund_id: 2 }],
|
119
|
+
transaction_code: 'asdf',
|
120
|
+
frequency: 'monthly',
|
121
|
+
next_payment_date: '2010-01-01',
|
122
|
+
start_date: '2010-01-01'
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'returns integer' do
|
127
|
+
expect(resource).to be_a(Integer)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'passes options' do
|
131
|
+
expect(client).to receive(:post)
|
132
|
+
.with(
|
133
|
+
'FinancialScheduledTransactions',
|
134
|
+
'AuthorizedPersonAliasId' => 1,
|
135
|
+
'TransactionFrequencyValueId' => 135,
|
136
|
+
'StartDate' => '2010-01-01',
|
137
|
+
'NextPaymentDate' => '2010-01-01',
|
138
|
+
'IsActive' => true,
|
139
|
+
'FinancialGatewayId' => nil,
|
140
|
+
'TransactionCode' => 'asdf',
|
141
|
+
'ScheduledTransactionDetails' => [{ 'Amount' => 450, 'AccountId' => 2 }],
|
142
|
+
'GatewayScheduleId' => nil,
|
143
|
+
'SourceTypeValueId' => 10,
|
144
|
+
'ForeignKey' => nil
|
145
|
+
)
|
146
|
+
.and_call_original
|
147
|
+
resource
|
148
|
+
end
|
149
|
+
end
|
86
150
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
12345
|
data/spec/support/rock_mock.rb
CHANGED
@@ -50,6 +50,7 @@ class RockMock < Sinatra::Base
|
|
50
50
|
create_transaction: 'FinancialTransactions',
|
51
51
|
create_payment_method: 'FinancialPaymentDetails',
|
52
52
|
create_batch: 'FinancialBatches',
|
53
|
+
create_recurring_donation: 'FinancialScheduledTransactions',
|
53
54
|
create_refund: 'FinancialTransactionRefunds',
|
54
55
|
create_refund_reason: 'DefinedValues'
|
55
56
|
}.each do |json, end_point|
|
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: 3.
|
4
|
+
version: 3.9.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: 2018-04-
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- spec/support/fixtures/create_batch.json
|
256
256
|
- spec/support/fixtures/create_group_member.json
|
257
257
|
- spec/support/fixtures/create_payment_method.json
|
258
|
+
- spec/support/fixtures/create_recurring_donation.json
|
258
259
|
- spec/support/fixtures/create_refund.json
|
259
260
|
- spec/support/fixtures/create_refund_reason.json
|
260
261
|
- spec/support/fixtures/create_transaction.json
|