northwestern-api 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -12
- data/lib/northwestern-api.rb +3 -2
- data/lib/northwestern/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b265f245e7f45935a9fb721658b30b7718ae8554
|
4
|
+
data.tar.gz: 05e68ee5ced4244d1721e125e108e1368775ff7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc811c70a56e961d92f7aefa91b749137a16728584aa3e8a9f46990e9decff167b5a816d326c46c3f425f41f2f56a5064372358b5a43482bc2e127e6ff02e1c1
|
7
|
+
data.tar.gz: 3fc37d2792041d320b25129c9a3b7c71047e25dfdb22863f70fb4897fadf95ee77084b8f57fe03dfe182172cf968ff3c76b5a4fa30dbd624db8586106b18f4c8
|
data/README.md
CHANGED
@@ -27,11 +27,7 @@ Initialize the Key like so:
|
|
27
27
|
```
|
28
28
|
require 'northwestern-api'
|
29
29
|
|
30
|
-
|
31
|
-
class Config
|
32
|
-
API_KEY = "###YOUR KEY GOES HERE###"
|
33
|
-
end
|
34
|
-
end
|
30
|
+
Northwestern::API_KEY = "### YOUR_KEY_GOES_HERE ###"
|
35
31
|
```
|
36
32
|
|
37
33
|
Then you can use the API anywhere without making an instance of it. The
|
@@ -41,22 +37,24 @@ endpoints from the API are all available. For `courses/details` and
|
|
41
37
|
Pass a list of parameters (not including your API key) as a Ruby hash to the
|
42
38
|
method. The resulting JSON is also parsed into Ruby Arrays and Hashes.
|
43
39
|
|
44
|
-
Use like so:
|
40
|
+
Use like so (assuming your key as been previously set):
|
45
41
|
|
46
42
|
```ruby
|
43
|
+
require 'northwestern-api'
|
44
|
+
|
47
45
|
all_terms = Northwestern.terms
|
48
46
|
# => [{"id"=>4560, "name"=>"2014 Fall", "start_date"=>"2014-09-23",
|
49
|
-
"end_date"=>"2014-12-12"}, ... ]
|
47
|
+
# "end_date"=>"2014-12-12"}, ... ]
|
50
48
|
|
51
49
|
fall2014 = all_terms[0]["id"]
|
52
50
|
|
53
51
|
fall_eecs_courses = Northwestern.courses({ term: fall2014, subject: "EECS" })
|
54
52
|
# => [{"id"=>109680, "title"=>"An Introduction to Computer Science for
|
55
|
-
Everyone", "term"=>"2014 Fall", "instructor"=>"Haoqi Zhang", "subject"=>"EECS",
|
56
|
-
"catalog_num"=>"101-0", "section"=>"20", "room"=>"Annenberg Hall G15",
|
57
|
-
"meeting_days"=>"MoWe", "start_time"=>"15:00", "end_time"=>"15:50",
|
58
|
-
"seats"=>110, "topic"=>nil, "component"=>"LEC", "class_num"=>14597,
|
59
|
-
"course_id"=>8093}, ... ]
|
53
|
+
# Everyone", "term"=>"2014 Fall", "instructor"=>"Haoqi Zhang", "subject"=>"EECS",
|
54
|
+
# "catalog_num"=>"101-0", "section"=>"20", "room"=>"Annenberg Hall G15",
|
55
|
+
# "meeting_days"=>"MoWe", "start_time"=>"15:00", "end_time"=>"15:50",
|
56
|
+
# "seats"=>110, "topic"=>nil, "component"=>"LEC", "class_num"=>14597,
|
57
|
+
# "course_id"=>8093}, ... ]
|
60
58
|
```
|
61
59
|
|
62
60
|
## Issues
|
data/lib/northwestern-api.rb
CHANGED
@@ -4,6 +4,7 @@ require 'json'
|
|
4
4
|
|
5
5
|
module Northwestern
|
6
6
|
BASE_URL = 'https://api.asg.northwestern.edu/'
|
7
|
+
|
7
8
|
class << self
|
8
9
|
def terms(params={})
|
9
10
|
self.get('/terms', {})
|
@@ -42,11 +43,11 @@ module Northwestern
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def get(path, params)
|
45
|
-
if defined? Northwestern::
|
46
|
+
if defined? Northwestern::API_KEY
|
46
47
|
uri = URI(BASE_URL)
|
47
48
|
uri.path = path
|
48
49
|
uri.query = URI.encode_www_form(params.merge(
|
49
|
-
{ key: Northwestern::
|
50
|
+
{ key: Northwestern::API_KEY }
|
50
51
|
))
|
51
52
|
|
52
53
|
JSON.parse(Net::HTTP.get(uri))
|
data/lib/northwestern/version.rb
CHANGED