virtuous 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-04 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
@@ -39,11 +39,12 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: A Ruby wrapper for the Virtuous CRM API
42
- email:
42
+ email:
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - ".github/workflows/publish.yml"
47
48
  - ".github/workflows/test.yml"
48
49
  - ".gitignore"
49
50
  - ".reek.yml"
@@ -62,6 +63,7 @@ files:
62
63
  - lib/virtuous/client/gift.rb
63
64
  - lib/virtuous/client/gift_designation.rb
64
65
  - lib/virtuous/client/individual.rb
66
+ - lib/virtuous/client/project.rb
65
67
  - lib/virtuous/client/recurring_gift.rb
66
68
  - lib/virtuous/error.rb
67
69
  - lib/virtuous/helpers/hash_helper.rb
@@ -81,6 +83,8 @@ files:
81
83
  - spec/support/fixtures/gifts.json
82
84
  - spec/support/fixtures/import.json
83
85
  - spec/support/fixtures/individual.json
86
+ - spec/support/fixtures/project_query_options.json
87
+ - spec/support/fixtures/projects.json
84
88
  - spec/support/fixtures/recurring_gift.json
85
89
  - spec/support/fixtures_helper.rb
86
90
  - spec/support/virtuous_mock.rb
@@ -91,6 +95,7 @@ files:
91
95
  - spec/virtuous/resources/gift_designation_spec.rb
92
96
  - spec/virtuous/resources/gift_spec.rb
93
97
  - spec/virtuous/resources/individual_spec.rb
98
+ - spec/virtuous/resources/project_spec.rb
94
99
  - spec/virtuous/resources/recurring_gift_spec.rb
95
100
  - spec/virtuous_spec.rb
96
101
  - virtuous.gemspec
@@ -99,7 +104,7 @@ licenses:
99
104
  - MIT
100
105
  metadata:
101
106
  rubygems_mfa_required: 'true'
102
- post_install_message:
107
+ post_install_message:
103
108
  rdoc_options: []
104
109
  require_paths:
105
110
  - lib
@@ -115,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
120
  version: '0'
116
121
  requirements: []
117
122
  rubygems_version: 3.4.10
118
- signing_key:
123
+ signing_key:
119
124
  specification_version: 4
120
125
  summary: A Ruby wrapper for the Virtuous CRM API
121
126
  test_files: []