feat: Ability to update CSAT over Client APIs (#6470)
This PR allows updating CSAT over Client APIs. ref: #6328 Co-authored-by: Cristian Duta <Cristian.Duta@ti8m.ch> Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
@@ -12,6 +12,8 @@ class Public::Api::V1::Inboxes::MessagesController < Public::Api::V1::InboxesCon
|
||||
end
|
||||
|
||||
def update
|
||||
render json: { error: 'You cannot update the CSAT survey after 14 days' }, status: :unprocessable_entity and return if check_csat_locked
|
||||
|
||||
@message.update!(message_update_params)
|
||||
rescue StandardError => e
|
||||
render json: { error: @contact.errors, message: e.message }.to_json, status: :internal_server_error
|
||||
@@ -43,7 +45,7 @@ class Public::Api::V1::Inboxes::MessagesController < Public::Api::V1::InboxesCon
|
||||
end
|
||||
|
||||
def message_update_params
|
||||
params.permit(submitted_values: [:name, :title, :value])
|
||||
params.permit(submitted_values: [:name, :title, :value, { csat_survey_response: [:feedback_message, :rating] }])
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
@@ -64,4 +66,8 @@ class Public::Api::V1::Inboxes::MessagesController < Public::Api::V1::InboxesCon
|
||||
message_type: :incoming
|
||||
}
|
||||
end
|
||||
|
||||
def check_csat_locked
|
||||
(Time.zone.now.to_date - @message.created_at.to_date).to_i > 14 and @message.content_type == 'input_csat'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user