ngp_van 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 986b916578056027f4a48d0697590e5b94a42fc1f19ce69064829eeebc307827
4
- data.tar.gz: 2f101d57778b4d3e42178101d7a4fcf92f0ee8d3a730a8d7a994956a95987ccd
3
+ metadata.gz: e8135b5448157fb85dc8ca3a23c2fc51e7311bd6c66549ac79791d988a3d810d
4
+ data.tar.gz: f651d7a9410049e0d9c5afd297bc04f879431e9b45b5111113fe8a9cac2ac7df
5
5
  SHA512:
6
- metadata.gz: 192aca1faea78289b8af83fdb77948ec925c453804a6d79e1eeb0afbce74d6f919c1f21e2d4b21fa64b0eee0fbf913cbd00b40e11ffe311c6c499eb03199fffc
7
- data.tar.gz: e39e207c65d3421268d90c71d07efd2a3484e3070814b6c443aac940a39b14610838e79907de5d072fc4a25cc9890fdb320a4f09735746c7e15ba53953c9db21
6
+ metadata.gz: a7006b741d31057e106402da68e17363fb575f7f465b70667c9b97222e6e6e48774a8e46ed43a259827c8e2abd7a338a8f46705e355088e5313697978e02291e
7
+ data.tar.gz: c186787fde9edf7961e2aacd316ad2e2404f47537d10afaf0c85e97533f000ac8c2f86e94357a7502a47661c5a0d6bee73a30d4c262c78dbc0cb7f68a695db60
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -11,11 +11,14 @@ 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'
20
23
  require 'ngp_van/client/stories'
21
24
  require 'ngp_van/client/survey_questions'
@@ -55,11 +58,14 @@ module NgpVan
55
58
  include NgpVan::Client::Echoes
56
59
  include NgpVan::Client::Events
57
60
  include NgpVan::Client::EventTypes
61
+ include NgpVan::Client::ExportJobs
58
62
  include NgpVan::Client::Locations
59
63
  include NgpVan::Client::Notes
60
64
  include NgpVan::Client::People
65
+ include NgpVan::Client::Phones
61
66
  include NgpVan::Client::PrintedLists
62
67
  include NgpVan::Client::MinivanExports
68
+ include NgpVan::Client::SavedLists
63
69
  include NgpVan::Client::Signups
64
70
  include NgpVan::Client::Stories
65
71
  include NgpVan::Client::SupporterGroups
@@ -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
@@ -40,6 +40,26 @@ module NgpVan
40
40
  verify_ids(id, codeId)
41
41
  delete(path: "people/#{id}/codes/#{codeId}")
42
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
43
63
  end
44
64
  end
45
65
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NgpVan
4
+ class Client
5
+ module Phones
6
+ def is_cell_statuses
7
+ get(path: 'phones/isCellStatuses')
8
+ end
9
+ end
10
+ end
11
+ 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
@@ -7,7 +7,7 @@ module NgpVan
7
7
 
8
8
  # Current minor release.
9
9
  # @return [Integer]
10
- MINOR = 9
10
+ MINOR = 10
11
11
 
12
12
  # Current patch level.
13
13
  # @return [Integer]
@@ -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
@@ -271,6 +271,152 @@ module NgpVan
271
271
  ).to eq('')
272
272
  end
273
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
274
420
  end
275
421
  end
