Socket
Socket
Sign inDemoInstall

@availity/api-core

Package Overview
Dependencies
Maintainers
12
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@availity/api-core - npm Package Compare versions

Comparing version 5.4.0 to 5.4.1

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [5.4.1](https://github.com/Availity/sdk-js/compare/@availity/api-core@5.4.0...@availity/api-core@5.4.1) (2019-09-27)
**Note:** Version bump only for package @availity/api-core
# [5.4.0](https://github.com/Availity/sdk-js/compare/@availity/api-core@5.2.1...@availity/api-core@5.4.0) (2019-08-01)

@@ -8,0 +16,0 @@

4

package.json
{
"name": "@availity/api-core",
"version": "5.4.0",
"version": "5.4.1",
"description": "Base API definitions for the Availity REST API",

@@ -29,3 +29,3 @@ "keywords": [

},
"gitHead": "d438228fc9ac6420cbded4c1a494f19b79954199"
"gitHead": "861ec87ed21a02680c7bf4ff616a2bb3e8dea906"
}

@@ -6,134 +6,2 @@ # api-core

## AvApi
`AvApi` is a class that wraps a provided http service with helper functions.
### Features
* Automatic polling of restful endpoints with timeouts
* Simple URI builder for API resources
* Life-cycle hooks into HTTP calls for GET, PUT, POST, and DELETE
## Usage
```js
import AvApi from '@availity/api-core';
new AvApi(http, promise, options);
```
### Options
#### `http`
Either Angular's `$http` service or Axios (or compatible lib).
#### `promise`
Either Angular `$q` or equivalent `Promise` object.
#### `config`
Either Angular `$http` or `axios` config object
### 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`
This is used for requests when `config.api` is false or `name` is undefined;
##### `config.path`
Used for url building when `config.api` is true. URL pattern `path/version/name`
##### `config.version`
Default `v1`. Used for url building when `config.api` is true. URL pattern `path/version/name`
##### `config.name`
The name of the resource. Used for url building when `api` is true. (`path/version/name`)
##### `config.cacheBust`
Disable caching for every request by adding a `cacheBust` parameter to the call.
Accepts a boolean, function, or some value:
- If `true`, a timestamp is generated and used
- If a function, it is called and return value is used
- If a value is passed then the cache bust param is set to this value.
##### `config.pageBust`
Bust the browser cache on page load, and keep its value for lifecycle of the page. Same behavior as `cacheBust` except if true, a value is only generated once and re-used. A hard refresh of page resets the `pageBust` value. To manually set the `pageBust` value call without changing the config, use `setPageBust(value)` which will set the it to `value` or if undefined generate a timestamp.
##### `config.sessionBust`
Default `true`. Attempts to read a value in local storage that is generated at login. This forces the browser to bust the cache when a new session has started. If the local storage value is not found, uses the `pageBust` value.
##### `config.polling`
Default `true`. If true and rest services return `202` statuc code, `AvApi` will attempt to poll on predefined internvals until the retries are exhausted or the api returns non `202` response.
##### `config.pollingIntervals`
An array of intervals (ms) to wait before making another request.
Default is 1, 2, 5, then 10 seconds. After all the intervals have been used, `AvApi` will stop attempting requests and return the last response.
##### `config.getHeader`
Used for polling, if the `http` service used has special logic to get a header value, then define this function to handle that logic. If defined, it is called with `(response, headerKey)`.
If not defined, attempts to get `key` from `response.headers[key]`.
### 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.
All methods accept a config object, which is merged into the resources config for that call only.
#### create or post
Makes `HTTP POST` request.
```js
create(data, config);
// or
post(data, config);
```
#### postGet
Makes `HTTP POST` using `X-HTTP-Method-Override = 'GET'`. There server must support override methods for the request to succeed.
```js
postGet(data, config);
```
#### get
Retrieves an entity by ID. Makes `HTTP GET` call with `/id` in url.
```js
get(id, config);
```
#### query
The query function is designed to fetch collections and search the API. Makes `HTTP GET` request with query params.
```js
query(config);
```
#### update or put
Update an entity with a PUT call. When an id is passed in, `/id` is added to the url.
```js
update(id, data, config);
// or wihthout id
update(data, config);
// or
put(id, data, config);
// or or without it
put(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.
```js
remove(id, config);
// or without id
remove(data, config);
// or
delete(data, config);
// or without id
delete(config);
```
## AvMicroservice
`AvMicroservice` extends `AvApi` and thus can call the same methods. It has slightly different `config` options used for some child apis.
## [Documentation](https://availity.github.io/sdk-js/api/getting-started)

@@ -27,3 +27,3 @@ import AvLocalStorage from '@availity/localstorage-core';

addParams(params = {}, config = {}, newObj = true) {
const output = newObj ? Object.assign({ params: {} }, config) : config;
const output = newObj ? { params: {}, ...config } : config;

@@ -34,3 +34,3 @@ if (!newObj) {

output.params = Object.assign({}, output.params, params);
output.params = { ...output.params, ...params };
return output;

@@ -37,0 +37,0 @@ }

@@ -5,8 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
name: 'codes',
},
config
);
const options = {
name: 'codes',
...config,
};
super({

@@ -13,0 +12,0 @@ http,

@@ -5,9 +5,8 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: '/api/sdk/platform',
name: '/disclaimers',
},
config
);
const options = {
path: '/api/sdk/platform',
name: '/disclaimers',
...config,
};
super({

@@ -14,0 +13,0 @@ http,

@@ -5,10 +5,8 @@ import AvMicroservice from '../ms';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: '/ms/api/availity/internal/dma/log-message-service/portal',
name: 'log-messages',
version: '/v2',
},
config
);
const options = {
path: '/ms/api/availity/internal/dma/log-message-service/portal',
name: 'log-messages',
version: '/v2',
...config,
};
super({

@@ -15,0 +13,0 @@ http,

@@ -5,11 +5,9 @@ import AvMicroservice from '../ms';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
name: 'core/vault/upload/v1',
headers: {
'Content-Type': undefined,
},
const options = {
name: 'core/vault/upload/v1',
headers: {
'Content-Type': undefined,
},
config
);
...config,
};
super({

@@ -16,0 +14,0 @@ http,

@@ -5,13 +5,11 @@ import AvMicroservice from '../ms';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
name: 'platform/file-upload-delivery/v1/batch/deliveries',
headers: {
'Content-Type': 'application/json',
},
polling: true,
pollingMethod: 'GET',
const options = {
name: 'platform/file-upload-delivery/v1/batch/deliveries',
headers: {
'Content-Type': 'application/json',
},
config
);
polling: true,
pollingMethod: 'GET',
...config,
};
super({

@@ -18,0 +16,0 @@ http,

@@ -5,8 +5,6 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
name: 'log-messages',
},
config
);
const options = {
name: 'log-messages',
...config,
};
super({

@@ -13,0 +11,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/sdk/platform',
name: 'navigation/spaces',
},
config
);
const options = {
path: 'api/sdk/platform',
name: 'navigation/spaces',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api',
name: 'notifications',
},
config
);
const options = {
path: 'api',
name: 'notifications',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, avUsers, config }) {
const options = Object.assign(
{
path: 'api/sdk/platform',
name: 'organizations',
},
config
);
const options = {
path: 'api/sdk/platform',
name: 'organizations',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/utils',
name: 'pdfs',
},
config
);
const options = {
path: 'api/utils',
name: 'pdfs',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/sdk/platform',
name: 'permissions',
},
config
);
const options = {
path: 'api/sdk/platform',
name: 'permissions',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/internal',
name: 'providers',
},
config
);
const options = {
path: 'api/internal',
name: 'providers',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -8,9 +8,7 @@ import AvApi from '../api';

}
const options = Object.assign(
{
path: `api/v1/proxy/${config.tenant}`,
version: '',
},
config
);
const options = {
path: `api/v1/proxy/${config.tenant}`,
version: '',
...config,
};
super({

@@ -17,0 +15,0 @@ http,

@@ -5,11 +5,9 @@ import AvApi from '../api';

constructor({ http, promise, merge, avUsers, config }) {
const options = Object.assign(
{
path: 'api/sdk/platform',
name: 'regions',
sessionBust: false,
pageBust: true,
},
config
);
const options = {
path: 'api/sdk/platform',
name: 'regions',
sessionBust: false,
pageBust: true,
...config,
};
super({

@@ -16,0 +14,0 @@ http,

@@ -5,11 +5,9 @@ import AvApi from '../api';

constructor({ http, promise, merge, avUsers, config }) {
const options = Object.assign(
{
path: 'api/utils',
name: 'settings',
sessionBust: false,
pageBust: true,
},
config
);
const options = {
path: 'api/utils',
name: 'settings',
sessionBust: false,
pageBust: true,
...config,
};
super({

@@ -16,0 +14,0 @@ http,

@@ -5,8 +5,6 @@ import AvMicroservice from '../ms';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
name: 'spc/slotmachine/graphql',
},
config
);
const options = {
name: 'spc/slotmachine/graphql',
...config,
};
super({

@@ -13,0 +11,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/sdk/platform',
name: 'spaces',
},
config
);
const options = {
path: 'api/sdk/platform',
name: 'spaces',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -5,9 +5,7 @@ import AvApi from '../api';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/sdk/platform',
name: 'users',
},
config
);
const options = {
path: 'api/sdk/platform',
name: 'users',
...config,
};
super({

@@ -14,0 +12,0 @@ http,

@@ -6,11 +6,9 @@ import qs from 'qs';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
path: 'api/internal',
name: 'axi-user-permissions',
paramsSerializer: params =>
qs.stringify(params, { arrayFormat: 'repeat' }),
},
config
);
const options = {
path: 'api/internal',
name: 'axi-user-permissions',
paramsSerializer: params =>
qs.stringify(params, { arrayFormat: 'repeat' }),
...config,
};
super({

@@ -17,0 +15,0 @@ http,

@@ -5,8 +5,6 @@ import AvMicroservice from '../ms';

constructor({ http, promise, merge, config }) {
const options = Object.assign(
{
name: 'spc/web/graphql',
},
config
);
const options = {
name: 'spc/web/graphql',
...config,
};
super({

@@ -13,0 +11,0 @@ http,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc