rock_rms 8.5.0 → 8.7.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 +4 -4
- data/README.md +7 -0
- data/lib/rock_rms/client.rb +15 -6
- data/lib/rock_rms/error.rb +1 -1
- data/lib/rock_rms/parse_oj.rb +13 -5
- data/lib/rock_rms/resources/group.rb +17 -0
- data/lib/rock_rms/resources/transaction.rb +3 -1
- data/lib/rock_rms/response/person.rb +2 -1
- data/lib/rock_rms/transform_hash_keys.rb +11 -0
- data/lib/rock_rms/version.rb +1 -1
- data/rock_rms.gemspec +1 -2
- data/spec/rock_rms/client_spec.rb +11 -8
- data/spec/rock_rms/resources/group_spec.rb +31 -0
- data/spec/support/fixtures/group_save_address.json +0 -0
- data/spec/support/rock_mock.rb +9 -0
- metadata +8 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e043a1d0535862e33752e94420a46d88c9f4fea44a35dfe89e2107f6d5123f98
|
|
4
|
+
data.tar.gz: d444592864acd5d433e0d0dae2524148626e794f49981a92ca8f6bab50a5a8cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f182e50f62ba496c0b164201731a62261262be9e8b12b54fba9c94c015b83beb704183761524cb1230f6ca9835c985509c3884737dbfef11f61e66e53fb10097
|
|
7
|
+
data.tar.gz: c239b799deec1dacfd080f93191dfe4afaa7de7a4791a7421c835a314dfe91c89d5b0be54bcd4472f9a92b3301a379d736ce833d89abad2f31affa41f17cbc66
|
data/README.md
CHANGED
|
@@ -22,12 +22,19 @@ Add this line to your application's Gemfile:
|
|
|
22
22
|
|
|
23
23
|
### Usage
|
|
24
24
|
````ruby
|
|
25
|
+
# Authenticating with username and password
|
|
25
26
|
client = RockRMS::Client.new(
|
|
26
27
|
url: ...,
|
|
27
28
|
username: ...,
|
|
28
29
|
password: ...,
|
|
29
30
|
)
|
|
30
31
|
|
|
32
|
+
# Authenticating with authorization token
|
|
33
|
+
client = RockRMS::Client.new(
|
|
34
|
+
url: ...,
|
|
35
|
+
authorization_token: ...,
|
|
36
|
+
)
|
|
37
|
+
|
|
31
38
|
# Find a specific person
|
|
32
39
|
client.find_person_by_email('gob@bluthco.com')
|
|
33
40
|
client.find_person_by_name('Tobias Funke')
|
data/lib/rock_rms/client.rb
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
require 'faraday'
|
|
2
|
-
require 'faraday_middleware'
|
|
3
2
|
require 'faraday/multipart'
|
|
4
3
|
|
|
5
4
|
Dir[File.expand_path('../resources/*.rb', __FILE__)].each { |f| require f }
|
|
6
5
|
require File.expand_path('../response/base.rb', __FILE__)
|
|
6
|
+
require File.expand_path('../transform_hash_keys.rb', __FILE__)
|
|
7
7
|
require File.expand_path('../recurring_frequencies.rb', __FILE__)
|
|
8
8
|
Dir[File.expand_path('../response/*.rb', __FILE__)].each { |f| require f }
|
|
9
9
|
|
|
10
10
|
module RockRMS
|
|
11
11
|
class Client
|
|
12
|
+
include TransformHashKeys
|
|
12
13
|
include RecurringFrequencies
|
|
13
14
|
include RockRMS::Client::Attribute
|
|
14
15
|
include RockRMS::Client::AttributeValue
|
|
@@ -46,16 +47,21 @@ module RockRMS
|
|
|
46
47
|
include RockRMS::Client::WorkflowActivityType
|
|
47
48
|
include RockRMS::Client::WorkflowType
|
|
48
49
|
|
|
49
|
-
attr_reader :url, :username, :password, :logger, :cookie, :connection, :adapter, :ssl
|
|
50
|
+
attr_reader :url, :username, :password, :logger, :cookie, :connection, :adapter, :ssl, :authorization_token
|
|
51
|
+
|
|
52
|
+
def initialize(url:, username: nil, password: nil, authorization_token: nil, logger: true, adapter: Faraday.default_adapter, ssl: nil)
|
|
53
|
+
if username.nil? && password.nil? && authorization_token.nil?
|
|
54
|
+
raise ArgumentError, 'either username and password or authorization_token is required'
|
|
55
|
+
end
|
|
50
56
|
|
|
51
|
-
def initialize(url:, username:, password:, logger: true, adapter: Faraday.default_adapter, ssl: nil)
|
|
52
57
|
@url = "#{url}/api/"
|
|
53
|
-
@username = username
|
|
54
|
-
@password = password
|
|
58
|
+
@username = username unless authorization_token
|
|
59
|
+
@password = password unless authorization_token
|
|
60
|
+
@authorization_token = authorization_token unless username && password
|
|
55
61
|
@logger = logger
|
|
56
62
|
@adapter = adapter
|
|
57
63
|
@ssl = ssl
|
|
58
|
-
@cookie = auth['set-cookie']
|
|
64
|
+
@cookie = auth['set-cookie'] unless auth.nil?
|
|
59
65
|
end
|
|
60
66
|
|
|
61
67
|
def delete(path, options = {})
|
|
@@ -81,6 +87,8 @@ module RockRMS
|
|
|
81
87
|
private
|
|
82
88
|
|
|
83
89
|
def auth
|
|
90
|
+
return nil if username.nil? && password.nil?
|
|
91
|
+
|
|
84
92
|
begin
|
|
85
93
|
auth_request('Auth/Login')
|
|
86
94
|
rescue Faraday::ParsingError => e
|
|
@@ -108,6 +116,7 @@ module RockRMS
|
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
headers['Cookie'] = cookie if cookie
|
|
119
|
+
headers['Authorization-Token'] = authorization_token if authorization_token
|
|
111
120
|
|
|
112
121
|
client_opts = {
|
|
113
122
|
url: url,
|
data/lib/rock_rms/error.rb
CHANGED
data/lib/rock_rms/parse_oj.rb
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'oj'
|
|
2
2
|
|
|
3
3
|
module FaradayMiddleware
|
|
4
|
-
class ParseOj <
|
|
5
|
-
|
|
4
|
+
class ParseOj < Faraday::Middleware
|
|
5
|
+
def on_complete(env)
|
|
6
|
+
if empty_body?(env[:body].strip)
|
|
7
|
+
env[:body] = nil
|
|
8
|
+
else
|
|
9
|
+
env[:body] = Oj.load(env[:body], mode: :compat)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|
|
15
|
+
def empty_body?(body)
|
|
16
|
+
body.empty? && body == ''
|
|
9
17
|
end
|
|
10
18
|
end
|
|
11
19
|
end
|
|
@@ -25,6 +25,23 @@ module RockRMS
|
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
#
|
|
29
|
+
# address_format
|
|
30
|
+
# {
|
|
31
|
+
# street1:,
|
|
32
|
+
# street2:,
|
|
33
|
+
# city:,
|
|
34
|
+
# state:,
|
|
35
|
+
# postal_code:,
|
|
36
|
+
# country:,
|
|
37
|
+
# }
|
|
38
|
+
#
|
|
39
|
+
def save_group_address(group_id:, location_type_id:, address:)
|
|
40
|
+
url_params = TransformHashKeys.camelize_keys(address)
|
|
41
|
+
|
|
42
|
+
put("Groups/SaveAddress/#{group_id}/#{location_type_id}?#{URI.encode_www_form(url_params)}")
|
|
43
|
+
end
|
|
44
|
+
|
|
28
45
|
private
|
|
29
46
|
|
|
30
47
|
def group_path(id = nil)
|
|
@@ -58,7 +58,8 @@ module RockRMS
|
|
|
58
58
|
transaction_code: nil,
|
|
59
59
|
transaction_type_value_id: nil,
|
|
60
60
|
authorized_person_id: nil,
|
|
61
|
-
date: nil
|
|
61
|
+
date: nil,
|
|
62
|
+
foreign_currency_code_value_id: nil
|
|
62
63
|
)
|
|
63
64
|
options = {}
|
|
64
65
|
|
|
@@ -71,6 +72,7 @@ module RockRMS
|
|
|
71
72
|
options['TransactionCode'] = transaction_code if transaction_code
|
|
72
73
|
options['AuthorizedPersonAliasId'] = authorized_person_id if authorized_person_id
|
|
73
74
|
options['TransactionDateTime'] = date if date
|
|
75
|
+
options['ForeignCurrencyCodeValueId'] = foreign_currency_code_value_id if foreign_currency_code_value_id
|
|
74
76
|
|
|
75
77
|
patch(transaction_path(id), options)
|
|
76
78
|
end
|
|
@@ -11,7 +11,8 @@ module RockRMS
|
|
|
11
11
|
giving_group_id: 'GivingGroupId',
|
|
12
12
|
alias_id: 'PrimaryAliasId',
|
|
13
13
|
connection_status_value_id: 'ConnectionStatusValueId',
|
|
14
|
-
record_type_value_id: 'RecordTypeValueId'
|
|
14
|
+
record_type_value_id: 'RecordTypeValueId',
|
|
15
|
+
primary_family_id: 'PrimaryFamilyId',
|
|
15
16
|
}.freeze
|
|
16
17
|
|
|
17
18
|
def format_single(data)
|
data/lib/rock_rms/version.rb
CHANGED
data/rock_rms.gemspec
CHANGED
|
@@ -20,8 +20,7 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
|
|
21
21
|
s.require_paths = ['lib']
|
|
22
22
|
|
|
23
|
-
s.add_runtime_dependency 'faraday'
|
|
24
|
-
s.add_runtime_dependency 'faraday_middleware'
|
|
23
|
+
s.add_runtime_dependency 'faraday', '> 2.0'
|
|
25
24
|
s.add_runtime_dependency 'faraday-multipart'
|
|
26
25
|
s.add_runtime_dependency 'json'
|
|
27
26
|
s.add_runtime_dependency 'oj'
|
|
@@ -9,6 +9,14 @@ RSpec.describe RockRMS::Client do
|
|
|
9
9
|
}
|
|
10
10
|
end
|
|
11
11
|
let(:attrs_without_logging) { attrs.merge(logger: false) }
|
|
12
|
+
let(:attrs_without_authentication) do
|
|
13
|
+
{
|
|
14
|
+
url: 'http://some-rock-uri.com',
|
|
15
|
+
username: nil,
|
|
16
|
+
password: nil,
|
|
17
|
+
authorization_token: nil
|
|
18
|
+
}
|
|
19
|
+
end
|
|
12
20
|
|
|
13
21
|
subject(:client) { described_class.new(**attrs_without_logging) }
|
|
14
22
|
let(:noisy_client) { described_class.new(**attrs) }
|
|
@@ -19,14 +27,9 @@ RSpec.describe RockRMS::Client do
|
|
|
19
27
|
.to raise_error(ArgumentError, /url/)
|
|
20
28
|
end
|
|
21
29
|
|
|
22
|
-
it 'requries `username` param' do
|
|
23
|
-
expect { described_class.new }
|
|
24
|
-
.to raise_error(ArgumentError, /username/)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'requries `password` param' do
|
|
28
|
-
expect { described_class.new }
|
|
29
|
-
.to raise_error(ArgumentError, /password/)
|
|
30
|
+
it 'requries either `username` and `password` params or `authorization_token` param' do
|
|
31
|
+
expect { described_class.new(attrs_without_authentication) }
|
|
32
|
+
.to raise_error(ArgumentError, /username and password or authorization_token/)
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
context 'url' do
|
|
@@ -107,4 +107,35 @@ RSpec.describe RockRMS::Client::Group, type: :model do
|
|
|
107
107
|
client.list_families_for_person(123)
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
describe '#save_address' do
|
|
113
|
+
context 'arguments' do
|
|
114
|
+
it 'require `group_id`' do
|
|
115
|
+
expect { client.save_group_address }
|
|
116
|
+
.to raise_error(ArgumentError, /group_id/)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'require `location_type_id`' do
|
|
120
|
+
expect { client.save_group_address }
|
|
121
|
+
.to raise_error(ArgumentError, /location_type_id/)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'require `address`' do
|
|
125
|
+
expect { client.save_group_address }
|
|
126
|
+
.to raise_error(ArgumentError, /address/)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
subject(:resource) do
|
|
132
|
+
client.save_group_address(group_id: 1, location_type_id: 1, address: { street1: '123 Main St', postal_code: '12345' })
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'passes options' do
|
|
136
|
+
expect(client).to receive(:put)
|
|
137
|
+
.with("Groups/SaveAddress/1/1?street1=123+Main+St&postalCode=12345").and_call_original
|
|
138
|
+
resource
|
|
139
|
+
end
|
|
140
|
+
end
|
|
110
141
|
end
|
|
File without changes
|
data/spec/support/rock_mock.rb
CHANGED
|
@@ -76,6 +76,15 @@ class RockMock < Sinatra::Base
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
# PUT requests
|
|
80
|
+
{
|
|
81
|
+
group_save_address: 'Groups/SaveAddress/:group_id/:location_type_id',
|
|
82
|
+
}.each do |json, end_point|
|
|
83
|
+
put "/api/#{end_point}" do
|
|
84
|
+
json_response 204, "#{json}.json"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
79
88
|
# PATCH requests
|
|
80
89
|
[
|
|
81
90
|
'FinancialBatches/:id',
|
metadata
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rock_rms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.
|
|
4
|
+
version: 8.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: 2023-04-
|
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
17
|
+
- - ">"
|
|
25
18
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: faraday_middleware
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
19
|
+
version: '2.0'
|
|
34
20
|
type: :runtime
|
|
35
21
|
prerelease: false
|
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
23
|
requirements:
|
|
38
|
-
- - "
|
|
24
|
+
- - ">"
|
|
39
25
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
26
|
+
version: '2.0'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: faraday-multipart
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -270,6 +256,7 @@ files:
|
|
|
270
256
|
- lib/rock_rms/response/workflow_action_type.rb
|
|
271
257
|
- lib/rock_rms/response/workflow_activity_type.rb
|
|
272
258
|
- lib/rock_rms/response/workflow_type.rb
|
|
259
|
+
- lib/rock_rms/transform_hash_keys.rb
|
|
273
260
|
- lib/rock_rms/version.rb
|
|
274
261
|
- rock_rms.gemspec
|
|
275
262
|
- spec/rock_rms/client_spec.rb
|
|
@@ -340,6 +327,7 @@ files:
|
|
|
340
327
|
- spec/support/fixtures/group.json
|
|
341
328
|
- spec/support/fixtures/group_locations.json
|
|
342
329
|
- spec/support/fixtures/group_members.json
|
|
330
|
+
- spec/support/fixtures/group_save_address.json
|
|
343
331
|
- spec/support/fixtures/groups.json
|
|
344
332
|
- spec/support/fixtures/groups_with_campus.json
|
|
345
333
|
- spec/support/fixtures/groups_with_locations.json
|