northwestern-api 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 1880e40fc33cb57c08a9a9f39fc51bf1b76a1f49
4
- data.tar.gz: 88cefff50c5cfd35dc7f39db73cb0cc6a5c7744a
3
+ metadata.gz: b265f245e7f45935a9fb721658b30b7718ae8554
4
+ data.tar.gz: 05e68ee5ced4244d1721e125e108e1368775ff7b
5
5
  SHA512:
6
- metadata.gz: 0e06feceb01a82c2bdae45c5d75611a05fd2b6119b8a7db57727ab0b82baa5272c5cf17b29823f563ab05bbd792c4678a44f103978a1c85232d3db8f20482c1c
7
- data.tar.gz: ac9145304d753cd0e922f594de7f7ac33d60292bd0ffa03389eb24013ed5ba936ee33abdd782e7efd7fd1c1235cb7cac27a9615209fdec7445976883a147bba3
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
- module Northwestern
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
@@ -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::Config::API_KEY
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::Config::API_KEY }
50
+ { key: Northwestern::API_KEY }
50
51
  ))
51
52
 
52
53
  JSON.parse(Net::HTTP.get(uri))
@@ -1,3 +1,3 @@
1
1
  module Northwestern
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: northwestern-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kowalczuk