From 461284f0cb5bdd3720fc6d5a7355ec019766fba5 Mon Sep 17 00:00:00 2001 From: Cam Tucker Date: Fri, 22 Jan 2016 17:09:46 -0600 Subject: [PATCH] updated section endpoints --- features/regis_api.feature | 3 ++- features/step_definitions/api_steps.rb | 16 ++++++++++------ lib/regis/endpoint/section.rb | 2 +- lib/regis/endpoint/sections.rb | 2 +- lib/regis/responses/models/instructor.rb | 19 +++++++++++++++++++ lib/regis/responses/models/section.rb | 24 +++++++++++++++++++----- lib/regis/responses/sections.rb | 6 ++---- lib/regis/version.rb | 2 +- 8 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 lib/regis/responses/models/instructor.rb diff --git a/features/regis_api.feature b/features/regis_api.feature index 886679f..b65e557 100644 --- a/features/regis_api.feature +++ b/features/regis_api.feature @@ -5,7 +5,7 @@ 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 @@ -13,6 +13,7 @@ Scenario: retrieve section 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 diff --git a/features/step_definitions/api_steps.rb b/features/step_definitions/api_steps.rb index 38698d3..68dbc8e 100644 --- a/features/step_definitions/api_steps.rb +++ b/features/step_definitions/api_steps.rb @@ -7,7 +7,7 @@ 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 @@ -15,18 +15,22 @@ 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 \ No newline at end of file diff --git a/lib/regis/endpoint/section.rb b/lib/regis/endpoint/section.rb index 1e922ce..9e80577 100644 --- a/lib/regis/endpoint/section.rb +++ b/lib/regis/endpoint/section.rb @@ -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 diff --git a/lib/regis/endpoint/sections.rb b/lib/regis/endpoint/sections.rb index b57e8f5..1c38fd0 100644 --- a/lib/regis/endpoint/sections.rb +++ b/lib/regis/endpoint/sections.rb @@ -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 diff --git a/lib/regis/responses/models/instructor.rb b/lib/regis/responses/models/instructor.rb new file mode 100644 index 0000000..45eefa7 --- /dev/null +++ b/lib/regis/responses/models/instructor.rb @@ -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 \ No newline at end of file diff --git a/lib/regis/responses/models/section.rb b/lib/regis/responses/models/section.rb index 2d355bf..7175152 100644 --- a/lib/regis/responses/models/section.rb +++ b/lib/regis/responses/models/section.rb @@ -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 @@ -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 diff --git a/lib/regis/responses/sections.rb b/lib/regis/responses/sections.rb index 946c51b..4750244 100644 --- a/lib/regis/responses/sections.rb +++ b/lib/regis/responses/sections.rb @@ -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 diff --git a/lib/regis/version.rb b/lib/regis/version.rb index b60709e..77b93a4 100644 --- a/lib/regis/version.rb +++ b/lib/regis/version.rb @@ -1,3 +1,3 @@ module Regis - VERSION = "0.0.3" + VERSION = "0.0.5" end \ No newline at end of file