rock_rms 4.0.0 → 4.1.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: a826c9dad155cd2dde1432bcf622307375bc5e16
4
- data.tar.gz: e5053d52043a7c4b7bc5e8a8089c4abc8623b2a9
3
+ metadata.gz: ed6a5d3502d7ae87cf56e2878a156176052aab6e
4
+ data.tar.gz: 0ff8631bc4df0fbc08a00baffe6b80d849a75caf
5
5
  SHA512:
6
- metadata.gz: abfce0335816d7d9ec0235fd08424781b75287a13c68acbfd86d4d6bd3c3dd365adafbc013eab222dfb3eb25080466249d8df999a0d57a31190a551b46ddeab2
7
- data.tar.gz: 11c7835281d1a541223d726125032d1508a40a054a2d25a659204f5396f8f591972c849a0fd33290c597b936b79a850b57a690faff3319e972d7554ab2d2f09d
6
+ metadata.gz: b9003d89888260cf0b0def946934ad0d87c8ec919ef353afb602ca6f8be0ee99faddd06ef33a26d5c9bc052b546cf84e1dee829dbfa33f7756097b342f125fa0
7
+ data.tar.gz: f4c08be6dd30bbd212a3edc0c85d4dba31693d5d8cd0acad9e8f582c14f6bb9be380567893d300406fe84075157a2f2f2db4aaba1c2137a5134a1ccc4f5aebf0
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', '~> 4.0'
17
+ gem 'rock_rms', '~> 4.1'
18
18
 
19
19
  # then...
20
20
  bundle install
@@ -8,6 +8,8 @@ Dir[File.expand_path('../response/*.rb', __FILE__)].each { |f| require f }
8
8
 
9
9
  module RockRMS
10
10
  class Client
11
+ include RockRMS::Client::Attribute
12
+ include RockRMS::Client::AttributeValue
11
13
  include RockRMS::Client::Batch
12
14
  include RockRMS::Client::Fund
13
15
  include RockRMS::Client::Campus
@@ -0,0 +1,37 @@
1
+ module RockRMS
2
+ class Client
3
+ module Attribute
4
+ def list_attributes(options = {})
5
+ Response::Attribute.format(
6
+ get(attributes_path, options)
7
+ )
8
+ end
9
+
10
+ def create_attribute(
11
+ description: nil,
12
+ field_type_id:,
13
+ entity_type_id:,
14
+ key:,
15
+ name:,
16
+ order: Random.rand(100..1000)
17
+ )
18
+ options = {
19
+ 'FieldTypeId' => field_type_id,
20
+ 'EntityTypeId' => entity_type_id,
21
+ 'Key' => key,
22
+ 'Name' => name,
23
+ 'Description' => description,
24
+ 'Order' => order
25
+ }
26
+
27
+ post(attributes_path, options)
28
+ end
29
+
30
+ private
31
+
32
+ def attributes_path
33
+ 'Attributes'.freeze
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,28 @@
1
+ module RockRMS
2
+ class Client
3
+ module AttributeValue
4
+ def list_attribute_values(options = {})
5
+ Response::AttributeValue.format(
6
+ get(attribute_values_path, options)
7
+ )
8
+ end
9
+
10
+ def create_attribute_value(attribute_id:, entity_id:, value:)
11
+ options = {
12
+ 'AttributeId' => attribute_id,
13
+ 'EntityId' => entity_id,
14
+ 'Value' => value,
15
+ 'IsSystem' => false
16
+ }
17
+
18
+ post(attribute_values_path, options)
19
+ end
20
+
21
+ private
22
+
23
+ def attribute_values_path
24
+ 'AttributeValues'.freeze
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ module RockRMS
2
+ module Response
3
+ class Attribute < Base
4
+ MAP = {
5
+ id: 'Id',
6
+ name: 'Name',
7
+ key: 'Key',
8
+ description: 'Description'
9
+ }.freeze
10
+
11
+ def format_single(data)
12
+ to_h(MAP, data)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module RockRMS
2
+ module Response
3
+ class AttributeValue < Base
4
+ MAP = {
5
+ id: 'Id',
6
+ value: 'Value',
7
+ value_as_number: 'ValueAsNumeric',
8
+ entity_id: 'EntityId'
9
+ }.freeze
10
+
11
+ def format_single(data)
12
+ to_h(MAP, data)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module RockRMS
2
- VERSION = '4.0.0'.freeze
2
+ VERSION = '4.1.0'.freeze
3
3
  end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client::Attribute, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#list_attributes' do
