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.
Refactor Conversation, Message API calls, store
- Loading branch information
1 parent
c21c839
commit 170f871
Showing
13 changed files
with
215 additions
and
402 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
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,24 @@ | ||
/* global axios */ | ||
import ApiClient from '../ApiClient'; | ||
|
||
class FBChannel extends ApiClient { | ||
constructor() { | ||
super('facebook_indicators'); | ||
} | ||
|
||
markSeen({ inboxId, contactId }) { | ||
return axios.post(`${this.url}/mark_seen`, { | ||
inbox_id: inboxId, | ||
contact_id: contactId, | ||
}); | ||
} | ||
|
||
toggleTyping({ status, inboxId, contactId }) { | ||
return axios.post(`${this.url}/typing_${status}`, { | ||
inbox_id: inboxId, | ||
contact_id: contactId, | ||
}); | ||
} | ||
} | ||
|
||
export default new FBChannel(); |
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 |
---|---|---|
@@ -1,104 +1,37 @@ | ||
/* eslint no-console: 0 */ | ||
/* global axios */ | ||
/* eslint no-undef: "error" */ | ||
/* eslint no-unused-expressions: ["error", { "allowShortCircuit": true }] */ | ||
import endPoints from '../endPoints'; | ||
import ApiClient from '../ApiClient'; | ||
|
||
export default { | ||
fetchConversation(id) { | ||
const urlData = endPoints('conversations')(id); | ||
const fetchPromise = new Promise((resolve, reject) => { | ||
axios | ||
.get(urlData.url) | ||
.then(response => { | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
reject(Error(error)); | ||
}); | ||
}); | ||
return fetchPromise; | ||
}, | ||
|
||
toggleStatus(id) { | ||
const urlData = endPoints('resolveConversation')(id); | ||
const fetchPromise = new Promise((resolve, reject) => { | ||
axios | ||
.post(urlData.url) | ||
.then(response => { | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
reject(Error(error)); | ||
}); | ||
}); | ||
return fetchPromise; | ||
}, | ||
class ConversationApi extends ApiClient { | ||
constructor() { | ||
super('conversations'); | ||
} | ||
|
||
assignAgent([id, agentId]) { | ||
const urlData = endPoints('assignAgent')(id, agentId); | ||
const fetchPromise = new Promise((resolve, reject) => { | ||
axios | ||
.post(urlData.url) | ||
.then(response => { | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
reject(Error(error)); | ||
}); | ||
get({ inboxId, convStatus, assigneeStatus }) { | ||
return axios.get(this.url, { | ||
params: { | ||
inbox_id: inboxId, | ||
conversation_status_id: convStatus, | ||
assignee_type_id: assigneeStatus, | ||
}, | ||
}); | ||
return fetchPromise; | ||
}, | ||
} | ||
|
||
markSeen({ inboxId, senderId }) { | ||
const urlData = endPoints('fbMarkSeen'); | ||
const fetchPromise = new Promise((resolve, reject) => { | ||
axios | ||
.post(urlData.url, { | ||
inbox_id: inboxId, | ||
sender_id: senderId, | ||
}) | ||
.then(response => { | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
reject(Error(error)); | ||
}); | ||
}); | ||
return fetchPromise; | ||
}, | ||
toggleStatus(conversationId) { | ||
return axios.post(`${this.url}/${conversationId}/toggle_status`, {}); | ||
} | ||
|
||
fbTyping({ flag, inboxId, senderId }) { | ||
const urlData = endPoints('fbTyping')(flag); | ||
const fetchPromise = new Promise((resolve, reject) => { | ||
axios | ||
.post(urlData.url, { | ||
inbox_id: inboxId, | ||
sender_id: senderId, | ||
}) | ||
.then(response => { | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
reject(Error(error)); | ||
}); | ||
}); | ||
return fetchPromise; | ||
}, | ||
assignAgent({ conversationId, agentId }) { | ||
axios.post( | ||
`${this.url}/${conversationId}/assignments?assignee_id=${agentId}`, | ||
{} | ||
); | ||
} | ||
|
||
markMessageRead({ id, lastSeen }) { | ||
const urlData = endPoints('markMessageRead')(id); | ||
urlData.params.agent_last_seen_at = lastSeen; | ||
const fetchPromise = new Promise((resolve, reject) => { | ||
axios | ||
.post(urlData.url, urlData.params) | ||
.then(response => { | ||
resolve(response); | ||
}) | ||
.catch(error => { | ||
reject(Error(error)); | ||
}); | ||
return axios.post(`${this.url}/${id}/update_last_seen`, { | ||
agent_last_seen_at: lastSeen, | ||
}); | ||
return fetchPromise; | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
export default new ConversationApi(); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.