rock_rms 1.2.0 → 1.3.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: 8020457d40757f3f46ae6fdbbbe7c9552503b9b8
4
- data.tar.gz: 914245cc572c0d6d528f904cc06c84becb679f16
3
+ metadata.gz: f1b5a8912599ca1d74291a287765abdf6f283efb
4
+ data.tar.gz: 031df795a7215c4d7c5c2ea350ae9e465b7a9c25
5
5
  SHA512:
6
- metadata.gz: d5f676541b1191b279237d2c64249b2af91b4556ffacbbde09eca5542f58f67d8711a8209beb3f8d9b81d74ae4b563c9065b200fd6652e4601eb954e1d1de211
7
- data.tar.gz: ca8621d50b0e2971cbbea78b616e81742956523ea4a88b0973eb46776c46dc0ba066edabbaaaebc93da9bea2deacdf2dc042199166419999e6016bab186e8d49
6
+ metadata.gz: e55025ccb035d05122bb77d4ea7028c35313b48ef607c39d1e119fc72d80b108fe7763fa785613d3aa33b17d47afece8a17a2690f27947437b9784751229250b
7
+ data.tar.gz: 1c8b77ad4eca61e4284a6eabcac460ef3fcdb795d3db0aa3654de546ecb58838e5545b4da744d1f499fc180c9dbbfd8fdc732756bdca58ae55aa9672c686e98d
data/Rakefile CHANGED
@@ -1,20 +1,20 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
7
7
 
8
8
  task :environment do
9
9
  require 'dotenv'
10
10
  Dotenv.load
11
11
 
12
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
12
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
13
13
  require 'rock_rms'
14
14
  end
15
15
 
16
- desc "Launch a pry shell with libraries loaded"
17
- task :pry => :environment do
16
+ desc 'Launch a pry shell with libraries loaded'
17
+ task pry: :environment do
18
18
  if ENV['ROCK_USERNAME']
19
19
  @client = RockRMS::Client.new(
20
20
  url: ENV['ROCK_API_URL'],
data/bin/rspec CHANGED
@@ -1,17 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
- #
3
+
4
4
  # This file was generated by Bundler.
5
5
  #
6
6
  # The application 'rspec' is installed as part of a gem, and
7
7
  # this file is here to facilitate running it.
8
8
  #
9
9
 
10
- require "pathname"
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
- Pathname.new(__FILE__).realpath)
10
+ require 'pathname'
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
12
+ '../../Gemfile',
13
+ Pathname.new(__FILE__).realpath
14
+ )
13
15
 
14
- require "rubygems"
15
- require "bundler/setup"
16
+ require 'rubygems'
17
+ require 'bundler/setup'
16
18
 
17
- load Gem.bin_path("rspec-core", "rspec")
19
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -21,9 +21,14 @@ module RockRMS
21
21
  end
22
22
 
23
23
  def update_batch(id, options = {})
24
+ options = options.collect { |k, v| [k.to_s, v] }.to_h
24
25
  patch(batches_path(id), options)
25
26
  end
26
27
 
28
+ def delete_batch(id)
29
+ delete(batches_path(id))
30
+ end
31
+
27
32
  private
28
33
 
29
34
  def batches_path(id = nil)
@@ -3,17 +3,17 @@ module RockRMS
3
3
  module Donation
4
4
  def list_donations(options = {})
5
5
  res = get(transaction_path, options)
6
- RockRMS::Donation.format(res)
6
+ RockRMS::Responses::Donation.format(res)
7
7
  end
8
8
 
9
9
  def find_donations_by_giving_id(id, raw = false)
10
10
  res = get("FinancialTransactions/GetByGivingId/#{id}?$expand=TransactionDetails")
11
- raw ? res : RockRMS::Donation.format(res)
11
+ raw ? res : RockRMS::Responses::Donation.format(res)
12
12
  end
13
13
 
14
14
  def find_donation(id)
15
15
  res = get(transaction_path(id))
16
- RockRMS::Donation.format(res)
16
+ RockRMS::Responses::Donation.format(res)
17
17
  end
18
18
 
19
19
  def create_donation(
@@ -23,11 +23,14 @@ module RockRMS
23
23
  funds:,
24
24
  payment_type:,
25
25
  source_type_id: 10,
26
- transaction_code: nil
26
+ transaction_code: nil,
27
+ summary: nil,
28
+ recurring_donation_id: nil
27
29
  )
