ngp_van 0.7.0 → 0.11.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
- checksums.yaml.gz.sig +0 -0
- data/lib/ngp_van/client/export_jobs.rb +20 -0
- data/lib/ngp_van/client/people.rb +30 -0
- data/lib/ngp_van/client/phones.rb +11 -0
- data/lib/ngp_van/client/saved_lists.rb +16 -0
- data/lib/ngp_van/client/stories.rb +16 -0
- data/lib/ngp_van/client/supporter_groups.rb +5 -0
- data/lib/ngp_van/client.rb +8 -0
- data/lib/ngp_van/response/raise_error.rb +0 -2
- data/lib/ngp_van/version.rb +1 -1
- data/spec/ngp_van/client/export_jobs_spec.rb +90 -0
- data/spec/ngp_van/client/people_spec.rb +195 -0
- data/spec/ngp_van/client/phones_spec.rb +28 -0
- data/spec/ngp_van/client/saved_lists_spec.rb +66 -0
- data/spec/ngp_van/client/stories_spec.rb +66 -0
- data/spec/ngp_van/client/supporter_groups_spec.rb +13 -0
- data/spec/ngp_van/request_spec.rb +16 -0
- data/spec/support/fixtures/create_export_job.json +5 -0
- data/spec/support/fixtures/create_notes.json +7 -0
- data/spec/support/fixtures/create_story.json +17 -0
- data/spec/support/fixtures/export_job.json +15 -0
- data/spec/support/fixtures/export_job_types.json +10 -0
- data/spec/support/fixtures/phones.json +22 -0
- data/spec/support/fixtures/saved_list.json +7 -0
- data/spec/support/fixtures/saved_lists.json +11 -0
- data/spec/support/fixtures/story.json +18 -0
- data.tar.gz.sig +1 -1
- metadata +47 -31
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1c36203e519dac30b6c3c4531346ad32258ff0d169c5c2254c710bab95ccec
|
4
|
+
data.tar.gz: c61035bcc7b037a70e98c21fe70cb9e77c72057a77e09f3b9fa5e1add1cc2347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce3146fb0e4bd2dc833f5357c278001cd6ce704514d8eb5e50a1bb16852a8e44e441ce492c5edc79773b0980d67f76eeccf90de273d117597d8484dbd94e65a1
|
7
|
+
data.tar.gz: 282d5d9ecc00c9ef81c1c0501048f0eb29fd44cc60b7aabad610b6e20e996888dc019498915fd647397d1af409bb45f88f86a757d1f77f7389f73000e7584d72
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NgpVan
|
4
|
+
class Client
|
5
|
+
module ExportJobs
|
6
|
+
def create_export_job(body: {})
|
7
|
+
post(path: 'exportJobs', body: body)
|
8
|
+
end
|
9
|
+
|
10
|
+
def export_job(id:)
|
11
|
+
verify_id(id)
|
12
|
+
get(path: "exportJobs/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def export_job_types
|
16
|
+
get(path: 'exportJobTypes')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -30,6 +30,36 @@ module NgpVan
|
|
30
30
|
verify_ids(id, type)
|
31
31
|
post(path: "people/#{type}:#{id}/canvassResponses", body: body)
|
32
32
|
end
|
33
|
+
|
34
|
+
def apply_code_to_person(id:, body: {})
|
35
|
+
verify_id(id)
|
36
|
+
post(path: "people/#{id}/codes", body: body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_code_from_person(id:, codeId:)
|
40
|
+
verify_ids(id, codeId)
|
41
|
+
delete(path: "people/#{id}/codes/#{codeId}")
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_person_by_van_id(id:, body: {})
|
45
|
+
verify_id(id)
|
46
|
+
post(path: "people/#{id}", body: body)
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_person_by_van_id(id:, params: {})
|
50
|
+
verify_id(id)
|
51
|
+
get(path: "people/#{id}", params: params)
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_notes_for_person(id:, body: {})
|
55
|
+
verify_id(id)
|
56
|
+
post(path: "people/#{id}/notes", body: body)
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_notes_for_person_by_type(id:, type:, body: {})
|
60
|
+
verify_ids(id, type)
|
61
|
+
post(path: "people/#{type}:#{id}/notes", body: body)
|
62
|
+
end
|
33
63
|
end
|
34
64
|
end
|
35
65
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module NgpVan
|
4
|
+
class Client
|
5
|
+
module SavedLists
|
6
|
+
def saved_lists(params: {})
|
7
|
+
get(path: 'savedLists', params: params)
|
8
|
+
end
|
9
|
+
|
10
|
+
def saved_list(id:)
|
11
|
+
verify_id(id)
|
12
|
+
get(path: "savedLists/#{id}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -16,6 +16,11 @@ module NgpVan
|
|
16
16
|
get(path: 'supporterGroups', params: params)
|
17
17
|
end
|
18
18
|
|
19
|
+
def delete_supporter_group(id:, params: {})
|
20
|
+
verify_id(id)
|
21
|
+
delete(path: "supporterGroups/#{id}", params: params)
|
22
|
+
end
|
23
|
+
|
19
24
|
def add_person_to_supporter_group(supporter_group_id:, id:)
|
20
25
|
verify_ids(id, supporter_group_id)
|
21
26
|
put(path: "supporterGroups/#{supporter_group_id}/people/#{id}")
|
data/lib/ngp_van/client.rb
CHANGED
@@ -11,12 +11,16 @@ require 'ngp_van/client/district_fields'
|
|
11
11
|
require 'ngp_van/client/echoes'
|
12
12
|
require 'ngp_van/client/events'
|
13
13
|
require 'ngp_van/client/event_types'
|
14
|
+
require 'ngp_van/client/export_jobs'
|
14
15
|
require 'ngp_van/client/locations'
|
15
16
|
require 'ngp_van/client/notes'
|
16
17
|
require 'ngp_van/client/people'
|
18
|
+
require 'ngp_van/client/phones'
|
17
19
|
require 'ngp_van/client/printed_lists'
|
18
20
|
require 'ngp_van/client/minivan_exports'
|
21
|
+
require 'ngp_van/client/saved_lists'
|
19
22
|
require 'ngp_van/client/signups'
|
23
|
+
require 'ngp_van/client/stories'
|
20
24
|
require 'ngp_van/client/survey_questions'
|
21
25
|
require 'ngp_van/client/supporter_groups'
|
22
26
|
require 'ngp_van/client/users'
|
@@ -54,12 +58,16 @@ module NgpVan
|
|
54
58
|
include NgpVan::Client::Echoes
|
55
59
|
include NgpVan::Client::Events
|
56
60
|
include NgpVan::Client::EventTypes
|
61
|
+
include NgpVan::Client::ExportJobs
|
57
62
|
include NgpVan::Client::Locations
|
58
63
|
include NgpVan::Client::Notes
|
59
64
|
include NgpVan::Client::People
|
65
|
+
include NgpVan::Client::Phones
|
60
66
|
include NgpVan::Client::PrintedLists
|
61
67
|
include NgpVan::Client::MinivanExports
|
68
|
+
include NgpVan::Client::SavedLists
|
62
69
|
include NgpVan::Client::Signups
|
70
|
+
include NgpVan::Client::Stories
|
63
71
|
include NgpVan::Client::SupporterGroups
|
64
72
|
include NgpVan::Client::SurveyQuestions
|
65
73
|
include NgpVan::Client::Users
|
data/lib/ngp_van/version.rb
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
class Client
|
7
|
+
RSpec.describe ExportJobs do
|
8
|
+
let(:client) { NgpVan::Client.new }
|
9
|
+
|
10
|
+
describe '#create_export_job' do
|
11
|
+
let(:body) do
|
12
|
+
JSON.parse(fixture('create_export_job.json').read)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:url) { build_url(client: client, path: 'exportJobs') }
|
16
|
+
|
17
|
+
before do
|
18
|
+
stub_request(:post, url)
|
19
|
+
.with(body: JSON.generate(body))
|
20
|
+
.to_return(
|
21
|
+
body: '999888',
|
22
|
+
status: 201
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns the correct resource' do
|
27
|
+
client.create_export_job(body: body)
|
28
|
+
expect(
|
29
|
+
a_request(:post, url)
|
30
|
+
.with(
|
31
|
+
body: body
|
32
|
+
)
|
33
|
+
).to have_been_made
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns the created id' do
|
37
|
+
expect(client.create_export_job(body: body)).to eq(999888)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#get_export_job' do
|
42
|
+
let(:response) { fixture('export_job.json') }
|
43
|
+
let(:url) { build_url(client: client, path: 'exportJobs/999888') }
|
44
|
+
|
45
|
+
before do
|
46
|
+
stub_request(:get, url).to_return(body: response)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'requests the correct resource' do
|
50
|
+
client.export_job(id: 999888)
|
51
|
+
expect(a_request(:get, url)).to have_been_made
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns an event object' do
|
55
|
+
export_job = client.export_job(id: 999888)
|
56
|
+
expect(export_job).to be_a(Hash)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns the requested export job' do
|
60
|
+
export_job = client.export_job(id: 999888)
|
61
|
+
expect(export_job['exportJobId']).to eq(999888)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#get_export_job_types' do
|
66
|
+
let(:response) { fixture('export_job_types.json') }
|
67
|
+
let(:url) { build_url(client: client, path: 'exportJobTypes') }
|
68
|
+
|
69
|
+
before do
|
70
|
+
stub_request(:get, url).to_return(body: response)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'requests the correct resource' do
|
74
|
+
client.export_job_types
|
75
|
+
expect(a_request(:get, url)).to have_been_made
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'returns an array of items' do
|
79
|
+
export_job_types = client.export_job_types
|
80
|
+
expect(export_job_types['items']).to be_a(Array)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns the request export job type' do
|
84
|
+
export_job_types = client.export_job_types
|
85
|
+
expect(export_job_types['items'].first['exportJobTypeId']).to eq(4)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -222,6 +222,201 @@ module NgpVan
|
|
222
222
|
).to eq('')
|
223
223
|
end
|
224
224
|
end
|
225
|
+
|
226
|
+
describe '#apply_code_to_person' do
|
227
|
+
let(:url) { build_url(client: client, path: 'people/123123/codes') }
|
228
|
+
let(:request_body) { {'codeId' => 123456} }
|
229
|
+
|
230
|
+
before do
|
231
|
+
stub_request(:post, url)
|
232
|
+
.with(body: request_body.to_json)
|
233
|
+
.to_return(status: 204)
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'sends the correct request' do
|
237
|
+
client.apply_code_to_person(id: 123123, body: request_body)
|
238
|
+
expect(
|
239
|
+
a_request(:post, url)
|
240
|
+
.with(
|
241
|
+
body: request_body
|
242
|
+
)
|
243
|
+
).to have_been_made
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'returns the empty response body' do
|
247
|
+
expect(
|
248
|
+
client.apply_code_to_person(id: 123123, body: request_body)
|
249
|
+
).to eq('')
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe '#delete_code_from_person' do
|
254
|
+
let(:url) { build_url(client: client, path: 'people/215501/codes/123') }
|
255
|
+
|
256
|
+
before do
|
257
|
+
stub_request(:delete, url)
|
258
|
+
.to_return(status: 204)
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'requests the correct resource' do
|
262
|
+
client.delete_code_from_person(id: 215_501, codeId: 123)
|
263
|
+
expect(
|
264
|
+
a_request(:delete, url)
|
265
|
+
).to have_been_made
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'returns an empty response body' do
|
269
|
+
expect(
|
270
|
+
client.delete_code_from_person(id: 215_501, codeId: 123)
|
271
|
+
).to eq('')
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe '#update_person_by_van_id' do
|
276
|
+
let(:body) do
|
277
|
+
JSON.parse(fixture('match_candidate.json').read)
|
278
|
+
end
|
279
|
+
let(:response) { fixture('match_response.json') }
|
280
|
+
let(:url) { build_url(client: client, path: 'people/1234') }
|
281
|
+
|
282
|
+
before do
|
283
|
+
stub_request(:post, url)
|
284
|
+
.with(body: JSON.generate(body))
|
285
|
+
.to_return(
|
286
|
+
body: response
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'requests the correct resource' do
|
291
|
+
client.update_person_by_van_id(id: 1234, body: body)
|
292
|
+
expect(
|
293
|
+
a_request(:post, url)
|
294
|
+
.with(
|
295
|
+
body: body
|
296
|
+
)
|
297
|
+
).to have_been_made
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'returns a person record when record is found' do
|
301
|
+
person = client.update_person_by_van_id(id: 1234, body: body)
|
302
|
+
expect(person).to be_a(Hash)
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'returns the requested person when record is found' do
|
306
|
+
person = client.update_person_by_van_id(id: 1234, body: body)
|
307
|
+
expect(person['vanId']).to eq(1_264_324)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe '#finds_person_by_van_id' do
|
312
|
+
let(:params) do
|
313
|
+
{
|
314
|
+
'$expand' => 'phones,emails,addresses'
|
315
|
+
}
|
316
|
+
end
|
317
|
+
let(:response) { fixture('person.json') }
|
318
|
+
let(:url) { build_url(client: client, path: 'people/215501') }
|
319
|
+
|
320
|
+
before do
|
321
|
+
stub_request(:get, url)
|
322
|
+
.with(query: params)
|
323
|
+
.to_return(
|
324
|
+
body: response
|
325
|
+
)
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'requests the correct resource' do
|
329
|
+
client.get_person_by_van_id(id: 215501, params: params)
|
330
|
+
expect(
|
331
|
+
a_request(:get, url)
|
332
|
+
.with(
|
333
|
+
query: params
|
334
|
+
)
|
335
|
+
).to have_been_made
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'returns a person record when record is found' do
|
339
|
+
person = client.get_person_by_van_id(id: 215501, params: params)
|
340
|
+
expect(person).to be_a(Hash)
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'returns the requested person when record is found' do
|
344
|
+
person = client.get_person_by_van_id(id: 215501, params: params)
|
345
|
+
expect(person['vanId']).to eq(215501)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe '#create_note_for_person' do
|
350
|
+
let(:body) do
|
351
|
+
JSON.parse(fixture('create_notes.json').read)
|
352
|
+
end
|
353
|
+
|
354
|
+
let(:url) { build_url(client: client, path: 'people/215501/notes') }
|
355
|
+
|
356
|
+
before do
|
357
|
+
stub_request(:post, url)
|
358
|
+
.with(body: JSON.generate(body))
|
359
|
+
.to_return(
|
360
|
+
body: '',
|
361
|
+
status: 204
|
362
|
+
)
|
363
|
+
end
|
364
|
+
|
365
|
+
it 'requests the correct resource' do
|
366
|
+
client.create_notes_for_person(id: 215_501, body: body)
|
367
|
+
expect(
|
368
|
+
a_request(:post, url)
|
369
|
+
.with(
|
370
|
+
body: body
|
371
|
+
)
|
372
|
+
).to have_been_made
|
373
|
+
end
|
374
|
+
|
375
|
+
it 'returns an empty response' do
|
376
|
+
expect(
|
377
|
+
client.create_notes_for_person(id: 215_501, body: body)
|
378
|
+
).to eq('')
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
describe '#create_note_for_person by type' do
|
383
|
+
let(:body) do
|
384
|
+
JSON.parse(fixture('create_notes.json').read)
|
385
|
+
end
|
386
|
+
|
387
|
+
let(:url) do
|
388
|
+
build_url(client: client, path: 'people/dwid:215501/notes')
|
389
|
+
end
|
390
|
+
|
391
|
+
before do
|
392
|
+
stub_request(:post, url)
|
393
|
+
.with(body: JSON.generate(body))
|
394
|
+
.to_return(
|
395
|
+
body: '',
|
396
|
+
status: 204
|
397
|
+
)
|
398
|
+
end
|
399
|
+
|
400
|
+
it 'requests the correct resource' do
|
401
|
+
client.create_notes_for_person_by_type(
|
402
|
+
id: 215_501, type: 'dwid', body: body
|
403
|
+
)
|
404
|
+
expect(
|
405
|
+
a_request(:post, url)
|
406
|
+
.with(
|
407
|
+
body: body
|
408
|
+
)
|
409
|
+
).to have_been_made
|
410
|
+
end
|
411
|
+
|
412
|
+
it 'returns an empty response' do
|
413
|
+
expect(
|
414
|
+
client.create_notes_for_person_by_type(
|
415
|
+
id: 215_501, type: 'dwid', body: body
|
416
|
+
)
|
417
|
+
).to eq('')
|
418
|
+
end
|
419
|
+
end
|
225
420
|
end
|
226
421
|
end
|
227
422
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
class Client
|
7
|
+
RSpec.describe Phones do
|
8
|
+
let(:client) { NgpVan::Client.new }
|
9
|
+
|
10
|
+
describe '#is_cell_statuses' do
|
11
|
+
let(:response) { fixture('phones.json') }
|
12
|
+
let(:url) { build_url(client: client, path: 'phones/isCellStatuses') }
|
13
|
+
|
14
|
+
before do
|
15
|
+
stub_request(:get, url)
|
16
|
+
.to_return(
|
17
|
+
body: response
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'requests the correct resource' do
|
22
|
+
client.is_cell_statuses
|
23
|
+
expect(a_request(:get, url)).to have_been_made
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
class Client
|
7
|
+
RSpec.describe SavedLists do
|
8
|
+
let(:client) { NgpVan::Client.new }
|
9
|
+
|
10
|
+
describe '#saved_lists' do
|
11
|
+
let(:params) do
|
12
|
+
{
|
13
|
+
folderId: '1234',
|
14
|
+
maxDoorCount: '1000',
|
15
|
+
maxPeopleCount: '2000'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:response) { fixture('saved_lists.json') }
|
20
|
+
let(:url) { build_url(client: client, path: 'savedLists') }
|
21
|
+
|
22
|
+
before do
|
23
|
+
stub_request(:get, url)
|
24
|
+
.with(query: params)
|
25
|
+
.to_return(
|
26
|
+
body: response
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'requests the correct resource' do
|
31
|
+
saved_lists = client.saved_lists(params: params)
|
32
|
+
expect(saved_lists['items']).to be_a(Array)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns the requested saved_lists' do
|
36
|
+
saved_lists = client.saved_lists(params: params)
|
37
|
+
expect(saved_lists['items'].first['savedListId']).to eq(999888777)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#saved_list' do
|
42
|
+
let(:response) { fixture('saved_list.json') }
|
43
|
+
let(:url) { build_url(client: client, path: 'savedLists/999888777') }
|
44
|
+
|
45
|
+
before do
|
46
|
+
stub_request(:get, url).to_return(body: response)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'requests the correct resource' do
|
50
|
+
client.saved_list(id: 999888777)
|
51
|
+
expect(a_request(:get, url)).to have_been_made
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns an event object' do
|
55
|
+
saved_list = client.saved_list(id: 999888777)
|
56
|
+
expect(saved_list).to be_a(Hash)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns the request saved_list' do
|
60
|
+
saved_list = client.saved_list(id: 999888777)
|
61
|
+
expect(saved_list['savedListId']).to eq(999888777)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
class Client
|
7
|
+
RSpec.describe Stories do
|
8
|
+
let(:client) { NgpVan::Client.new }
|
9
|
+
|
10
|
+
describe '#create_story' do
|
11
|
+
let(:body) do
|
12
|
+
JSON.parse(fixture('create_story.json').read)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:url) { build_url(client: client, path: 'stories') }
|
16
|
+
|
17
|
+
before do
|
18
|
+
stub_request(:post, url)
|
19
|
+
.with(body: JSON.generate(body))
|
20
|
+
.to_return(
|
21
|
+
body: '123',
|
22
|
+
status: 201
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'requests the correct resource' do
|
27
|
+
client.create_story(body: body)
|
28
|
+
expect(
|
29
|
+
a_request(:post, url)
|
30
|
+
.with(
|
31
|
+
body: body
|
32
|
+
)
|
33
|
+
).to have_been_made
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns the created id' do
|
37
|
+
expect(client.create_story(body: body)).to eq(123)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'story' do
|
42
|
+
let(:response) { fixture('story.json') }
|
43
|
+
let(:url) { build_url(client: client, path: 'stories/123') }
|
44
|
+
|
45
|
+
before do
|
46
|
+
stub_request(:get, url).to_return(body: response)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'requests the correct resource' do
|
50
|
+
client.story(id: 123)
|
51
|
+
expect(a_request(:get, url)).to have_been_made
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'returns an event object' do
|
55
|
+
story = client.story(id: 123)
|
56
|
+
expect(story).to be_a(Hash)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns the requested story' do
|
60
|
+
story = client.story(id: 123)
|
61
|
+
expect(story['storyId']).to eq(123)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -66,6 +66,19 @@ module NgpVan
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
describe '#delete_supporter_group' do
|
70
|
+
let(:url) { build_url(client: client, path: 'supporterGroups/1122') }
|
71
|
+
|
72
|
+
before do
|
73
|
+
stub_request(:delete, url).to_return(status: 204, body: '')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'performs the request' do
|
77
|
+
client.delete_supporter_group(id: 1122)
|
78
|
+
expect(a_request(:delete, url)).to have_been_made
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
69
82
|
describe '#supporter_groups' do
|
70
83
|
let(:params) do
|
71
84
|
{
|
@@ -62,6 +62,22 @@ module NgpVan
|
|
62
62
|
.to have_been_made
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
context 'when the response has a non-success status code' do
|
67
|
+
let(:response_body) do
|
68
|
+
{ errors: [{ code: 'NOT_FOUND', text: 'it was not found' }] }.to_json
|
69
|
+
end
|
70
|
+
|
71
|
+
before do
|
72
|
+
stub_request(:get, url).to_return(status: 404, body: response_body)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'raises an appropriate error' do
|
76
|
+
expect do
|
77
|
+
NgpVan.get(path: '/some/resource')
|
78
|
+
end.to raise_error(NgpVan::NotFound)
|
79
|
+
end
|
80
|
+
end
|
65
81
|
end
|
66
82
|
|
67
83
|
describe '#post' do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"title": "A Tale of Two Cities",
|
3
|
+
"storyText": "It was the best of times, it was the worst of times ...",
|
4
|
+
"storyStatus": {
|
5
|
+
"storyStatusId": 1
|
6
|
+
},
|
7
|
+
"vanId": 1000000000,
|
8
|
+
"tags": [
|
9
|
+
{
|
10
|
+
"codeId": 123
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"codeId": 456
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"campaignId": 123456
|
17
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"exportJobId": 999888,
|
3
|
+
"exportJobGuid": "7B623929-05DA-4356-BF30-EF7D1BB0248C",
|
4
|
+
"savedListId": 1234,
|
5
|
+
"webhookUrl": "https://webhook.example.org/completedExportJobs",
|
6
|
+
"downloadUrl": "https://ngpvan.blob.core.windows.net/completed-export-jobs/7B623929-05DA-4356-BF30-EF7D1BB0248C_2017-01-01T12:00:00.csv",
|
7
|
+
"status": "Completed",
|
8
|
+
"type": 777,
|
9
|
+
"dateExpired": "2017-01-04T12:00:00Z",
|
10
|
+
"errorCode": null,
|
11
|
+
"surveyQuestions": [ { "surveyQuestionId": 1234 } ],
|
12
|
+
"activistCodes": [ { "activistCodeId": 4567 } ],
|
13
|
+
"customFields": [ { "customFieldId": 5678 } ],
|
14
|
+
"districtFields": [ { "districtFieldId": 10 } ]
|
15
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"items": [
|
3
|
+
{
|
4
|
+
"statusId": 1,
|
5
|
+
"statusName": "Verified Cell"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"statusId": 2,
|
9
|
+
"statusName": "Likely Cell"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"statusId": 3,
|
13
|
+
"statusName": "Likely Not a Cell"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"statusId": 4,
|
17
|
+
"statusName": "Not a Cell"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"nextPageLink": null,
|
21
|
+
"count": 4
|
22
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"storyId": 123,
|
3
|
+
"title": "A Tale of Two Cities",
|
4
|
+
"storyText": "It was the best of times, it was the worst of times ...",
|
5
|
+
"storyStatus": {
|
6
|
+
"storyStatusId": 1
|
7
|
+
},
|
8
|
+
"vanId": 1000000000,
|
9
|
+
"tags": [
|
10
|
+
{
|
11
|
+
"codeId": 123
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"codeId": 456
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"campaignId": 123456
|
18
|
+
}
|
data.tar.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Y���gi��H ���7��:疟MU���F��{.}&K~��O��b�7q��G�2UB�����+(����Y����a� "���
|
metadata
CHANGED
@@ -1,42 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ngp_van
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Styles
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Hje6PutFGypAA8f9kmLl8X2Eu74D8PI9ywc=
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFjaHJp
|
14
|
+
c3RvcGhlcnN0eWxlcy9EQz1nbWFpbC9EQz1jb20wHhcNMjEwOTI5MDM1NzM3WhcN
|
15
|
+
MjIwOTI5MDM1NzM3WjAsMSowKAYDVQQDDCFjaHJpc3RvcGhlcnN0eWxlcy9EQz1n
|
16
|
+
bWFpbC9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCt5iPa
|
17
|
+
K6stF4Rn0OGZWJYze/VYgVsRAHHo+J3G4aWy+3fLU6K3Qx0e/SRaTcTbEdJORO5P
|
18
|
+
/0sZYqBH1zr9dh7mBxBhMIDH+vujozFCVIw8A/8GYGZ0D9Th1nW8k34Tqp3oi9+7
|
19
|
+
UlUejmyvmqkUNkwBwnLmf3dgox/RjzLhN0NeNbLCQAyTVXbgoalEYIYYVQLQcduM
|
20
|
+
doxDgcWI7IKqb3peDo3eKOPg6ch8YWfamMga40Vzqk5SsoSIui91doBcfjMMAkkm
|
21
|
+
uZ59BoEIR4grbzv+HmyXrcKCLqhW6L7gaRKhQQvWH9x0Mbb0lQOFAN/YEUE5Qrcg
|
22
|
+
KjIoScVk3aanlR9KnqZr9Ft7vEx9Dh2L9Tshby0Tzmr5GzY5Me0J+c6qUdIgNmUI
|
23
|
+
E1OC/sXs5EvGoldyxJQympvwdKCYC1EmzNbhJvAFVMkZOgJgxNkszQFIDNhct9kh
|
24
|
+
BfWe1L9BKqAQHKg5Hw4Ke9FtYktaIIwpr/FusC67kKyoYwDxu5tD2G18DK8CAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQULR6mwjcn
|
26
|
+
lN7EwjFvJ4/HmBhdUSswJgYDVR0RBB8wHYEbY2hyaXN0b3BoZXJzdHlsZXNAZ21h
|
27
|
+
aWwuY29tMCYGA1UdEgQfMB2BG2NocmlzdG9waGVyc3R5bGVzQGdtYWlsLmNvbTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAa/34LPueG9EuA5MJAtvFB5uejjUHEQ++ooHHpw4s
|
29
|
+
j0n4WWM3vjLEgKCPYwSAGtCQ/cTuSA7I6cSJmoHteFtPl25yF6I3HrQV0fXVakcg
|
30
|
+
2CoInNkvaownFBwGwFswBbJQ2B55K/yYlsLmGHrAI2FziqETbS+cgB0K4If/yUrs
|
31
|
+
vw2MYWBgTF5lpCwOHxrqsN6ogab0uG6EvQ4PAjldwrvr/xjP1wViH3O0f6hBHIrt
|
32
|
+
gNPHyKmcpWYMSoe9WXn/nTiKH9INtJNJqoEXDjlGRdiSm6BBdICNEpxR3goFoeyb
|
33
|
+
n7tIcqQbKatEB5H+soY9i0MHCpuc64zrzOLnz2GqdiZbQe17Pqt48U3F3FmxRqmc
|
34
|
+
NnUOqH+WWATRHr6wYD5Trfijb5wHQhg45Ly07Bzi19qHXFUc1L5U8x4TP83/yNY1
|
35
|
+
38e01GMYs1FtUnCSmy1dqPhVb9aXCYjYaKn65gPvoWjb45tvXVdW3h4Bpz/CVsuw
|
36
|
+
/GZTPns/mKeY8wXW7xIhhd10
|
38
37
|
-----END CERTIFICATE-----
|
39
|
-
date:
|
38
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
40
39
|
dependencies:
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: faraday
|
@@ -96,12 +95,16 @@ files:
|
|
96
95
|
- lib/ngp_van/client/echoes.rb
|
97
96
|
- lib/ngp_van/client/event_types.rb
|
98
97
|
- lib/ngp_van/client/events.rb
|
98
|
+
- lib/ngp_van/client/export_jobs.rb
|
99
99
|
- lib/ngp_van/client/locations.rb
|
100
100
|
- lib/ngp_van/client/minivan_exports.rb
|
101
101
|
- lib/ngp_van/client/notes.rb
|
102
102
|
- lib/ngp_van/client/people.rb
|
103
|
+
- lib/ngp_van/client/phones.rb
|
103
104
|
- lib/ngp_van/client/printed_lists.rb
|
105
|
+
- lib/ngp_van/client/saved_lists.rb
|
104
106
|
- lib/ngp_van/client/signups.rb
|
107
|
+
- lib/ngp_van/client/stories.rb
|
105
108
|
- lib/ngp_van/client/supporter_groups.rb
|
106
109
|
- lib/ngp_van/client/survey_questions.rb
|
107
110
|
- lib/ngp_van/client/users.rb
|
@@ -120,12 +123,16 @@ files:
|
|
120
123
|
- spec/ngp_van/client/district_fields_spec.rb
|
121
124
|
- spec/ngp_van/client/event_types_spec.rb
|
122
125
|
- spec/ngp_van/client/events_spec.rb
|
126
|
+
- spec/ngp_van/client/export_jobs_spec.rb
|
123
127
|
- spec/ngp_van/client/locations_spec.rb
|
124
128
|
- spec/ngp_van/client/minivan_exports_spec.rb
|
125
129
|
- spec/ngp_van/client/notes_spec.rb
|
126
130
|
- spec/ngp_van/client/people_spec.rb
|
131
|
+
- spec/ngp_van/client/phones_spec.rb
|
127
132
|
- spec/ngp_van/client/printed_lists_spec.rb
|
133
|
+
- spec/ngp_van/client/saved_lists_spec.rb
|
128
134
|
- spec/ngp_van/client/signups_spec.rb
|
135
|
+
- spec/ngp_van/client/stories_spec.rb
|
129
136
|
- spec/ngp_van/client/supporter_groups_spec.rb
|
130
137
|
- spec/ngp_van/client/survey_questions_spec.rb
|
131
138
|
- spec/ngp_van/client/users_spec.rb
|
@@ -146,8 +153,11 @@ files:
|
|
146
153
|
- spec/support/fixtures/create_code.json
|
147
154
|
- spec/support/fixtures/create_event.json
|
148
155
|
- spec/support/fixtures/create_event_shift.json
|
156
|
+
- spec/support/fixtures/create_export_job.json
|
149
157
|
- spec/support/fixtures/create_location.json
|
158
|
+
- spec/support/fixtures/create_notes.json
|
150
159
|
- spec/support/fixtures/create_signup.json
|
160
|
+
- spec/support/fixtures/create_story.json
|
151
161
|
- spec/support/fixtures/create_supporter_group.json
|
152
162
|
- spec/support/fixtures/create_user_district_field_values.json
|
153
163
|
- spec/support/fixtures/district_field.json
|
@@ -156,6 +166,8 @@ files:
|
|
156
166
|
- spec/support/fixtures/event_type.json
|
157
167
|
- spec/support/fixtures/event_types.json
|
158
168
|
- spec/support/fixtures/events.json
|
169
|
+
- spec/support/fixtures/export_job.json
|
170
|
+
- spec/support/fixtures/export_job_types.json
|
159
171
|
- spec/support/fixtures/location.json
|
160
172
|
- spec/support/fixtures/locations.json
|
161
173
|
- spec/support/fixtures/match_candidate.json
|
@@ -166,6 +178,7 @@ files:
|
|
166
178
|
- spec/support/fixtures/note_category.json
|
167
179
|
- spec/support/fixtures/note_category_types.json
|
168
180
|
- spec/support/fixtures/person.json
|
181
|
+
- spec/support/fixtures/phones.json
|
169
182
|
- spec/support/fixtures/printed_list.json
|
170
183
|
- spec/support/fixtures/printed_lists.json
|
171
184
|
- spec/support/fixtures/pronouns.json
|
@@ -174,9 +187,12 @@ files:
|
|
174
187
|
- spec/support/fixtures/reported_language_preferences.json
|
175
188
|
- spec/support/fixtures/reported_races.json
|
176
189
|
- spec/support/fixtures/reported_sexual_orientations.json
|
190
|
+
- spec/support/fixtures/saved_list.json
|
191
|
+
- spec/support/fixtures/saved_lists.json
|
177
192
|
- spec/support/fixtures/signup.json
|
178
193
|
- spec/support/fixtures/signup_statuses.json
|
179
194
|
- spec/support/fixtures/signups.json
|
195
|
+
- spec/support/fixtures/story.json
|
180
196
|
- spec/support/fixtures/supporter_group.json
|
181
197
|
- spec/support/fixtures/supporter_groups.json
|
182
198
|
- spec/support/fixtures/survey_question.json
|
@@ -194,7 +210,7 @@ homepage: https://github.com/christopherstyles/ngp_van
|
|
194
210
|
licenses:
|
195
211
|
- MIT
|
196
212
|
metadata: {}
|
197
|
-
post_install_message:
|
213
|
+
post_install_message:
|
198
214
|
rdoc_options: []
|
199
215
|
require_paths:
|
200
216
|
- lib
|
@@ -209,8 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
225
|
- !ruby/object:Gem::Version
|
210
226
|
version: '0'
|
211
227
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
213
|
-
signing_key:
|
228
|
+
rubygems_version: 3.1.4
|
229
|
+
signing_key:
|
214
230
|
specification_version: 4
|
215
231
|
summary: Ruby wrapper for the NGP VAN API
|
216
232
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|