276
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,5 @@
1
+ {
2
+ "savedListId": 1234,
3
+ "type": 777,
4
+ "webhookUrl": "https://webhook.example.org/completedExportJobs"
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "text": "Great chat! This person will be able to volunteer next year.",
3
+ "isViewRestricted": false,
4
+ "category": {
5
+ "noteCategoryId": 99
6
+ }
7
+ }
@@ -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,10 @@
1
+ {
2
+ "items": [
3
+ {
4
+ "exportJobTypeId": 4,
5
+ "name": "SavedListExport"
6
+ }
7
+ ],
8
+ "nextPageLink": null,
9
+ "count": 1
10
+ }
@@ -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,7 @@
1
+ {
2
+ "savedListId": 999888777,
3
+ "name": "GOTV list",
4
+ "description": "People we want to talk to for GOTV",
5
+ "listCount": 2000,
6
+ "doorCount": 987
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "items": [
3
+ {
4
+ "savedListId": 999888777,
5
+ "name": "GOTV list",
6
+ "description": "People we want to talk to for GOTV",
7
+ "listCount": 2000,
8
+ "doorCount": 987
9
+ }
10
+ ]
11
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ngp_van
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Styles
@@ -35,7 +35,7 @@ cert_chain:
35
35
  39TOGM5UYCjPNfgN1phZsQZYAqt9izy3YK2+ih92vtsB+0z4Cs9UanhYj97Z4lj+
36
36
  cQFVep+b/7Dph1WPZLQM7aAX
37
37
  -----END CERTIFICATE-----
38
- date: 2019-10-03 00:00:00.000000000 Z
38
+ date: 2019-11-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: faraday
@@ -95,11 +95,14 @@ files:
95
95
  - lib/ngp_van/client/echoes.rb
96
96
  - lib/ngp_van/client/event_types.rb
97
97
  - lib/ngp_van/client/events.rb
98
+ - lib/ngp_van/client/export_jobs.rb
98
99
  - lib/ngp_van/client/locations.rb
99
100
  - lib/ngp_van/client/minivan_exports.rb
100
101
  - lib/ngp_van/client/notes.rb
101
102
  - lib/ngp_van/client/people.rb
103
+ - lib/ngp_van/client/phones.rb
102
104
  - lib/ngp_van/client/printed_lists.rb
105
+ - lib/ngp_van/client/saved_lists.rb
103
106
  - lib/ngp_van/client/signups.rb
104
107
  - lib/ngp_van/client/stories.rb
105
108
  - lib/ngp_van/client/supporter_groups.rb
@@ -120,11 +123,14 @@ 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
129
135
  - spec/ngp_van/client/stories_spec.rb
130
136
  - spec/ngp_van/client/supporter_groups_spec.rb
@@ -147,7 +153,9 @@ files:
147
153
  - spec/support/fixtures/create_code.json
148
154
  - spec/support/fixtures/create_event.json
149
155
  - spec/support/fixtures/create_event_shift.json
156
+ - spec/support/fixtures/create_export_job.json
150
157
  - spec/support/fixtures/create_location.json
158
+ - spec/support/fixtures/create_notes.json
151
159
  - spec/support/fixtures/create_signup.json
152
160
  - spec/support/fixtures/create_story.json
153
161
  - spec/support/fixtures/create_supporter_group.json
@@ -158,6 +166,8 @@ files:
158
166
  - spec/support/fixtures/event_type.json
159
167
  - spec/support/fixtures/event_types.json
160
168
  - spec/support/fixtures/events.json
169
+ - spec/support/fixtures/export_job.json
170
+ - spec/support/fixtures/export_job_types.json
161
171
  - spec/support/fixtures/location.json
162
172
  - spec/support/fixtures/locations.json
163
173
  - spec/support/fixtures/match_candidate.json
@@ -168,6 +178,7 @@ files:
168
178
  - spec/support/fixtures/note_category.json
169
179
  - spec/support/fixtures/note_category_types.json
170
180
  - spec/support/fixtures/person.json
181
+ - spec/support/fixtures/phones.json
171
182
  - spec/support/fixtures/printed_list.json
172
183
  - spec/support/fixtures/printed_lists.json
173
184
  - spec/support/fixtures/pronouns.json
@@ -176,6 +187,8 @@ files:
176
187
  - spec/support/fixtures/reported_language_preferences.json
177
188
  - spec/support/fixtures/reported_races.json
178
189
  - spec/support/fixtures/reported_sexual_orientations.json
190
+ - spec/support/fixtures/saved_list.json
191
+ - spec/support/fixtures/saved_lists.json
179
192
  - spec/support/fixtures/signup.json
180
193
  - spec/support/fixtures/signup_statuses.json
181
194
  - spec/support/fixtures/signups.json
metadata.gz.sig CHANGED
Binary file