28
30
 
29
31
  options = {
30
32
  'AuthorizedPersonAliasId' => authorized_person_id,
33
+ 'ScheduledTransactionId' => recurring_donation_id,
31
34
  'BatchId' => batch_id,
32
35
  'FinancialPaymentDetailId' => payment_type,
33
36
  'TransactionCode' => transaction_code,
@@ -35,14 +38,18 @@ module RockRMS
35
38
  'TransactionDetails' => translate_funds(funds),
36
39
  'TransactionTypeValueId' => 53, # contribution, registration
37
40
  'SourceTypeValueId' => source_type_id, # website, kiosk, mobile app
41
+ 'Summary' => summary
38
42
  }
39
43
  post(transaction_path, options)
40
44
  end
41
45
 
42
- def update_donation(id, batch_id:)
43
- options = {
44
- 'BatchId' => batch_id
45
- }
46
+ def update_donation(id, batch_id: nil, summary: nil, recurring_donation_id: nil)
47
+ options = {}
48
+
49
+ options['Summary'] = summary if summary
50
+ options['BatchId'] = batch_id if batch_id
51
+ options['ScheduledTransactionId'] = recurring_donation_id if recurring_donation_id
52
+
46
53
  patch(transaction_path(id), options)
47
54
  end
48
55
 
@@ -7,13 +7,11 @@ module RockRMS
7
7
  person_id:)
8
8
  post(
9
9
  group_member_path,
10
- {
11
- IsSystem: false,
12
- GroupId: group_id,
13
- GroupMemberStatus: group_member_status,
14
- GroupRoleId: group_role_id,
15
- PersonId: person_id
16
- }
10
+ IsSystem: false,
11
+ GroupId: group_id,
12
+ GroupMemberStatus: group_member_status,
13
+ GroupRoleId: group_role_id,
14
+ PersonId: person_id
17
15
  )
18
16
  end
19
17
 
@@ -29,4 +27,3 @@ module RockRMS
29
27
  end
30
28
  end
31
29
  end
32
-
@@ -1,22 +1,26 @@
1
1
  module RockRMS
2
- class Donation
3
- def self.format(response)
4
- if response.is_a?(Array)
5
- response.map { |donation| format_donation(donation) }
6
- else
7
- format_donation(response)
2
+ module Responses
3
+ class Donation
4
+ def self.format(response)
5
+ if response.is_a?(Array)
6
+ response.map { |donation| format_donation(donation) }
7
+ else
8
+ format_donation(response)
9
+ end
8
10
  end
9
- end
10
11
 
11
- def self.format_donation(donation)
12
- {
13
- id: donation['Id'],
14
- date: donation['TransactionDateTime'],
15
- amount: donation['TransactionDetails'].reduce(0) { |sum, td| sum + td['Amount'] },
16
- person_id: donation['AuthorizedPersonAliasId'],
17
- fund: '',
18
- batch_id: donation['BatchId']
19
- }
12
+ def self.format_donation(donation)
13
+ {
14
+ id: donation['Id'],
15
+ date: donation['TransactionDateTime'],
16
+ amount: donation['TransactionDetails'].reduce(0) { |sum, td| sum + td['Amount'] },
17
+ person_id: donation['AuthorizedPersonAliasId'],
18
+ fund: '',
19
+ batch_id: donation['BatchId'],
20
+ recurring_donation_id: donation['ScheduledTransactionId'],
21
+ summary: donation['Summary']
22
+ }
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -2,14 +2,14 @@ module RockRMS
2
2
  module Responses
3
3
  class Group
4
4
  MAP = {
5
- id: "Id",
6
- name: "Name",
7
- group_type_id: "GroupTypeId",
8
- parent_group_id: "ParentGroupId",
9
- campus_id: "CampusId",
10
- is_active: "IsActive",
11
- guid: "Guid",
12
- members: "Members"
5
+ id: 'Id',
6
+ name: 'Name',
7
+ group_type_id: 'GroupTypeId',
8
+ parent_group_id: 'ParentGroupId',
9
+ campus_id: 'CampusId',
10
+ is_active: 'IsActive',
11
+ guid: 'Guid',
12
+ members: 'Members'
13
13
  }.freeze
