forked from chatwoot/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reply multiple action and csat trigger
- Loading branch information
Showing
37 changed files
with
649 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/controllers/api/v1/accounts/conversations/reply_action_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class Api::V1::Accounts::Conversations::ReplyActionController < Api::V1::Accounts::Conversations::BaseController | ||
# def show | ||
# render json: { action_type: 'default' } and return unless Redis::Alfred.exists?(action_redis_key) | ||
|
||
# action_type = Redis::Alfred.get(action_redis_key) | ||
# render json: { action_type: action_type } | ||
# end | ||
|
||
def show | ||
puts ' ---------------- default action show -------------' | ||
render json: { action_type: 'default_reply_action'} | ||
end | ||
|
||
# def update | ||
# # Redis::Alfred.set(action_redis_key, action_type_params) | ||
# puts ' ---------------- default action updated -------------' | ||
# head :ok | ||
# end | ||
|
||
# def destroy | ||
# Redis::Alfred.delete(action_redis_key) | ||
# head :ok | ||
# end | ||
|
||
# private | ||
|
||
# def action_redis_key | ||
# format(Redis::Alfred::CONVERSATION_DRAFT_MESSAGE, conversation_id: conversation_id, account_id: current_account.id) | ||
# end | ||
|
||
# def conversation_id | ||
# params[:conversation_id] | ||
# end | ||
|
||
# def action_type_params | ||
# params.dig(:reply_action, :type) || '' | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint no-console: 0 */ | ||
/* global axios */ | ||
import ApiClient from '../ApiClient'; | ||
|
||
class ReplyActionApi extends ApiClient { | ||
constructor() { | ||
super('conversations', { accountScoped: true }); | ||
} | ||
|
||
get(conversationId) { | ||
return axios.get(`${this.url}/${conversationId}/reply_action`); | ||
} | ||
|
||
update({ conversationId, message }) { | ||
return axios.put(`${this.url}/${conversationId}/reply_action`, { | ||
message, | ||
}); | ||
} | ||
|
||
delete(conversationId) { | ||
return axios.delete(`${this.url}/${conversationId}/reply_action`); | ||
} | ||
} | ||
|
||
export default new ReplyActionApi(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import replyActionApi from '../../inbox/conversation'; | ||
import ApiClient from '../../ApiClient'; | ||
import describeWithAPIMock from '../apiSpecHelper'; | ||
|
||
describe('#ReplyActionApi', () => { | ||
it('creates correct instance', () => { | ||
expect(replyActionApi).toBeInstanceOf(ApiClient); | ||
expect(replyActionApi).toHaveProperty('get'); | ||
expect(replyActionApi).toHaveProperty('update'); | ||
expect(replyActionApi).toHaveProperty('delete'); | ||
}); | ||
|
||
describeWithAPIMock('API calls', context => { | ||
it('#get', () => { | ||
replyActionApi.get({ | ||
conversationId: 2, | ||
}); | ||
expect(context.axiosMock.get).toHaveBeenCalledWith( | ||
`/api/v1/conversations/2/reply_action` | ||
); | ||
}); | ||
|
||
it('#update', () => { | ||
replyActionApi.update({ | ||
conversationId: 45, | ||
message: 'Hello', | ||
}); | ||
expect(context.axiosMock.post).toHaveBeenCalledWith( | ||
'/api/v1/conversations/45/reply_action', | ||
{ | ||
message: 'Hello', | ||
} | ||
); | ||
}); | ||
|
||
it('#delete', () => { | ||
replyActionApi.delete({ | ||
conversationId: 12, | ||
}); | ||
expect(context.axiosMock.delete).toHaveBeenCalledWith( | ||
`/api/v1/conversations/12/reply_action` | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.