openapply 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 89fcc25f4b251ea7bed8c94a12e05f69bd379c6c87d097576ed9bd589365af3c
4
+ data.tar.gz: c806bc3f83c5b8e4879b739f98cbb384c78e7b2d2091161ca115faf50ed5d6b8
5
+ SHA512:
6
+ metadata.gz: 8ef763e465b040b37bf910483266a85a84960948a05b62f081475a5943262e5e42bccb0f9dc1c42a447224a973469ab89443950b1ca931490560023c0b9c2cd7
7
+ data.tar.gz: b7cfa50c180eaefefba50bb44f04cfae1eb1c3d7f766950228a58cdb9815403f9974aa8f333bab411b572f4027a4cda42509ca4c3689470faecc809ce06394e1
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ # !examples/demo/.rbenv-vars
16
+ examples/demo/.rbenv-vars
17
+ /.rbenv-vars
18
+
19
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.15.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at btihen@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in openapply.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Bill Tihen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,506 @@
1
+ # Openapply
2
+
3
+ This gem allows ruby access to the OpenApply API v1 - and supports the GET features described at: https://dev.faria.co/oa
4
+
5
+ ### Still TODO
6
+
7
+ * test timeouts
8
+ * write PUTS methods
9
+ * fix rdocs - not mapping to methods
10
+ * write method to flatten data structures
11
+ * write a recursive query to pull students by since date (with any status or change date)
12
+ * write a recursive query to pull students by since id (with any status or change date)
13
+ * investigate faster response when returning large number of records
14
+
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'openapply'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install openapply
31
+
32
+ ## Usage
33
+
34
+ ### Full Docs
35
+
36
+ * http://www.rubydoc.info/gems/openapply
37
+
38
+ ### Configuration
39
+
40
+ * Setup / Config the following ENV-VARS (example code uses **.rbenv-vars**):
41
+
42
+ ```bash
43
+ # timeout in seconds (before retry - 3 times)
44
+ OA_TIMEOUT=5
45
+
46
+ # 100 records is the advertised default record count, but in reality it is 10
47
+ OA_RELPY_RECORDS=100
48
+
49
+ # currently this is the only API path available
50
+ OA_API_PATH=/api/v1/students/
51
+
52
+ # point to your own site (this is the demo site)
53
+ OA_BASE_URI=demo.openapply.com
54
+
55
+ # this is the demo site key - you will need your own key for your own site
56
+ OA_AUTH_TOKEN=demo_site_api_key
57
+ ```
58
+
59
+ ### Instantiation
60
+ Associates the above settings with HTTParty
61
+ (so that you can access the OpenApply api)
62
+
63
+ ```ruby
64
+ @oa = OpenApply::Client.new
65
+ ```
66
+
67
+ #### Example Usage
68
+
69
+ ```ruby
70
+ # instantiate
71
+ @oa = OpenApply::Client.new
72
+
73
+ # see settings
74
+ @oa.api_url
75
+ @oa.api_key
76
+ @oa.base_path
77
+ @oa.api_timeout
78
+ @oa.record_count
79
+ # replace record_count with reply count
80
+ # oa.reply_count
81
+ ```
82
+
83
+ #### Method list
84
+
85
+ * individual student details
86
+
87
+ ```ruby
88
+ # all student info & parents info
89
+ def student_by_id(student_id, options ={})
90
+ # all payments associated with a student
91
+ def payments_by_id(student_id, options={})
92
+ # this is all student details (combines studnet, parent and payments)
93
+ def student_details_by_id(id, flatten = false)
94
+ ```
95
+
96
+ * group of students (summary data) -- **(recursive - collects all pages of records if return_count < total_records)**
97
+
98
+ ```ruby
99
+ # summary info of students with a given status
100
+ def students_by_status(status)
101
+ # only student ids of students with a given status
102
+ def student_ids_by_status(status)
103
+ #
104
+ # returns all student details for all students of a given status **returned as a hash)**
105
+ def students_details_by_status(status)
106
+ #
107
+ # TODO: add in v0.2.1
108
+ # # returns all student details for all students of a given status **(returned as a csv string - only returns data matching the keys given)**
109
+ # def students_details_by_status_as_csv(status,keys)
110
+ # # returns all student details for all students of a given status **(returned as an array - only returns data matching the keys given)**
111
+ # def students_details_by_status_as_array(status,keys)
112
+ ```
113
+
114
+ * custom grouping
115
+ ```ruby
116
+ def custom_students_query(status=nil, since_id=nil, since_date=nil, count=api_records)
117
+ def custom_students_url(status=nil, since_id=nil, since_date=nil, count=api_records)
118
+ ```
119
+
120
+ #### Get Individual student information
121
+
122
+ * Get a complete student record using student id -- includes: *(demographic, custom_fields, parent info & sibling ids)*
123
+
124
+ ```ruby
125
+ # def one_student_record_by_id(student_id, options ={})
126
+
127
+ @oa = OpenApply::Client.new
128
+ @answer = @oa.student_by_id(95)
129
+
130
+ # answer formats include:
131
+ # { student:
132
+ # { id: value1,
133
+ # name: kid_name,
134
+ # custom_fields: {
135
+ # key3: value3,
136
+ # key4: value4
137
+ # }
138
+ # },
139
+ # linked: {
140
+ # parents: [
141
+ # id: value5,
142
+ # name: parent_name,
143
+ # custom_fields: {
144
+ # key6: value6,
145
+ # ...
146
+ # }
147
+ # ]
148
+ # }
149
+ # }
150
+ ```
151
+
152
+ * Get a student's payment records
153
+
154
+ ```ruby
155
+ @oa = OpenApply::Client.new
156
+ @answer = @oa.payments_by_id(95)
157
+
158
+ # answer format is:
159
+ # {
160
+ # payments: [
161
+ # {key1: value1, key2: value2},
162
+ # {key1: value3, key2: value3}
163
+ # ],
164
+ # }
165
+ ```
166
+
167
+ * Get all student data about one individual - includes: *(demographic, gardians, sibling ids, & payment records)*
168
+
169
+ ```ruby
170
+ @oa = OpenApply::Client.new
171
+ @answer = @oa.student_details_by_id(95)
172
+
173
+ # answer format is:
174
+ # { student:
175
+ # {
176
+ # id: id,
177
+ # record:
178
+ # { id: id,
179
+ # name: kid_name,
180
+ # ... ,
181
+ # custom_fields: {
182
+ # key2: value2,
183
+ # ...
184
+ # }
185
+ # },
186
+ # payments: [
187
+ # {payment1},
188
+ # {payment2}
189
+ # ],
190
+ # guardians: [
191
+ # { id: id,
192
+ # name: guardian1,
193
+ # ... ,
194
+ # custom_fields: {
195
+ # key2: value2,
196
+ # ...
197
+ # }
198
+ # },
199
+ # { id: id,
200
+ # name: guardian2,
201
+ # ... ,
202
+ # custom_fields: {
203
+ # key2: value2,
204
+ # ...
205
+ # }
206
+ # }
207
+ # ]
208
+ # }
209
+ # }
210
+ ```
211
+
212
+ #### Group queries (by status)
213
+
214
+ * **valid status includes:**
215
+ - Status
216
+ - Pending
217
+ - Applied
218
+ - Admitted
219
+ - Wait-listed
220
+ - Declined
221
+ - Enrolled
222
+ - Graduated
223
+ - Withdrawn
224
+
225
+
226
+ * Get student summary info of all students of a given status **(all pages - uses recursion)**
227
+
228
+ ```ruby
229
+ # def all_student_summaries_by_status(status)
230
+
231
+ @oa = OpenApply::Client.new
232
+ @answer = @oa.students_by_status('applied')
233
+
234
+ # answer format is:
235
+ # { students: [
236
+ # { id: id1,
237
+ # name: kid1,
238
+ # ...,
239
+ # { id: id2,
240
+ # name: kid_name_2,
241
+ # ...,
242
+ # }
243
+ # ],
244
+ # linked: {
245
+ # parents: [
246
+ # id: value5,
247
+ # name: parent_name,
248
+ # custom_fields: {
249
+ # key6: value6,
250
+ # ...
251
+ # }
252
+ # ]
253
+ # }
254
+ # }
255
+ ```
256
+
257
+ * Get a list of student ids of all students of a given status **(all pages - uses recursion)**
258
+
259
+ ```ruby
260
+ # def all_student_ids_by_status(status)
261
+
262
+ @oa = OpenApply::Client.new
263
+ @answer = @oa.student_ids_by_status('applied')
264
+
265
+ # answer format is:
266
+ # { student_ids: [95, 160, 240] }
267
+ ```
268
+
269
+ * Get all student data of all students of a given status **(all pages - uses recursion)**
270
+
271
+ ```ruby
272
+ # def all_students_all_data_by_status(status)
273
+
274
+ @oa = OpenApply::Client.new
275
+ @answer = @oa.students_details_by_status('enrolled')
276
+
277
+ # TODO: add correct info
278
+ # answer formats include:
279
+ # { students:
280
+ # [
281
+ # { id: value1,
282
+ # key2: value2,
283
+ # custom_fields: {
284
+ # key3: value3,
285
+ # key4: value4
286
+ # }
287
+ # },
288
+ # { id: valueX,
289
+ # key2: valueY,
290
+ # custom_fields: {
291
+ # key3: valueZ,
292
+ # key4: valueA
293
+ # }
294
+ # }
295
+ # ],
296
+ # guardians: [
297
+ # {
298
+ # id: value5,
299
+ # custom_fields: {
300
+ # key6: value6,
301
+ # ...
302
+ # },
303
+ # {
304
+ # id: value6,
305
+ # custom_fields: {
306
+ # key6: value7,
307
+ # ...
308
+ # },
309
+ # ]
310
+ # }
311
+ ```
312
+
313
+
314
+ * Get all student data of all students of a given status **(all pages - uses recursion)**
315
+
316
+ ```ruby
317
+ # FLATTEN RECORDS
318
+ # def all_students_all_data_by_status(status,true)
319
+
320
+ @oa = OpenApply::Client.new
321
+ @answer = @oa.students_details_by_status('enrolled',true)
322
+
323
+ # answer formats include:
324
+ # { students:
325
+ # [
326
+ # { id: value1,
327
+ # name: kid_1,
328
+ # key3: value3,
329
+ # key4: value4
330
+ # },
331
+ # { id: valueX,
332
+ # name: kid_2,
333
+ # key3: valueZ,
334
+ # key4: valueA
335
+ # }
336
+ # ],
337
+ # guardians: [
338
+ # { id: value5,
339
+ # name: guardian_1
340
+ # key6: value6,
341
+ # ...
342
+ # },
343
+ # { id: value6,
344
+ # name: guardian_2
345
+ # key6: value7,
346
+ # ...
347
+ # },
348
+ # ]
349
+ # }
350
+ ```
351
+
352
+ #### Custom URL (GET) API calls
353
+
354
+ * Get student summary info of students with a custom query - supporting the description here: https://dev.faria.co/oa/#responses **(one page - no recursion)**
355
+
356
+ ```ruby
357
+ # def custom_student_summaries(status=nil, since_id=nil, since_date=nil, count=self.record_count)
358
+
359
+ @oa = OpenApply::Client.new
360
+ # status -- return records matching this status
361
+ # since_id -- return records with ids after this id
362
+ # since_date (format: 'YYYY-MM-DD') -- return records updated after this date
363
+ # count (>= 1) -- is the number of records to return
364
+ @answer = @oa.students_custom('applied',240,nil,3)
365
+ @answer = @oa.students_custom('applied',nil,'2015-09-12',3)
366
+
367
+ # answer formats include:
368
+ # { students:
369
+ # [
370
+ # { id: value1,
371
+ # name: kid_1,
372
+ # ...,
373
+ # custom_fields: {
374
+ # key3: value3,
375
+ # key4: value4
376
+ # }
377
+ # },
378
+ # { id: valueX,
379
+ # name: kid_2,
380
+ # ...,
381
+ # custom_fields: {
382
+ # key3: valueZ,
383
+ # key4: valueA
384
+ # }
385
+ # }
386
+ # ],
387
+ # linked: {}
388
+ # parents: [
389
+ # {
390
+ # id: value5,
391
+ # name: parent_1,
392
+ # ...,
393
+ # custom_fields: {
394
+ # key6: value6,
395
+ # ...
396
+ # },
397
+ # {
398
+ # id: value6,
399
+ # name: parent_2,
400
+ # ...,
401
+ # custom_fields: {
402
+ # key6: value7,
403
+ # ...
404
+ # },
405
+ # ]
406
+ # }
407
+ # meta: {
408
+ # page: 3,
409
+ # per_page": "2"
410
+ # }
411
+ # }
412
+ ```
413
+
414
+ * Get a response to a custom url query - this is the lowest level access
415
+
416
+ ```ruby
417
+ # def oa_answer( url, options={} )
418
+
419
+ url = "api/v1/students?since_id=269&auth_token=demo_site_api_key"
420
+
421
+ @oa = OpenApply::Client.new
422
+ @oa_answer = @oa.oa_answer( url )
423
+
424
+ # answer format like:
425
+ #<HTTParty::Response:0x7f851fa20408 parsed_response="{\"payments\":[]}", @response=#<Net::HTTPOK 200 readbody=true>, @headers={}>
426
+ #
427
+ # access data using something like:
428
+ return { error: "no answer" } unless @oa_answer.responds_to? 'response'
429
+ return { error: "no answer" } unless (@oa_answer.response).responds_to? 'body'
430
+ return JSON.parse( @api_answer.response.body, symbolize_names: true )
431
+
432
+ # answer formats include:
433
+ # { student:
434
+ # { id: value1,
435
+ # key2: value2,
436
+ # custom_fields: {
437
+ # key3: value3,
438
+ # key4: value4
439
+ # }
440
+ # },
441
+ # linked: {
442
+ # parents: [
443
+ # id: value5,
444
+ # custom_fields: {
445
+ # key6: value6,
446
+ # ...
447
+ # }
448
+ # ]
449
+ # }
450
+ # }
451
+ # or
452
+ # {
453
+ # payments: [
454
+ # {key1: value1, key2: value2},
455
+ # {key1: value3, key2: value3}
456
+ # ],
457
+ # }
458
+ # or
459
+ # {
460
+ # students: [
461
+ # {id: value1, key2: value2, custom_fields: {key3: value3, key4: value4} },
462
+ # {id: value3, key2: value3, custom_fields: {key3: value3, key5: value5} }
463
+ # ],
464
+ # linked: {
465
+ # parents: [
466
+ # id: value5,
467
+ # custom_fields: {
468
+ # key6: value6,
469
+ # ...
470
+ # }
471
+ # ]
472
+ # }
473
+ # meta: {
474
+ # page: 3,
475
+ # per_page": "10"
476
+ # }
477
+ # }
478
+ ```
479
+
480
+ #### Group queries with recursion (by since_date)
481
+ not done (just code stubs)- not yet needed
482
+
483
+ #### Group queries with recursion (by since_id)
484
+ not done (just code stubs)- not yet needed
485
+
486
+ #### See Examples Folder
487
+
488
+ for an actual complete code examples
489
+
490
+ ## Development
491
+
492
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
493
+
494
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
495
+
496
+ ## Contributing
497
+
498
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/openapply. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
499
+
500
+ ## License
501
+
502
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
503
+
504
+ ## Code of Conduct
505
+
506
+ Everyone interacting in the Openapply project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/openapply/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "openapply"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ OA_TIMEOUT=5
2
+ OA_RELPY_RECORDS=50
3
+ OA_BASE_PATH=/api/v1/students/
4
+ OA_BASE_URI=demo.openapply.com
5
+ OA_AUTH_TOKEN=319d9a3fbd50c8272a2b508e138a1ada
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
+
6
+ gem "openapply", "~> 0.2"