14
14
 
15
15
  def self.format(data)
@@ -20,10 +20,8 @@ module RockRMS
20
20
  end
21
21
  end
22
22
 
23
- private
24
-
25
23
  def self.format_single(data)
26
- result = MAP.each.with_object({}) do |(l,r), object|
24
+ result = MAP.each.with_object({}) do |(l, r), object|
27
25
  object[l] = data[r]
28
26
  end
29
27
 
@@ -16,10 +16,8 @@ module RockRMS
16
16
  end
17
17
  end
18
18
 
19
- private
20
-
21
19
  def self.format_single(data)
22
- result = MAP.each.with_object({}) do |(l,r), object|
20
+ result = MAP.each.with_object({}) do |(l, r), object|
23
21
  object[l] = data[r]
24
22
  end
25
23
 
@@ -25,10 +25,8 @@ module RockRMS
25
25
  end
26
26
  end
27
27
 
28
- private
29
-
30
28
  def self.format_single(data)
31
- MAP.each.with_object({}) do |(l,r), object|
29
+ MAP.each.with_object({}) do |(l, r), object|
32
30
  object[l] = data[r]
33
31
  end
34
32
  end
@@ -20,10 +20,8 @@ module RockRMS
20
20
  end
21
21
  end
22
22
 
23
- private
24
-
25
23
  def self.format_single(data)
26
- MAP.each.with_object({}) do |(l,r), object|
24
+ MAP.each.with_object({}) do |(l, r), object|
27
25
  object[l] = data[r]
28
26
  end
29
27
  end
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
data/rock_rms.gemspec CHANGED
@@ -1,25 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "rock_rms/version"
4
- require "base64"
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'rock_rms/version'
3
+ require 'base64'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = "rock_rms"
6
+ s.name = 'rock_rms'
8
7
  s.version = RockRMS::VERSION
9
- s.authors = ["Taylor Brooks"]
10
- s.email = ["dGJyb29rc0BnbWFpbC5jb20="].map{ |e| Base64.decode64(e) }
11
- s.homepage = "https://github.com/taylorbrooks/rock_rms"
12
- s.summary = %q{A Ruby wrapper for the Rock RMS API}
13
- s.description = %q{A Ruby wrapper for the Rock RMS API -- a church management platform, simplified.}
14
- s.license = "MIT"
8
+ s.authors = ['Taylor Brooks']
9
+ s.email = ['dGJyb29rc0BnbWFpbC5jb20='].map { |e| Base64.decode64(e) }
10
+ s.homepage = 'https://github.com/taylorbrooks/rock_rms'
11
+ s.summary = 'A Ruby wrapper for the Rock RMS API'
12
+ s.description = 'A Ruby wrapper for the Rock RMS API -- a church management platform, simplified.'
13
+ s.license = 'MIT'
15
14
 
16
15
  s.files = `git ls-files`.split($/)
17
- s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
18
17
  s.test_files = s.files.grep(%r{^(test)/})
19
18
 
20
19
  s.required_ruby_version = '~> 2.2'
21
20
 
22
- s.require_paths = ["lib"]
21
+ s.require_paths = ['lib']
23
22
 
24
23
  s.add_runtime_dependency 'faraday'
25
24
  s.add_runtime_dependency 'faraday_middleware'
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
  require 'rack/utils'
3
3
 
4
4
  RSpec.describe RockRMS::Error do
5
- let(:client) {
5
+ let(:client) do
6
6
  RockRMS::Client.new(
7
7
  url: 'http://some-rock-uri.com',
8
8
  username: 'test',
9
9
  password: 'test',
10
10
  logger: false
11
11
  )
12
- }
12
+ end
13
13
 
14
14
  CODES = Rack::Utils::HTTP_STATUS_CODES.keys.freeze
