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