diff --git a/packages/api-core/src/resources/organizations.js b/packages/api-core/src/resources/organizations.js index 980b1605a..57b67ff5b 100644 --- a/packages/api-core/src/resources/organizations.js +++ b/packages/api-core/src/resources/organizations.js @@ -18,12 +18,6 @@ export default class AvOrganizations extends AvApi { this.avUsers = avUsers; } - afterQuery(response) { - return response && response.data && response.data.organizations - ? response.data.organizations - : []; - } - queryOrganizations(user, config) { const params = Object.assign({}, { userId: user.id }, config.params || {}); return this.query(Object.assign({}, { params }, config)); diff --git a/packages/api-core/src/resources/permissions.js b/packages/api-core/src/resources/permissions.js index f88491366..47c7810e2 100644 --- a/packages/api-core/src/resources/permissions.js +++ b/packages/api-core/src/resources/permissions.js @@ -11,11 +11,7 @@ export default class AvPermissions extends AvApi { ); super(http, promise, thisConfig); } - afterQuery(response) { - return response && response.data && response.data.permissions - ? response.data.permissions - : []; - } + getPermissions(id, region) { return this.query({ params: { id, region }, diff --git a/packages/api-core/src/resources/providers.js b/packages/api-core/src/resources/providers.js index 755733cc6..4f6a83b65 100644 --- a/packages/api-core/src/resources/providers.js +++ b/packages/api-core/src/resources/providers.js @@ -12,12 +12,6 @@ export default class AvProviders extends AvApi { super(http, promise, thisConfig); } - afterQuery(response) { - return response && response.data && response.data.providers - ? response.data.providers - : []; - } - getProviders(customerId, config) { const params = Object.assign({}, { customerId }, config.params || {}); return this.query(Object.assign({}, { params }, config)); diff --git a/packages/api-core/src/resources/regions.js b/packages/api-core/src/resources/regions.js index 9a7060389..77d8d3a38 100644 --- a/packages/api-core/src/resources/regions.js +++ b/packages/api-core/src/resources/regions.js @@ -15,12 +15,6 @@ export default class AvRegions extends AvApi { this.AvUsers = AvUsers; } - afterGet(response) { - return response && response.data && response.data.regions - ? response.data.regions - : []; - } - afterUpdate(response) { this.setPageBust(); return response; diff --git a/packages/api-core/src/resources/tests/organizations.test.js b/packages/api-core/src/resources/tests/organizations.test.js index 452ceda75..a51618f8d 100644 --- a/packages/api-core/src/resources/tests/organizations.test.js +++ b/packages/api-core/src/resources/tests/organizations.test.js @@ -28,19 +28,6 @@ describe('AvOrganizations', () => { }).toThrow('[avUsers] must be defined'); }); - test('afterQuery() should return response.data.organizations if it exists or an empty array', () => { - api = new AvOrganizations(mockHttp, Promise, mockAvUsers); - const testResponse1 = {}; - const organizations = ['testOrg']; - const testResponse2 = { - data: { - organizations, - }, - }; - expect(api.afterQuery(testResponse1)).toEqual([]); - expect(api.afterQuery(testResponse2)).toEqual(organizations); - }); - test('queryOrganizations() should call query with user.id added to params.userId', () => { api = new AvOrganizations(mockHttp, Promise, mockAvUsers); api.query = jest.fn(); diff --git a/packages/api-core/src/resources/tests/permissions.test.js b/packages/api-core/src/resources/tests/permissions.test.js index daadbb3c4..bbfc1a7d7 100644 --- a/packages/api-core/src/resources/tests/permissions.test.js +++ b/packages/api-core/src/resources/tests/permissions.test.js @@ -15,20 +15,7 @@ describe('AvPermissions', () => { expect(api).toBeDefined(); }); - test('afterQuery should return response.data.permissions if it exists or an empty array', () => { - api = new AvPermissions(mockHttp, Promise); - const testResponse1 = {}; - const permissions = ['testPermission']; - const testResponse2 = { - data: { - permissions, - }, - }; - expect(api.afterQuery(testResponse1)).toEqual([]); - expect(api.afterQuery(testResponse2)).toEqual(permissions); - }); - - test('getPermissions should query with permissionId and region params from arguments', () => { + test('getPermissions() should query with permissionId and region params from arguments', () => { api = new AvPermissions(mockHttp, Promise); api.query = jest.fn(); const id = 'testPermissionId'; diff --git a/packages/api-core/src/resources/tests/providers.test.js b/packages/api-core/src/resources/tests/providers.test.js index 959154b5b..c2ae1d9dd 100644 --- a/packages/api-core/src/resources/tests/providers.test.js +++ b/packages/api-core/src/resources/tests/providers.test.js @@ -15,19 +15,6 @@ describe('AvProviders', () => { expect(api).toBeDefined(); }); - test('afterQuery should return response.data.providers if it exists or an empty array', () => { - api = new AvProviders(mockHttp, Promise); - const testResponse1 = {}; - const providers = ['testProvider']; - const testResponse2 = { - data: { - providers, - }, - }; - expect(api.afterQuery(testResponse1)).toEqual([]); - expect(api.afterQuery(testResponse2)).toEqual(providers); - }); - test('getProviders should query with customerId param added', () => { api = new AvProviders(mockHttp, Promise); api.query = jest.fn(); diff --git a/packages/api-core/src/resources/tests/regions.test.js b/packages/api-core/src/resources/tests/regions.test.js index f076bafde..6e727ac78 100644 --- a/packages/api-core/src/resources/tests/regions.test.js +++ b/packages/api-core/src/resources/tests/regions.test.js @@ -22,19 +22,6 @@ describe('AvRegions', () => { expect(api).toBeDefined(); }); - test('afterGet should return response.data.regions if it exists or an empty array', () => { - api = new AvRegions(mockHttp, Promise, mockAvUsers); - const testResponse1 = {}; - const regions = ['testOrg']; - const testResponse2 = { - data: { - regions, - }, - }; - expect(api.afterGet(testResponse1)).toEqual([]); - expect(api.afterGet(testResponse2)).toEqual(regions); - }); - test('afterUpdate should call setPageBust and return response', () => { api = new AvRegions(mockHttp, Promise, mockAvUsers); api.setPageBust = jest.fn(); diff --git a/packages/api-core/src/resources/tests/user.test.js b/packages/api-core/src/resources/tests/user.test.js index f3ce0e3d9..62a49a0c3 100644 --- a/packages/api-core/src/resources/tests/user.test.js +++ b/packages/api-core/src/resources/tests/user.test.js @@ -15,19 +15,6 @@ describe('AvUsers', () => { expect(api).toBeDefined(); }); - test('afterGet should return response.data.user if it exists or an empty object', () => { - api = new AvUsers(mockHttp, Promise); - const testResponse1 = {}; - const user = ['testUser']; - const testResponse2 = { - data: { - user, - }, - }; - expect(api.afterGet(testResponse1)).toEqual({}); - expect(api.afterGet(testResponse2)).toEqual(user); - }); - test("me() should get with id 'me'", () => { api = new AvUsers(mockHttp, Promise); api.get = jest.fn(); diff --git a/packages/api-core/src/resources/user.js b/packages/api-core/src/resources/user.js index 82e8092e0..35f40ff94 100644 --- a/packages/api-core/src/resources/user.js +++ b/packages/api-core/src/resources/user.js @@ -11,9 +11,7 @@ export default class AvUsers extends AvApi { ); super(http, promise, thisConfig); } - afterGet(response) { - return (response && response.data && response.data.user) || {}; - } + me(config) { return this.get('me', config); }