virtuous 0.0.2 → 0.0.3

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.
@@ -0,0 +1,93 @@
1
+ {
2
+ "list": [
3
+ {
4
+ "id": 1,
5
+ "name": "Test project 1",
6
+ "projectCode": "test_project_1",
7
+ "externalAccountingCode": null,
8
+ "onlineDisplayName": null,
9
+ "description": null,
10
+ "photoUrl": null,
11
+ "parentId": null,
12
+ "parentName": null,
13
+ "isSubProject": false,
14
+ "inventoryStatus": null,
15
+ "type": null,
16
+ "location": null,
17
+ "isRestrictedToGiftSpecifications": false,
18
+ "isLimitedToFinancialNeed": false,
19
+ "isPublic": true,
20
+ "isActive": true,
21
+ "isAvailableOnline": true,
22
+ "isTaxDeductible": true,
23
+ "treatAsAccountsPayable": false,
24
+ "beginningBalance": 0.0,
25
+ "currentBalance": 123.123,
26
+ "financialNeedType": null,
27
+ "financialNeedFrequency": null,
28
+ "financialNeedAmount": 0.0,
29
+ "startDate": "2023-12-08T00:00:00",
30
+ "endDate": "2024-12-08T00:00:00",
31
+ "durationType": null,
32
+ "lifeToDateGiving": null,
33
+ "lifeToDateGiftCount": null,
34
+ "lifeToDateGiversCount": null,
35
+ "lifeToDateExpenseTotal": null,
36
+ "calendarYearToDateGiving": null,
37
+ "calendarYearToDateGiftCount": null,
38
+ "calendarYearToDateGiversCount": null,
39
+ "calendarYearToDateExpenseTotal": null,
40
+ "createDateTimeUtc": "2023-12-08T00:00:00",
41
+ "createdByUser": "Test User",
42
+ "modifiedDateTimeUtc": "2023-12-08T00:00:00",
43
+ "modifiedByUser": "Test User",
44
+ "giftSpecifications": [],
45
+ "customFields": {}
46
+ },
47
+ {
48
+ "id": 2,
49
+ "name": "Test project 2",
50
+ "projectCode": "test_project_2",
51
+ "externalAccountingCode": null,
52
+ "onlineDisplayName": null,
53
+ "description": null,
54
+ "photoUrl": null,
55
+ "parentId": null,
56
+ "parentName": null,
57
+ "isSubProject": false,
58
+ "inventoryStatus": null,
59
+ "type": null,
60
+ "location": null,
61
+ "isRestrictedToGiftSpecifications": false,
62
+ "isLimitedToFinancialNeed": false,
63
+ "isPublic": true,
64
+ "isActive": true,
65
+ "isAvailableOnline": true,
66
+ "isTaxDeductible": true,
67
+ "treatAsAccountsPayable": false,
68
+ "beginningBalance": 0.0,
69
+ "currentBalance": 123.123,
70
+ "financialNeedType": null,
71
+ "financialNeedFrequency": null,
72
+ "financialNeedAmount": 0.0,
73
+ "startDate": "2023-12-08T00:00:00",
74
+ "endDate": "2024-12-08T00:00:00",
75
+ "durationType": null,
76
+ "lifeToDateGiving": null,
77
+ "lifeToDateGiftCount": null,
78
+ "lifeToDateGiversCount": null,
79
+ "lifeToDateExpenseTotal": null,
80
+ "calendarYearToDateGiving": null,
81
+ "calendarYearToDateGiftCount": null,
82
+ "calendarYearToDateGiversCount": null,
83
+ "calendarYearToDateExpenseTotal": null,
84
+ "createDateTimeUtc": "2023-12-08T00:00:00",
85
+ "createdByUser": "Test User",
86
+ "modifiedDateTimeUtc": "2023-12-08T00:00:00",
87
+ "modifiedByUser": "Test User",
88
+ "giftSpecifications": [],
89
+ "customFields": {}
90
+ }
91
+ ],
92
+ "total": 123
93
+ }
@@ -14,7 +14,8 @@ class VirtuousMock < Sinatra::Base
14
14
  'Gift/:id' => :gift,
15
15
  'RecurringGift/:id' => :recurring_gift,
16
16
  'Gift/:transaction_source/:transaction_id' => :gift,
17
- 'GiftDesignation/QueryOptions' => :gift_designation_query_options
17
+ 'GiftDesignation/QueryOptions' => :gift_designation_query_options,
18
+ 'Project/QueryOptions' => :project_query_options # TODO: change fixture
18
19
  }.each do |end_point, json|