7
+ it 'returns a array' do
8
+ resource = client.list_attributes
9
+ expect(resource).to be_a(Array)
10
+ expect(resource.first).to be_a(Hash)
11
+ end
12
+ end
13
+
14
+ describe '#create_attribute' do
15
+ context 'arguments' do
16
+ it 'require `field_type_id`' do
17
+ expect { client.create_attribute }
18
+ .to raise_error(ArgumentError, /field_type_id/)
19
+ end
20
+
21
+ it 'require `entity_type_id`' do
22
+ expect { client.create_attribute }
23
+ .to raise_error(ArgumentError, /entity_type_id/)
24
+ end
25
+
26
+ it 'require `key`' do
27
+ expect { client.create_attribute }
28
+ .to raise_error(ArgumentError, /key/)
29
+ end
30
+
31
+ it 'require `name`' do
32
+ expect { client.create_attribute }
33
+ .to raise_error(ArgumentError, /name/)
34
+ end
35
+ end
36
+
37
+ subject(:resource) do
38
+ client.create_attribute(
39
+ key: 'TransactionFee',
40
+ name: 'Transaction Fee',
41
+ entity_type_id: 85,
42
+ field_type_id: 14,
43
+ description: 'Transaction fees for a specific gateway',
44
+ order: 1234
45
+ )
46
+ end
47
+
48
+ it 'returns integer' do
49
+ expect(resource).to be_a(Integer)
50
+ end
51
+
52
+ it 'passes options' do
53
+ expect(client).to receive(:post)
54
+ .with(
55
+ 'Attributes',
56
+ 'FieldTypeId' => 14,
57
+ 'EntityTypeId' => 85,
58
+ 'Key' => 'TransactionFee',
59
+ 'Name' => 'Transaction Fee',
60
+ 'Description' => 'Transaction fees for a specific gateway',
61
+ 'Order' => 1234
62
+ )
63
+ .and_call_original
64
+ resource
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Client::AttributeValue, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#list_attribute_values' do
7
+ it 'returns a array' do
8
+ resource = client.list_attribute_values
9
+ expect(resource).to be_a(Array)
10
+ expect(resource.first).to be_a(Hash)
11
+ end
12
+ end
13
+
14
+ describe '#create_attribute_value' do
15
+ context 'arguments' do
16
+ it 'require `attribute_id`' do
17
+ expect { client.create_attribute_value }
18
+ .to raise_error(ArgumentError, /attribute_id/)
19
+ end
20
+
21
+ it 'require `entity_id`' do
22
+ expect { client.create_attribute_value }
23
+ .to raise_error(ArgumentError, /entity_id/)
24
+ end
25
+
26
+ it 'require `value`' do
27
+ expect { client.create_attribute_value }
28
+ .to raise_error(ArgumentError, /value/)
29
+ end
30
+ end
31
+
32
+ subject(:resource) do
33
+ client.create_attribute_value(
34
+ attribute_id: 12993,
35
+ entity_id: 731,
36
+ value: 100
37
+ )
38
+ end
39
+
40
+ it 'returns integer' do
41
+ expect(resource).to be_a(Integer)
42
+ end
43
+
44
+ it 'passes options' do
45
+ expect(client).to receive(:post)
46
+ .with(
47
+ 'AttributeValues',
48
+ 'AttributeId' => 12993,
49
+ 'EntityId' => 731,
50
+ 'Value' => 100,
51
+ 'IsSystem' => false
52
+ )
53
+ .and_call_original
54
+ resource
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Response::Attribute, type: :model do
4
+ let(:parsed) { JSON.parse(FixturesHelper.read('attributes.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[:name]).to eq(p['Name'])
19
+ expect(r[:key]).to eq(p['Key'])
20
+ expect(r[:description]).to eq(p['Description'])
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RockRMS::Response::AttributeValue, type: :model do
4
+ let(:parsed) { JSON.parse(FixturesHelper.read('attribute_values.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 'has the correct number keys' do
16
+ keys = result.first.keys
17
+ expect(keys.count).to eq(4)
18
+ end
19
+
20
+ it 'translates keys' do
21
+ result.zip(parsed) do |r, p|
22
+ expect(r[:id]).to eq(p['Id'])
23
+ expect(r[:value]).to eq(p['Value'])
24
+ expect(r[:value_as_number]).to eq(p['ValueAsNumeric'])
25
+ expect(r[:entity_id]).to eq(p['EntityId'])
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "IsSystem": false,
4
+ "AttributeId": 12993,
5
+ "EntityId": 731,
6
+ "Value": "23",
7
+ "ValueAsNumeric": 23.0000,
8
+ "ValueAsBoolean": false,
9
+ "CreatedDateTime": "2018-04-13T07:22:23.723",
10
+ "ModifiedDateTime": "2018-04-13T07:22:23.723",
11
+ "CreatedByPersonAliasId": 1,
12
+ "ModifiedByPersonAliasId": 1,
13
+ "ModifiedAuditValuesAlreadyUpdated": false,
14
+ "Id": 11615,
15
+ "Guid": "70d06b09-97cd-4788-9667-6f0b11dcde70"
16
+ }
17
+ ]
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "IsSystem": false,
4
+ "FieldTypeId": 14,
5
+ "EntityTypeId": 85,
6
+ "EntityTypeQualifierColumn": "",
7
+ "EntityTypeQualifierValue": "",
8
+ "Key": "TransactionFee",
9
+ "Name": "Transaction Fee",
10
+ "Description": "",
11
+ "Order": 1001,
12
+ "IsGridColumn": false,
13
+ "DefaultValue": "",
14
+ "IsMultiValue": false,
15
+ "IsRequired": false,
16
+ "IconCssClass": "",
17
+ "AllowSearch": false,
18
+ "IsIndexEnabled": false,
19
+ "IsAnalytic": false,
20
+ "IsAnalyticHistory": false,
21
+ "EntityType": null,
22
+ "AttributeQualifiers": [],
23
+ "FieldType": null,
24
+ "Categories": [],
25
+ "CreatedDateTime": "2018-04-13T07:01:36.123",
26
+ "ModifiedDateTime": "2018-04-13T07:01:36.123",
27
+ "CreatedByPersonAliasId": 1,
28
+ "ModifiedByPersonAliasId": 1,
29
+ "ModifiedAuditValuesAlreadyUpdated": false,
30
+ "Attributes": null,
31
+ "AttributeValues": null,
32
+ "Id": 12993,
33
+ "Guid": "35a283dd-f411-427a-9296-da37007efe93",
34
+ "ForeignId": null,
35
+ "ForeignGuid": null,
36
+ "ForeignKey": null
37
+ }
38
+ ]
@@ -19,6 +19,8 @@ class RockMock < Sinatra::Base
19
19
 
20
20
  # GET requests
21
21
  {
22
+ attributes: 'Attributes',
23
+ attribute_values: 'AttributeValues',
22
24
  batch: 'FinancialBatches/:id',
23
25
  batches: 'FinancialBatches',
24
26
  campus: 'Campuses/:id',
@@ -46,6 +48,8 @@ class RockMock < Sinatra::Base
46
48
 
47
49
  # POST requests
48
50
  {
51
+ create_attribute: 'Attributes',
52
+ create_attribute_value: 'AttributeValues',
49
53
  create_group_member: 'GroupMembers',
50
54
  create_transaction: 'FinancialTransactions',
51
55
  create_payment_detail: 'FinancialPaymentDetails',
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: 4.0.0
4
+ version: 4.1.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-11 00:00:00.000000000 Z
11
+ date: 2018-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -184,6 +184,8 @@ files:
184
184
  - lib/rock_rms.rb
185
185
  - lib/rock_rms/client.rb
186
186
  - lib/rock_rms/error.rb
187
+ - lib/rock_rms/resources/attribute.rb
188
+ - lib/rock_rms/resources/attribute_value.rb
187
189
  - lib/rock_rms/resources/batch.rb
188
190
  - lib/rock_rms/resources/campus.rb
189
191
  - lib/rock_rms/resources/fund.rb
@@ -199,6 +201,8 @@ files:
199
201
  - lib/rock_rms/resources/saved_payment_method.rb
200
202
  - lib/rock_rms/resources/transaction.rb
201
203
  - lib/rock_rms/resources/transaction_detail.rb
204
+ - lib/rock_rms/response/attribute.rb
205
+ - lib/rock_rms/response/attribute_value.rb
202
206
  - lib/rock_rms/response/base.rb
203
207
  - lib/rock_rms/response/batch.rb
204
208
  - lib/rock_rms/response/campus.rb
@@ -220,6 +224,8 @@ files:
220
224
  - rock_rms.gemspec
221
225
  - spec/rock_rms/client_spec.rb
222
226
  - spec/rock_rms/error_spec.rb
227
+ - spec/rock_rms/resources/attribute_spec.rb
228
+ - spec/rock_rms/resources/attribute_values_spec.rb
223
229
  - spec/rock_rms/resources/batch_spec.rb
224
230
  - spec/rock_rms/resources/campus_spec.rb
225
231
  - spec/rock_rms/resources/gateway_spec.rb
@@ -234,6 +240,8 @@ files:
234
240
  - spec/rock_rms/resources/saved_payment_method_spec.rb
235
241
  - spec/rock_rms/resources/transaction_detail_spec.rb
236
242
  - spec/rock_rms/resources/transaction_spec.rb
243
+ - spec/rock_rms/response/attribute_spec.rb
244
+ - spec/rock_rms/response/attribute_value_spec.rb
237
245
  - spec/rock_rms/response/batch_spec.rb
238
246
  - spec/rock_rms/response/campus_spec.rb
239
247
  - spec/rock_rms/response/group_location_spec.rb
@@ -248,10 +256,14 @@ files:
248
256
  - spec/rock_rms_spec.rb
249
257
  - spec/spec_helper.rb
250
258
  - spec/support/client_factory.rb
259
+ - spec/support/fixtures/attribute_values.json
260
+ - spec/support/fixtures/attributes.json
251
261
  - spec/support/fixtures/batch.json
252
262
  - spec/support/fixtures/batches.json
253
263
  - spec/support/fixtures/campus.json
254
264
  - spec/support/fixtures/campuses.json
265
+ - spec/support/fixtures/create_attribute.json
266
+ - spec/support/fixtures/create_attribute_value.json
255
267
  - spec/support/fixtures/create_batch.json
256
268
  - spec/support/fixtures/create_group_member.json
257
269
  - spec/support/fixtures/create_payment_detail.json