rock_rms 4.16.0 → 5.2.0
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 +4 -4
- data/lib/rock_rms/client.rb +5 -3
- data/lib/rock_rms/error.rb +28 -1
- data/lib/rock_rms/resources/recurring_donation.rb +6 -2
- data/lib/rock_rms/resources/recurring_donation_detail.rb +19 -0
- data/lib/rock_rms/response/recurring_donation_details.rb +2 -1
- data/lib/rock_rms/version.rb +1 -1
- data/rock_rms.gemspec +1 -1
- data/spec/rock_rms/error_spec.rb +3 -1
- data/spec/rock_rms/resources/recurring_donation_detail_spec.rb +29 -0
- data/spec/rock_rms/resources/recurring_donation_spec.rb +2 -1
- data/spec/support/rock_mock.rb +2 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 254d23847753a9c7485898497ce71ae8e8c0a1e0
|
|
4
|
+
data.tar.gz: 9e72e019d5a769b61a9c1ec2c85bc2d7027c2654
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07573a1687f67e903c1b2aac4383c56f8eae27f946db1ea22dc685afc3429e0a08661bfd6ff825f916d8ca93cf821183b0bb3ad71e94e20c601ed442c3067c1a
|
|
7
|
+
data.tar.gz: cb827f4264e4c8b7587aeb68af53a9b45dac71f119fa6496fe696f35a037c1d388259716ae73ef42eb97e7018a8b210ced22ba9224c042b2254655e0383da87a
|
data/lib/rock_rms/client.rb
CHANGED
|
@@ -27,6 +27,7 @@ module RockRMS
|
|
|
27
27
|
include RockRMS::Client::Person
|
|
28
28
|
include RockRMS::Client::PhoneNumber
|
|
29
29
|
include RockRMS::Client::RecurringDonation
|
|
30
|
+
include RockRMS::Client::RecurringDonationDetail
|
|
30
31
|
include RockRMS::Client::Refund
|
|
31
32
|
include RockRMS::Client::RefundReason
|
|
32
33
|
include RockRMS::Client::SavedPaymentMethod
|
|
@@ -38,13 +39,14 @@ module RockRMS
|
|
|
38
39
|
include RockRMS::Client::WorkflowActivityType
|
|
39
40
|
include RockRMS::Client::WorkflowType
|
|
40
41
|
|
|
41
|
-
attr_reader :url, :username, :password, :logger, :cookie, :connection
|
|
42
|
+
attr_reader :url, :username, :password, :logger, :cookie, :connection, :adapter
|
|
42
43
|
|
|
43
|
-
def initialize(url:, username:, password:, logger: true)
|
|
44
|
+
def initialize(url:, username:, password:, logger: true, adapter: Faraday.default_adapter)
|
|
44
45
|
@url = "#{url}/api/"
|
|
45
46
|
@username = username
|
|
46
47
|
@password = password
|
|
47
48
|
@logger = logger
|
|
49
|
+
@adapter = adapter
|
|
48
50
|
@cookie = auth['set-cookie']
|
|
49
51
|
end
|
|
50
52
|
|
|
@@ -92,7 +94,7 @@ module RockRMS
|
|
|
92
94
|
conn.response :logger if logger
|
|
93
95
|
conn.response :oj
|
|
94
96
|
conn.use FaradayMiddleware::RockRMSErrorHandler
|
|
95
|
-
conn.adapter
|
|
97
|
+
conn.adapter adapter
|
|
96
98
|
end
|
|
97
99
|
end
|
|
98
100
|
end
|
data/lib/rock_rms/error.rb
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
module RockRMS
|
|
2
2
|
class Error < StandardError; end
|
|
3
|
+
class BadRequest < Error; end
|
|
4
|
+
class Forbidden < Error; end
|
|
5
|
+
class GatewayTimeout < Error; end
|
|
6
|
+
class InternalServerError < Error; end
|
|
7
|
+
class NotFound < Error; end
|
|
8
|
+
class ServiceUnavailable < Error; end
|
|
9
|
+
class Unauthorized < Error; end
|
|
3
10
|
end
|
|
4
11
|
|
|
5
12
|
require 'faraday'
|
|
@@ -9,9 +16,29 @@ module FaradayMiddleware
|
|
|
9
16
|
|
|
10
17
|
def on_complete(env)
|
|
11
18
|
case env[:status]
|
|
19
|
+
when 400
|
|
20
|
+
raise RockRMS::BadRequest, error_message(env)
|
|
21
|
+
when 401
|
|
22
|
+
raise RockRMS::Unauthorized, error_message(env)
|
|
23
|
+
when 403
|
|
24
|
+
raise RockRMS::Forbidden, error_message(env)
|
|
25
|
+
when 404
|
|
26
|
+
raise RockRMS::NotFound, error_message(env)
|
|
27
|
+
when 500
|
|
28
|
+
raise RockRMS::InternalServerError, error_message(env)
|
|
29
|
+
when 503
|
|
30
|
+
raise RockRMS::ServiceUnavailable, error_message(env)
|
|
31
|
+
when 504
|
|
32
|
+
raise RockRMS::GatewayTimeout, error_message(env)
|
|
12
33
|
when ERROR_STATUSES
|
|
13
|
-
raise RockRMS::Error,
|
|
34
|
+
raise RockRMS::Error, error_message(env)
|
|
14
35
|
end
|
|
15
36
|
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def error_message(env)
|
|
41
|
+
"#{env[:status]}: #{env[:url]} #{env[:body]}"
|
|
42
|
+
end
|
|
16
43
|
end
|
|
17
44
|
end
|
|
@@ -20,6 +20,7 @@ module RockRMS
|
|
|
20
20
|
gateway_id: nil,
|
|
21
21
|
gateway_schedule_id: nil,
|
|
22
22
|
next_payment_date:,
|
|
23
|
+
payment_detail_id: nil,
|
|
23
24
|
source_type_id: 10,
|
|
24
25
|
transaction_code: nil,
|
|
25
26
|
start_date:
|
|
@@ -32,6 +33,7 @@ module RockRMS
|
|
|
32
33
|
'NextPaymentDate' => next_payment_date,
|
|
33
34
|
'IsActive' => active,
|
|
34
35
|
'FinancialGatewayId' => gateway_id,
|
|
36
|
+
'FinancialPaymentDetailId' => payment_detail_id,
|
|
35
37
|
'TransactionCode' => transaction_code,
|
|
36
38
|
'ScheduledTransactionDetails' => translate_funds(funds),
|
|
37
39
|
'GatewayScheduleId' => gateway_schedule_id,
|
|
@@ -45,11 +47,13 @@ module RockRMS
|
|
|
45
47
|
id,
|
|
46
48
|
next_payment_date:,
|
|
47
49
|
transaction_code: nil,
|
|
50
|
+
payment_detail_id: nil,
|
|
48
51
|
active: nil
|
|
49
52
|
)
|
|
50
53
|
options = { 'NextPaymentDate' => next_payment_date }
|
|
51
|
-
options['
|
|
52
|
-
options['
|
|
54
|
+
options['FinancialPaymentDetailId'] = payment_detail_id if payment_detail_id
|
|
55
|
+
options['TransactionCode'] = transaction_code if transaction_code
|
|
56
|
+
options['IsActive'] = active if !active.nil?
|
|
53
57
|
|
|
54
58
|
patch(recurring_donation_path(id), options)
|
|
55
59
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module RockRMS
|
|
2
|
+
class Client
|
|
3
|
+
module RecurringDonationDetail
|
|
4
|
+
def update_recurring_donation_detail(id, fund_id: nil, amount: nil)
|
|
5
|
+
options = {}
|
|
6
|
+
options['AccountId'] = fund_id if fund_id
|
|
7
|
+
options['Amount'] = amount if amount
|
|
8
|
+
|
|
9
|
+
patch(recurring_donation_detail_path(id), options)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def recurring_donation_detail_path(id = nil)
|
|
15
|
+
id ? "FinancialScheduledTransactionDetails/#{id}" : 'FinancialScheduledTransactionDetails'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/rock_rms/version.rb
CHANGED
data/rock_rms.gemspec
CHANGED
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.add_runtime_dependency 'faraday_middleware-parse_oj'
|
|
26
26
|
s.add_runtime_dependency 'json'
|
|
27
27
|
|
|
28
|
-
s.add_development_dependency 'bundler', '~>
|
|
28
|
+
s.add_development_dependency 'bundler', '~> 2.0'
|
|
29
29
|
s.add_development_dependency 'dotenv'
|
|
30
30
|
s.add_development_dependency 'pry'
|
|
31
31
|
s.add_development_dependency 'rake', '~> 10.4'
|
data/spec/rock_rms/error_spec.rb
CHANGED
|
@@ -18,9 +18,11 @@ RSpec.describe RockRMS::Error do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def expect_failure(code, body)
|
|
21
|
+
url = 'http://some-rock-uri.com/api/Auth/Login'
|
|
22
|
+
|
|
21
23
|
expect {
|
|
22
24
|
client.get('anything')
|
|
23
|
-
}.to raise_error(RockRMS::Error, /#{code}: #{body}/)
|
|
25
|
+
}.to raise_error(RockRMS::Error, /#{code}: #{url} #{body}/)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def expect_success
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe RockRMS::Client::RecurringDonationDetail, type: :model do
|
|
4
|
+
include_context 'resource specs'
|
|
5
|
+
|
|
6
|
+
describe '#update_recurring_donation_detail' do
|
|
7
|
+
subject(:resource) do
|
|
8
|
+
client.update_recurring_donation_detail(
|
|
9
|
+
123,
|
|
10
|
+
fund_id: 2,
|
|
11
|
+
amount: 100.0
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'returns nothing' do
|
|
16
|
+
expect(client.update_recurring_donation_detail(123, fund_id: 5, amount: 100.0)).to eq(nil)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'passes options' do
|
|
20
|
+
expect(client).to receive(:patch)
|
|
21
|
+
.with(
|
|
22
|
+
'FinancialScheduledTransactionDetails/123',
|
|
23
|
+
'AccountId' => 2,
|
|
24
|
+
'Amount' => 100.0
|
|
25
|
+
).and_call_original
|
|
26
|
+
resource
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -49,7 +49,7 @@ RSpec.describe RockRMS::Client::RecurringDonation, type: :model do
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
describe '#update_recurring_donation(id)' do
|
|
52
|
-
it '
|
|
52
|
+
it 'updates the recurring donation' do
|
|
53
53
|
expect(client).to receive(:patch)
|
|
54
54
|
.with(
|
|
55
55
|
'FinancialScheduledTransactions/123',
|
|
@@ -137,6 +137,7 @@ RSpec.describe RockRMS::Client::RecurringDonation, type: :model do
|
|
|
137
137
|
'NextPaymentDate' => '2010-01-01',
|
|
138
138
|
'IsActive' => true,
|
|
139
139
|
'FinancialGatewayId' => nil,
|
|
140
|
+
'FinancialPaymentDetailId' => nil,
|
|
140
141
|
'TransactionCode' => 'asdf',
|
|
141
142
|
'ScheduledTransactionDetails' => [{ 'Amount' => 450, 'AccountId' => 2 }],
|
|
142
143
|
'GatewayScheduleId' => nil,
|
data/spec/support/rock_mock.rb
CHANGED
|
@@ -76,7 +76,8 @@ class RockMock < Sinatra::Base
|
|
|
76
76
|
'FinancialBatches/:id',
|
|
77
77
|
'FinancialScheduledTransactions/:id',
|
|
78
78
|
'FinancialTransactions/:id',
|
|
79
|
-
'FinancialTransactionDetails/:id'
|
|
79
|
+
'FinancialTransactionDetails/:id',
|
|
80
|
+
'FinancialScheduledTransactionDetails/:id',
|
|
80
81
|
].each do |end_point|
|
|
81
82
|
patch "/api/#{end_point}" do
|
|
82
83
|
content_type :json
|
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:
|
|
4
|
+
version: 5.2.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: 2020-
|
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -72,14 +72,14 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
75
|
+
version: '2.0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '2.0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: dotenv
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -202,6 +202,7 @@ files:
|
|
|
202
202
|
- lib/rock_rms/resources/person.rb
|
|
203
203
|
- lib/rock_rms/resources/phone_number.rb
|
|
204
204
|
- lib/rock_rms/resources/recurring_donation.rb
|
|
205
|
+
- lib/rock_rms/resources/recurring_donation_detail.rb
|
|
205
206
|
- lib/rock_rms/resources/refund.rb
|
|
206
207
|
- lib/rock_rms/resources/refund_reason.rb
|
|
207
208
|
- lib/rock_rms/resources/saved_payment_method.rb
|
|
@@ -253,6 +254,7 @@ files:
|
|
|
253
254
|
- spec/rock_rms/resources/payment_detail_spec.rb
|
|
254
255
|
- spec/rock_rms/resources/person_spec.rb
|
|
255
256
|
- spec/rock_rms/resources/phone_number_spec.rb
|
|
257
|
+
- spec/rock_rms/resources/recurring_donation_detail_spec.rb
|
|
256
258
|
- spec/rock_rms/resources/recurring_donation_spec.rb
|
|
257
259
|
- spec/rock_rms/resources/refund_reason_spec.rb
|
|
258
260
|
- spec/rock_rms/resources/refund_spec.rb
|