openapply 0.4.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4ee6cacbef6eb99105ac78c9e04694826b438d47e84e5ea201fea38b1afd726
4
- data.tar.gz: 0d453e0fa1de5cc230d7eeb66fddb59923e34577db1cd3dd418869cdebfc74ce
3
+ metadata.gz: bf864da57109681a1adb1ae6d731a5ca050ff81b15898bc6a8e367d0282cb556
4
+ data.tar.gz: 95d9e5d3eecc372e783b533f68cb0a76ced1f13c91194b90d08bda785a28b30e
5
5
  SHA512:
6
- metadata.gz: 21e601d8e4ccf3e471e8d83c9eab78b03772bd7fd3ad4a9d02d1eeb82cf9be653ec966f895e978327e306d8d506031f9c5808c4b1af620597346f7f350b6c5ba
7
- data.tar.gz: 9d76fcb9bfcf38def07e0e72fdfa61d072a7914d26ca4354ed2c740ce12aa3aa049ebe3da61f816427a76359c5b969b8d41ee183769dd136eee2d301a398395d
6
+ metadata.gz: 9bbbe78d657c7a12a6032337e008da9473a7a65bfd02c43b511c84e56deded8854c0d5cf6280736dad56d1f5bb9bc7b2d0efde9f81529c0088c9b4365b3181ae
7
+ data.tar.gz: ac7a26c9ba21561a69236e8946ecea501cec6e0019b312dff64342e4258183a4b06aeb0808028eedc946302a1294d211adf8e95455e57330890c61effcb53379
@@ -1,8 +1,19 @@
1
1
  ### Openapply CHANGE LOG
2
2
 
3
+ * **v1.0.1** - compatible with 1.0.x - 2020-05-18
4
+ - update dependencies
5
+
6
+ * **v1.0.0** - compatible with 1.0.x - 2020-05-14
7
+ - update path to use OpenApply API v3
8
+ - oauth authentification
9
+ - add arguments in addition to environment variables
10
+
11
+ * **v0.4.2** - compatible with 0.4.x - 2020-03-03
12
+ - update dependencies
13
+
3
14
  * **v0.4.1** - compatible with 0.4.x - 2018-06-19
4
15
  - force all openapply interactions to use https
5
-
16
+
6
17
  * **v0.4.0** - compatible with 0.3.x - 2018-06-08
7
18
  - add put ability for student id and status
8
19
 
@@ -1,68 +1,84 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapply (0.4.1)
5
- httparty (~> 0.15)
6
- json (~> 2.1)
4
+ openapply (1.0.1)
5
+ httparty (~> 0.18)
6
+ json (~> 2.3)
7
+ oauth2 (~> 1.4)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- addressable (2.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
13
- codacy-coverage (1.1.8)
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ codacy-coverage (2.2.1)
14
15
  simplecov
15
16
  coderay (1.1.2)
16
17
  crack (0.4.3)
17
18
  safe_yaml (~> 1.0.0)
18
19
  diff-lcs (1.3)
19
- docile (1.3.1)
20
- hashdiff (0.3.7)
21
- httparty (0.16.2)
20
+ docile (1.3.2)
21
+ faraday (1.0.1)
22
+ multipart-post (>= 1.2, < 3)
23
+ hashdiff (1.0.1)
24
+ httparty (0.18.0)
25
+ mime-types (~> 3.0)
22
26
  multi_xml (>= 0.5.2)
23
- json (2.1.0)
24
- method_source (0.9.0)
27
+ json (2.3.0)
28
+ jwt (2.2.1)
29
+ method_source (1.0.0)
30
+ mime-types (3.3.1)
31
+ mime-types-data (~> 3.2015)
32
+ mime-types-data (3.2020.0512)
33
+ multi_json (1.14.1)
25
34
  multi_xml (0.6.0)
26
- pry (0.11.3)
27
- coderay (~> 1.1.0)
28
- method_source (~> 0.9.0)
29
- public_suffix (3.0.2)
30
- rake (12.3.1)
31
- rspec (3.7.0)
32
- rspec-core (~> 3.7.0)
33
- rspec-expectations (~> 3.7.0)
34
- rspec-mocks (~> 3.7.0)
35
- rspec-core (3.7.1)
36
- rspec-support (~> 3.7.0)
37
- rspec-expectations (3.7.0)
35
+ multipart-post (2.1.1)
36
+ oauth2 (1.4.4)
37
+ faraday (>= 0.8, < 2.0)
38
+ jwt (>= 1.0, < 3.0)
39
+ multi_json (~> 1.3)
40
+ multi_xml (~> 0.5)
41
+ rack (>= 1.2, < 3)
42
+ pry (0.13.1)
43
+ coderay (~> 1.1)
44
+ method_source (~> 1.0)
45
+ public_suffix (4.0.5)
46
+ rack (2.2.2)
47
+ rake (13.0.1)
48
+ rspec (3.9.0)
49
+ rspec-core (~> 3.9.0)
50
+ rspec-expectations (~> 3.9.0)
51
+ rspec-mocks (~> 3.9.0)
52
+ rspec-core (3.9.2)
53
+ rspec-support (~> 3.9.3)
54
+ rspec-expectations (3.9.2)
38
55
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.7.0)
40
- rspec-mocks (3.7.0)
56
+ rspec-support (~> 3.9.0)
57
+ rspec-mocks (3.9.1)
41
58
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.7.0)
43
- rspec-support (3.7.1)
44
- safe_yaml (1.0.4)
45
- simplecov (0.16.1)
59
+ rspec-support (~> 3.9.0)
60
+ rspec-support (3.9.3)
61
+ safe_yaml (1.0.5)
62
+ simplecov (0.18.5)
46
63
  docile (~> 1.1)
