openapply 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGE_LOG.md +3 -0
- data/Gemfile.lock +2 -2
- data/examples/demo.rb +4 -0
- data/lib/openapply/client.rb +21 -8
- data/lib/openapply/put.rb +2 -2
- data/lib/openapply/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ee6cacbef6eb99105ac78c9e04694826b438d47e84e5ea201fea38b1afd726
|
4
|
+
data.tar.gz: 0d453e0fa1de5cc230d7eeb66fddb59923e34577db1cd3dd418869cdebfc74ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21e601d8e4ccf3e471e8d83c9eab78b03772bd7fd3ad4a9d02d1eeb82cf9be653ec966f895e978327e306d8d506031f9c5808c4b1af620597346f7f350b6c5ba
|
7
|
+
data.tar.gz: 9d76fcb9bfcf38def07e0e72fdfa61d072a7914d26ca4354ed2c740ce12aa3aa049ebe3da61f816427a76359c5b969b8d41ee183769dd136eee2d301a398395d
|
data/CHANGE_LOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/examples/demo.rb
CHANGED
@@ -21,6 +21,10 @@ require 'openapply'
|
|
21
21
|
params = {status: 'applied'}
|
22
22
|
summaries = @oa.many_students_summaries( params )
|
23
23
|
|
24
|
+
# get information details on one student
|
25
|
+
oa_id = 123456
|
26
|
+
one_details = @oa.one_student_details_by_id(oa_id)
|
27
|
+
|
24
28
|
# get details of of many kids - after kid 95 (only get 50 records at a time)
|
25
29
|
params = {since_id: 95, count: 50}
|
26
30
|
kid_ids = @oa.many_students_ids( params )
|
data/lib/openapply/client.rb
CHANGED
@@ -11,8 +11,17 @@ module Openapply
|
|
11
11
|
include Openapply::GetOneStudent # GET api calls
|
12
12
|
include Openapply::GetManyStudents # GET api calls
|
13
13
|
|
14
|
-
|
15
|
-
API_TIMEOUT
|
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
|
16
25
|
|
17
26
|
base_uri API_URL
|
18
27
|
default_timeout API_TIMEOUT
|
@@ -20,7 +29,7 @@ module Openapply
|
|
20
29
|
# attr_reader :api_url, :api_key
|
21
30
|
|
22
31
|
def initialize
|
23
|
-
api_url =
|
32
|
+
api_url = API_URL
|
24
33
|
api_key = ENV['OA_AUTH_TOKEN']
|
25
34
|
|
26
35
|
raise ArgumentError, 'OA_TIMEOUT is missing' if api_timeout.nil? or
|
@@ -34,7 +43,7 @@ module Openapply
|
|
34
43
|
end
|
35
44
|
|
36
45
|
def api_url
|
37
|
-
|
46
|
+
API_URL
|
38
47
|
end
|
39
48
|
|
40
49
|
def api_timeout
|
@@ -93,6 +102,8 @@ module Openapply
|
|
93
102
|
self.class.put(url,
|
94
103
|
query: query,
|
95
104
|
headers: header )
|
105
|
+
# self.class.put(url,
|
106
|
+
# headers: header )
|
96
107
|
rescue Net::ReadTimeout, Net::OpenTimeout
|
97
108
|
if times_retried < max_retries
|
98
109
|
times_retried += 1
|
@@ -113,10 +124,12 @@ module Openapply
|
|
113
124
|
return { error: 'no url given' } if url.nil? or url.to_s.eql? ""
|
114
125
|
return { error: 'bad url - has space' } if url&.include? " "
|
115
126
|
return { error: 'bad api_path' } unless url&.include? "#{api_path}"
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
127
|
+
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?
|
130
|
+
else
|
131
|
+
api_answer = send(:put, url, value, options) unless value.empty?
|
132
|
+
end
|
120
133
|
|
121
134
|
return api_answer unless api_answer.respond_to? "response"
|
122
135
|
return { error: 'no response' } if api_answer.response.nil?
|
data/lib/openapply/put.rb
CHANGED
@@ -11,7 +11,7 @@ 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}#{
|
14
|
+
# url = "#{api_path}#{oa_id}?student_id=#{student_id}&auth_token=#{api_key}"
|
15
15
|
url = "#{api_path}#{oa_id}"
|
16
16
|
return oa_answer( url, {student_id: student_id})
|
17
17
|
end
|
@@ -22,7 +22,7 @@ module Openapply
|
|
22
22
|
# PUT https://<school_subdomain>.openapply.com/api/v1/students/1/status
|
23
23
|
# PUT Data status=Applied
|
24
24
|
def update_student_status(oa_id, status)
|
25
|
-
# url = "#{api_path}#{
|
25
|
+
# url = "#{api_path}#{oa_id}/status?auth_token=#{api_key}"
|
26
26
|
url = "#{api_path}#{oa_id}/status"
|
27
27
|
return oa_answer( url, {status: status})
|
28
28
|
end
|
data/lib/openapply/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapply
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Tihen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.7.
|
177
|
+
rubygems_version: 2.7.7
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Access OpenApply's v1 API with Ruby
|