feat: Conversation and contact endpoint (#3198)
This commit is contained in:
3
app/views/api/v1/accounts/contacts/filter.json.jbuilder
Normal file
3
app/views/api/v1/accounts/contacts/filter.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
json.array! @contacts do |contact|
|
||||
json.partial! 'api/v1/models/contact.json.jbuilder', resource: contact
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
json.array! @conversations do |conversation|
|
||||
json.partial! 'api/v1/models/conversation.json.jbuilder', conversation: conversation
|
||||
end
|
||||
@@ -5,26 +5,6 @@ json.meta do
|
||||
end
|
||||
json.payload do
|
||||
json.array! @conversations do |conversation|
|
||||
json.id conversation.display_id
|
||||
json.created_at conversation.created_at.to_i
|
||||
json.contact do
|
||||
json.id conversation.contact.id
|
||||
json.name conversation.contact.name
|
||||
end
|
||||
json.inbox do
|
||||
json.id conversation.inbox.id
|
||||
json.name conversation.inbox.name
|
||||
json.channel_type conversation.inbox.channel_type
|
||||
end
|
||||
json.messages do
|
||||
json.array! conversation.messages do |message|
|
||||
json.content message.content
|
||||
json.id message.id
|
||||
json.sender_name message.sender.name if message.sender
|
||||
json.message_type message.message_type_before_type_cast
|
||||
json.created_at message.created_at.to_i
|
||||
end
|
||||
end
|
||||
json.account_id conversation.account_id
|
||||
json.partial! 'api/v1/models/conversation.json.jbuilder', conversation: conversation
|
||||
end
|
||||
end
|
||||
|
||||
21
app/views/api/v1/models/_conversation.json.jbuilder
Normal file
21
app/views/api/v1/models/_conversation.json.jbuilder
Normal file
@@ -0,0 +1,21 @@
|
||||
json.id conversation.display_id
|
||||
json.created_at conversation.created_at.to_i
|
||||
json.contact do
|
||||
json.id conversation.contact.id
|
||||
json.name conversation.contact.name
|
||||
end
|
||||
json.inbox do
|
||||
json.id conversation.inbox.id
|
||||
json.name conversation.inbox.name
|
||||
json.channel_type conversation.inbox.channel_type
|
||||
end
|
||||
json.messages do
|
||||
json.array! conversation.messages do |message|
|
||||
json.content message.content
|
||||
json.id message.id
|
||||
json.sender_name message.sender.name if message.sender
|
||||
json.message_type message.message_type_before_type_cast
|
||||
json.created_at message.created_at.to_i
|
||||
end
|
||||
end
|
||||
json.account_id conversation.account_id
|
||||
Reference in New Issue
Block a user