Skip to content

Commit

Permalink
updated section endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
camerontucker committed Jan 22, 2016
1 parent 8bc692a commit 461284f
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 19 deletions.
3 changes: 2 additions & 1 deletion features/regis_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ Feature: regis api can connect
Scenario: search sections
When I search for sections
Then I should receive a list of sections

Scenario: retrieve section
When I ask for a section
Then I should receive the section I asked for

Scenario: section values are populated
When I ask for a section
Then I should have populated section values
Then I should have an instructor

Scenario: api is cached
When I reset the section cache
Expand Down
16 changes: 10 additions & 6 deletions features/step_definitions/api_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@
end

When /^I reset the section cache$/ do
Regis.client.configuration.cache.delete("/Section/Admin/#{$REGIS_TEST_VALUES['section_uuid']}?format=json")
Regis.client.configuration.cache.delete("/Section/#{$REGIS_TEST_VALUES['section_uuid']}?format=json")
end

When /^I ask for a section$/ do
@response = Regis.client.section_get_by_uuid($REGIS_TEST_VALUES['section_uuid'])
end

Then /^I should receive the section I asked for$/ do
expect(@response.section.uuid == $REGIS_TEST_VALUES['section_uuid']).to be true
expect(@response.section.secUUID == $REGIS_TEST_VALUES['section_uuid']).to be true
end

Then /^I should have populated section values$/ do
expect(@response.section.uuid).not_to be_empty
expect(@response.section.secUUID).not_to be_empty
expect(@response.section.reporting_term).not_to be_empty
expect(@response.section.course_name).not_to be_empty
expect(@response.section.title).not_to be_empty
expect(@response.section.min_credits).to be > 0
expect(@response.section.course_title).not_to be_empty
expect(@response.section.credits_long_name).not_to be_empty
end

Then /^I should have an instructor$/ do
expect(@response.section.instructors[0].regent_id).to be > 0
end

Then /^I should have a cached response$/ do
response = Regis.client.configuration.cache.read("/Section/Admin/#{$REGIS_TEST_VALUES['section_uuid']}?format=json")
response = Regis.client.configuration.cache.read("/Section/#{$REGIS_TEST_VALUES['section_uuid']}?format=json")
expect(response).to be_instance_of(Faraday::Response)
end
2 changes: 1 addition & 1 deletion lib/regis/endpoint/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(client)
end

def section_get_by_uuid(uuid)
response = @client.connection.get "/Section/Admin/#{uuid}", { :format => 'json' }
response = @client.connection.get "/Section/#{uuid}", { :format => 'json' }
Response::Section.new(response.body)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/regis/endpoint/sections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(client)
end

def sections_get_by_reporting_term(reporting_term)
response = @client.connection.get "/Sections/Admin/#{reporting_term}", { :format => 'json' }
response = @client.connection.get "/Sections/Lookup/#{reporting_term}", { :format => 'json' }
Response::Sections.new(response.body)
end
end
Expand Down
19 changes: 19 additions & 0 deletions lib/regis/responses/models/instructor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'regis/responses/base'

module Regis
module Response
module Model
class Instructor < Response::Base
attr_reader :regent_id
attr_reader :first_name
attr_reader :last_name
attr_reader :full_name
attr_reader :image_base64

def initialize(json)
super(json)
end
end
end
end
end
24 changes: 19 additions & 5 deletions lib/regis/responses/models/section.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
require 'regis/responses/base'
require 'regis/responses/models/instructor'

module Regis
module Response
module Model
class Section < Response::Base
attr_reader :uuid
attr_reader :secUUID
attr_reader :course_name
attr_reader :title
attr_reader :location
attr_reader :course_description
attr_reader :course_title
attr_reader :section_code
attr_reader :location_code
attr_reader :location_long_name
attr_reader :room

attr_reader :is_audio
attr_reader :is_oncampus

attr_reader :prerequisites
attr_reader :corequisites

attr_reader :current_status

attr_reader :start_date
attr_reader :end_date
attr_reader :meeting_days
Expand All @@ -27,12 +36,17 @@ class Section < Response::Base
attr_reader :is_unlisted

attr_reader :reporting_term
attr_reader :min_credits
attr_reader :term
attr_reader :credits_long_name
attr_reader :max_credits
attr_reader :is_pass_fail


attr_reader :instructors

def initialize(json)
super(json)

@instructors = parse(@instructors, Instructor)
end
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/regis/responses/sections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ module Response
class Sections < Base
attr_reader :sections

def initialize(json)
super(json)

@sections = parse(@sections, Model::Section)
def initialize(json)
@sections = parse(json, Model::Section)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/regis/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Regis
VERSION = "0.0.3"
VERSION = "0.0.5"
end

0 comments on commit 461284f

Please sign in to comment.