feat: API to add label to contacts (#1563)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
class Api::V1::Accounts::Contacts::LabelsController < Api::V1::Accounts::BaseController
|
||||
include LabelConcern
|
||||
|
||||
private
|
||||
|
||||
def model
|
||||
@model ||= Current.account.contacts.find(params[:contact_id])
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
params.permit(:contact_id, :labels)
|
||||
end
|
||||
end
|
||||
@@ -1,11 +1,13 @@
|
||||
class Api::V1::Accounts::Conversations::LabelsController < Api::V1::Accounts::Conversations::BaseController
|
||||
def create
|
||||
@conversation.update_labels(params[:labels])
|
||||
@labels = @conversation.label_list
|
||||
include LabelConcern
|
||||
|
||||
private
|
||||
|
||||
def model
|
||||
@model ||= @conversation
|
||||
end
|
||||
|
||||
# all labels of the current conversation
|
||||
def index
|
||||
@labels = @conversation.label_list
|
||||
def permitted_params
|
||||
params.permit(:conversation_id, :labels)
|
||||
end
|
||||
end
|
||||
|
||||
10
app/controllers/concerns/label_concern.rb
Normal file
10
app/controllers/concerns/label_concern.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
module LabelConcern
|
||||
def create
|
||||
model.update_labels(permitted_params[:labels])
|
||||
@labels = model.label_list
|
||||
end
|
||||
|
||||
def index
|
||||
@labels = model.label_list
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user