@availity/api-core
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
{ | ||
"name": "@availity/api-core", | ||
"version": "1.0.0-alpha.0", | ||
"description": "Base API definitions", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Base definitions for Availity API", | ||
"keywords": [ | ||
@@ -17,6 +17,6 @@ "availity", | ||
"peerDependencies": { | ||
"@availity/localstorage-core": "^1.0.0-alpha.0" | ||
"@availity/localstorage-core": "^1.0.0-alpha.1" | ||
}, | ||
"devDependencies": { | ||
"@availity/localstorage-core": "^1.0.0-alpha.0" | ||
"@availity/localstorage-core": "^1.0.0-alpha.1" | ||
}, | ||
@@ -23,0 +23,0 @@ "publishConfig": { |
@@ -27,15 +27,17 @@ # AvApi | ||
##### `config.api` | ||
### Config | ||
#### `config.api` | ||
Default `true`. When `true`, the url is built out by joining `path`, `version`, and `name` or just `url` if no name is defined. The `id` is also added when appropriate. When `api` is `false`, all calls just use `url`. URL pattern: `path/version/name` | ||
##### `config.url` | ||
#### `config.url` | ||
This is used for requests when `config.api` is false or `name` is undefined; | ||
##### `path` | ||
#### `path` | ||
Used for url building when `config.api` is true. URL pattern `path/version/name` | ||
##### `version` | ||
#### `version` | ||
Default `v1`. Used for url building when `config.api` is true. URL pattern `path/version/name` | ||
##### `name` | ||
#### `name` | ||
The name of the resource. Used for url building when `api` is true. (`path/version/name`) | ||
@@ -70,8 +72,6 @@ | ||
### Methods | ||
Each method can use an after function, (ex. `afterGet` with `get`). These are available to modify the response before it is resolved. Each method that has data available has a before function in order to modify data before the call is made. | ||
Each method can use an after function, (ex. `afterGet` with `get`). These are available to modify the response before it is resolved. Each method that has data available has a before function in order to modify data before the call is made. All methods accept a config object, which is merged into the resources config for that call only. | ||
All methods accept a config object, which is merged into the resources config for that call only. | ||
#### create or post | ||
Makes `HTTP POST` request. | ||
Makes HTTP`POST` request. | ||
```javascript | ||
@@ -83,6 +83,4 @@ create(data, config); | ||
#### postGet | ||
Makes `HTTP POST` using `X-HTTP-Method-Override = 'GET'`. There server must support override methods for the request to succeed. | ||
Makes HTTP`POST` using `X-HTTP-Method-Override = `GET`. There server must support override methods for the request to succeed. | ||
@@ -94,3 +92,3 @@ ```javascript | ||
#### get | ||
Retrieves an entity by ID. Makes `HTTP GET` call with `/id` in url. | ||
Retrieves an entity by ID. Makes HTTP`GET` call with `/id` in url. | ||
```javascript | ||
@@ -101,3 +99,3 @@ get(id, config); | ||
#### query | ||
The query function is designed to fetch collections and search the API. Makes `HTTP GET` request with query params. | ||
The query function is designed to fetch collections and search the API. Makes HTTP`GET` request with query params. | ||
@@ -109,3 +107,3 @@ ```javascript | ||
#### update or put | ||
Update an entity with a PUT call. When an id is passed in, `/id` is added to the url. | ||
Update an entity with a `PUT` call. When an id is passed in, `/id` is added to the url. | ||
```javascript | ||
@@ -122,3 +120,3 @@ update(id, data, config); | ||
#### remove or delete | ||
Remove an entity with a DELETE call. When an id is passed in, `/id` is added to the url. If the first parameter is a string or number, it is treated as an ID, otherwise data. | ||
Remove an entity with a `DELETE` call. When an `id` is passed in, `/id` is added to the url. If the first parameter is a string or number, it is treated as an ID, otherwise it is treated as an object. | ||
@@ -125,0 +123,0 @@ ```javascript |
@@ -21,8 +21,2 @@ import AvApi from '../resource'; | ||
afterQuery(response) { | ||
return response && response.data && response.data.organizations | ||
? response.data.organizations | ||
: []; | ||
} | ||
queryOrganizations(user, config) { | ||
@@ -29,0 +23,0 @@ const params = Object.assign({}, { userId: user.id }, config.params || {}); |
@@ -14,7 +14,3 @@ import AvApi from '../resource'; | ||
} | ||
afterQuery(response) { | ||
return response && response.data && response.data.permissions | ||
? response.data.permissions | ||
: []; | ||
} | ||
getPermissions(id, region) { | ||
@@ -21,0 +17,0 @@ return this.query({ |
@@ -15,8 +15,2 @@ import AvApi from '../resource'; | ||
afterQuery(response) { | ||
return response && response.data && response.data.providers | ||
? response.data.providers | ||
: []; | ||
} | ||
getProviders(customerId, config) { | ||
@@ -23,0 +17,0 @@ const params = Object.assign({}, { customerId }, config.params || {}); |
@@ -1,2 +0,2 @@ | ||
# Predefined Availity API's | ||
# Availity API's | ||
@@ -21,3 +21,3 @@ ## Table of Contents | ||
Used to get data about user by id | ||
Get information about current logged-in user. | ||
@@ -27,43 +27,37 @@ #### Methods | ||
##### `me()` | ||
Gets the currently logged in user profile | ||
Helper function that returns information about logged-in user. | ||
### AvRegions | ||
Gets the current users current region as well as all available regions. | ||
Gets the logged-in user's current selected region as well as the regions the user is associated with. | ||
#### Configuration | ||
`AvRegions` requires an `AvUser` object or similar object. | ||
#### Methods | ||
##### `getRegions(config)` | ||
Get regions for currently logged-in user. | ||
Get regions for logged-in user. | ||
##### `getCurrentRegion()` | ||
Returns just the current region for the currently logged-in user. | ||
Returns just the current region for the logged-in user. | ||
### AvPermissions | ||
Get permissions belonging to the current user. | ||
Get permissions belonging to the logged-in user. | ||
### AvUserPermissions | ||
Get permissions and resources of currently logged-in user. | ||
Get permissions as well as resources of the logged-in user. | ||
### AvSpaces | ||
Get data about any of the Space types. | ||
Get metadata for the various content types for the Spaces platform. | ||
### AvOrganizations | ||
Service that allows you to get a user's active organizations. | ||
Service that allows you to get logged=in user's active organizations. | ||
#### Configuration | ||
`AvOrganizations` requires an AvUser object, can use the `AvUser` predefined resource, or any object with a `.me()` promise that returns similar data. | ||
#### Methods | ||
#### `queryOrganizations(user, config)` | ||
Returns organizations belonging to the passed in user. | ||
Returns organizations belonging to the `user`. | ||
##### `getOrganizations(config)` | ||
Returns organizations belonging to the currently logged in User | ||
Returns organizations belonging to the logged-in user. | ||
### AvProviders | ||
Get providers associated to the current user's organization. | ||
Get providers associated to the logged-in user's organization. | ||
@@ -70,0 +64,0 @@ ### AvLogMessage |
@@ -18,8 +18,2 @@ import AvApi from '../resource'; | ||
afterGet(response) { | ||
return response && response.data && response.data.regions | ||
? response.data.regions | ||
: []; | ||
} | ||
afterUpdate(response) { | ||
@@ -26,0 +20,0 @@ this.setPageBust(); |
@@ -31,15 +31,2 @@ import AvOrganizations from '../organizations'; | ||
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', () => { | ||
@@ -46,0 +33,0 @@ api = new AvOrganizations(mockHttp, Promise, mockAvUsers); |
@@ -18,17 +18,4 @@ import AvPermissions from '../permissions'; | ||
test('afterQuery should return response.data.permissions if it exists or an empty array', () => { | ||
test('getPermissions() should query with permissionId and region params from arguments', () => { | ||
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', () => { | ||
api = new AvPermissions(mockHttp, Promise); | ||
api.query = jest.fn(); | ||
@@ -35,0 +22,0 @@ const id = 'testPermissionId'; |
@@ -18,15 +18,2 @@ import AvProviders from '../providers'; | ||
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', () => { | ||
@@ -33,0 +20,0 @@ api = new AvProviders(mockHttp, Promise); |
@@ -25,15 +25,2 @@ import AvRegions from '../regions'; | ||
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', () => { | ||
@@ -40,0 +27,0 @@ api = new AvRegions(mockHttp, Promise, mockAvUsers); |
@@ -18,15 +18,2 @@ import AvUsers from '../user'; | ||
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'", () => { | ||
@@ -33,0 +20,0 @@ api = new AvUsers(mockHttp, Promise); |
@@ -14,5 +14,3 @@ import AvApi from '../resource'; | ||
} | ||
afterGet(response) { | ||
return (response && response.data && response.data.user) || {}; | ||
} | ||
me(config) { | ||
@@ -19,0 +17,0 @@ return this.get('me', config); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61138
1599