feat: expand idb cache to agents, canned responses, and custom attributes
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/* global axios */
|
||||
|
||||
import ApiClient from './ApiClient';
|
||||
import CacheEnabledApiClient from './CacheEnabledApiClient';
|
||||
|
||||
class Agents extends ApiClient {
|
||||
class Agents extends CacheEnabledApiClient {
|
||||
constructor() {
|
||||
super('agents', { accountScoped: true });
|
||||
super('agents', { accountScoped: true, cacheModel: 'account_user' });
|
||||
}
|
||||
|
||||
bulkInvite({ emails }) {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
/* global axios */
|
||||
import ApiClient from './ApiClient';
|
||||
import CacheEnabledApiClient from './CacheEnabledApiClient';
|
||||
|
||||
class AttributeAPI extends ApiClient {
|
||||
class AttributeAPI extends CacheEnabledApiClient {
|
||||
constructor() {
|
||||
super('custom_attribute_definitions', { accountScoped: true });
|
||||
super('custom_attribute_definitions', {
|
||||
accountScoped: true,
|
||||
cacheModel: 'custom_attribute_definition',
|
||||
});
|
||||
}
|
||||
|
||||
getAttributesByModel() {
|
||||
return axios.get(this.url);
|
||||
return super.get(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
/* global axios */
|
||||
|
||||
import ApiClient from './ApiClient';
|
||||
import CacheEnabledApiClient from './CacheEnabledApiClient';
|
||||
|
||||
class CannedResponse extends ApiClient {
|
||||
class CannedResponse extends CacheEnabledApiClient {
|
||||
constructor() {
|
||||
super('canned_responses', { accountScoped: true });
|
||||
super('canned_responses', {
|
||||
accountScoped: true,
|
||||
cacheModel: 'canned_response',
|
||||
});
|
||||
}
|
||||
|
||||
get({ searchKey }) {
|
||||
const url = searchKey ? `${this.url}?search=${searchKey}` : this.url;
|
||||
return axios.get(url);
|
||||
get({ searchKey } = {}) {
|
||||
if (searchKey) {
|
||||
return axios.get(`${this.url}?search=${searchKey}`);
|
||||
}
|
||||
return super.get(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user