15
15
 
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client::Batch, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#list_batches' do
7
+ it 'returns a array' do
8
+ resource = client.list_batches
9
+ expect(resource).to be_a(Array)
10
+ expect(resource.first).to be_a(Hash)
11
+ end
12
+ end
13
+
14
+ describe '#find_batch(id)' do
15
+ it 'returns a hash' do
16
+ expect(client.find_batch(123)).to be_a(Hash)
17
+ end
18
+
19
+ it 'queries groups' do
20
+ expect(client).to receive(:get).with('FinancialBatches/123')
21
+ .and_call_original
22
+
23
+ resource = client.find_batch(123)
24
+
25
+ expect(resource['Id']).to eq(123)
26
+ end
27
+ end
28
+
29
+ describe '#create_batch' do
30
+ context 'arguments' do
31
+ it 'require `name`' do
32
+ expect { client.create_batch }
33
+ .to raise_error(ArgumentError, /name/)
34
+ end
35
+
36
+ it 'require `start_time`' do
37
+ expect { client.create_batch }
38
+ .to raise_error(ArgumentError, /start_time/)
39
+ end
40
+
41
+ it 'require `end_time`' do
42
+ expect { client.create_batch }
43
+ .to raise_error(ArgumentError, /end_time/)
44
+ end
45
+ end
46
+
47
+ subject(:resource) do
48
+ client.create_batch(
49
+ name: '1',
50
+ start_time: '1',
51
+ end_time: '1',
52
+ foreign_key: 1
53
+ )
54
+ end
55
+
56
+ it 'returns integer' do
57
+ expect(resource).to be_a(Integer)
58
+ end
59
+
60
+ it 'passes options' do
61
+ expect(client).to receive(:post)
62
+ .with(
63
+ 'FinancialBatches',
64
+ 'Name' => '1',
65
+ 'BatchStartDateTime' => '1',
66
+ 'BatchEndDateTime' => '1',
67
+ 'ForeignKey' => 1
68
+ ).and_call_original
69
+ resource
70
+ end
71
+ end
72
+
73
+ describe '#update_batch' do
74
+ subject(:resource) do
75
+ client.update_batch(
76
+ 123,
77
+ 'Name' => '1',
78
+ 'ForeignKey': 1
79
+ )
80
+ end
81
+
82
+ it 'returns nothing' do
83
+ expect(client.update_batch(123)).to eq(nil)
84
+ end
85
+
86
+ it 'passes options' do
87
+ expect(client).to receive(:patch)
88
+ .with(
89
+ 'FinancialBatches/123',
90
+ 'Name' => '1',
91
+ 'ForeignKey' => 1
92
+ ).and_call_original
93
+ resource
94
+ end
95
+ end
96
+
97
+ describe '#delete_batch' do
98
+ it 'returns nothing' do
99
+ expect(client.delete_batch(123)).to eq(nil)
100
+ end
101
+
102
+ it 'passes id' do
103
+ expect(client).to receive(:delete).with('FinancialBatches/123')
104
+ client.delete_batch(123)
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,132 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client::Donation, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#list_donations' do
7
+ it 'returns a array' do
8
+ resource = client.list_donations
9
+ expect(resource).to be_a(Array)
10
+ expect(resource.first).to be_a(Hash)
11
+ end
12
+ end
13
+
14
+ describe '#find_donation(id)' do
15
+ it 'returns a hash' do
16
+ expect(client.find_donation(123)).to be_a(Hash)
17
+ end
18
+
19
+ it 'queries groups' do
20
+ expect(client).to receive(:get).with('FinancialTransactions/123')
21
+ .and_call_original
22
+
23
+ resource = client.find_donation(123)
24
+
25
+ expect(resource[:id]).to eq(1422)
26
+ end
27
+
28
+ it 'formats with Donation' do
29
+ response = double
30
+ expect(RockRMS::Responses::Donation).to receive(:format).with(response)
31
+ allow(client).to receive(:get).and_return(response)
32
+ client.find_donation(123)
33
+ end
34
+ end
35
+
36
+ describe '#create_donation' do
37
+ context 'arguments' do
38
+ it 'require `authorized_person_id`' do
39
+ expect { client.create_donation }
40
+ .to raise_error(ArgumentError, /authorized_person_id/)
41
+ end
42
+
43
+ it 'require `batch_id`' do
44
+ expect { client.create_donation }
45
+ .to raise_error(ArgumentError, /batch_id/)
46
+ end
47
+
48
+ it 'require `date`' do
49
+ expect { client.create_donation }
50
+ .to raise_error(ArgumentError, /date/)
51
+ end
52
+
53
+ it 'require `funds`' do
54
+ expect { client.create_donation }
55
+ .to raise_error(ArgumentError, /funds/)
56
+ end
57
+
58
+ end
59
+
60
+ subject(:resource) do
61
+ client.create_donation(
62
+ authorized_person_id: 1,
63
+ batch_id: 1,
64
+ date: 1,
65
+ funds: [{ amount: 450, fund_id: 2 }],
66
+ payment_type: 1,
67
+ transaction_code: 'asdf',
68
+ summary: 'taco tuesday',
69
+ recurring_donation_id: 1
70
+ )
71
+ end
72
+
73
+ it 'returns integer' do
74
+ expect(resource).to be_a(Integer)
75
+ end
76
+
77
+ it 'passes options' do
78
+ expect(client).to receive(:post)
79
+ .with(
80
+ 'FinancialTransactions',
81
+ 'AuthorizedPersonAliasId' => 1,
82
+ 'ScheduledTransactionId' => 1,
83
+ 'BatchId' => 1,
84
+ 'FinancialPaymentDetailId' => 1,
85
+ 'TransactionCode' => 'asdf',
86
+ 'TransactionDateTime' => 1,
87
+ 'TransactionDetails' => [{ 'Amount' => 450, 'AccountId' => 2 }],
88
+ 'TransactionTypeValueId' => 53,
89
+ 'SourceTypeValueId' => 10,
90
+ 'Summary' => 'taco tuesday'
91
+ )
92
+ .and_call_original
93
+ resource
94
+ end
95
+ end
96
+
97
+ describe '#update_donation' do
98
+ subject(:resource) do
99
+ client.update_donation(
100
+ 123,
101
+ batch_id: 1,
102
+ summary: 'taco tuesday'
103
+ )
104
+ end
105
+
106
+ it 'returns nothing' do
107
+ expect(client.update_donation(123)).to eq(nil)
108
+ end
109
+
110
+ it 'passes options' do
111
+ expect(client).to receive(:patch)
112
+ .with(
113
+ 'FinancialTransactions/123',
114
+ 'BatchId' => 1,
115
+ 'Summary' => 'taco tuesday'
116
+ )
117
+ .and_call_original
118
+ resource
119
+ end
120
+ end
121
+
122
+ describe '#delete_donation' do
123
+ it 'returns nothing' do
124
+ expect(client.delete_donation(123)).to eq(nil)
125
+ end
126
+
127
+ it 'passes id' do
128
+ expect(client).to receive(:delete).with('FinancialTransactions/123')
129
+ client.delete_donation(123)
130
+ end
131
+ end
132
+ end
@@ -31,7 +31,7 @@ RSpec.describe RockRMS::Client::GroupMember, type: :model do
31
31
  group_id: 123,
