rock_rms 5.0.0 → 5.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cdc3ac5eda8e89243df3cdf319e1ea4d0a2db7a
4
- data.tar.gz: b3ba9b0089c70ed7cd709e3857b2a16e2ade5e45
3
+ metadata.gz: 2a4add6f6df087698b9ec91bbad6880ca717aeef
4
+ data.tar.gz: '09e175b379477bf5fc3dc930985624465a513bea'
5
5
  SHA512:
6
- metadata.gz: 673884c975f563c2945dafdc321611b989c8d5e6a87914c2fa26c6806b245107c932cd84ae29e2376b8b3e2d3f807501c39dd36161436ff0efc31e6b7001ea96
7
- data.tar.gz: a4eb7aa401b7c6fa52aa651cb4953ddedcd9969ba445b72609500253d9d4d4c0982828cf82c46d298c49a9f5b3eb9789671938f57d0495c3cd7688e05b1e23a5
6
+ metadata.gz: 012ae60c7c8f6791350250e9baa7ea365f833346bc3666b87924d5e3841f3f38e86e042b5862555bcb348b44a9a776ca398a783cfe746c337d825d7af63dc3bb
7
+ data.tar.gz: 368e177d21b30126c09df30601bb8709a5caa1720a19c97156f18c7fa6f9ab5be70bf43dce6fc4436550657396856184b4906c2a765e65597140c42e2e67f150
@@ -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
@@ -5,6 +5,7 @@ module RockRMS
5
5
  class GatewayTimeout < Error; end
6
6
  class InternalServerError < Error; end
7
7
  class NotFound < Error; end
8
+ class ServiceUnavailable < Error; end
8
9
  class Unauthorized < Error; end
9
10
  end
10
11
 
@@ -16,20 +17,28 @@ module FaradayMiddleware
16
17
  def on_complete(env)
17
18
  case env[:status]
18
19
  when 400
19
- raise RockRMS::BadRequest, "#{env[:status]}: #{env[:body]} #{env[:url]}"
20
+ raise RockRMS::BadRequest, error_message(env)
20
21
  when 401
21
- raise RockRMS::Unauthorized, "#{env[:status]}: #{env[:body]} #{env[:url]}"
22
+ raise RockRMS::Unauthorized, error_message(env)
22
23
  when 403
23
- raise RockRMS::Forbidden, "#{env[:status]}: #{env[:body]} #{env[:url]}"
24
+ raise RockRMS::Forbidden, error_message(env)
24
25
  when 404
25
- raise RockRMS::NotFound, "#{env[:status]}: #{env[:body]} #{env[:url]}"
26
+ raise RockRMS::NotFound, error_message(env)
26
27
  when 500
27
- raise RockRMS::InternalServerError, "#{env[:status]}: #{env[:body]} #{env[:url]}"
28
+ raise RockRMS::InternalServerError, error_message(env)
29
+ when 503
30
+ raise RockRMS::ServiceUnavailable, error_message(env)
28
31
  when 504
29
- raise RockRMS::GatewayTimeout, "#{env[:status]}: #{env[:body]} #{env[:url]}"
32
+ raise RockRMS::GatewayTimeout, error_message(env)
30
33
  when ERROR_STATUSES
31
- raise RockRMS::Error, "#{env[:status]}: #{env[:body]} #{env[:url]}"
34
+ raise RockRMS::Error, error_message(env)
32
35
  end
33
36
  end
37
+
38
+ private
39
+
40
+ def error_message(env)
41
+ "#{env[:status]}: #{env[:url]} #{env[:body]}"
42
+ end
34
43
  end
35
44
  end
@@ -58,6 +58,16 @@ module RockRMS
58
58
  patch(recurring_donation_path(id), options)
59
59
  end
60
60
 
61
+ def launch_scheduled_transaction_workflow(
62
+ id,
63
+ workflow_type_id:,
64
+ workflow_name:,
65
+ attributes: {}
66
+ )
67
+ query_string = "?workflowTypeId=#{workflow_type_id}&workflowName=#{workflow_name}"
68
+ post(recurring_donation_path + "/LaunchWorkflow/#{id}#{query_string}", attributes)
69
+ end
70
+
61
71
  private
62
72
 
63
73
  def translate_funds(funds)
@@ -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
@@ -77,6 +77,10 @@ module RockRMS
77
77
  delete(transaction_path(id))
78
78
  end
79
79
 
80
+ def refund_transaction(id)
81
+ post(transaction_path + "/Refund/#{id}")
82
+ end
83
+
80
84
  def launch_transaction_workflow(
81
85
  id,
82
86
  workflow_type_id:,
@@ -11,9 +11,10 @@ module RockRMS
11
11
  Response::TransactionDetail.format(res)
12
12
  end
13
13
 
14
- def update_transaction_detail(id, fund_id: nil, fee_amount: nil)
14
+ def update_transaction_detail(id, fund_id: nil, amount: nil, fee_amount: nil)
15
15
  options = {}
16
16
  options['AccountId'] = fund_id if fund_id
17
+ options['Amount'] = amount if amount
17
18
  options['FeeAmount'] = fee_amount if fee_amount
18
19
 
19
20
  patch(transaction_detail_path(id), options)
@@ -3,7 +3,8 @@ module RockRMS
3
3
  class RecurringDonationDetails < Base
4
4
  MAP = {
5
5
  amount: 'Amount',
6
- fund_id: 'AccountId'
6
+ fund_id: 'AccountId',
7
+ id: 'Id'
7
8
  }.freeze
8
9
 
9
10
  def format_single(data)
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = '5.0.0'.freeze
2
+ VERSION = '5.5.0'.freeze
3
3
  end
@@ -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 'queries updates the recurring donation' do
52
+ it 'updates the recurring donation' do
53
53
  expect(client).to receive(:patch)
54
54
  .with(
55
55
  'FinancialScheduledTransactions/123',
@@ -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: 5.0.0
4
+ version: 5.5.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-04-18 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -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