UNPKG

2.71 kBMarkdownView Raw
1# api-angular
2
3> A package wrapping [@av/api-core](../api-core/README.md) with Angular `$http`.
4
5[![Version](https://img.shields.io/npm/v/@availity/api-angular.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/api-angular)
6
7## Install
8
9`npm install @availity/api-angular @availity/api-core @availity/localstorage-core --save`
10
11## Usage
12
13```javascript
14import availityApi from '@availity/api-angular';
15angular.module('app', [availityApi]);
16```
17
18Inject one of the predefined API classes in a controller or service:
19
20```javascript
21app.service('myCustomService', avUsersApi => {
22 return avUsersApi.me();
23});
24```
25
26## API Definitions
27
28> The services below can be injected into other services or controllers
29
30- `avApiOptions`
31- `AvMicroserviceApi`
32- `avLogMessagesApi`
33- `AvProxyApi`
34- `avWebQLApi`
35- `avPdfApi`
36- `avNavigationApi`
37- `avNotificationApi`
38- `avOrganizationsApi`
39- `avPermissionsApi`
40- `avProvidersApi`
41- `avRegionsApi`
42- `avSpacesApi`
43- `avUsersApi`
44- `avUserPermissionsApi`
45- `avFilesApi`
46- `avFilesDeliverApi`
47- `avSettingsApi`
48- `avCodesApi`
49
50Details about each api can be found [here](../api-core/src/resources/README.md)
51
52```js
53app.service(
54 'myCustomService',
55 (
56 avPdfApi,
57 avNavigationApi,
58 avNotificationApi,
59 avOrganizationsApi,
60 avPermissionsApi,
61 avProvidersApi,
62 AvProxyApi,
63 avRegionsApi,
64 avSpacesApi,
65 avUsersApi,
66 avUserPermissionsApi
67 ) => {
68 // code
69 }
70);
71```
72
73## Options
74
75Configure the default options:
76
77```javascript
78config(avApiOptionsProvider => {
79 avApiOptionsProvider.setOptions({
80 version: 'v2',
81 });
82});
83```
84
85## Create API Definitions
86
87Create API definitions by extending `AvApi`. Extending `AvApi` provides services the behaviors described in [@api-core/README#features](../api-core/README.md#features)
88
89```js
90function factory(AvApi) {
91 class AvExampleResource extends AvApi {
92 constructor() {
93 super({
94 name: 'exampleApi',
95 });
96 }
97 }
98 return new AvExampleResource();
99}
100```
101
102## Create Proxy API Definitions
103
104Create proxy API definitions by extending `AvApiProxy`. Extending `AvApiProxy` provides services the behaviors described in [@api-core/README#features](../api-core/README.md#features) as well as building the url to match your tenant's proxy REST conventions.
105
106```js
107function factory(AvApiProxy) {
108 class AvExampleResource extends AvApiProxy {
109 constructor() {
110 super({
111 tenant: 'myhealthplan',
112 name: 'patients',
113 });
114 }
115 }
116 return new AvExampleResource();
117}
118```