47
- json (>= 1.8, < 3)
48
- simplecov-html (~> 0.10.0)
49
- simplecov-html (0.10.2)
50
- webmock (3.4.2)
64
+ simplecov-html (~> 0.11)
65
+ simplecov-html (0.12.2)
66
+ webmock (3.8.3)
51
67
  addressable (>= 2.3.6)
52
68
  crack (>= 0.3.2)
53
- hashdiff
69
+ hashdiff (>= 0.4.0, < 2.0.0)
54
70
 
55
71
  PLATFORMS
56
72
  ruby
57
73
 
58
74
  DEPENDENCIES
59
- bundler (~> 1.15)
60
- codacy-coverage (~> 1.1)
75
+ bundler (~> 2.1)
76
+ codacy-coverage (~> 2.1)
61
77
  openapply!
62
- pry (~> 0.11)
63
- rake (~> 12.3)
64
- rspec (~> 3.7)
65
- webmock (~> 3.2)
78
+ pry (~> 0.13)
79
+ rake (~> 13.0)
80
+ rspec (~> 3.9)
81
+ webmock (~> 3.8)
66
82
 
67
83
  BUNDLED WITH
68
- 1.16.2
84
+ 2.1.4
data/README.md CHANGED
@@ -1,125 +1,17 @@
1
- [![Build Status](https://travis-ci.org/btihen/openapply.svg?branch=master)](https://travis-ci.org/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&amp;utm_medium=referral&amp;utm_content=btihen/openapply&amp;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/)
1
+ [![Codeship Status for LAS-IT/openapply](https://app.codeship.com/projects/b3b1a8b0-3f90-0138-630c-02a65faac0e6/status?branch=master)](https://app.codeship.com/projects/387673) [![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&amp;utm_medium=referral&amp;utm_content=btihen/openapply&amp;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/)
2
+ # Openapply API wrapper
2
3
 
3
-
4
- # Openapply
5
-
6
- This gem allows ruby access to the OpenApply API v1 - and supports the GET features described at: https://dev.faria.co/oa
7
-
8
-
9
- ### Still TODO
10
-
11
-
12
- ### CHANGE LOG
4
+ ## CHANGE LOG
13
5
 
14
6
  [Change Log](https://github.com/btihen/openapply/blob/master/CHANGE_LOG.md)
15
7
 
8
+ ## Openapply v3
16
9
 
17
- ### Installation
18
-
19
- Add this line to your application's Gemfile:
20
-
21
- ```ruby
22
- gem 'openapply'
23
- ```
24
-
25
- And then execute:
26
-
27
- $ bundle
28
-
29
- Or install it yourself as:
30
-
31
- $ gem install openapply
32
-
33
-
34
- ### Docs
35
-
36
- * http://www.rubydoc.info/gems/openapply
37
-
38
-
39
- ### Configuration
40
-
41
- * Setup / Config the following ENV-VARS (example code uses **.rbenv-vars**):
42
-
43
- ```bash
44
- # timeout in seconds (before retry - 3 times)
45
- OA_TIMEOUT=5
46
-
47
- # 100 records is the advertised default record count, but in reality it is 10
48
- # this gem uses 50 as the default
49
- OA_RELPY_RECORDS=50
50
-
51
- # currently this is the only API path available
52
- OA_API_PATH=/api/v1/students/
53
-
54
- # point to your own site (this is the demo site)
55
- OA_BASE_URI=demo.openapply.com
56
-
57
- # this is the demo site key - you will need your own key for your own site
58
- # from https://demo.openapply.com/admin/dashboard (it will reset every hour)
59
- # navigate to Settings > Integrations, and enable the API, and generate a token
60
- OA_AUTH_TOKEN=demo_site_api_key
61
- ```
62
-
63
- ### Instantiation
64
- Associates the above settings with HTTParty
65
- (so that you can access the OpenApply api)
66
-
67
- ```ruby
68
- @oa = Openapply::Client.new
69
- ```
70
-
71
- ### USAGE
72
-
73
- #### USAGE SUMMARY
74
-
75
- ```ruby
76
- require 'openapply'
77
- # instantiate
78
- @oa = Openapply::Client.new
79
-
80
- # see settings
81
- @oa.api_url
82
- @oa.api_key
83
- @oa.api_path
84
- @oa.api_timeout
85
- @oa.api_records
86
-
87
- # Individual student record
88
- # (note: parent info is duplicated)
89
- @oa.student_by_id( id )
90
- @oa.payments_by_id( id )
91
-
92
- # Student Details by IDs:
93
- # id - student's record number
94
- # options = {get_payments: false}
95
- @oa.one_student_details_by_id( id, options={} )
96
- # ids - in array format
97
- @oa.many_students_details_by_ids( ids, options={} )
98
-
99
- # Query many students by params:
100
- # params = {status: 'applied', since_id: 95, since_date: '2018-01-20', count: 50}
101
- @oa.many_students_ids( params )
102
- @oa.many_ids_updated_time( params )
103
- @oa.many_students_summaries( params )
104
- @oa.many_students_details( params, options )
105
-
106
- # directly call the OA API - with custom URL
107
- @oa.oa_api_call('/api/v1/students/?status=accepted&count=5&auth_token=add_api_key')
108
- ```
109
-
110
- #### OpenApply's allowed statuses
10
+ [OpenApply V3 README](README_v3.md)
111
11
 
112
- * **valid status includes:**
113
- - Status
114
- - Pending
115
- - Applied
116
- - Admitted
117
- - Wait-listed
118
- - Declined
119
- - Enrolled
120
- - Graduated
121
- - Withdrawn
12
+ ## Openapply v1
122
13
 
14
+ [OpenApply V1 README](README_v1.md)
123
15
 
124
16
  ## Development
125
17
 
@@ -0,0 +1,109 @@
1
+ # Openapply v1
2
+
3
+ This gem allows ruby access to the OpenApply API v1 - and supports the GET features described at: https://(your openapply domain)/help/api_v1
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'openapply', "~> 0.4"
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install openapply -v "~> 0.4"
21
+
22
+ ## Docs
23
+
24
+ * http://www.rubydoc.info/gems/openapply
25
+
26
+
27
+ ## Configuration
28
+
29
+ * Setup / Config the following ENV-VARS (example code uses **.rbenv-vars**):
30
+
31
+ ```bash
32
+ # timeout in seconds (before retry - 3 times)
33
+ OA_TIMEOUT=5
34
+
35
+ # 100 records is the advertised default record count, but in reality it is 10
36
+ # this gem uses 50 as the default
37
+ OA_RELPY_RECORDS=50
38
+
39
+ # currently this is the only API path available
40
+ OA_API_PATH=/api/v1/students/
41
+
42
+ # point to your own site (this is the demo site)
43
+ OA_BASE_URI=demo.openapply.com
44
+
45
+ # this is the demo site key - you will need your own key for your own site
46
+ # from https://demo.openapply.com/admin/dashboard (it will reset every hour)
47
+ # navigate to Settings > Integrations, and enable the API, and generate a token
48
+ OA_AUTH_TOKEN=demo_site_api_key
49
+ ```
50
+
51
+ ## Instantiation
52
+ Associates the above settings with HTTParty
53
+ (so that you can access the OpenApply api)
54
+
55
+ ```ruby
56
+ @oa = Openapply::Client.new
57
+ ```
58
+
59
+ ## USAGE
60
+
61
+ ### USAGE SUMMARY
62
+
63
+ ```ruby
64
+ require 'openapply'
65
+ # instantiate
66
+ @oa = Openapply::Client.new
67
+
68
+ # see settings
69
+ @oa.api_url
70
+ @oa.api_key
71
+ @oa.api_path
72
+ @oa.api_timeout
73
+ @oa.api_records
74
+
75
+ # Individual student record
76
+ # (note: parent info is duplicated)
77
+ @oa.student_by_id( id )
78
+ @oa.payments_by_id( id )
79
+
80
+ # Student Details by IDs:
81
+ # id - student's record number
82
+ # options = {get_payments: false}
83
+ @oa.one_student_details_by_id( id, options={} )
84
+ # ids - in array format
85
+ @oa.many_students_details_by_ids( ids, options={} )
86
+
87
+ # Query many students by params:
88
+ # params = {status: 'applied', since_id: 95, since_date: '2018-01-20', count: 50}
89
+ @oa.many_students_ids( params )
90
+ @oa.many_ids_updated_time( params )
91
+ @oa.many_students_summaries( params )
92
+ @oa.many_students_details( params, options )
93
+
94
+ # directly call the OA API - with custom URL
95
+ @oa.oa_api_call('/api/v1/students/?status=accepted&count=5&auth_token=add_api_key')
96
+ ```
97
+
98
+ ### OpenApply's allowed statuses
99
+
100
+ * **valid status includes:**
101
+ - Status
102
+ - Pending
103
+ - Applied
104
+ - Admitted
105
+ - Wait-listed
106
+ - Declined
107
+ - Enrolled
108
+ - Graduated
109
+ - Withdrawn
@@ -0,0 +1,130 @@
1
+ # Openapply v3
2
+
3
+ This gem allows ruby access to the OpenApply API v3 - and supports the GET features described at: https://(your openapply domain)/help/api_v3
4
+
5
+ ## TODO
6
+ - [x] implement OAuth 2.0
7
+ - [x] update students GET wrapper
8
+ - [x] update students payement info GET wrapper
9
+ - [] implement students advanced search
10
+ - [] implement parents GET wrapper
11
+ - [] implement parents advanced search
12
+ - [] implement students and parent PUT wrapper
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'openapply', "~> 1.0"
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install openapply -v "~> 1.0"
29
+
30
+ ## Docs
31
+
32
+ * http://www.rubydoc.info/gems/openapply
33
+
34
+
35
+ ## Configuration
36
+
37
+ Note: (these are example value uses your own **.rbenv-vars**):
38
+
39
+ * Setup / Config the following ENV-VARS
40
+
41
+ ```bash
42
+ # Please set this before instantiation
43
+ # timeout in seconds (before retry - 3 times)
44
+ OA_TIMEOUT=5
45
+ ```
46
+
47
+ * Setup your defaults
48
+
49
+ ```bash
50
+ # 100 records is the advertised default
51
+ OA_RELPY_RECORDS=100
52
+
53
+ # point to your own site (this is the demo site)
54
+ OA_BASE_URI=demo.openapply.com
55
+
56
+ # this is the demo site key - you will need your own key for your own site
57
+ # from https://demo.openapply.com/admin/dashboard (it will reset every two hours)
58
+ # navigate to Settings > Integrations, and enable the API, and generate a client id and client secret
59
+ OA_CLIENT_ID=demo_site_client_id
60
+ OA_CLIENT_SECRET=demo_site_client_secret
61
+ ```
62
+
63
+ ## Instantiation
64
+ You can also associate your own configuration value on the fly using instantiation arguments, if an arguments is missing it will fallback to ENV variables for this specific arguments.
65
+
66
+ ```ruby
67
+ @oa = Openapply::Client.new(url: "", client_id: "", client_secret: "", token: "")
68
+ ```
69
+
70
+ ## USAGE
71
+
72
+ ### Authentication
73
+ If `:token` is not present, a new token will be generated, tokens are valid for ~30 days. For performance optimization we encourage you to cache your token, and regenerate one when it expires. You can find a rails example on the wiki.
74
+
75
+ ### USAGE SUMMARY
76
+
77
+ ```ruby
78
+ require 'openapply'
79
+ # instantiate
80
+ @oa = Openapply::Client.new
81
+
82
+ # see settings
83
+ @oa.api_url
84
+ @oa.api_key
85
+ # => auth_token
86
+ @oa.api_path
87
+ @oa.api_timeout
88
+ @oa.api_records
89
+ @oa.api_client_id
90
+ @oa.api_client_secret
91
+
92
+ # get auth token
93
+ @oa.authentificate
94
+ # => OAuth2::AccessToken
95
+
96
+ # Individual student record
97
+ # (note: parent info is duplicated)
98
+ @oa.student_by_id( id )
99
+ @oa.payments_by_id( id )
100
+
101
+ # Student Details by IDs:
102
+ # id - student's record number
103
+ # options = {get_payments: false}
104
+ @oa.one_student_details_by_id( id, options={} )
105
+ # ids - in array format
106
+ @oa.many_students_details_by_ids( ids, options={} )
107
+
108
+ # Query many students by params:
109
+ # params = {status: 'applied', since_id: 95, since_date: '2018-01-20', count: 50}
110
+ @oa.many_students_ids( params )
111
+ @oa.many_ids_updated_time( params )
112
+ @oa.many_students_summaries( params )
113
+ @oa.many_students_details( params, options )
114
+
115
+ # directly call the OA API - with custom URL
116
+ @oa.oa_api_call('/api/v1/students/?status=accepted&count=5&auth_token=add_api_key')
117
+ ```
118
+
119
+ ### OpenApply's allowed statuses
120
+
121
+ * **valid status includes:**
122
+ - Status
123
+ - Pending
124
+ - Applied
125
+ - Admitted
126
+ - Wait-listed
127
+ - Declined
128
+ - Enrolled
129
+ - Graduated
130
+ - Withdrawn
@@ -1,3 +1,4 @@
1
+ require 'oauth2'
1
2
  require "openapply/get_many_students"
2
3
  require "openapply/get_one_student"
3
4
  require "openapply/put"
@@ -11,55 +12,55 @@ module Openapply
11
12
  include Openapply::GetOneStudent # GET api calls
12
13
  include Openapply::GetManyStudents # GET api calls
13
14
 
14
-
15
- API_TIMEOUT = ENV['OA_TIMEOUT'].to_i || 5
16
- # Force RBENV var base_uri to https://
17
- API_URL = case
18
- when ENV['OA_BASE_URI'].start_with?('https://')
19
- "#{ENV['OA_BASE_URI']}"
20
- when ENV['OA_BASE_URI'].start_with?('http://')
21
- "#{ENV['OA_BASE_URI']}".gsub("http", "https")
22
- else
23
- "https://#{ENV['OA_BASE_URI']}"
24
- end
25
-
26
- base_uri API_URL
15
+ API_TIMEOUT = ENV['OA_TIMEOUT'].to_i == 0 ? 5 : ENV['OA_TIMEOUT'].to_i
27
16
  default_timeout API_TIMEOUT
28
17
 
29
- # attr_reader :api_url, :api_key
18
+ # @param [String] url Base uri
19
+ # @param [String] client_id
20
+ # @param [String] client_secret
21
+ # @param [String] token if present will not generate an auth token
22
+ def initialize(url: nil, client_id: nil, client_secret: nil, token: nil)
23
+ @api_url = format_api_url(url || ENV['OA_BASE_URI'])
24
+ @api_client_id = client_id || ENV['OA_CLIENT_ID']
25
+ @api_client_secret = client_secret || ENV['OA_CLIENT_SECRET']
26
+ @api_key = token || authentificate.token
30
27
 
31
- def initialize
32
- api_url = API_URL
33
- api_key = ENV['OA_AUTH_TOKEN']
34
-
35
- raise ArgumentError, 'OA_TIMEOUT is missing' if api_timeout.nil? or
36
- not api_timeout.is_a? Integer
37
- raise ArgumentError, 'OA_API_PATH is missing' if api_path.nil? or
38
- api_path.empty?
39
28
  raise ArgumentError, 'OA_BASE_URI is missing' if api_url.nil? or
40
29
  api_url.empty?
41
- raise ArgumentError, 'OA_AUTH_TOKEN is missing' if api_key.nil? or
42
- api_key.empty?
30
+ raise ArgumentError, 'OA_CLIENT_ID is missing' if api_client_id.nil? or
31
+ api_client_id.empty?
32
+ raise ArgumentError, 'OA_CLIENT_SECRET is missing' if api_client_secret.nil? or
33
+ api_client_secret.empty?
34
+
35
+ self.class.base_uri api_url
43
36
  end
44
37
 
45
38
  def api_url
46
- API_URL
39
+ @api_url
47
40
  end
48
41
 
49
42
  def api_timeout
50
- ENV['OA_TIMEOUT'].to_i
43
+ API_TIMEOUT
44
+ end
45
+
46
+ def api_client_id
47
+ @api_client_id
48
+ end
49
+
50
+ def api_client_secret
51
+ @api_client_secret
51
52
  end
52
53
 
53
54
  def api_key
54
- ENV['OA_AUTH_TOKEN']
55
+ @api_key
55
56
  end
56
57
 
57
58
  def api_path
58
- ENV['OA_API_PATH'] || "/api/v1/students/"
59
+ "/api/v3"
59
60
  end
60
61
 
61
62
  def api_records
62
- ENV['OA_RECORD_COUNT'] || '50'
63
+ ENV['OA_RECORD_COUNT'] || '100'
63
64
  end
64
65
 
65
66
  # @note Does the actual api call(get) to OpenApply & handles API timeouts gracefully
@@ -67,10 +68,10 @@ module Openapply
67
68
  # @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
68
69
 
69
70
  def get(url, options={})
70
- # add exception if ENV are not set
71
71
  max_retries = 3
72
72
  times_retried = 0
73
73
  begin
74
+ options[:headers] = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8', "Authorization" => auth_token}
74
75
  self.class.get(url, options)
75
76
  rescue Net::ReadTimeout, Net::OpenTimeout
76
77
  if times_retried < max_retries
@@ -88,7 +89,6 @@ module Openapply
88
89
  # @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
89
90
 
90
91
  def put(url, value, options={})
91
- # add exception if ENV are not set
92
92
  # Per emai from Mackenzine on API call formatting, vs what is found on API site
93
93
  # curl -X "PUT" "https://las.openapply.com/api/v1/students/OAID" \
94
94
  # -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
@@ -97,13 +97,9 @@ module Openapply
97
97
  max_retries = 3
98
98
  times_retried = 0
99
99
  begin
100
- query = {auth_token: api_key}.merge(value)
101
- header = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8' }
102
- self.class.put(url,
103
- query: query,
104
- headers: header )
105
- # self.class.put(url,
106
- # headers: header )
100
+ options[:headers] = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8', "Authorization" => auth_token}
101
+ options[:body] = value
102
+ self.class.put(url, options)
107
103
  rescue Net::ReadTimeout, Net::OpenTimeout
108
104
  if times_retried < max_retries
109
105
  times_retried += 1
@@ -115,7 +111,7 @@ module Openapply
115
111
  end
116
112
 
117
113
 
118
- # @note checks the info for validity & unpacks the json retubed to a JS formatt
114
+ # @note checks the info for validity & unpacks the json retubed to a JS format
119
115
  # @note by passing in a value such as student_id or status this will automatically trigger the change form get to put
120
116
  # @param url [String] - this is the url to do the call
121
117
  # @param value [Hash] - This is used to update the student_id or status
@@ -125,8 +121,7 @@ module Openapply
125
121
  return { error: 'bad url - has space' } if url&.include? " "
126
122
  return { error: 'bad api_path' } unless url&.include? "#{api_path}"
127
123
  if value.empty?
128
- return { error: 'bad auth_token' } unless url&.include? "auth_token=#{api_key}"
129
- api_answer = send(:get, url, options) if value.empty?
124
+ api_answer = send(:get, url, options) if value.empty?
130
125
  else
131
126
  api_answer = send(:put, url, value, options) unless value.empty?
132
127
  end
@@ -137,6 +132,34 @@ module Openapply
137
132
  return JSON.parse(api_answer.response.body, symbolize_names: true)
138
133
  end
139
134
 
135
+ # @note authentificate using oauth2
136
+ # @return [OAuth2::AccessToken]
137
+ def authentificate
138
+ client = OAuth2::Client.new(api_client_id, api_client_secret, site: api_url)
139
+ return client.client_credentials.get_token
140
+ end
141
+
142
+ private
143
+
144
+ # @note Force url to https://
145
+ def format_api_url(url)
146
+ return case
147
+ when url.nil?
148
+ raise ArgumentError, 'OA_BASE_URI is missing'
149
+ when url.start_with?('https://')
150
+ url
151
+ when url.start_with?('http://')
152
+ url.gsub("http", "https")
153
+ else
154
+ "https://#{url}"
155
+ end
156
+ end
157
+
158
+ # @note format auth token
159
+ def auth_token
160
+ "Bearer " + api_key
161
+ end
162
+
140
163
  end
141
164
 
142
165
  end
@@ -109,9 +109,8 @@ module Openapply
109
109
  url_options << "since_id=#{since_id}" unless since_id.to_s.eql? ""
110
110
  url_options << "since_date=#{since_date}" unless since_date.to_s.eql? ""
111
111
  url_options << "count=#{count}"
112
- url_options << "auth_token=#{api_key}"
113
112
 
114
- return "#{api_path}?#{url_options.join('&')}"
113
+ return "#{api_path}/students/?#{url_options.join('&')}"
115
114
  end
116
115
 
117
116
  end
@@ -38,7 +38,7 @@ module Openapply
38
38
  # @param ids - (Integer) - ids of student to lookup
39
39
  # @param options - http options
40
40
  def one_student_record_by_id(id, options ={})
41
- url = "#{api_path}#{id}?auth_token=#{api_key}"
41
+ url = "#{api_path}/students/#{id}"
42
42
  return oa_answer( url, options )
43
43
  end
44
44
 
@@ -46,7 +46,7 @@ module Openapply
46
46
  # @param ids - (Integer) - ids of student to lookup
47
47
  # @param options - http options
48
48
  def one_student_payments_by_id(id, options={})
49
- url = "#{api_path}#{id}/payments?auth_token=#{api_key}"
49
+ url = "#{api_path}/students/#{id}/payments"
50
50
  return oa_answer( url, options )
51
51
  end
52
52
 
@@ -11,22 +11,21 @@ module Openapply
11
11
  # PUT https://<school_subdomain>.openapply.com/api/v1/students/1/student_id
12
12
  # PUT Data student_id=123456
13
13
  def update_student_id(oa_id, student_id)
14
- # url = "#{api_path}#{oa_id}?student_id=#{student_id}&auth_token=#{api_key}"
15
- url = "#{api_path}#{oa_id}"
14
+ # url = "#{api_path}#{oa_id}"
15
+ url = "#{api_path}/students/#{oa_id}"
16
16
  return oa_answer( url, {student_id: student_id})
17
17
  end
18
18
 
19
- # @note Update one student's status
20
- # @param oa_id - (Integer) - id of student to update
21
- # @param status - (string) - status to update for student
22
- # PUT https://<school_subdomain>.openapply.com/api/v1/students/1/status
23
- # PUT Data status=Applied
24
- def update_student_status(oa_id, status)
25
- # url = "#{api_path}#{oa_id}/status?auth_token=#{api_key}"
26
- url = "#{api_path}#{oa_id}/status"
27
- return oa_answer( url, {status: status})
28
- end
29
-
19
+ # # @note Update one student's status
20
+ # # @param oa_id - (Integer) - id of student to update
21
+ # # @param status - (string) - status to update for student
22
+ # # PUT https://<school_subdomain>.openapply.com/api/v1/students/1/status
23
+ # # PUT Data status=Applied
24
+ # def update_student_status(oa_id, status)
25
+ # # url = "#{api_path}#{oa_id}/status"
26
+ # url = "#{api_path}/students/#{oa_id}/status"
27
+ # return oa_answer( url, {status: status})
28
+ # end
30
29
 
31
30
  end
32
31
  end
@@ -1,5 +1,5 @@
1
1
  module Openapply
2
2
  module Version
3
- VERSION = "0.4.1"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -6,10 +6,10 @@ require "openapply/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "openapply"
8
8
  spec.version = Openapply::Version::VERSION
9
- spec.authors = ["Bill Tihen"]
10
- spec.email = ["btihen@gmail.com","btihen@las.ch"]
9
+ spec.authors = ["Bill Tihen", "Elliott Hébert"]
10
+ spec.email = ["btihen@gmail.com","btihen@las.ch","ell.heb@container4.ch","ehebert@las.ch"]
11
11
 
12
- spec.summary = %q{Access OpenApply's v1 API with Ruby}
12
+ spec.summary = %q{Access OpenApply's APIs with Ruby}
13
13
  spec.homepage = "https://github.com/las-it/openapply"
14
14
  spec.license = "MIT"
15
15
 
@@ -20,14 +20,14 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency "httparty", "~> 0.15"
24
- spec.add_dependency "json" , "~> 2.1"
25
-
26
- spec.add_development_dependency 'codacy-coverage', '~> 1.1'
27
- spec.add_development_dependency "webmock", "~> 3.2"
28
- spec.add_development_dependency "bundler", "~> 1.15"
29
- spec.add_development_dependency "rake", "~> 12.3"
30
- spec.add_development_dependency "rspec", "~> 3.7"
31
- spec.add_development_dependency "pry", "~> 0.11"
23
+ spec.add_dependency "httparty", "~> 0.18"
24
+ spec.add_dependency "json" , "~> 2.3"
25
+ spec.add_dependency "oauth2", "~> 1.4"
32
26
 
27
+ spec.add_development_dependency 'codacy-coverage', '~> 2.1'
28
+ spec.add_development_dependency "webmock", "~> 3.8"
29
+ spec.add_development_dependency "bundler", "~> 2.1"
30
+ spec.add_development_dependency "rake", "~> 13.0"
31
+ spec.add_development_dependency "rspec", "~> 3.9"
32
+ spec.add_development_dependency "pry", "~> 0.13"
33
33
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Tihen
8
+ - Elliott Hébert
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2018-06-19 00:00:00.000000000 Z
12
+ date: 2020-05-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: httparty
@@ -16,133 +17,147 @@ dependencies:
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '0.15'
20
+ version: '0.18'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '0.15'
27
+ version: '0.18'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: json
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
- version: '2.1'
34
+ version: '2.3'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
- version: '2.1'
41
+ version: '2.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: oauth2
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.4'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.4'
41
56
  - !ruby/object:Gem::Dependency
42
57
  name: codacy-coverage
43
58
  requirement: !ruby/object:Gem::Requirement
44
59
  requirements:
45
60
  - - "~>"
46
61
  - !ruby/object:Gem::Version
47
- version: '1.1'
62
+ version: '2.1'
48
63
  type: :development
49
64
  prerelease: false
50
65
  version_requirements: !ruby/object:Gem::Requirement
51
66
  requirements:
52
67
  - - "~>"
53
68
  - !ruby/object:Gem::Version
54
- version: '1.1'
69
+ version: '2.1'
55
70
  - !ruby/object:Gem::Dependency
56
71
  name: webmock
57
72
  requirement: !ruby/object:Gem::Requirement
58
73
  requirements:
59
74
  - - "~>"
60
75
  - !ruby/object:Gem::Version
61
- version: '3.2'
76
+ version: '3.8'
62
77
  type: :development
63
78
  prerelease: false
64
79
  version_requirements: !ruby/object:Gem::Requirement
65
80
  requirements:
66
81
  - - "~>"
67
82
  - !ruby/object:Gem::Version
68
- version: '3.2'
83
+ version: '3.8'
69
84
  - !ruby/object:Gem::Dependency
70
85
  name: bundler
71
86
  requirement: !ruby/object:Gem::Requirement
72
87
  requirements:
73
88
  - - "~>"
74
89
  - !ruby/object:Gem::Version
75
- version: '1.15'
90
+ version: '2.1'
76
91
  type: :development
77
92
  prerelease: false
78
93
  version_requirements: !ruby/object:Gem::Requirement
79
94
  requirements:
80
95
  - - "~>"
81
96
  - !ruby/object:Gem::Version
82
- version: '1.15'
97
+ version: '2.1'
83
98
  - !ruby/object:Gem::Dependency
84
99
  name: rake
85
100
  requirement: !ruby/object:Gem::Requirement
86
101
  requirements:
87
102
  - - "~>"
88
103
  - !ruby/object:Gem::Version
89
- version: '12.3'
104
+ version: '13.0'
90
105
  type: :development
91
106
  prerelease: false
92
107
  version_requirements: !ruby/object:Gem::Requirement
93
108
  requirements:
94
109
  - - "~>"
95
110
  - !ruby/object:Gem::Version
96
- version: '12.3'
111
+ version: '13.0'
97
112
  - !ruby/object:Gem::Dependency
98
113
  name: rspec
99
114
  requirement: !ruby/object:Gem::Requirement
100
115
  requirements:
101
116
  - - "~>"
102
117
  - !ruby/object:Gem::Version
103
- version: '3.7'
118
+ version: '3.9'
104
119
  type: :development
105
120
  prerelease: false
106
121
  version_requirements: !ruby/object:Gem::Requirement
107
122
  requirements:
108
123
  - - "~>"
109
124
  - !ruby/object:Gem::Version
110
- version: '3.7'
125
+ version: '3.9'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: pry
113
128
  requirement: !ruby/object:Gem::Requirement
114
129
  requirements:
115
130
  - - "~>"
116
131
  - !ruby/object:Gem::Version
117
- version: '0.11'
132
+ version: '0.13'
118
133
  type: :development
119
134
  prerelease: false
120
135
  version_requirements: !ruby/object:Gem::Requirement
121
136
  requirements:
122
137
  - - "~>"
123
138
  - !ruby/object:Gem::Version
124
- version: '0.11'
139
+ version: '0.13'
125
140
  description:
126
141
  email:
127
142
  - btihen@gmail.com
128
143
  - btihen@las.ch
144
+ - ell.heb@container4.ch
145
+ - ehebert@las.ch
129
146
  executables: []
130
147
  extensions: []
131
148
  extra_rdoc_files: []
132
149
  files:
133
150
  - ".bettercodehub.yml"
134
- - ".circleci/config.yml"
135
151
  - ".gitignore"
136
152
  - ".rspec"
137
- - ".travis.yml"
138
- - ".travis.yml.bak"
139
153
  - CHANGE_LOG.md
140
154
  - CODE_OF_CONDUCT.md
141
155
  - Gemfile
142
156
  - Gemfile.lock
143
157
  - LICENSE.txt
144
- - MM
145
158
  - README.md
159
+ - README_v1.md
160
+ - README_v3.md
146
161
  - Rakefile
147
162
  - bin/console
148
163
  - bin/setup
@@ -173,9 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
188
  - !ruby/object:Gem::Version
174
189
  version: '0'
175
190
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.7.7
191
+ rubygems_version: 3.0.6
178
192
  signing_key:
179
193
  specification_version: 4
180
- summary: Access OpenApply's v1 API with Ruby
194
+ summary: Access OpenApply's APIs with Ruby
181
195
  test_files: []
@@ -1,70 +0,0 @@
1
- # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
- dependencies:
6
- pre:
7
- - gem install bundler -v 1.16.0
8
- # - rvm install rubygems 2.4.8 --force
9
-
10
- version: 2
11
- jobs:
12
- build:
13
- test:
14
- override:
15
- - bundle exec rspec -r rspec_junit_formatter --format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec/junit.xml
16
-
17
- docker:
18
- # specify the version you desire here
19
- - image: circleci/ruby:2.4.1-node-browsers
20
-
21
- # Specify service dependencies here if necessary
22
- # CircleCI maintains a library of pre-built images
23
- # documented at https://circleci.com/docs/2.0/circleci-images/
24
- # - image: circleci/postgres:9.4
25
-
26
- working_directory: ~/repo
27
-
28
- steps:
29
- - checkout
30
-
31
- # Download and cache dependencies
32
- - restore_cache:
33
- keys:
34
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
35
- # fallback to using the latest cache if no exact match is found
36
- - v1-dependencies-
37
-
38
- - run:
39
- name: install dependencies
40
- command: |
41
- bundle install --jobs=4 --retry=3 --path vendor/bundle
42
-
43
- - save_cache:
44
- paths:
45
- - ./vendor/bundle
46
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
47
-
48
- # # Database setup
49
- # - run: bundle exec rake db:create
50
- # - run: bundle exec rake db:schema:load
51
-
52
- # run tests!
53
- - run:
54
- name: run tests
55
- command: |
56
- mkdir /tmp/test-results
57
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
58
-
59
- bundle exec rspec --format progress \
60
- --format RspecJunitFormatter \
61
- --out /tmp/test-results/rspec.xml \
62
- --format progress \
63
- "${TEST_FILES}"
64
-
65
- # collect reports
66
- - store_test_results:
67
- path: /tmp/test-results
68
- - store_artifacts:
69
- path: /tmp/test-results
70
- destination: test-results
@@ -1,14 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- branches:
4
- only:
5
- - master
6
- - staging
7
- rvm:
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=
@@ -1,18 +0,0 @@
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/MM DELETED
File without changes