openapply 0.3.3 → 0.4.0
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 +3 -3
- data/examples/demo.rb +3 -0
- data/lib/openapply/client.rb +39 -4
- data/lib/openapply/put.rb +27 -0
- data/lib/openapply/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8737224f666de68e77a77cd2b7b5c0a640635bcf6d1ecef71314859aa8b061
|
4
|
+
data.tar.gz: fc001a7b77f3d66dbbb8b3c6cf56cf09457b1c3d4fbb86b219995b88ef92dd61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a99d27d4feed780a81d7d6f1f3699394aab6e4cccc87057b9166021b43baf4ac41470de484f918c978d5a97882ff169a33754cc5324005d6e6ce61cef4b6ae9d
|
7
|
+
data.tar.gz: 483cad9cc3d138b92a995fcd5af9a21c766b7abadceab9298fdff380eae3c9e26f363c0d1c291227e7b007da385bac1e6eec1ba38d82d05bc31b336ce44e64c1
|
data/CHANGE_LOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openapply (0.
|
4
|
+
openapply (0.4.0)
|
5
5
|
httparty (~> 0.15)
|
6
6
|
json (~> 2.1)
|
7
7
|
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
crack (0.4.3)
|
17
17
|
safe_yaml (~> 1.0.0)
|
18
18
|
diff-lcs (1.3)
|
19
|
-
docile (1.3.
|
19
|
+
docile (1.3.1)
|
20
20
|
hashdiff (0.3.7)
|
21
21
|
httparty (0.16.2)
|
22
22
|
multi_xml (>= 0.5.2)
|
@@ -47,7 +47,7 @@ GEM
|
|
47
47
|
json (>= 1.8, < 3)
|
48
48
|
simplecov-html (~> 0.10.0)
|
49
49
|
simplecov-html (0.10.2)
|
50
|
-
webmock (3.
|
50
|
+
webmock (3.4.2)
|
51
51
|
addressable (>= 2.3.6)
|
52
52
|
crack (>= 0.3.2)
|
53
53
|
hashdiff
|
data/examples/demo.rb
CHANGED
@@ -29,3 +29,6 @@ details = @oa.many_students_details_by_ids( kid_ids )
|
|
29
29
|
# get all student records that have been updated in the last week
|
30
30
|
params = {since_date: "#{Date.today-7}"}
|
31
31
|
updates = @oa.many_ids_updated_time( params )
|
32
|
+
|
33
|
+
# Update Student ID
|
34
|
+
update_id = @oa.update_student_id(533497, 533497)
|
data/lib/openapply/client.rb
CHANGED
@@ -53,10 +53,11 @@ module Openapply
|
|
53
53
|
ENV['OA_RECORD_COUNT'] || '50'
|
54
54
|
end
|
55
55
|
|
56
|
-
# @note Does the actual api call to OpenApply & handles API timeouts gracefully
|
56
|
+
# @note Does the actual api call(get) to OpenApply & handles API timeouts gracefully
|
57
57
|
# @param url [String] - this is the url to do the call
|
58
58
|
# @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
|
59
|
-
|
59
|
+
|
60
|
+
def get(url, options={})
|
60
61
|
# add exception if ENV are not set
|
61
62
|
max_retries = 3
|
62
63
|
times_retried = 0
|
@@ -71,17 +72,51 @@ module Openapply
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
end
|
75
|
+
alias_method :oa_api_call, :get
|
76
|
+
|
77
|
+
# @note Does the actual api call(put) to OpenApply & handles API timeouts gracefully
|
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]
|
80
|
+
|
81
|
+
def put(url, value, options={})
|
82
|
+
# add exception if ENV are not set
|
83
|
+
# Per emai from Mackenzine on API call formatting, vs what is found on API site
|
84
|
+
# curl -X "PUT" "https://las.openapply.com/api/v1/students/OAID" \
|
85
|
+
# -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
|
86
|
+
# --data-urlencode "student_id=YOURID" \
|
87
|
+
# --data-urlencode "auth_token=YOURTOKEN"
|
88
|
+
max_retries = 3
|
89
|
+
times_retried = 0
|
90
|
+
begin
|
91
|
+
query = {auth_token: api_key}.merge(value)
|
92
|
+
header = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8' }
|
93
|
+
self.class.put(url,
|
94
|
+
query: query,
|
95
|
+
headers: header )
|
96
|
+
rescue Net::ReadTimeout, Net::OpenTimeout
|
97
|
+
if times_retried < max_retries
|
98
|
+
times_retried += 1
|
99
|
+
retry
|
100
|
+
else
|
101
|
+
{ error: "no response (timeout) from URL: #{url}" }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
74
106
|
|
75
107
|
# @note checks the info for validity & unpacks the json retubed to a JS formatt
|
108
|
+
# @note by passing in a value such as student_id or status this will automatically trigger the change form get to put
|
76
109
|
# @param url [String] - this is the url to do the call
|
110
|
+
# @param value [Hash] - This is used to update the student_id or status
|
77
111
|
# @param options - see httparty options [http://www.rubydoc.info/github/jnunemaker/httparty]
|
78
|
-
def oa_answer(url, options={})
|
112
|
+
def oa_answer(url, value={}, options={})
|
79
113
|
return { error: 'no url given' } if url.nil? or url.to_s.eql? ""
|
80
114
|
return { error: 'bad url - has space' } if url&.include? " "
|
81
115
|
return { error: 'bad api_path' } unless url&.include? "#{api_path}"
|
82
116
|
return { error: 'bad auth_token' } unless url&.include? "auth_token=#{api_key}"
|
83
117
|
|
84
|
-
api_answer =
|
118
|
+
api_answer = send(:get, url, options) if value.empty?
|
119
|
+
api_answer = send(:put, url, value, options) unless value.empty?
|
85
120
|
|
86
121
|
return api_answer unless api_answer.respond_to? "response"
|
87
122
|
return { error: 'no response' } if api_answer.response.nil?
|
data/lib/openapply/put.rb
CHANGED
@@ -1,5 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Openapply
|
4
|
+
# OpenApply API Page
|
5
|
+
# https://dev.faria.co/oa/#resources-reference
|
2
6
|
module Put
|
3
7
|
|
8
|
+
# @note Update one student's Student ID (Field in OpenApply must be currently Blank)
|
9
|
+
# @param oa_id - (Integer) - id of student to update
|
10
|
+
# @param student_id - (Integer) - id to put in student_id field
|
11
|
+
# PUT https://<school_subdomain>.openapply.com/api/v1/students/1/student_id
|
12
|
+
# PUT Data student_id=123456
|
13
|
+
def update_student_id(oa_id, student_id)
|
14
|
+
# url = "#{api_path}#{id}?auth_token=#{api_key}"
|
15
|
+
url = "#{api_path}#{oa_id}"
|
16
|
+
return oa_answer( url, {student_id: student_id})
|
17
|
+
end
|
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}#{id}/status?auth_token=#{api_key}"
|
26
|
+
url = "#{api_path}#{oa_id}/status"
|
27
|
+
return oa_answer( url, {status: status})
|
28
|
+
end
|
29
|
+
|
30
|
+
|
4
31
|
end
|
5
32
|
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
|
+
version: 0.4.0
|
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-
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|