chore: Add Contact Note APIs (#3266)
This commit is contained in:
32
app/controllers/api/v1/accounts/contacts/notes_controller.rb
Normal file
32
app/controllers/api/v1/accounts/contacts/notes_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class Api::V1::Accounts::Contacts::NotesController < Api::V1::Accounts::Contacts::BaseController
|
||||
before_action :note, except: [:index, :create]
|
||||
|
||||
def index
|
||||
@notes = @contact.notes.includes(:user)
|
||||
end
|
||||
|
||||
def create
|
||||
@note = @contact.notes.create!(note_params)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@note.destroy
|
||||
head :ok
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
def update
|
||||
@note.update(note_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def note
|
||||
@note ||= @contact.notes.find(params[:id])
|
||||
end
|
||||
|
||||
def note_params
|
||||
params.require(:note).permit(:content).merge({ contact_id: @contact.id, user_id: Current.user.id })
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user