Skip to content

Commit

Permalink
move qualifications API into v1 namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
alkesh committed Jan 14, 2025
1 parent 0f5e112 commit ac39162
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module API
module TeacherRecordService
module V1
class QualificationsController < BaseController
def show
participant_outcomes = participant_outcome_query

render json: to_json(participant_outcomes)
end

private

def trn
params[:trn]
end

def participant_outcome_query
Qualifications::Query.new.qualifications(trn:)
end

def to_json(participant_outcomes)
QualificationsSerializer.render(trn, root: "data", participant_outcomes:)
end

def api_token_scope
APIToken.scopes[:teacher_record_service]
end
end
end
end
end
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@
end

namespace :teacher_record_service, path: "teacher-record-service", defaults: { format: :json } do
resources :qualifications, path: "npq-qualifications", only: %i[show], param: :trn
namespace :v1 do
resources :qualifications, path: "npq-qualifications", only: %i[show], param: :trn
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion docs/qualifications_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It returns both qualifications that are currently held in NPQ registration and t

To get qualifications for a TRN:

`GET /api/teacher-record-service/npq-qualifications/1000207`
`GET /api/teacher-record-service/v1/npq-qualifications/1000207`

Example response:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require "rails_helper"

RSpec.describe "Qualifications endpoint", type: :request do
describe "GET /api/teacher-record-service/npq-qualifications/:trn" do
let(:path) { "/api/teacher-record-service/npq-qualifications/#{trn}" }
describe "GET /api/teacher-record-service/v1/npq-qualifications/:trn" do
let(:path) { "/api/teacher-record-service/v1/npq-qualifications/#{trn}" }

before { create(:api_token, :teacher_record_service) }

Expand Down

0 comments on commit ac39162

Please sign in to comment.