northwestern-api 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +2 -0
- data/lib/northwestern.rb +58 -0
- data/lib/northwestern/version.rb +3 -0
- data/northwestern-api.gemspec +21 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: af41ff1a8ac413a6b8c4157edcafd7f9133927ee
|
4
|
+
data.tar.gz: 976e00fd583c3e4880d91daf9da83c99f5d9a0e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53a0231139df6b5fa8c70bbe6dc794323b1d4c225b5aac5f22499b9fd3e2521b48147be4ea139f3caaa48b011d00603921454ddc859235727190493904b7d977
|
7
|
+
data.tar.gz: c230f691ecd2ad10e210e9855a04ff2992b1a1eaa66d3d8548e43022b2d3d547ea49d5728b349ee45e10132f85506e408005af33cc368143d0888c57071a2049
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex Kowalczuk
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Northwestern API
|
2
|
+
|
3
|
+
A Ruby wrapper for the Northwestern Course data API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add it to your Gemfile:
|
8
|
+
|
9
|
+
gem 'northwestern-api'
|
10
|
+
|
11
|
+
run:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself with:
|
16
|
+
|
17
|
+
$ gem install northwestern-api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You'll have to set your client ID somewhere, in some sort of config directory
|
22
|
+
should do nicely. If you're using Rails try the `config` directory and make an
|
23
|
+
initializer.
|
24
|
+
|
25
|
+
Initialize the Key like so:
|
26
|
+
|
27
|
+
```
|
28
|
+
require 'northwestern-api'
|
29
|
+
|
30
|
+
module Northwestern
|
31
|
+
class Config
|
32
|
+
API_KEY = "###YOUR KEY GOES HERE###"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
Then you can use the API anywhere without making an instance of it. The
|
38
|
+
endpoints from the API are all available. For `courses/details` and
|
39
|
+
`rooms/details` just use and underscore.
|
40
|
+
|
41
|
+
Pass a list of parameters (not including your API key) as a Ruby hash to the
|
42
|
+
method. The resulting JSON is also parsed into Ruby Arrays and Hashes.
|
43
|
+
|
44
|
+
Use like so:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
all_terms = Northwestern.terms
|
48
|
+
# => [{"id"=>4560, "name"=>"2014 Fall", "start_date"=>"2014-09-23",
|
49
|
+
"end_date"=>"2014-12-12"}, ... ]
|
50
|
+
|
51
|
+
fall2014 = all_terms[0]["id"]
|
52
|
+
|
53
|
+
fall_eecs_courses = Northwestern.courses({ term: fall2014, subject: "EECS" })
|
54
|
+
# => [{"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}, ... ]
|
60
|
+
```
|
61
|
+
|
62
|
+
## Issues
|
63
|
+
|
64
|
+
If you find an issue, please put up a Github Issue request. If you have an idea
|
65
|
+
you think make the gem better or easier to use, feel free to run that by me too.
|
66
|
+
Run now it's a very thin wrapper around those functions.
|
data/Rakefile
ADDED
data/lib/northwestern.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Northwestern
|
6
|
+
BASE_URL = 'https://api.asg.northwestern.edu/'
|
7
|
+
class << self
|
8
|
+
def terms(params={})
|
9
|
+
self.get('/terms', {})
|
10
|
+
end
|
11
|
+
|
12
|
+
def schools(params={})
|
13
|
+
self.get('/schools', {})
|
14
|
+
end
|
15
|
+
|
16
|
+
def terms(params={})
|
17
|
+
self.get('/terms', {})
|
18
|
+
end
|
19
|
+
|
20
|
+
def subjects(params={})
|
21
|
+
self.get('/subjects', params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def courses(params={})
|
25
|
+
self.get('/courses', params)
|
26
|
+
end
|
27
|
+
|
28
|
+
def course_details(params={})
|
29
|
+
self.get('/courses/details', params)
|
30
|
+
end
|
31
|
+
|
32
|
+
def instructors(params={})
|
33
|
+
self.get('/instructors', params)
|
34
|
+
end
|
35
|
+
|
36
|
+
def rooms(params={})
|
37
|
+
self.get('/rooms', params)
|
38
|
+
end
|
39
|
+
|
40
|
+
def room_details(params={})
|
41
|
+
self.get('/rooms/details', params)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get(path, params)
|
45
|
+
if defined? Northwestern::Config::API_KEY
|
46
|
+
uri = URI(BASE_URL)
|
47
|
+
uri.path = path
|
48
|
+
uri.query = URI.encode_www_form(params.merge(
|
49
|
+
{ key: Northwestern::Config::API_KEY }
|
50
|
+
))
|
51
|
+
|
52
|
+
JSON.parse(Net::HTTP.get(uri))
|
53
|
+
else
|
54
|
+
"Please set your API key (see readme)"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'northwestern/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "northwestern-api"
|
8
|
+
spec.version = Northwestern::VERSION
|
9
|
+
spec.authors = ["Alex Kowalczuk"]
|
10
|
+
spec.email = ["alexskowalczuk@gmail.com"]
|
11
|
+
spec.summary = %q{A Ruby wrapper for the ASG Northwestern Course data API}
|
12
|
+
spec.homepage = %q{https://github.com/northwesternapis/ruby-client}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: northwestern-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Kowalczuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- alexskowalczuk@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/northwestern.rb
|
54
|
+
- lib/northwestern/version.rb
|
55
|
+
- northwestern-api.gemspec
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.3.0
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: A Ruby wrapper for the ASG Northwestern Course data API
|
80
|
+
test_files: []
|