rock_rms 3.9.0 → 4.0.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: d90a904297b23290523da3e063a61f5cbb76a8ed
4
- data.tar.gz: '03943e2c02fb2ceab23a892798614a154a1c5a84'
3
+ metadata.gz: a826c9dad155cd2dde1432bcf622307375bc5e16
4
+ data.tar.gz: e5053d52043a7c4b7bc5e8a8089c4abc8623b2a9
5
5
  SHA512:
6
- metadata.gz: 686e3dc2fdfc3328eb324f5e028cea1fd6644b159942535b2d23df6ceda43d11b5fd45d9cf533dc1e3e94de253e752670f07b02e06abad3fac2e03fb6c7eb7f7
7
- data.tar.gz: c06a373d5b5d7c09582cf7daec6e42ca06743f96dfef13f6c9b6a5401ed4660f361b1efe51b6a21c04f9449ddabd9c4c1f88b09c02ded477db38920ce703f914
6
+ metadata.gz: abfce0335816d7d9ec0235fd08424781b75287a13c68acbfd86d4d6bd3c3dd365adafbc013eab222dfb3eb25080466249d8df999a0d57a31190a551b46ddeab2
7
+ data.tar.gz: 11c7835281d1a541223d726125032d1508a40a054a2d25a659204f5396f8f591972c849a0fd33290c597b936b79a850b57a690faff3319e972d7554ab2d2f09d
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.7'
17
+ gem 'rock_rms', '~> 4.0'
18
18
 
19
19
  # then...
20
20
  bundle install
@@ -14,7 +14,7 @@ module RockRMS
14
14
  include RockRMS::Client::Gateway
15
15
  include RockRMS::Client::Group
16
16
  include RockRMS::Client::GroupMember
17
- include RockRMS::Client::PaymentMethod
17
+ include RockRMS::Client::PaymentDetail
18
18
  include RockRMS::Client::Person
19
19
  include RockRMS::Client::PhoneNumber
20
20
  include RockRMS::Client::RecurringDonation
@@ -0,0 +1,56 @@
1
+ module RockRMS
2
+ class Client
3
+ module PaymentDetail
4
+ def list_payment_details(options = {})
5
+ res = get(payment_detail_path, options)
6
+ Response::PaymentDetail.format(res)
7
+ end
8
+
9
+ def create_payment_detail(payment_type:, foreign_key: nil, card_type: nil)
10
+ options = {
11
+ 'CurrencyTypeValueId' => cast_payment_type(payment_type),
12
+ 'CreditCardTypeValueId' => cast_card_type(card_type),
13
+ 'ForeignKey' => foreign_key
14
+ }
15
+
16
+ post(payment_detail_path, options)
17
+ end
18
+
19
+ def delete_payment_detail(id)
20
+ delete(payment_detail_path(id))
21
+ end
22
+
23
+ private
24
+
25
+ def cast_payment_type(payment_type)
26
+ case payment_type
27
+ when 'card'
28
+ 156
29
+ when 'bank account', 'ach'
30
+ 157
31
+ end
32
+ end
33
+
34
+ def cast_card_type(card_type)
35
+ case card_type
36
+ when 'visa'
37
+ 7
38
+ when 'mastercard'
39
+ 8
40
+ when 'amex'
41
+ 159
42
+ when 'discover'
43
+ 160
44
+ when 'diner'
45
+ 161
46
+ when 'jcb'
47
+ 162
48
+ end
49
+ end
50
+
51
+ def payment_detail_path(id = nil)
52
+ id ? "FinancialPaymentDetails/#{id}" : 'FinancialPaymentDetails'
53
+ end
54
+ end
55
+ end
56
+ end
@@ -23,7 +23,7 @@ module RockRMS
23
23
  batch_id:,
24
24
  date:,
25
25
  funds:,
26
- payment_type:,
26
+ payment_detail_id:,
27
27
  source_type_id: 10,
28
28
  transaction_code: nil,
29
29
  summary: nil,
@@ -36,7 +36,7 @@ module RockRMS
36
36
  'ScheduledTransactionId' => recurring_donation_id,
37
37
  'BatchId' => batch_id,
38
38
  'FinancialGatewayId' => gateway_id,
39
- 'FinancialPaymentDetailId' => payment_type,
39
+ 'FinancialPaymentDetailId' => payment_detail_id,
40
40
  'TransactionCode' => transaction_code,
41
41
  'TransactionDateTime' => date,
42
42
  'TransactionDetails' => translate_funds(funds),
@@ -1,6 +1,6 @@
1
1
  module RockRMS
2
2
  module Response
