rock_rms 3.6.3 → 3.7.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: eecbd53510e41101fae6aba55416d284167f9939
4
- data.tar.gz: 464fa1235580a72808bbebd095b23fe8f3610ce7
3
+ metadata.gz: fd375e13d1ddbcc18d07158eef1623732f1ddf94
4
+ data.tar.gz: eaaf26fe10343d12fd205d28355e6ecc3a0b2bfa
5
5
  SHA512:
6
- metadata.gz: 8683d70cd8aead89734d46fcbdd09d8f178656d992d0dc28945f5ffe19efc364703add2ca9ccf53fddec0e832a4752ea061af7a85946a5d1ceb2b70cc30e04c3
7
- data.tar.gz: d26ac80aa6ee432d36078cb70250f8907a15909a4bb7cdc9ecaa059936c9e81f4ac91ba4bce8901d20d05435ca05a97a12268d50d6fdf29e54757425055017a0
6
+ metadata.gz: c12ed63721dfd7b629f68bbbfba73305bfac2e989d8f1d170982ca144fd4b594ce62ba4963b1c6caac1dc88a5e976b6449623ee8efe7a5e88108f0fe6108cd36
7
+ data.tar.gz: a58a9265d8f6b51bd6fbead0981055f4eee142ca37909ad4b45b37b6d32acab877f76449cc1f38dd66d6a6dd9b3b7956359c82ae213f7ea631468a0d73af1b9b
data/README.md CHANGED
@@ -14,7 +14,7 @@ I'm a big fan of Rock so if you have problems using the gem or would like to see
14
14
  Add this line to your application's Gemfile:
15
15
  ````ruby
16
16
  # in your Gemfile
17
- gem 'rock_rms', '~> 3.6'
17
+ gem 'rock_rms', '~> 3.7'
18
18
 
19
19
  # then...
20
20
  bundle install
@@ -19,6 +19,7 @@ module RockRMS
19
19
  include RockRMS::Client::PhoneNumber
20
20
  include RockRMS::Client::RecurringDonation
21
21
  include RockRMS::Client::Refund
22
+ include RockRMS::Client::RefundReason
22
23
  include RockRMS::Client::SavedPaymentMethod
23
24
  include RockRMS::Client::Transaction
24
25
  include RockRMS::Client::TransactionDetail
@@ -0,0 +1,32 @@
1
+ module RockRMS
2
+ class Client
3
+ module RefundReason
4
+ def list_refund_reasons(options = {})
5
+ options['$filter'] = 'DefinedTypeId eq 37' unless options.keys.include?('$filter')
6
+
7
+ Response::DefinedValue.format(
8
+ get(defined_values_path, options)
9
+ )
10
+ end
11
+
12
+ def create_refund_reason(value:, description:, order: nil)
13
+ order ||= Random.rand(100..1000)
14
+
15
+ options = {
16
+ 'Value' => value,
17
+ 'Description' => description,
18
+ 'Order' => order,
19
+ 'IsSystem' => false,
20
+ 'DefinedTypeId' => 37
21
+ }
22
+ post(defined_values_path, options)
23
+ end
24
+
25
+ private
26
+
27
+ def defined_values_path
28
+ 'DefinedValues'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module RockRMS
2
+ module Response
3
+ class DefinedValue < Base
4
+ MAP = {
5
+ id: 'Id',
6
+ defined_type_id: 'DefinedTypeId',
7
+ description: 'Description',
8
+ order: 'Order',
9
+ value: 'Value',
10
+ }.freeze
11
+
12
+ def format_single(data)
13
+ to_h(MAP, data)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = '3.6.3'.freeze
2
+ VERSION = '3.7.0'.freeze
3
3
  end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client::RefundReason, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#list_refund_reasons' do