19
20
  get "/api/#{end_point}" do
20
21
  json_response 200, "#{json}.json"
@@ -32,6 +33,7 @@ class VirtuousMock < Sinatra::Base
32
33
  'RecurringGift' => :recurring_gift,
33
34
  'Gift/Bulk' => :gifts,
34
35
  'GiftDesignation/Query' => :gift_designations,
36
+ 'Project/Query' => :projects, # TODO: change fixture
35
37
  'ContactAddress' => :contact_address
36
38
  }.each do |end_point, json|
37
39
  post "/api/#{end_point}" do
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Virtuous::Client::Individual, type: :model do
4
+ include_context 'resource specs'
5
+
6
+ describe '#project_query_options' do
7
+ it 'returns a hash' do
8
+ expect(client.project_query_options).to be_a(Hash)
9
+ end
10
+
11
+ it 'queries options' do
12
+ expect(client).to receive(:get).with('api/Project/QueryOptions').and_call_original
13
+
14
+ response = client.project_query_options
15
+
16
+ expect(response).to have_key(:options)
17
+ end
18
+ end
19
+
20
+ describe '#query_projects(**options)' do
21
+ it 'returns a list of projects' do
22
+ response = client.query_projects
23
+ expect(response).to be_a(Hash)
24
+
25
+ expect(response).to have_key(:list)
26
+ expect(response).to have_key(:total)
27
+ end
28
+
29
+ it 'sends take as a query param' do
30
+ expect(client).to receive(:post).with(URI('api/Project/Query?take=12'),
31
+ {}).and_call_original
32
+
33
+ client.query_projects(take: 12)
34
+ end
35
+
36
+ it 'sends skip as a query param' do
37
+ expect(client).to receive(:post).with(URI('api/Project/Query?skip=12'),
38
+ {}).and_call_original
39
+
40
+ client.query_projects(skip: 12)
41
+ end
42
+
43
+ it 'sends sort_by in the body' do
44
+ expect(client).to receive(:post).with(URI('api/Project/Query'), { 'sortBy' => 'Id' })
45
+ .and_call_original
46
+
47
+ client.query_projects(sort_by: 'Id')
48
+ end
49
+
50
+ it 'sends descending in the body' do
51
+ expect(client).to receive(:post).with(
52
+ URI('api/Project/Query'), { 'descending' => true }
53
+ ).and_call_original
54
+
55
+ client.query_projects(descending: true)
56
+ end
57
+
58
+ it 'sends conditions in the body' do
59
+ expect(client).to receive(:post).with(
60
+ URI('api/Project/Query'), { 'groups' => [{ 'conditions' => [{
61
+ 'parameter' => 'Project Code', 'operator' => 'Is', 'value' => 102
62
+ }] }] }
63
+ ).and_call_original
64
+
65
+ client.query_projects(conditions: [{
66
+ parameter: 'Project Code', operator: 'Is', value: 102
67
+ }])
68
+ end
69
+ end
70
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtuous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-05 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -63,6 +63,7 @@ files:
63
63
  - lib/virtuous/client/gift.rb
64
64
  - lib/virtuous/client/gift_designation.rb
65
65
  - lib/virtuous/client/individual.rb
66
+ - lib/virtuous/client/project.rb
66
67
  - lib/virtuous/client/recurring_gift.rb
67
68
  - lib/virtuous/error.rb
68
69
  - lib/virtuous/helpers/hash_helper.rb
@@ -82,6 +83,8 @@ files:
82
83
  - spec/support/fixtures/gifts.json
83
84
  - spec/support/fixtures/import.json
84
85
  - spec/support/fixtures/individual.json
86
+ - spec/support/fixtures/project_query_options.json
87
+ - spec/support/fixtures/projects.json
85
88
  - spec/support/fixtures/recurring_gift.json
86
89
  - spec/support/fixtures_helper.rb
87
90
  - spec/support/virtuous_mock.rb
@@ -92,6 +95,7 @@ files:
92
95
  - spec/virtuous/resources/gift_designation_spec.rb
93
96
  - spec/virtuous/resources/gift_spec.rb
94
97
  - spec/virtuous/resources/individual_spec.rb
98
+ - spec/virtuous/resources/project_spec.rb
95
99
  - spec/virtuous/resources/recurring_gift_spec.rb
96
100
  - spec/virtuous_spec.rb
97
101
  - virtuous.gemspec