rock_rms 1.1.0 → 1.2.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: c3bf2fbd0092ad9afa7bc274f05201848d886b5f
4
- data.tar.gz: 10715556852bd2472671646798a50ab35c78dd54
3
+ metadata.gz: 8020457d40757f3f46ae6fdbbbe7c9552503b9b8
4
+ data.tar.gz: 914245cc572c0d6d528f904cc06c84becb679f16
5
5
  SHA512:
6
- metadata.gz: 96eda68c2764ce38ecab7e8efcda03c6558c279c12f728bc9a927223ceb60bc40ce0ec971086475ce51d770f54036b8c933eec78d8c7ac1a9643d118b19a5536
7
- data.tar.gz: 2862be265f417d8a922a6c45c123d2d8c85cb4347be3d2f279bfc949a0af56c8a3df5c20a424227ddbb8895d404678491e1e857c5b5a048dac1e79d05bba4277
6
+ metadata.gz: d5f676541b1191b279237d2c64249b2af91b4556ffacbbde09eca5542f58f67d8711a8209beb3f8d9b81d74ae4b563c9065b200fd6652e4601eb954e1d1de211
7
+ data.tar.gz: ca8621d50b0e2971cbbea78b616e81742956523ea4a88b0973eb46776c46dc0ba066edabbaaaebc93da9bea2deacdf2dc042199166419999e6016bab186e8d49
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ language: ruby
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- ### A Ruby wrapper for the Rock RMS API
1
+ ![](https://www.rockrms.com/Themes/RockExternal/Assets/Images/rock-logo.svg)
2
+
3
+ # Rock RMS Ruby Client [![Build Status](https://travis-ci.org/taylorbrooks/rock_rms.svg?branch=master)](https://travis-ci.org/taylorbrooks/rock_rms)
4
+
5
+ A Ruby wrapper for the Rock RMS API
2
6
 
3
7
  To get a general overview of Rock RMS: https://www.rockrms.com
4
8
 
@@ -8,7 +8,7 @@ module RockRMS
8
8
  private
9
9
 
10
10
  def phone_number_path(id = nil)
11
- id ? "PhoneNumbers/#{id}" : "PhoneNumbers"
11
+ id ? "PhoneNumbers/#{id}" : 'PhoneNumbers'
12
12
  end
13
13
  end
14
14
  end
@@ -3,12 +3,23 @@ module RockRMS
3
3
  module RecurringDonation
4
4
  def list_recurring_donations(options = {})
5
5
  res = get(recurring_donation_path, options)
6
- RockRMS::RecurringDonation.format(res)
6
+ RockRMS::Responses::RecurringDonation.format(res)
7
7
  end
8
8
 
9
9
  def find_recurring_donation(id)
10
10
  res = get(recurring_donation_path(id))
11
- RockRMS::RecurringDonation.format(res)
11
+ RockRMS::Responses::RecurringDonation.format(res)
12
+ end
13
+
14
+ def update_recurring_donation(
15
+ id,
16
+ next_payment_date:,
17
+ transaction_code: nil
18
+ )
19
+ options = { 'NextPaymentDate' => next_payment_date }
20
+ options['TransactionCode'] = transaction_code if transaction_code
21
+
22
+ patch(recurring_donation_path(id), options)
12
23
  end
13
24
 
14
25
  private
@@ -22,10 +22,8 @@ module RockRMS
22
22
  end
23
23
  end
24
24
 
25
- private
26
-
27
25
  def self.format_single(data)
28
- MAP.each.with_object({}) do |(l,r), object|
26
+ MAP.each.with_object({}) do |(l, r), object|
29
27
  object[l] = data[r]
30
28
  end
31
29
  end
@@ -18,7 +18,7 @@ module RockRMS
18
18
  end
19
19
 
20
20
  def self.format_number(data)
21
- MAP.each.with_object({}) do |(l,r), object|
21
+ MAP.each.with_object({}) do |(l, r), object|
22
22
  object[l] = data[r]
23
23
  end
24
24
  end
@@ -1,26 +1,31 @@
1
1
  module RockRMS
2
- class RecurringDonation
3
- MAP = {
4
- id: 'Id',
5
- person_id: 'AuthorizedPersonAliasId',
6
- transaction_details: 'ScheduledTransactionDetails'
7
- }.freeze
2
+ module Responses
3
+ class RecurringDonation
4
+ MAP = {
5
+ id: 'Id',
6
+ foreign_key: 'ForeignKey',
7
+ next_payment_date: 'NextPaymentDate',
8
+ person_id: 'AuthorizedPersonAliasId',
9
+ transaction_details: 'ScheduledTransactionDetails',
10
+ transaction_code: 'TransactionCode'
11
+ }.freeze
8
12
 
9
- def self.format(data)
10
- if data.is_a?(Array)
11
- data.map { |object| format_single(object) }
12
- else
13
- format_single(data)
13
+ def self.format(data)
14
+ if data.is_a?(Array)
15
+ data.map { |object| format_single(object) }
16
+ else
17
+ format_single(data)
18
+ end
14
19
  end
15
- end
16
20
 
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
21
+ def self.format_single(data)
22
+ MAP.each.with_object({}) do |(l, r), object|
23
+ object[l] = if l == :transaction_details
24
+ RockRMS::Responses::RecurringDonationDetails.format(data[r])
25
+ else
26
+ data[r]
27
+ end
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -1,21 +1,23 @@
1
1
  module RockRMS
2
- class RecurringDonationDetails
3
- MAP = {
4
- fund_id: 'AccountId',
5
- amount: 'Amount'
6
- }.freeze
2
+ module Responses
3
+ class RecurringDonationDetails
4
+ MAP = {
5
+ fund_id: 'AccountId',
6
+ amount: 'Amount'
7
+ }.freeze
7
8
 
8
- def self.format(data)
9
- if data.is_a?(Array)
10
- data.map { |object| format_single(object) }
11
- else
12
- format_single(data)
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
13
15
  end
14
- end
15
16
 
16
- def self.format_single(data)
17
- MAP.each.with_object({}) do |(l, r), object|
18
- object[l] = data[r]
17
+ def self.format_single(data)
18
+ MAP.each.with_object({}) do |(l, r), object|
19
+ object[l] = data[r]
20
+ end
19
21
  end
20
22
  end
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -24,17 +24,16 @@ RSpec.describe RockRMS::Client::GroupMember, type: :model do
24
24
  expect { client.create_group_member }
25
25
  .to raise_error(ArgumentError, /person_id/)
26
26
  end
27
-
28
27
  end
29
28
 
30
- subject(:resource) {
29
+ subject(:resource) do
31
30
  client.create_group_member(
32
31
  group_id: 123,
33
32
  group_member_status: 1,
34
33
  group_role_id: 456,
35
34
  person_id: 123456
36
35
  )
37
- }
36
+ end
38
37
 
39
38
  it 'returns integer' do
40
39
  expect(resource).to be_a(Integer)
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client::RecurringDonation, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#list_recurring_donations(options = {})' do
7
+ it 'returns a array of hashes' do
8
+ resource = client.list_recurring_donations
9
+ expect(resource).to be_a(Array)
10
+ expect(resource.first).to be_a(Hash)
11
+ end
12
+
13
+ it 'queries recurring donations' do
14
+ expect(client).to receive(:get)
15
+ .with('FinancialScheduledTransactions', {})
16
+ .and_call_original
17
+ client.list_recurring_donations
18
+ end
19
+
20
+ it 'formats with RecurringDonation' do
21
+ response = double
22
+ expect(RockRMS::Responses::RecurringDonation).to receive(:format).with(response)
23
+ allow(client).to receive(:get).and_return(response)
24
+ client.list_recurring_donations
25
+ end
26
+ end
27
+
28
+ describe '#find_recurring_donation(id)' do
29
+ it 'returns a hash' do
30
+ expect(client.find_recurring_donation(12_345)).to be_a(Hash)
31
+ end
32
+
33
+ it 'queries recurring donations' do
34
+ expect(client).to receive(:get)
35
+ .with('FinancialScheduledTransactions/12345')
36
+ .and_call_original
37
+
38
+ resource = client.find_recurring_donation(12_345)
39
+
40
+ expect(resource[:id]).to eq(12_345)
41
+ end
42
+
43
+ it 'formats with RecurringDonation' do
44
+ response = double
45
+ expect(RockRMS::Responses::RecurringDonation).to receive(:format).with(response)
46
+ allow(client).to receive(:get).and_return(response)
47
+ client.find_recurring_donation(12_345)
48
+ end
49
+ end
50
+
51
+ describe '#update_recurring_donation(id)' do
52
+ it 'queries updates the recurring donation' do
53
+ expect(client).to receive(:patch)
54
+ .with(
55
+ 'FinancialScheduledTransactions/123',
56
+ 'NextPaymentDate' => '2018-01-01'
57
+ ).and_call_original
58
+
59
+ resource = client.update_recurring_donation(
60
+ 123,
61
+ next_payment_date: '2018-01-01'
62
+ )
63
+
64
+ expect(resource).to be_nil
65
+ end
66
+
67
+ context 'arguments' do
68
+ it 'require `id`' do
69
+ expect { client.update_recurring_donation }
70
+ .to raise_error(ArgumentError, /wrong number/)
71
+ end
72
+ end
73
+
74
+ subject(:resource) do
75
+ client.update_recurring_donation(
76
+ 1,
77
+ transaction_code: 'recur_1234',
78
+ next_payment_date: '2018-01-01'
79
+ )
80
+ end
81
+
82
+ it 'returns nil' do
83
+ expect(resource).to be_nil
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Responses::RecurringDonationDetails, type: :model do
4
+ let(:parsed) { JSON.parse(FixturesHelper.read('recurring_donation_details.json')) }
5
+
6
+ describe '.format' do
7
+ subject(:result) { described_class.format(parsed) }
8
+
9
+ context 'when response is array' do
10
+ it 'returns an array' do
11
+ expect(described_class.format([])).to be_a(Array)
12
+ end
13
+ end
14
+
15
+ it 'translates keys' do
16
+ result.zip(parsed) do |r, p|
17
+ expect(r[:fund_id]).to eq(p['AccountId'])
18
+ expect(r[:amount]).to eq(p['Amount'])
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Responses::RecurringDonation, type: :model do
4
+ let(:parsed) { JSON.parse(FixturesHelper.read('recurring_donations.json')) }
5
+
6
+ describe '.format' do
7
+ subject(:result) { described_class.format(parsed) }
8
+
9
+ context 'when response is array' do
10
+ it 'returns an array' do
11
+ expect(described_class.format([])).to be_a(Array)
12
+ end
13
+ end
14
+
15
+ it 'translates keys' do
16
+ result.zip(parsed) do |r, p|
17
+ expect(r[:id]).to eq(p['Id'])
18
+ expect(r[:foreign_key]).to eq(p['ForeignKey'])
19
+ expect(r[:next_payment_date]).to eq(p['NextPaymentDate'])
20
+ expect(r[:person_id]).to eq(p['AuthorizedPersonAliasId'])
21
+ expect(r[:transaction_details]).to eq(
22
+ RockRMS::Responses::RecurringDonationDetails.format(p['ScheduledTransactionDetails'])
23
+ )
24
+ expect(r[:transaction_code]).to eq(p['TransactionCode'])
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ {
2
+ "AuthorizedPersonAliasId": 1234,
3
+ "TransactionTypeValueId": null,
4
+ "SourceTypeValueId": 10,
5
+ "TransactionFrequencyValueId": 135,
6
+ "StartDate": "2018-01-26T00:00:00",
7
+ "EndDate": null,
8
+ "NumberOfPayments": null,
9
+ "NextPaymentDate": null,
10
+ "LastStatusUpdateDateTime": null,
11
+ "IsActive": true,
12
+ "FinancialGatewayId": 4,
13
+ "FinancialPaymentDetailId": 28,
14
+ "TransactionCode": "",
15
+ "GatewayScheduleId": "",
16
+ "CardReminderDate": null,
17
+ "LastRemindedDate": null,
18
+ "TransactionTypeValue": null,
19
+ "SourceTypeValue": null,
20
+ "FinancialGateway": null,
21
+ "FinancialPaymentDetail": null,
22
+ "TransactionFrequencyValue": null,
23
+ "ScheduledTransactionDetails": [],
24
+ "Transactions":[],
25
+ "CreatedDateTime": "2018-01-23T17:12:54.123",
26
+ "ModifiedDateTime": "2018-01-23T17:12:54.123",
27
+ "CreatedByPersonAliasId": null,
28
+ "ModifiedByPersonAliasId": null,
29
+ "ModifiedAuditValuesAlreadyUpdated": false,
30
+ "Attributes": null,
31
+ "AttributeValues": null,
32
+ "Id": 12345,
33
+ "Guid": "036c27ba-7cba-4a8f-b8d6-36a2e60a9bb0",
34
+ "ForeignId": 56789,
35
+ "ForeignGuid": null,
36
+ "ForeignKey": "RecurringDonation"
37
+ }
@@ -0,0 +1,23 @@
1
+ [
2
+ {
3
+ "ScheduledTransactionId": 1,
4
+ "AccountId": 1,
5
+ "Amount": 10.00,
6
+ "Summary": null,
7
+ "EntityTypeId": null,
8
+ "EntityId": null,
9
+ "EntityType": null,
10
+ "CreatedDateTime": "2017-12-19T14:48:02.553",
11
+ "ModifiedDateTime": "2017-12-19T14:48:02.553",
12
+ "CreatedByPersonAliasId": 12,
13
+ "ModifiedByPersonAliasId": 12,
14
+ "ModifiedAuditValuesAlreadyUpdated": false,
15
+ "Attributes": null,
16
+ "AttributeValues": null,
17
+ "Id": 1,
18
+ "Guid": "c5b5ebf6-faec-41d8-8089-51b83633334f",
19
+ "ForeignId": null,
20
+ "ForeignGuid": null,
21
+ "ForeignKey": null
22
+ }
23
+ ]
@@ -0,0 +1,45 @@
1
+ [
2
+ {
3
+ "AuthorizedPersonAliasId": 1234,
4
+ "TransactionTypeValueId": null,
5
+ "SourceTypeValueId": 10,
6
+ "TransactionFrequencyValueId": 135,
7
+ "StartDate": "2018-01-26T00:00:00",
8
+ "EndDate": null,
9
+ "NumberOfPayments": null,
10
+ "NextPaymentDate": null,
11
+ "LastStatusUpdateDateTime": null,
12
+ "IsActive": true,
13
+ "FinancialGatewayId": 4,
14
+ "FinancialPaymentDetailId": 28,
15
+ "TransactionCode": "",
16
+ "GatewayScheduleId": "",
17
+ "CardReminderDate": null,
18
+ "LastRemindedDate": null,
19
+ "TransactionTypeValue": null,
20
+ "SourceTypeValue": null,
21
+ "FinancialGateway": null,
22
+ "FinancialPaymentDetail": null,
23
+ "TransactionFrequencyValue": null,
24
+ "ScheduledTransactionDetails": [
25
+ {
26
+ "ScheduledTransactionId": 1,
27
+ "AccountId": 1,
28
+ "Amount": 10.00
29
+ }
30
+ ],
31
+ "Transactions":[],
32
+ "CreatedDateTime": "2018-01-23T17:12:54.123",
33
+ "ModifiedDateTime": "2018-01-23T17:12:54.123",
34
+ "CreatedByPersonAliasId": null,
35
+ "ModifiedByPersonAliasId": null,
36
+ "ModifiedAuditValuesAlreadyUpdated": false,
37
+ "Attributes": null,
38
+ "AttributeValues": null,
39
+ "Id": 12345,
40
+ "Guid": "036c27ba-7cba-4a8f-b8d6-36a2e60a9bb0",
41
+ "ForeignId": 56789,
42
+ "ForeignGuid": null,
43
+ "ForeignKey": "RecurringDonation"
44
+ }
45
+ ]
@@ -19,7 +19,9 @@ class RockMock < Sinatra::Base
19
19
  group: 'Groups/:id',
20
20
  groups: 'Groups',
21
21
  people_search: 'People/Search',
22
- phone_numbers: 'PhoneNumbers'
22
+ phone_numbers: 'PhoneNumbers',
23
+ recurring_donation: 'FinancialScheduledTransactions/:id',
24
+ recurring_donations: 'FinancialScheduledTransactions'
23
25
  }.each do |json, end_point|