32
32
  group_member_status: 1,
33
33
  group_role_id: 456,
34
- person_id: 123456
34
+ person_id: 123_456
35
35
  )
36
36
  end
37
37
 
@@ -41,14 +41,14 @@ RSpec.describe RockRMS::Client::GroupMember, type: :model do
41
41
 
42
42
  it 'passes options' do
43
43
  expect(client).to receive(:post)
44
- .with('GroupMembers', {
44
+ .with(
45
+ 'GroupMembers',
45
46
  IsSystem: false,
46
47
  GroupId: 123,
47
48
  GroupMemberStatus: 1,
48
49
  GroupRoleId: 456,
49
- PersonId: 123456
50
- })
51
- .and_call_original
50
+ PersonId: 123_456
51
+ ).and_call_original
52
52
  resource
53
53
  end
54
54
  end
@@ -9,12 +9,11 @@ RSpec.describe RockRMS::Client::Group, type: :model do
9
9
  end
10
10
 
11
11
  it 'queries groups' do
12
- expect(client).to receive(:get).with('Groups/123')
13
- .and_call_original
12
+ expect(client).to receive(:get).with('Groups/123').and_call_original
14
13
 
15
14
  resource = client.find_group(123)
16
15
 
17
- expect(resource[:id]).to eq(112233)
16
+ expect(resource[:id]).to eq(112_233)
18
17
  end
19
18
 
20
19
  it 'formats with Group' do
@@ -33,14 +32,13 @@ RSpec.describe RockRMS::Client::Group, type: :model do
33
32
  end
34
33
 
35
34
  it 'queries groups' do