3
- class PaymentMethod < Base
3
+ class PaymentDetail < Base
4
4
  MAP = {
5
5
  id: 'Id',
6
6
  exp_month: 'ExpirationMonth',
@@ -15,7 +15,7 @@ module RockRMS
15
15
  def format_single(data)
16
16
  result = to_h(MAP, data)
17
17
  result[:transaction_details] = RecurringDonationDetails.format(result[:transaction_details])
18
- result[:payment_details] = PaymentMethod.format(result[:payment_details])
18
+ result[:payment_details] = PaymentDetail.format(result[:payment_details])
19
19
  result
20
20
  end
21
21
  end
@@ -13,7 +13,7 @@ module RockRMS
13
13
 
14
14
  def format_single(data)
15
15
  response = to_h(MAP, data)
16
- response[:payment_details] = PaymentMethod.format(response[:payment_details])
16
+ response[:payment_details] = PaymentDetail.format(response[:payment_details])
17
17
  response
18
18
  end
19
19
  end
@@ -21,7 +21,7 @@ module RockRMS
21
21
  def format_single(data)
22
22
  response = to_h(MAP, data)
23
23
  response[:details] = TransactionDetail.format(response[:details])
24
- response[:payment_details] = PaymentMethod.format(response[:payment_details])
24
+ response[:payment_details] = PaymentDetail.format(response[:payment_details])
25
25
  response[:person] = format_person(response[:person])
26
26
  response[:amount] = calculate_total(response[:details])
27
27
  response
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = '3.9.0'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -1,26 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe RockRMS::Client::PaymentMethod, type: :model do
3
+ RSpec.describe RockRMS::Client::PaymentDetail, type: :model do
4
4
  include_context 'resource specs'
5
5
 
6
- describe '#list_payment_methods' do
6
+ describe '#list_payment_details' do
7
7
  it 'returns a array' do
8
- resource = client.list_payment_methods
8
+ resource = client.list_payment_details
9
9
  expect(resource).to be_a(Array)
10
10
  expect(resource.first).to be_a(Hash)
11
11
  end
12
12
  end
13
13
 
14
- describe '#create_payment_method' do
14
+ describe '#create_payment_detail' do
15
15
  context 'arguments' do
16
16
  it 'require `payment_type`' do
17
- expect { client.create_payment_method }
17
+ expect { client.create_payment_detail }
18
18
  .to raise_error(ArgumentError, /payment_type/)
19
19
  end
20
20
  end
21
21
 
22
22
  subject(:resource) do
23
- client.create_payment_method(payment_type: 'card')
23
+ client.create_payment_detail(payment_type: 'card', card_type: 'amex')
24
24
  end
25
25
 
26
26
  it 'returns integer' do
@@ -32,6 +32,7 @@ RSpec.describe RockRMS::Client::PaymentMethod, type: :model do
32
32
  .with(
33
33
  'FinancialPaymentDetails',
34
34
  'CurrencyTypeValueId' => 156,
35
+ 'CreditCardTypeValueId' => 159,
35
36
  'ForeignKey' => nil
36
37
  )
37
38
  .and_call_original
@@ -39,14 +40,15 @@ RSpec.describe RockRMS::Client::PaymentMethod, type: :model do
39
40
  end
40
41
  end
41
42
 
42
- describe '#delete_payment_method' do
43
+ describe '#delete_payment_detail' do
43
44
  it 'returns nothing' do
44
- expect(client.delete_payment_method(123)).to eq(nil)
45
+ expect(client.delete_payment_detail(123)).to eq(nil)
45
46
  end
46
47
 
47
48
  it 'passes id' do
48
49
  expect(client).to receive(:delete).with('FinancialPaymentDetails/123')
49
- client.delete_payment_method(123)
50
+ client.delete_payment_detail(123)
50
51
  end
51
52
  end
53
+
52
54
  end
@@ -63,7 +63,7 @@ RSpec.describe RockRMS::Client::Transaction, type: :model do
63
63
  batch_id: 1,
64
64
  date: 1,
65
65
  funds: [{ amount: 450, fund_id: 2 }],
66
- payment_type: 1,
66
+ payment_detail_id: 1,
67
67
  transaction_code: 'asdf',
68
68
  summary: 'taco tuesday',
69
69
  recurring_donation_id: 1
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe RockRMS::Response::PaymentMethod, type: :model do
4
- let(:parsed) { JSON.parse(FixturesHelper.read('payment_methods.json')) }
3
+ RSpec.describe RockRMS::Response::PaymentDetail, type: :model do
4
+ let(:parsed) { JSON.parse(FixturesHelper.read('payment_details.json')) }
5
5
 
6
6
  describe '.format' do
7
7
  subject(:result) { described_class.format(parsed) }
@@ -29,7 +29,7 @@ class RockMock < Sinatra::Base
29
29
  gateways: 'FinancialGateways',
30
30
  group: 'Groups/:id',
31
31
  groups: 'Groups',
32
- payment_methods: 'FinancialPaymentDetails',
32
+ payment_details: 'FinancialPaymentDetails',
33
33
  people_search: 'People/Search',
34
34
  person_by_alias: 'People/GetByPersonAliasId/:id',
35
35
  phone_numbers: 'PhoneNumbers',
@@ -48,7 +48,7 @@ class RockMock < Sinatra::Base
48
48
  {
49
49
  create_group_member: 'GroupMembers',
50
50
  create_transaction: 'FinancialTransactions',
51
- create_payment_method: 'FinancialPaymentDetails',
51
+ create_payment_detail: 'FinancialPaymentDetails',
52
52
  create_batch: 'FinancialBatches',
53
53
  create_recurring_donation: 'FinancialScheduledTransactions',
54
54
  create_refund: 'FinancialTransactionRefunds',
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.9.0
4
+ version: 4.0.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-10 00:00:00.000000000 Z
11
+ date: 2018-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -190,7 +190,7 @@ files:
190
190
  - lib/rock_rms/resources/gateway.rb
191
191
  - lib/rock_rms/resources/group.rb
192
192
  - lib/rock_rms/resources/group_member.rb
193
- - lib/rock_rms/resources/payment_method.rb
193
+ - lib/rock_rms/resources/payment_detail.rb
194
194
  - lib/rock_rms/resources/person.rb
195
195
  - lib/rock_rms/resources/phone_number.rb
196
196
  - lib/rock_rms/resources/recurring_donation.rb
@@ -208,7 +208,7 @@ files:
208
208
  - lib/rock_rms/response/group.rb
209
209
  - lib/rock_rms/response/group_location.rb
210
210
  - lib/rock_rms/response/location.rb
211
- - lib/rock_rms/response/payment_method.rb
211
+ - lib/rock_rms/response/payment_detail.rb
212
212
  - lib/rock_rms/response/person.rb
213
213
  - lib/rock_rms/response/phone_number.rb
214
214
  - lib/rock_rms/response/recurring_donation.rb
@@ -225,7 +225,7 @@ files:
225
225
  - spec/rock_rms/resources/gateway_spec.rb
226
226
  - spec/rock_rms/resources/group_member_spec.rb
227
227
  - spec/rock_rms/resources/group_spec.rb
228
- - spec/rock_rms/resources/payment_method_spec.rb
228
+ - spec/rock_rms/resources/payment_detail_spec.rb
229
229
  - spec/rock_rms/resources/person_spec.rb
230
230
  - spec/rock_rms/resources/phone_number_spec.rb
231
231
  - spec/rock_rms/resources/recurring_donation_spec.rb
@@ -239,7 +239,7 @@ files:
239
239
  - spec/rock_rms/response/group_location_spec.rb
240
240
  - spec/rock_rms/response/group_spec.rb
241
241
  - spec/rock_rms/response/location_spec.rb
242
- - spec/rock_rms/response/payment_method_spec.rb
242
+ - spec/rock_rms/response/payment_detail_spec.rb
243
243
  - spec/rock_rms/response/phone_number_spec.rb
244
244
  - spec/rock_rms/response/recurring_donation_details_spec.rb
245
245
  - spec/rock_rms/response/recurring_donation_spec.rb
@@ -254,7 +254,7 @@ files:
254
254
  - spec/support/fixtures/campuses.json
255
255
  - spec/support/fixtures/create_batch.json
256
256
  - spec/support/fixtures/create_group_member.json
257
- - spec/support/fixtures/create_payment_method.json
257
+ - spec/support/fixtures/create_payment_detail.json
258
258
  - spec/support/fixtures/create_recurring_donation.json
259
259
  - spec/support/fixtures/create_refund.json
260
260
  - spec/support/fixtures/create_refund_reason.json
@@ -269,7 +269,7 @@ files:
269
269
  - spec/support/fixtures/groups_with_locations.json
270
270
  - spec/support/fixtures/groups_with_members.json
271
271
  - spec/support/fixtures/locations.json
272
- - spec/support/fixtures/payment_methods.json
272
+ - spec/support/fixtures/payment_details.json
273
273
  - spec/support/fixtures/people_search.json
274
274
  - spec/support/fixtures/person_by_alias.json
275
275
  - spec/support/fixtures/phone_numbers.json
@@ -1,38 +0,0 @@
1
- module RockRMS
2
- class Client
3
- module PaymentMethod
4
- def list_payment_methods(options = {})
5
- res = get(payment_method_path, options)
6
- Response::PaymentMethod.format(res)
7
- end
8
-
9
- def create_payment_method(payment_type:, foreign_key: nil)
10
- options = {
11
- 'CurrencyTypeValueId' => cast_payment_type(payment_type),
12
- 'ForeignKey' => foreign_key
13
- }
14
-
15
- post(payment_method_path, options)
16
- end
17
-
18
- def delete_payment_method(id)
19
- delete(payment_method_path(id))
20
- end
21
-
22
- private
23
-
24
- def cast_payment_type(payment_type)
25
- case payment_type
26
- when 'card'
27
- 156
28
- when 'bank account', 'ach'
29
- 157
30
- end
31
- end
32
-
33
- def payment_method_path(id = nil)
34
- id ? "FinancialPaymentDetails/#{id}" : 'FinancialPaymentDetails'
35
- end
36
- end
37
- end
38
- end