24
26
  get "/api/#{end_point}" do
25
27
  json_response 200, "#{json}.json"
@@ -35,6 +37,16 @@ class RockMock < Sinatra::Base
35
37
  end
36
38
  end
37
39
 
40
+ # PATCH requests
41
+ [
42
+ 'FinancialScheduledTransactions/:id'
43
+ ].each do |end_point|
44
+ patch "/api/#{end_point}" do
45
+ content_type :json
46
+ status 204
47
+ end
48
+ end
49
+
38
50
  post '/api/Auth/Login' do
39
51
  content_type :json
40
52
 
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: 1.1.0
4
+ version: 1.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: 2018-01-18 00:00:00.000000000 Z
11
+ date: 2018-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -175,6 +175,7 @@ extra_rdoc_files: []
175
175
  files:
176
176
  - ".gitignore"
177
177
  - ".ruby-version"
178
+ - ".travis.yml"
178
179
  - Gemfile
179
180
  - LICENSE
180
181
  - README.md
@@ -212,11 +213,14 @@ files:
212
213
  - spec/rock_rms/resources/group_spec.rb
213
214
  - spec/rock_rms/resources/person_spec.rb
214
215
  - spec/rock_rms/resources/phone_number_spec.rb
216
+ - spec/rock_rms/resources/recurring_donation_spec.rb
215
217
  - spec/rock_rms/responses/campus_spec.rb
216
218
  - spec/rock_rms/responses/group_location_spec.rb
217
219
  - spec/rock_rms/responses/group_spec.rb
218
220
  - spec/rock_rms/responses/location_spec.rb
219
221
  - spec/rock_rms/responses/phone_number_spec.rb
222
+ - spec/rock_rms/responses/recurring_donation_details_spec.rb
223
+ - spec/rock_rms/responses/recurring_donation_spec.rb
220
224
  - spec/rock_rms_spec.rb
221
225
  - spec/spec_helper.rb
222
226
  - spec/support/client_factory.rb
@@ -232,6 +236,9 @@ files:
232
236
  - spec/support/fixtures/locations.json
233
237
  - spec/support/fixtures/people_search.json
234
238
  - spec/support/fixtures/phone_numbers.json
239
+ - spec/support/fixtures/recurring_donation.json
240
+ - spec/support/fixtures/recurring_donation_details.json
241
+ - spec/support/fixtures/recurring_donations.json
235
242
  - spec/support/fixtures_helper.rb
236
243
  - spec/support/rock_mock.rb
237
244
  homepage: https://github.com/taylorbrooks/rock_rms