openapply 0.2.10 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -7
- data/.travis.yml.bak +18 -0
- data/CHANGE_LOG.md +50 -0
- data/Gemfile.lock +6 -4
- data/MM +0 -0
- data/README.md +26 -200
- data/lib/openapply/client.rb +13 -39
- data/lib/openapply/get_many_students.rb +125 -0
- data/lib/openapply/get_one_student.rb +65 -0
- data/lib/openapply/version.rb +1 -1
- data/openapply.gemspec +9 -39
- metadata +17 -18
- data/examples/demo/Gemfile +0 -6
- data/examples/demo/Gemfile.lock +0 -24
- data/examples/demo/README.md +0 -123
- data/examples/demo/demo_site.rb +0 -92
- data/lib/openapply/convert_to_array.rb +0 -215
- data/lib/openapply/convert_to_csv.rb +0 -59
- data/lib/openapply/convert_to_xlsx.rb +0 -80
- data/lib/openapply/get_student.rb +0 -219
- data/lib/openapply/get_students.rb +0 -209
- data/lib/openapply/send_to_remote.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d215ce3e5704b8f304e92d62662e7c2cb43caa5de24c4048e08c40d69021be1
|
4
|
+
data.tar.gz: 8fc1fffd0992271dbbf8830135d7bfb21d16c37bf716560555b262e51d82496c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d83905b01dd0f99615be384bc96dc463cfb7c73043bc3f4435ebdbeee56005b391744e2127cd9b18158bd0738c45e719c8471703c8ea7312249f4762be642b4
|
7
|
+
data.tar.gz: 655011c0694be255269277ec02bc3aff80828eedf48bb637545240671a763a70cd8721aa2f55cc516e013a2d159f0d21ff3c59968131e9fbd234a8dc863cd3e7
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
sudo: false
|
2
|
-
|
3
2
|
language: ruby
|
4
|
-
|
5
3
|
branches:
|
6
4
|
only:
|
7
5
|
- master
|
8
6
|
- staging
|
9
|
-
|
10
7
|
rvm:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
- 2.5.0
|
9
|
+
before_install:
|
10
|
+
- gem update --system
|
11
|
+
- gem install bundler -v 1.16.0
|
12
|
+
env:
|
13
|
+
global:
|
14
|
+
secure: IVOwOQStCtCmZBLQszuNwWyYUapjAc3eNOH4trC/hNoYrrtse+WT2c4fRbvL3dFt+Iu/hFxVmtS9Gefmidfp0vCRLm/tPiL2Qsq97brZgb1oekcYx0QlelwXEk76QekIc9RXRle/UZArH+XLcsYzgW2mCVqe6IHElqQAilleu7B5yxtyor/Z+zMfi2d6qYJDMYockISlcmBG1ydshRqrh6sYXCeQutXdPKz1OBuSzwTiz2YcZfVV6SIqkavn6KfQCIQJNBCEU93i54i9f8IV1qrtYLMUfEV4Fah/MT5VGOGH4kNG5OTGna++oqrA9wXRZxPuEX/5e4kELxzg775Wvn9Jfq/NAZVVC63Uk84cags9yp98x0p1Le+JWunQNV1FMb4iuK7wnI07iT1VCtweiPZ6zobW50IyjOS3teyElikBF+j46x63vLNMmzlUU7VkYXTorfr/EOX6v4Pwkgde+b4SIvCemq0pYEahxumY+z6QFbHkvJ7xXiV5n5TLtI1WaLiB/X95X+gF3DUALf3CBgj5rx6cIIgTb5nON8OGYKVo6Oym2VvoSXiCRo2eFjQxtt5fT0AGvDPDg8AlsA+sMR9ISOk2xEkKEM9YG8XIwlQPctZdNHXLlq/rgRuQVvCjlDpbGL202Nw6LGav+dIrnnuGfCIyASC8pAALvmz5ZWw=
|
data/.travis.yml.bak
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
sudo: false
|
2
|
+
|
3
|
+
language: ruby
|
4
|
+
|
5
|
+
branches:
|
6
|
+
only:
|
7
|
+
- master
|
8
|
+
- staging
|
9
|
+
|
10
|
+
rvm:
|
11
|
+
- 2.5.0
|
12
|
+
|
13
|
+
before_install:
|
14
|
+
# needed for ruby 2.5.0
|
15
|
+
# https://github.com/travis-ci/travis-ci/issues/8978
|
16
|
+
- gem update --system
|
17
|
+
- gem install bundler -v 1.16.0
|
18
|
+
# before_install: gem install bundler -v 1.15.4
|
data/CHANGE_LOG.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
### Openapply CHANGE LOG
|
2
|
+
|
3
|
+
* **v0.3.0** - compatible with 0.3.x - 2018-01-31
|
4
|
+
- NOT compatible with 0.2.x
|
5
|
+
- migrate to new documentation style
|
6
|
+
- refactor to use options - simplify and improve usage
|
7
|
+
- refactor to be more modular (usage will change)
|
8
|
+
|
9
|
+
* **v0.2.10** - compatible with 0.2.x - 2018-01-04
|
10
|
+
- updated rake and webmock gems in deve
|
11
|
+
- removed roo - not needed
|
12
|
+
|
13
|
+
* **v0.2.9** - compatible with 0.2.x - 2017-12-13 *(https://github.com/straydogstudio/axlsx_rails/issues/77)*
|
14
|
+
- separated convert (& its dependencies) into separate modules that can be loaded on need in the next version (0.3.x)
|
15
|
+
- hash to array now handles both student_details and student_summaries (this also allows conversion then to csv)
|
16
|
+
|
17
|
+
* **v0.2.8** - compatible with 0.2.x - 2017-12-11 *(https://github.com/randym/axlsx/issues/234)*
|
18
|
+
- axlsx - passes tests - but won't properly install inside another project (even using gem install ./openapply-0.2.7) - will look for a solution
|
19
|
+
|
20
|
+
* **v0.2.7** - compatible with 0.2.x - 2017-12-10
|
21
|
+
- safely re-enabled axlsx by using the master branch and upgradeing rubyzip
|
22
|
+
|
23
|
+
* **v0.2.6** - compatible with 0.2.x - 2017-12-08
|
24
|
+
- allow ssh/scp options to be passed
|
25
|
+
|
26
|
+
* **v0.2.5** - compatible with 0.2.x - 2017-11-30
|
27
|
+
- removed a reference to AXLSX in scp transfers *(haven't figured out how to test that yet!)*
|
28
|
+
|
29
|
+
* **v0.2.4** - compatible with 0.2.x - 2017-11-30
|
30
|
+
- rubyzip 1.1.7 - has a serious security flaw - Axlsx and Roo cannot use rubyzip 1.2.1 -- YET (which doesn't have the flaw) - so xlsx features are disabled until rubyzip 1.2.1 can be used by both roo and axlsx. **CSV** conversions are still usable. **BIG THANKS TO GitHub for the notification!**
|
31
|
+
|
32
|
+
* **v0.2.3** - compatible with 0.2.x - 2017-11-23
|
33
|
+
- allow detailed queries *(_by_id & _by_status)* to skip payment information
|
34
|
+
- allow array, csv & xlsx transformations to skip payment queries (when no payment_info requested)
|
35
|
+
|
36
|
+
* **v0.2.2** - compatible with 0.2.x - 2017-11-21
|
37
|
+
- refactor and test url timeouts
|
38
|
+
- refactor openapply client
|
39
|
+
|
40
|
+
* **v0.2.1** - compatible with 0.2.x - 2017-11-20
|
41
|
+
- convert api data into an array, csv or xlsx
|
42
|
+
- allow data flattening prep for post processing
|
43
|
+
- allow queries to lookup students with multiple statuses
|
44
|
+
- allow scp string object to file export (no automated tests)
|
45
|
+
|
46
|
+
* **v0.2.0** - first release -- **NOT** compatible with 0.1.0 -- 2017-11-07
|
47
|
+
- get student details of a give status (and pure api calls)
|
48
|
+
- recursive query until all receipt of all records received
|
49
|
+
|
50
|
+
* **v0.1.0** - test release -- 2017-11-01
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openapply (0.
|
4
|
+
openapply (0.3.0)
|
5
5
|
httparty (~> 0.15)
|
6
6
|
json (~> 2.1)
|
7
7
|
net-scp (~> 1.2)
|
@@ -12,6 +12,8 @@ GEM
|
|
12
12
|
specs:
|
13
13
|
addressable (2.5.2)
|
14
14
|
public_suffix (>= 2.0.2, < 4.0)
|
15
|
+
codacy-coverage (1.1.8)
|
16
|
+
simplecov
|
15
17
|
coderay (1.1.2)
|
16
18
|
crack (0.4.3)
|
17
19
|
safe_yaml (~> 1.0.0)
|
@@ -43,14 +45,14 @@ GEM
|
|
43
45
|
rspec-mocks (3.7.0)
|
44
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
47
|
rspec-support (~> 3.7.0)
|
46
|
-
rspec-support (3.7.
|
48
|
+
rspec-support (3.7.1)
|
47
49
|
safe_yaml (1.0.4)
|
48
50
|
simplecov (0.15.1)
|
49
51
|
docile (~> 1.1.0)
|
50
52
|
json (>= 1.8, < 3)
|
51
53
|
simplecov-html (~> 0.10.0)
|
52
54
|
simplecov-html (0.10.2)
|
53
|
-
webmock (3.
|
55
|
+
webmock (3.3.0)
|
54
56
|
addressable (>= 2.3.6)
|
55
57
|
crack (>= 0.3.2)
|
56
58
|
hashdiff
|
@@ -60,11 +62,11 @@ PLATFORMS
|
|
60
62
|
|
61
63
|
DEPENDENCIES
|
62
64
|
bundler (~> 1.15)
|
65
|
+
codacy-coverage (~> 1.1)
|
63
66
|
openapply!
|
64
67
|
pry (~> 0.11)
|
65
68
|
rake (~> 12.3)
|
66
69
|
rspec (~> 3.7)
|
67
|
-
simplecov (~> 0.15)
|
68
70
|
webmock (~> 3.2)
|
69
71
|
|
70
72
|
BUNDLED WITH
|
data/MM
ADDED
File without changes
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/btihen/openapply.svg?branch=master)](https://travis-ci.org/btihen/openapply)
|
1
|
+
[![Build Status](https://travis-ci.org/btihen/openapply.svg?branch=master)](https://travis-ci.org/btihen/openapply) [![Dependency Status](https://beta.gemnasium.com/badges/github.com/btihen/openapply.svg)](https://beta.gemnasium.com/projects/github.com/btihen/openapply) [![Known Vulnerabilities](https://snyk.io/test/github/btihen/openapply/badge.svg?targetFile=Gemfile.lock)](https://snyk.io/test/github/btihen/openapply?targetFile=Gemfile.lock) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b2062680fd14704bd321baef8dbddce)](https://www.codacy.com/app/btihen/openapply?utm_source=github.com&utm_medium=referral&utm_content=btihen/openapply&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/7b2062680fd14704bd321baef8dbddce)](https://www.codacy.com/app/btihen/openapply?utm_source=github.com&utm_medium=referral&utm_content=btihen/openapply&utm_campaign=Badge_Coverage) [![Code Quality](https://bettercodehub.com/edge/badge/btihen/shop?branch=master)](https://bettercodehub.com/) [![Coverage Status](https://coveralls.io/repos/github/btihen/openapply/badge.svg?branch=master)](https://coveralls.io/github/btihen/openapply?branch=master)
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -10,55 +10,11 @@ This gem allows ruby access to the OpenApply API v1 - and supports the GET featu
|
|
10
10
|
|
11
11
|
### Still TODO
|
12
12
|
|
13
|
-
* allow flattening to work with arrays?
|
14
|
-
* allow flattening and reject to work at 2 levels of depth?
|
15
|
-
* make tests for scp / ssh (at least data type conversions)?
|
16
|
-
* write PUTS methods - *currently api only allows status update*
|
17
|
-
* write a recursive custom query - when results are more than one page
|
18
|
-
* allow flattening and reject to work at any depth (with recursion)?
|
19
|
-
* speed up response when returning large number of records? - **looks like API**
|
20
|
-
|
21
13
|
|
22
14
|
### CHANGE LOG
|
23
15
|
|
24
|
-
|
25
|
-
- separated convert (& its dependencies) into separate modules that can be loaded on need in the next version (0.3.x)
|
26
|
-
- hash to array now handles both student_details and student_summaries (this also allows conversion then to csv)
|
27
|
-
|
28
|
-
* **v0.2.8** - compatible with 0.2.x - 2017-12-11 *(https://github.com/randym/axlsx/issues/234)*
|
29
|
-
- axlsx - passes tests - but won't properly install inside another project (even using gem install ./openapply-0.2.7) - will look for a solution
|
30
|
-
|
31
|
-
* **v0.2.7** - compatible with 0.2.x - 2017-12-10
|
32
|
-
- safely re-enabled axlsx by using the master branch and upgradeing rubyzip
|
33
|
-
|
34
|
-
* **v0.2.6** - compatible with 0.2.x - 2017-12-08
|
35
|
-
- allow ssh/scp options to be passed
|
36
|
-
|
37
|
-
* **v0.2.5** - compatible with 0.2.x - 2017-11-30
|
38
|
-
- removed a reference to AXLSX in scp transfers *(haven't figured out how to test that yet!)*
|
39
|
-
|
40
|
-
* **v0.2.4** - compatible with 0.2.x - 2017-11-30
|
41
|
-
- rubyzip 1.1.7 - has a serious security flaw - Axlsx and Roo cannot use rubyzip 1.2.1 -- YET (which doesn't have the flaw) - so xlsx features are disabled until rubyzip 1.2.1 can be used by both roo and axlsx. **CSV** conversions are still usable. **BIG THANKS TO GitHub for the notification!**
|
42
|
-
|
43
|
-
* **v0.2.3** - compatible with 0.2.x - 2017-11-23
|
44
|
-
- allow detailed queries *(_by_id & _by_status)* to skip payment information
|
45
|
-
- allow array, csv & xlsx transformations to skip payment queries (when no payment_info requested)
|
46
|
-
|
47
|
-
* **v0.2.2** - compatible with 0.2.x - 2017-11-21
|
48
|
-
- refactor and test url timeouts
|
49
|
-
- refactor openapply client
|
50
|
-
|
51
|
-
* **v0.2.1** - compatible with 0.2.x - 2017-11-20
|
52
|
-
- convert api data into an array, csv or xlsx
|
53
|
-
- allow data flattening prep for post processing
|
54
|
-
- allow queries to lookup students with multiple statuses
|
55
|
-
- allow scp string object to file export (no automated tests)
|
16
|
+
[Change Log](https://github.com/btihen/openapply/blob/master/CHANGE_LOG.md)
|
56
17
|
|
57
|
-
* **v0.2.0** - first release -- **NOT** compatible with 0.1.0 -- 2017-11-07
|
58
|
-
- get student details of a give status (and pure api calls)
|
59
|
-
- recursive query until all receipt of all records received
|
60
|
-
|
61
|
-
* **v0.1.0** - test release -- 2017-11-01
|
62
18
|
|
63
19
|
### Installation
|
64
20
|
|
@@ -116,7 +72,7 @@ Associates the above settings with HTTParty
|
|
116
72
|
(so that you can access the OpenApply api)
|
117
73
|
|
118
74
|
```ruby
|
119
|
-
@oa =
|
75
|
+
@oa = Openapply::Client.new
|
120
76
|
```
|
121
77
|
|
122
78
|
### USAGE
|
@@ -133,160 +89,30 @@ Associates the above settings with HTTParty
|
|
133
89
|
@oa.base_path
|
134
90
|
@oa.api_timeout
|
135
91
|
@oa.api_records
|
136
|
-
#
|
137
|
-
# directly call against the OA API
|
138
|
-
@oa.oa_api_call('/api/v1/students/?status=accepted&count=5&auth_token=add_api_key')
|
139
|
-
#
|
140
|
-
|
141
|
-
# Individual students records (separated)
|
142
|
-
@oa.student_by_id(95)
|
143
|
-
@oa.payments_by_id(95)
|
144
|
-
#
|
145
|
-
# individual student records combined & possible pre-processing
|
146
|
-
@oa.student_details_by_id(95)
|
147
|
-
|
148
|
-
# ATTRIBUTES: id, [:keys_to_un-nest], [:keys_to_exclude]
|
149
|
-
@oa.student_details_by_id(95, [:custom_fields], [:parent_guardian])
|
150
|
-
|
151
|
-
# skip payment info -- (payments: [])
|
152
|
-
@oa.student_details_by_id(95, [:custom_fields], [:parent_guardian], false)
|
153
|
-
#
|
154
|
-
# student summaries of a given status (recursively if more than on page)
|
155
|
-
@oa.students_by_status('applied')
|
156
|
-
#
|
157
|
-
# student details of a given status (recursively if more than on page)
|
158
|
-
@oa.students_details_by_status('applied')
|
159
|
-
@oa.students_details_by_status('applied', [:custom_fields], [:parent_guardian])
|
160
|
-
# skip payment info (payments: [])
|
161
|
-
@oa.students_details_by_status('applied', [:custom_fields], [:parent_guardian], false)
|
162
|
-
#
|
163
|
-
# student details with multiple status (recursively if more than on page)
|
164
|
-
@oa.students_details_by_statuses(['applied','enrolled'], [:custom_fields])
|
165
|
-
#
|
166
|
-
# create an array
|
167
|
-
@oa.students_as_array_by_status('applied', [:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
|
168
|
-
# multiple statuses into an array
|
169
|
-
@oa.students_as_array_by_statuses(['applied','enrolled'], [:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
|
170
|
-
#
|
171
|
-
# Create a csv string
|
172
|
-
# multiple status into
|
173
|
-
csv_string=@oa.students_as_csv_by_statuses(['applied','enrolled'],[:custom_fields], [:parent_guardian], [:id, :name], {type: :guardians, count: 1, keys: [:id, :name, :address]}, {type: :payments, count: 2, order: :newest, keys: [:date, :amount]} )
|
174
|
-
#
|
175
|
-
# send CSV to a remote server as a file - using ssh-keys
|
176
|
-
@oa.send_data_to_remote_server(csv_string, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
|
177
|
-
#
|
178
|
-
# send CSV to a remote server as a file - using ssh-keys - don't check host_key of remote server
|
179
|
-
@oa.send_data_to_remote_server( csv_string, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750', {verify_host_key: false} )
|
180
|
-
|
181
|
-
# Create XLSX file
|
182
|
-
# @oa.students_as_xlsx_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {type: :guardians, count: 1, keys: [:id, :name, :address]}, {type: :payments, count: 2, order: :newest, keys: [:date, :amount]} )
|
183
|
-
# # # multiple status into
|
184
|
-
# xlsx_obj=@oa.students_as_xlsx_by_statuses(['applied','enrolled'],[:custom_fields], [:parent_guardian], [:id, :name], {type: :guardians, count: 1, keys: [:id, :name, :address]}, {type: :payments, count: 2, order: :newest, keys: [:date, :amount]} )
|
185
|
-
# #
|
186
|
-
# # send XLSX to a remote server as a file - using ssh-keys
|
187
|
-
# @oa.send_data_to_remote_server(xlsx_obj, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.xlsx', '0750')
|
188
|
-
```
|
189
|
-
|
190
|
-
#### INDIVIDUAL STUDENT QUERIES
|
191
|
-
|
192
|
-
```ruby
|
193
|
-
# all student info & parents info -- returns the data straight from OpenApply
|
194
|
-
student_record = @oa.student_by_id(95)
|
195
|
-
|
196
|
-
# all payments associated with a student -- returns the data straight from OpenApply
|
197
|
-
student_payments = @oa.payments_by_id(95)
|
198
|
-
|
199
|
-
# Returns all student details (combines studnet, parent and payments)
|
200
|
-
# **flatten_keys** - brings these keys to the top level - prepending the group name to the key name -- we usually use:
|
201
|
-
# flatten_keys = [:custom_fields]
|
202
|
-
# **reject keys** -- removes the data matching these keys -- we usually use:
|
203
|
-
# reject_keys = [:parent_guardian] (since this is duplicated)
|
204
|
-
# returns the data structured as:
|
205
|
-
# { student: {
|
206
|
-
# id: xxx,
|
207
|
-
# record: {xxx} # complete student record
|
208
|
-
# guardians: [ {} ] # all guardian information
|
209
|
-
# payments: [ {} ] # all payments made via openapply
|
210
|
-
# }
|
211
|
-
# }
|
212
|
-
@oa.student_details_by_id(95)
|
213
|
-
# or
|
214
|
-
@oa.student_details_by_id(95, [:custom_fields], [:parent_guardian])
|
215
|
-
```
|
216
92
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
#
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
ids
|
227
|
-
|
228
|
-
|
229
|
-
#
|
230
|
-
#
|
231
|
-
|
232
|
-
|
233
|
-
@oa.
|
234
|
-
@oa.
|
235
|
-
|
236
|
-
|
237
|
-
@oa.
|
238
|
-
```
|
239
|
-
|
240
|
-
|
241
|
-
#### STUDENT DATA TRANFORMATIONS
|
242
|
-
|
243
|
-
```ruby
|
244
|
-
# student details - in an array format (instead of hash)
|
245
|
-
# ATTRIBUTES - status, flatten_keys, reject_keys, student_keys(into array), guardian_info(into array), payment_info(into array)
|
246
|
-
# guardian and payment info options:
|
247
|
-
# count - how many records to return
|
248
|
-
# keys - which keys to return to array/csv
|
249
|
-
# order: :newest/:oldest (for payments) - return newest or oldest payments first
|
250
|
-
@oa.students_as_array_by_status('applied', nil, nil, [:id, :name], nil, {count: 2, order: :newest, keys: [:date, :amount]} )
|
251
|
-
# all options
|
252
|
-
@oa.students_as_array_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
|
253
|
-
#
|
254
|
-
# Create a csv string
|
255
|
-
@oa.students_as_csv_by_status('applied', nil, nil, [:id, :name], nil, {count: 2, order: :newest, keys: [:date, :amount]} )
|
256
|
-
# all options
|
257
|
-
csv=@oa.students_as_csv_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
|
258
|
-
#
|
259
|
-
# send CSV to a remote server as a file - using ssh-keys
|
260
|
-
# attributes: csv_string, srv_hostname, srv_username, srv_path_file, file_permissions(0750 - default if not specified)
|
261
|
-
@oa.send_data_to_remote_server(csv, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
|
262
|
-
#
|
263
|
-
# # Create a XLSX package
|
264
|
-
@oa.students_as_xlsx_by_status('applied', nil, nil, [:id, :name], nil, {count: 2, order: :newest, keys: [:date, :amount]} )
|
265
|
-
# # all options
|
266
|
-
xlsx_obj=@oa.students_as_xlsx_by_status('applied',[:custom_fields], [:parent_guardian], [:id, :name], {count: 1, keys: [:id, :name, :address]}, {count: 2, order: :newest, keys: [:date, :amount]} )
|
267
|
-
# #
|
268
|
-
# # send CSV to a remote server as a file - using ssh-keys
|
269
|
-
# # attributes: csv_string, srv_hostname, srv_username, srv_path_file, file_permissions(0750 - default if not specified)
|
270
|
-
@oa.send_data_to_remote_server(xlsx_obj, 'hostname.domain.name', 'myusername', '/home/myusername/xfer/myexport.csv', '0750')
|
271
|
-
```
|
272
|
-
|
273
|
-
#### CUSTOM GROUP QUERIES - summary data
|
274
|
-
|
275
|
-
```ruby
|
276
|
-
# status = 'applied' # all records matching a valid openapply status
|
277
|
-
# since_id = 95 # all records with ids after 95
|
278
|
-
# since_date = '2017-11-12' # all records modified after 2017-11-12 (& time)
|
279
|
-
# count = 20 # records per page
|
280
|
-
|
281
|
-
# build a custom url query to send to OA api
|
282
|
-
# returns a url that can be passed to api
|
283
|
-
@oa.students_query_url('applied', 106, '2017-11-12', 25)
|
284
|
-
|
285
|
-
# executes a custom query and returns a group of student summaries matching criteria
|
286
|
-
@oa.students_query('applied', 106, '2017-11-12', 25)
|
93
|
+
# Individual student record
|
94
|
+
# (note: parent info is duplicated)
|
95
|
+
@oa.student_by_id( id )
|
96
|
+
@oa.payments_by_id( id )
|
97
|
+
|
98
|
+
# Student Details by IDs:
|
99
|
+
# id - student's record number
|
100
|
+
# options = {get_payments: false}
|
101
|
+
@oa.one_student_details_by_id( id, options={} )
|
102
|
+
# ids - in array format
|
103
|
+
@oa.many_students_details_by_ids( ids, options={} )
|
104
|
+
|
105
|
+
# Query many students by params:
|
106
|
+
# params = {status: 'applied', since_id: 95, since_date: '2018-01-20', count: 50}
|
107
|
+
@oa.many_students_ids( params )
|
108
|
+
@oa.many_ids_updated_time( params )
|
109
|
+
@oa.many_students_summaries( params )
|
110
|
+
@oa.many_students_details( params, options )
|
111
|
+
|
112
|
+
# directly call the OA API - with custom URL
|
113
|
+
@oa.oa_api_call('/api/v1/students/?status=accepted&count=5&auth_token=add_api_key')
|
287
114
|
```
|
288
115
|
|
289
|
-
|
290
116
|
#### OpenApply's allowed statuses
|
291
117
|
|
292
118
|
* **valid status includes:**
|
@@ -309,7 +135,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
309
135
|
|
310
136
|
## Contributing
|
311
137
|
|
312
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
138
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/btihen/btihen/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.
|
313
139
|
|
314
140
|
## License
|
315
141
|
|
@@ -317,4 +143,4 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
317
143
|
|
318
144
|
## Code of Conduct
|
319
145
|
|
320
|
-
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/
|
146
|
+
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/btihen/openapply/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/openapply/client.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
|
-
|
2
|
-
require "openapply/
|
3
|
-
# require "openapply/convert_to_xlsx"
|
4
|
-
require "openapply/convert_to_csv"
|
5
|
-
require "openapply/send_to_remote"
|
6
|
-
require "openapply/get_students"
|
7
|
-
require "openapply/get_student"
|
8
|
-
# require "openapply/convert"
|
9
|
-
# require "openapply/client"
|
1
|
+
require "openapply/get_many_students"
|
2
|
+
require "openapply/get_one_student"
|
10
3
|
require "openapply/put"
|
11
4
|
require 'httparty'
|
12
5
|
|
@@ -21,15 +14,6 @@ module Openapply
|
|
21
14
|
include Put
|
22
15
|
# GET api calls
|
23
16
|
include Get
|
24
|
-
# Convert student data to various formats
|
25
|
-
include ConvertToArray
|
26
|
-
# AXLSX files
|
27
|
-
include ConvertToCsv
|
28
|
-
# AXLSX files
|
29
|
-
# include ConvertToXlsx
|
30
|
-
# Send To Remote ssh
|
31
|
-
include SendToRemote
|
32
|
-
|
33
17
|
# Library for API calls to OpenApply
|
34
18
|
include HTTParty
|
35
19
|
|
@@ -68,21 +52,17 @@ module Openapply
|
|
68
52
|
ENV['OA_RECORD_COUNT'] || '50'
|
69
53
|
end
|
70
54
|
|
71
|
-
# Does the actual api call to OpenApply & handles API timeouts gracefully
|
72
|
-
#
|
73
|
-
#
|
74
|
-
# * +url+ - this is the url to do the call
|
75
|
-
# /api/v1/students/95?auth_token=demo_site_api_key
|
76
|
-
# is the url passed when wanting to do the following cli api call
|
77
|
-
# curl http://demo.openapply.com/api/v1/students/95?auth_token=demo_site_api_key
|
78
|
-
# * +options+ - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
|
55
|
+
# @note Does the actual api call to OpenApply & handles API timeouts gracefully
|
56
|
+
# @param url [String] - this is the url to do the call
|
57
|
+
# @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
|
79
58
|
def oa_api_call(url, options={})
|
80
59
|
# https://stackoverflow.com/questions/26251422/handling-netreadtimeout-error-in-httparty
|
81
60
|
max_retries = 3
|
82
61
|
times_retried = 0
|
83
62
|
begin
|
84
63
|
self.class.get(url, options)
|
85
|
-
rescue Net::ReadTimeout, Net::OpenTimeout => error
|
64
|
+
# rescue Net::ReadTimeout, Net::OpenTimeout => error
|
65
|
+
rescue Net::ReadTimeout, Net::OpenTimeout
|
86
66
|
if times_retried < max_retries
|
87
67
|
times_retried += 1
|
88
68
|
# puts "TIMEOUT RETRY: #{times_retried} of #{max_retries} - USING: #{url.inspect}"
|
@@ -94,14 +74,9 @@ module Openapply
|
|
94
74
|
end
|
95
75
|
end
|
96
76
|
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
# * +url+ - this is the url to do the call
|
101
|
-
# /api/v1/students/95?auth_token=demo_site_api_key
|
102
|
-
# is the url passed when wanting to do the following cli api call
|
103
|
-
# curl http://demo.openapply.com/api/v1/students/95?auth_token=demo_site_api_key
|
104
|
-
# * +options+ - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
|
77
|
+
# @note checks the info for validity & unpacks the json retubed to a JS formatt
|
78
|
+
# @param url [String] - this is the url to do the call
|
79
|
+
# @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
|
105
80
|
def oa_answer(url, options={})
|
106
81
|
# puts
|
107
82
|
# puts "GIVEN URL: #{ url.inspect }"
|
@@ -109,8 +84,8 @@ module Openapply
|
|
109
84
|
return { error: 'bad url - has space' } if url.include? " "
|
110
85
|
return { error: 'bad api_path' } unless url.include? "#{api_path}"
|
111
86
|
return { error: 'bad auth_token' } unless url.include? "auth_token=#{api_key}"
|
112
|
-
api_answer = nil
|
113
87
|
|
88
|
+
# api_answer = nil
|
114
89
|
api_answer = oa_api_call(url, options)
|
115
90
|
|
116
91
|
return api_answer unless api_answer.respond_to? "response" # and not api_answer[:error].nil?
|
@@ -119,8 +94,7 @@ module Openapply
|
|
119
94
|
return { error: 'no response' } if api_answer.response.to_s.eql? ""
|
120
95
|
return JSON.parse(api_answer.response.body, symbolize_names: true)
|
121
96
|
end
|
122
|
-
# alias_method :openapply_answer, :oa_answer
|
123
97
|
|
124
|
-
end
|
98
|
+
end
|
125
99
|
|
126
|
-
end
|
100
|
+
end
|