36
- expect(client).to receive(:get).with('Groups', {})
37
- .and_call_original
35
+ expect(client).to receive(:get).with('Groups', {}).and_call_original
38
36
  client.list_groups
39
37
  end
40
38
 
41
39
  it 'passes options' do
42
40
  expect(client).to receive(:get)
43
- .with('Groups', { option1: '1' })
41
+ .with('Groups', option1: '1')
44
42
  .and_return([])
45
43
  client.list_groups(option1: '1')
46
44
  end
@@ -89,14 +87,15 @@ RSpec.describe RockRMS::Client::Group, type: :model do
89
87
  end
90
88
 
91
89
  it 'queries families scoped to person' do
92
- expect(client).to receive(:get).with('Groups/GetFamilies/123', {})
90
+ expect(client).to receive(:get)
91
+ .with('Groups/GetFamilies/123', {})
93
92
  .and_call_original
94
93
  client.list_families_for_person(123)
95
94
  end
96
95
 
97
96
  it 'passes options' do
98
97
  expect(client).to receive(:get)
99
- .with('Groups/GetFamilies/123', { option1: '1' })
98
+ .with('Groups/GetFamilies/123', option1: '1')
100
99
  .and_return([])
101
100
  client.list_families_for_person(123, option1: '1')
102
101
  end
@@ -12,14 +12,13 @@ RSpec.describe RockRMS::Client::PhoneNumber, type: :model do
12
12
  end
13
13
 
14
14
  it 'queries phone numbers' do
15
- expect(client).to receive(:get).with('PhoneNumbers', {})
16
- .and_call_original
15
+ expect(client).to receive(:get).with('PhoneNumbers', {}).and_call_original
17
16
  resource
18
17
  end
19
18
 
20
19
  it 'passes options' do
21
20
  expect(client).to receive(:get)
22
- .with('PhoneNumbers', { option1: '1' })
21
+ .with('PhoneNumbers', option1: '1')
23
22
  .and_return([])
24
23
  client.list_phone_numbers(option1: '1')
