Chore: API Improvements (#3469)

This commit is contained in:
Sojan Jose
2021-11-27 00:48:46 +05:30
committed by GitHub
parent 55843c5bad
commit add004a56e
13 changed files with 55 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ class Api::V1::Accounts::CannedResponsesController < Api::V1::Accounts::BaseCont
def canned_responses
if params[:search]
Current.account.canned_responses.where('short_code ILIKE ?', "#{params[:search]}%")
Current.account.canned_responses.where('short_code ILIKE :search OR content ILIKE :search', search: "%#{params[:search]}%")
else
Current.account.canned_responses
end

View File

@@ -0,0 +1,7 @@
class AgentBotPresenter < SimpleDelegator
def access_token
return if account_id.blank?
Current.account.id == account_id ? super&.token : nil
end
end

View File

@@ -1 +1 @@
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: @agent_bot
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -1,3 +1,3 @@
json.array! @agent_bots do |agent_bot|
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: agent_bot
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: AgentBotPresenter.new(agent_bot)
end

View File

@@ -1 +1 @@
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: @agent_bot
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -1 +1 @@
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: @agent_bot
json.partial! 'api/v1/models/agent_bot.json.jbuilder', resource: AgentBotPresenter.new(@agent_bot)

View File

@@ -3,3 +3,4 @@ json.name resource.name
json.description resource.description
json.outgoing_url resource.outgoing_url
json.account_id resource.account_id
json.access_token resource.access_token if resource.access_token.present?

View File

@@ -3,3 +3,4 @@ json.name resource.name
json.description resource.description
json.outgoing_url resource.name
json.account_id resource.account_id
json.access_token resource.access_token.token