chmeetings 0.0.1 → 0.0.2
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/lib/chmeetings/client/batch.rb +25 -0
- data/lib/chmeetings/client.rb +1 -0
- data/lib/chmeetings/version.rb +1 -1
- data/spec/chmeetings/resources/batch_spec.rb +73 -0
- data/spec/support/chmeetings_mock.rb +15 -1
- data/spec/support/fixtures/batch.json +7 -0
- data/spec/support/fixtures/batches.json +18 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f313d85fb7b9873e8d795e838be58a8421fcd404ec47a93247a33547c038de0a
|
|
4
|
+
data.tar.gz: 688dfb271a343a83ad135a1c8f6d2ba42d63e166d12f02a100154dc1423f6a94
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ffa31ae76d8df7b0df37cfebb837f06ce4d3eb034facf738e7a1b142afa1f1a8014af2fe1f91e26d8e32f0118a96a90bb25210db33f76fee323cef244f12c6e
|
|
7
|
+
data.tar.gz: b21a9399c5814cbc1cd4b0beb2f1c4334198262676195ef62b12c183f63f3d92b017ac92581cd9ca4407810baa86615982d219370e362170972f587f87aa78e4
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Chmeetings
|
|
2
|
+
class Client
|
|
3
|
+
module Batch
|
|
4
|
+
def list_batches(**options)
|
|
5
|
+
get('contributions/batches', options)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def create_batch(**data)
|
|
9
|
+
post('contributions/batches', data)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_batch(id:)
|
|
13
|
+
get("contributions/batches/#{id}")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def update_batch(id:, **data)
|
|
17
|
+
put("contributions/batches/#{id}", data)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def delete_batch(id:)
|
|
21
|
+
delete("contributions/batches/#{id}")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/chmeetings/client.rb
CHANGED
data/lib/chmeetings/version.rb
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Chmeetings::Client::Batch, type: :model do
|
|
4
|
+
include_context 'resource specs'
|
|
5
|
+
|
|
6
|
+
describe '#list_batches' do
|
|
7
|
+
it 'returns a hash' do
|
|
8
|
+
expect(client.list_batches).to be_a(Hash)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'queries batches' do
|
|
12
|
+
expect(client).to receive(:get).with('contributions/batches', {}).and_call_original
|
|
13
|
+
|
|
14
|
+
resource = client.list_batches
|
|
15
|
+
|
|
16
|
+
expect(resource['data'].first['id']).to eq(1)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'passes options' do
|
|
20
|
+
expect(client).to receive(:get).with('contributions/batches', { page: 1 }).and_call_original
|
|
21
|
+
|
|
22
|
+
client.list_batches(page: 1)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe '#create_batch' do
|
|
27
|
+
it 'returns a hash' do
|
|
28
|
+
expect(client.create_batch(name: 'Test Batch', date: '2026-02-16')).to be_a(Hash)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'passes data' do
|
|
32
|
+
expect(client).to receive(:post)
|
|
33
|
+
.with('contributions/batches', { name: 'Test Batch', date: '2026-02-16' })
|
|
34
|
+
.and_call_original
|
|
35
|
+
|
|
36
|
+
client.create_batch(name: 'Test Batch', date: '2026-02-16')
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#get_batch' do
|
|
41
|
+
it 'returns a hash' do
|
|
42
|
+
expect(client.get_batch(id: 1)).to be_a(Hash)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'passes id' do
|
|
46
|
+
expect(client).to receive(:get).with('contributions/batches/1').and_call_original
|
|
47
|
+
|
|
48
|
+
client.get_batch(id: 1)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#update_batch' do
|
|
53
|
+
it 'returns a hash' do
|
|
54
|
+
expect(client.update_batch(id: 1, name: 'Updated Batch')).to be_a(Hash)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'passes data' do
|
|
58
|
+
expect(client).to receive(:put)
|
|
59
|
+
.with('contributions/batches/1', { name: 'Updated Batch' })
|
|
60
|
+
.and_call_original
|
|
61
|
+
|
|
62
|
+
client.update_batch(id: 1, name: 'Updated Batch')
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '#delete_batch' do
|
|
67
|
+
it 'passes id' do
|
|
68
|
+
expect(client).to receive(:delete).with('contributions/batches/1').and_call_original
|
|
69
|
+
|
|
70
|
+
client.delete_batch(id: 1)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -10,6 +10,8 @@ class ChmeetingsMock < Sinatra::Base
|
|
|
10
10
|
'family-members' => :family_members,
|
|
11
11
|
'groups' => :groups,
|
|
12
12
|
'contributions' => :contributions,
|
|
13
|
+
'contributions/batches' => :batches,
|
|
14
|
+
'contributions/batches/:id' => :batch,
|
|
13
15
|
'pledges' => :pledges,
|
|
14
16
|
'campaigns' => :campaigns
|
|
15
17
|
}.each do |end_point, json|
|
|
@@ -22,6 +24,7 @@ class ChmeetingsMock < Sinatra::Base
|
|
|
22
24
|
{
|
|
23
25
|
'people' => :person,
|
|
24
26
|
'people/delete' => :person,
|
|
27
|
+
'contributions/batches' => :batch,
|
|
25
28
|
'families' => :family,
|
|
26
29
|
'families/delete' => :family,
|
|
27
30
|
'family-members' => :family_member,
|
|
@@ -37,13 +40,24 @@ class ChmeetingsMock < Sinatra::Base
|
|
|
37
40
|
{
|
|
38
41
|
'people' => :person,
|
|
39
42
|
'families' => :family,
|
|
40
|
-
'family-members' => :family_member
|
|
43
|
+
'family-members' => :family_member,
|
|
44
|
+
'contributions/batches/:id' => :batch
|
|
41
45
|
}.each do |end_point, json|
|
|
42
46
|
put "/api/v1/#{end_point}" do
|
|
43
47
|
json_response 200, "#{json}.json"
|
|
44
48
|
end
|
|
45
49
|
end
|
|
46
50
|
|
|
51
|
+
# DELETE requests
|
|
52
|
+
[
|
|
53
|
+
'contributions/batches/:id'
|
|
54
|
+
].each do |end_point|
|
|
55
|
+
delete "/api/v1/#{end_point}" do
|
|
56
|
+
content_type :json
|
|
57
|
+
status 204
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
47
61
|
# PATCH requests
|
|
48
62
|
{
|
|
49
63
|
'family-members' => :family_member
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": 1,
|
|
5
|
+
"name": "Simple - Feb 16 2026",
|
|
6
|
+
"date": "2026-02-16",
|
|
7
|
+
"status": "open",
|
|
8
|
+
"created_at": "2026-02-10T10:00:00"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": 2,
|
|
12
|
+
"name": "Simple - Feb 23 2026",
|
|
13
|
+
"date": "2026-02-23",
|
|
14
|
+
"status": "open",
|
|
15
|
+
"created_at": "2026-02-17T10:00:00"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chmeetings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Taylor Brooks
|
|
@@ -55,6 +55,7 @@ files:
|
|
|
55
55
|
- chmeetings.gemspec
|
|
56
56
|
- lib/chmeetings.rb
|
|
57
57
|
- lib/chmeetings/client.rb
|
|
58
|
+
- lib/chmeetings/client/batch.rb
|
|
58
59
|
- lib/chmeetings/client/campaign.rb
|
|
59
60
|
- lib/chmeetings/client/contribution.rb
|
|
60
61
|
- lib/chmeetings/client/family.rb
|
|
@@ -67,6 +68,7 @@ files:
|
|
|
67
68
|
- lib/chmeetings/version.rb
|
|
68
69
|
- spec/chmeetings/client_spec.rb
|
|
69
70
|
- spec/chmeetings/error_spec.rb
|
|
71
|
+
- spec/chmeetings/resources/batch_spec.rb
|
|
70
72
|
- spec/chmeetings/resources/campaign_spec.rb
|
|
71
73
|
- spec/chmeetings/resources/contribution_spec.rb
|
|
72
74
|
- spec/chmeetings/resources/family_member_spec.rb
|
|
@@ -78,6 +80,8 @@ files:
|
|
|
78
80
|
- spec/spec_helper.rb
|
|
79
81
|
- spec/support/chmeetings_mock.rb
|
|
80
82
|
- spec/support/client_factory.rb
|
|
83
|
+
- spec/support/fixtures/batch.json
|
|
84
|
+
- spec/support/fixtures/batches.json
|
|
81
85
|
- spec/support/fixtures/campaigns.json
|
|
82
86
|
- spec/support/fixtures/contribution.json
|
|
83
87
|
- spec/support/fixtures/contributions.json
|