25
24
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Responses::Donation, type: :model do
4
+ let(:parsed) { JSON.parse(FixturesHelper.read('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[:date]).to eq(p['TransactionDateTime'])
19
+ expect(r[:batch_id]).to eq(p['BatchId'])
20
+ expect(r[:recurring_donation_id]).to eq(p['ScheduledTransactionId'])
21
+ expect(r[:summary]).to eq(p['Summary'])
22
+ end
23
+ end
24
+ end
25
+ end
@@ -27,9 +27,9 @@ RSpec.describe RockRMS::Responses::GroupLocation, type: :model do
27
27
  parsed.first['Location'] = location
28
28
  expect(RockRMS::Responses::Location).to receive(:format)
29
29
  .with(location)
30
- .and_return({ some_key: :value })
30
+ .and_return(some_key: :value)
31
31
  result
32
- expect(result.first[:location]).to eq({ some_key: :value })
32
+ expect(result.first[:location]).to eq(some_key: :value)
33
33
  end
34
34
  end
35
35
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.unshift(File.join(__FILE__, "..", "..", "lib"))
1
+ $LOAD_PATH.unshift(File.join(__FILE__, '..', '..', 'lib'))
2
2
 
3
3
  SPEC_DIR = File.dirname(__FILE__)
4
4
  FIXTURES_DIR = File.join(SPEC_DIR, 'support', 'fixtures')
@@ -0,0 +1,24 @@
1
+ {
2
+ "ForeignGuid": null,
3
+ "ForeignId": null,
4
+ "ForeignKey": null,
5
+ "AttributeValues" : null,
6
+ "Attributes" : null,
7
+ "CreatedDateTime": null,
8
+ "ModifiedByPersonAliasId": null,
9
+ "ModifiedDateTime": null,
10
+ "AccountingSystemCode": null,
11
+ "Campus": null,
12
+ "CampusId": null,
13
+ "Note": null,
14
+ "Guid": "ce01d12e-dac1-4079-b454-ae5edbafb0df",
15
+ "Id": 123,
16
+ "CreatedByPersonAliasId": 1,
17
+ "ModifiedAuditValuesAlreadyUpdated": false,
18
+ "ControlAmount": 300.00,
19
+ "Name": "SampleData1357448400000",
20
+ "Status": "Closed",
21
+ "BatchEndDateTime": "2013-01-06T00:00:00",
22
+ "BatchStartDateTime": "2013-01-06T00:00:00",
23
+ "Transactions": []
24
+ }
@@ -0,0 +1,26 @@
1
+ [
2
+ {
3
+ "ForeignGuid": null,
4
+ "ForeignId": null,
5
+ "ForeignKey": null,
6
+ "AttributeValues" : null,
7
+ "Attributes" : null,
8
+ "CreatedDateTime": null,
9
+ "ModifiedByPersonAliasId": null,
10
+ "ModifiedDateTime": null,
11
+ "AccountingSystemCode": null,
12
+ "Campus": null,
13
+ "CampusId": null,
14
+ "Note": null,
15
+ "Guid": "ce01d12e-dac1-4079-b454-ae5edbafb0df",
16
+ "Id": 12312345,
17
+ "CreatedByPersonAliasId": 1,
18
+ "ModifiedAuditValuesAlreadyUpdated": false,
19
+ "ControlAmount": 300.00,
20
+ "Name": "SampleData1357448400000",
21
+ "Status": "Closed",
22
+ "BatchEndDateTime": "2013-01-06T00:00:00",
23
+ "BatchStartDateTime": "2013-01-06T00:00:00",
24
+ "Transactions": []
25
+ }
26
+ ]
@@ -0,0 +1 @@
1
+ 12345
@@ -0,0 +1 @@
1
+ 12345
@@ -0,0 +1,37 @@
1
+ {
2
+ "ForeignGuid": null,
3
+ "ForeignId": null,
4
+ "ForeignKey": null,
5
+ "Guid": "49fdc90aaabb",
6
+ "Id": 1422,
7
+ "AttributeValues": null,
8
+ "Attributes": null,
9
+ "CreatedByPersonAliasId": 1,
10
+ "CreatedDateTime": 727,
11
+ "ModifiedAuditValuesAlreadyUpdated": false,
12
+ "ModifiedByPersonAliasId": 1,
13
+ "ModifiedDateTime": 727,
14
+ "AuthorizedPersonAlias": null,
15
+ "AuthorizedPersonAliasId": 120,
16
+ "BatchId": 270,
17
+ "CheckMicrEncrypted": null,
18
+ "CheckMicrHash": null,
19
+ "CheckMicrParts": null,
20
+ "FinancialGateway": null,
21
+ "FinancialGatewayId": null,
22
+ "FinancialPaymentDetail": null,
23
+ "FinancialPaymentDetailId": 156,
24
+ "MICRStatus": null,
25
+ "ScheduledTransactionId": 1,
26
+ "SourceTypeValue": null,
27
+ "SourceTypeValueId": 10,
28
+ "Status": null,
29
+ "StatusMessage": null,
30
+ "Summary": "I shot the sheriff",
31
+ "SundayDate": "2013-01-06T00:00:00",
32
+ "TransactionCode": 1239,
33
+ "TransactionDateTime": "2013-01-06T00:00:00",
34
+ "TransactionTypeValue": null,
35
+ "TransactionDetails": [],
36
+ "TransactionTypeValueId": 53
37
+ }
@@ -0,0 +1,39 @@
1
+ [
2
+ {
3
+ "ForeignGuid": null,
4
+ "ForeignId": null,
5
+ "ForeignKey": null,
6
+ "Guid": "49fdc90aaabb",
7
+ "Id": 1422,
8
+ "AttributeValues": null,
9
+ "Attributes": null,
10
+ "CreatedByPersonAliasId": 1,
11
+ "CreatedDateTime": 727,
12
+ "ModifiedAuditValuesAlreadyUpdated": false,
13
+ "ModifiedByPersonAliasId": 1,
14
+ "ModifiedDateTime": 727,
15
+ "AuthorizedPersonAlias": null,
16
+ "AuthorizedPersonAliasId": 120,
17
+ "BatchId": 270,
18
+ "CheckMicrEncrypted": null,
19
+ "CheckMicrHash": null,
20
+ "CheckMicrParts": null,
21
+ "FinancialGateway": null,
22
+ "FinancialGatewayId": null,
23
+ "FinancialPaymentDetail": null,
24
+ "FinancialPaymentDetailId": 156,
25
+ "MICRStatus": null,
26
+ "ScheduledTransactionId": 1,
27
+ "SourceTypeValue": null,
28
+ "SourceTypeValueId": 10,
29
+ "Status": null,
30
+ "StatusMessage": null,
31
+ "Summary": "I shot the sheriff",
32
+ "SundayDate": "2013-01-06T00:00:00",
33
+ "TransactionCode": 1239,
34
+ "TransactionDateTime": "2013-01-06T00:00:00",
35
+ "TransactionTypeValue": null,
36
+ "TransactionDetails": [],
37
+ "TransactionTypeValueId": 53
38
+ }
39
+ ]
@@ -4,8 +4,10 @@ require_relative './fixtures_helper'
4
4
 
5
5
  class RockMock < Sinatra::Base
6
6
  # DELETE requests
7
- %w[
8
- GroupMembers/:id
7
+ [
8
+ 'FinancialBatches/:id',
9
+ 'FinancialTransactions/:id',
10
+ 'GroupMembers/:id'
9
11
  ].each do |end_point|
10
12
  delete "/api/#{end_point}" do
11
13
  content_type :json
@@ -15,6 +17,10 @@ class RockMock < Sinatra::Base
15
17
 
16
18
  # GET requests
17
19
  {
20
+ batch: 'FinancialBatches/:id',
21
+ batches: 'FinancialBatches',
22
+ donation: 'FinancialTransactions/:id',
23
+ donations: 'FinancialTransactions',
18
24
  families: 'Groups/GetFamilies/:id',
19
25
  group: 'Groups/:id',
20
26
  groups: 'Groups',
@@ -30,7 +36,9 @@ class RockMock < Sinatra::Base
30
36
 
31
37
  # POST requests
32
38
  {
33
- create_group_member: 'GroupMembers'
39
+ create_group_member: 'GroupMembers',
40
+ create_donation: 'FinancialTransactions',
41
+ create_batch: 'FinancialBatches'
34
42
  }.each do |json, end_point|
35
43
  post "/api/#{end_point}" do
36
44
  json_response 201, "#{json}.json"
@@ -39,7 +47,9 @@ class RockMock < Sinatra::Base
39
47
 
40
48
  # PATCH requests
41
49
  [
42
- 'FinancialScheduledTransactions/:id'
50
+ 'FinancialBatches/:id',
51
+ 'FinancialScheduledTransactions/:id',
52
+ 'FinancialTransactions/:id'
43
53
  ].each do |end_point|
44
54
  patch "/api/#{end_point}" do
45
55
  content_type :json
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rock_rms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
@@ -209,12 +209,15 @@ files:
209
209
  - rock_rms.gemspec
210
210
  - spec/rock_rms/client_spec.rb
211
211
  - spec/rock_rms/error_spec.rb
212
+ - spec/rock_rms/resources/batch_spec.rb
213
+ - spec/rock_rms/resources/donation_spec.rb
212
214
  - spec/rock_rms/resources/group_member_spec.rb
213
215
  - spec/rock_rms/resources/group_spec.rb
214
216
  - spec/rock_rms/resources/person_spec.rb
215
217
  - spec/rock_rms/resources/phone_number_spec.rb
216
218
  - spec/rock_rms/resources/recurring_donation_spec.rb
217
219
  - spec/rock_rms/responses/campus_spec.rb
220
+ - spec/rock_rms/responses/donation_spec.rb
218
221
  - spec/rock_rms/responses/group_location_spec.rb
219
222
  - spec/rock_rms/responses/group_spec.rb
220
223
  - spec/rock_rms/responses/location_spec.rb
@@ -224,8 +227,14 @@ files:
224
227
  - spec/rock_rms_spec.rb
225
228
  - spec/spec_helper.rb
226
229
  - spec/support/client_factory.rb
230
+ - spec/support/fixtures/batch.json
231
+ - spec/support/fixtures/batches.json
227
232
  - spec/support/fixtures/campuses.json
233
+ - spec/support/fixtures/create_batch.json
234
+ - spec/support/fixtures/create_donation.json
228
235
  - spec/support/fixtures/create_group_member.json
236
+ - spec/support/fixtures/donation.json
237
+ - spec/support/fixtures/donations.json
229
238
  - spec/support/fixtures/families.json
230
239
  - spec/support/fixtures/group.json
231
240
  - spec/support/fixtures/group_locations.json