Skip to content

Commit

Permalink
Rename MCP notifications endpoint (#12453)
Browse files Browse the repository at this point in the history
* Drop new from mcp notifications endpoint

* Update before controller hooks

* Update swagger spec
  • Loading branch information
Scott James authored Apr 28, 2023
1 parent 7f95c5f commit 74d525b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions app/controllers/v0/medical_copays_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module V0
class MedicalCopaysController < ApplicationController
before_action(except: :send_new_statements_notifications) { authorize :medical_copays, :access? }
before_action(only: :send_new_statements_notifications) { authorize :medical_copays, :access_notifications? }
before_action(except: :send_statement_notifications) { authorize :medical_copays, :access? }
before_action(only: :send_statement_notifications) { authorize :medical_copays, :access_notifications? }

skip_before_action :verify_authenticity_token, only: [:send_new_statements_notifications]
skip_before_action :authenticate, only: [:send_new_statements_notifications]
skip_after_action :set_csrf_header, only: [:send_new_statements_notifications]
skip_before_action :verify_authenticity_token, only: [:send_statement_notifications]
skip_before_action :authenticate, only: [:send_statement_notifications]
skip_after_action :set_csrf_header, only: [:send_statement_notifications]

rescue_from ::MedicalCopays::VBS::Service::StatementNotFound, with: :render_not_found

Expand All @@ -28,8 +28,8 @@ def get_pdf_statement_by_id
)
end

def send_new_statements_notifications
render json: vbs_service.send_new_statements_notifications(params[:statements])
def send_statement_notifications
render json: vbs_service.send_statement_notifications(params[:statements])
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/services/medical_copays/vbs/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_pdf_statement_by_id(statement_id)
Base64.decode64(response.body['statement'])
end

def send_new_statements_notifications(_statements_json)
def send_statement_notifications(_statements_json)
# Placeholder until we know JSON structure

{ status: 200, message: 'New Statement Notifications Coming Soon' }
Expand Down
2 changes: 1 addition & 1 deletion app/swagger/swagger/requests/medical_copays.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class MedicalCopays
end
end

swagger_path '/v0/medical_copays/send_new_statements_notifications' do
swagger_path '/v0/medical_copays/send_statement_notifications' do
operation :post do
key :description, 'Endpoint to trigger notifications from new statements'
key :operationId, 'sendNewStatementsNotifications'
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

resources :medical_copays, only: %i[index show]
get 'medical_copays/get_pdf_statement_by_id/:statement_id', to: 'medical_copays#get_pdf_statement_by_id'
post 'medical_copays/send_new_statements_notifications', to: 'medical_copays#send_new_statements_notifications'
post 'medical_copays/send_statement_notifications', to: 'medical_copays#send_statement_notifications'

resources :apps, only: %i[index show]
scope_default = { category: 'unknown_category' }
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/v0/medical_copays_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
end
end

describe '#send_new_statements_notifications' do
describe '#send_statement_notifications' do
it 'returns a success message when notifications are sent' do
post(:send_new_statements_notifications, params: { statements: [] })
post(:send_statement_notifications, params: { statements: [] })
expect(response).to have_http_status(:ok)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/swagger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,11 @@
end
end

context 'medical copays send_new_statements_notifications' do
context 'medical copays send_statement_notifications' do
it 'validates the route' do
expect(subject).to validate(
:post,
'/v0/medical_copays/send_new_statements_notifications',
'/v0/medical_copays/send_statement_notifications',
200,
headers
)
Expand Down

0 comments on commit 74d525b

Please sign in to comment.