7
+ it 'returns a array' do
8
+ resource = client.list_refund_reasons
9
+ expect(resource).to be_a(Array)
10
+ expect(resource.first).to be_a(Hash)
11
+ end
12
+ end
13
+
14
+ describe '#create_refund_reason' do
15
+ context 'arguments' do
16
+
17
+ it 'require `value`' do
18
+ expect { client.create_refund_reason }
19
+ .to raise_error(ArgumentError, /value/)
20
+ end
21
+
22
+ it 'require `description`' do
23
+ expect { client.create_refund_reason }
24
+ .to raise_error(ArgumentError, /description/)
25
+ end
26
+
27
+ end
28
+
29
+ subject(:resource) do
30
+ client.create_refund_reason(
31
+ value: "Angry Donor",
32
+ description: "Very Very not Happy",
33
+ order: 500,
34
+ )
35
+ end
36
+
37
+ it 'returns integer' do
38
+ expect(resource).to be_a(Integer)
39
+ end
40
+
41
+ it 'passes options' do
42
+ expect(client).to receive(:post)
43
+ .with(
44
+ 'DefinedValues',
45
+ 'DefinedTypeId' => 37,
46
+ 'IsSystem' => false,
47
+ 'Order' => 500,
48
+ 'Description' => "Very Very not Happy",
49
+ 'Value' => "Angry Donor",
50
+ )
51
+ .and_call_original
52
+ resource
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ [
2
+
3
+ {
4
+ "Guid": "36cf10d6-c695-413d-8e7c-4546efef385e",
5
+ "Id": 1,
6
+ "DefinedTypeId": 1,
7
+ "Description": "A Person Record",
8
+ "IsSystem": true,
9
+ "Order": 0,
10
+ "Value": "Person"
11
+ }
12
+
13
+ ]
@@ -24,6 +24,7 @@ class RockMock < Sinatra::Base
24
24
  campus: 'Campuses/:id',
25
25
  transaction: 'FinancialTransactions/:id',
26
26
  transactions: 'FinancialTransactions',
27
+ defined_values:'DefinedValues',
27
28
  families: 'Groups/GetFamilies/:id',
28
29
  gateways: 'FinancialGateways',
29
30
  group: 'Groups/:id',
@@ -49,7 +50,8 @@ class RockMock < Sinatra::Base
49
50
  create_transaction: 'FinancialTransactions',
50
51
  create_payment_method: 'FinancialPaymentDetails',
51
52
  create_batch: 'FinancialBatches',
52
- create_refund: 'FinancialTransactionRefunds'
53
+ create_refund: 'FinancialTransactionRefunds',
54
+ create_refund_reason: 'DefinedValues'
53
55
  }.each do |json, end_point|
54
56
  post "/api/#{end_point}" do
55
57
  json_response 201, "#{json}.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: 3.6.3
4
+ version: 3.7.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-03-26 00:00:00.000000000 Z
11
+ date: 2018-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -195,12 +195,14 @@ files:
195
195
  - lib/rock_rms/resources/phone_number.rb
196
196
  - lib/rock_rms/resources/recurring_donation.rb
197
197
  - lib/rock_rms/resources/refund.rb
198
+ - lib/rock_rms/resources/refund_reason.rb
198
199
  - lib/rock_rms/resources/saved_payment_method.rb
199
200
  - lib/rock_rms/resources/transaction.rb
200
201
  - lib/rock_rms/resources/transaction_detail.rb
201
202
  - lib/rock_rms/response/base.rb
202
203
  - lib/rock_rms/response/batch.rb
203
204
  - lib/rock_rms/response/campus.rb
205
+ - lib/rock_rms/response/defined_value.rb
204
206
  - lib/rock_rms/response/fund.rb
205
207
  - lib/rock_rms/response/gateway.rb
206
208
  - lib/rock_rms/response/group.rb
@@ -227,6 +229,7 @@ files:
227
229
  - spec/rock_rms/resources/person_spec.rb
228
230
  - spec/rock_rms/resources/phone_number_spec.rb
229
231
  - spec/rock_rms/resources/recurring_donation_spec.rb
232
+ - spec/rock_rms/resources/refund_reason_spec.rb
230
233
  - spec/rock_rms/resources/refund_spec.rb
231
234
  - spec/rock_rms/resources/saved_payment_method_spec.rb
232
235
  - spec/rock_rms/resources/transaction_detail_spec.rb
@@ -253,7 +256,9 @@ files:
253
256
  - spec/support/fixtures/create_group_member.json
254
257
  - spec/support/fixtures/create_payment_method.json
255
258
  - spec/support/fixtures/create_refund.json
259
+ - spec/support/fixtures/create_refund_reason.json
256
260
  - spec/support/fixtures/create_transaction.json
261
+ - spec/support/fixtures/defined_values.json
257
262
  - spec/support/fixtures/families.json
258
263
  - spec/support/fixtures/gateways.json
259
264
  - spec/support/fixtures/group.json