@redhat-cloud-services/notifications-client 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +21 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [3.1.1](https://github.com/RedHatInsights/javascript-clients/compare/@redhat-cloud-services/notifications-client-3.1.0...@redhat-cloud-services/notifications-client-3.1.1) (2024-12-09)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `@redhat-cloud-services/javascript-clients-shared` updated to version `1.2.7`
|
|
5
10
|
## [3.1.0](https://github.com/RedHatInsights/javascript-clients/compare/@redhat-cloud-services/notifications-client-3.0.1...@redhat-cloud-services/notifications-client-3.1.0) (2024-11-19)
|
|
6
11
|
|
|
7
12
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Javascript client for
|
|
2
|
-
If you want to use [RedHatInsights/notifications
|
|
1
|
+
# Javascript client for the notifications API
|
|
2
|
+
If you want to use [RedHatInsights/notifications](https://github.com/RedHatInsights/notifications) you shouldn't use get requests directly, but rather use this client to integrate with this service.
|
|
3
3
|
|
|
4
4
|
## Install
|
|
5
5
|
NPM
|
|
@@ -15,25 +15,29 @@ yarn add @redhat-cloud-services/notifications-client
|
|
|
15
15
|
### Usage
|
|
16
16
|
This client is using typescript and axios. Types are distributed with this package, so no need to define or install them separately.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
This package comes with a client in its `api.ts` already defined with every call available.
|
|
19
19
|
```JS
|
|
20
|
-
|
|
21
|
-
import APIFactory from '@redhat-cloud-services/notifications-client/utils';
|
|
22
|
-
import createBehaviorGroup from '@redhat-cloud-services/notifications-client/NotificationResourceV1CreateBehaviorGroup';
|
|
23
|
-
import updateBehaviorGroup from '@redhat-cloud-services/notifications-client/NotificationResourceV1UpdateBehaviorGroup';
|
|
24
|
-
import deleteBehaviorGroup from '@redhat-cloud-services/notifications-client/NotificationResourceV1DeleteBehaviorGroup';
|
|
20
|
+
`import notificationsClient from '@redhat-cloud-services/javascript-clients-shared/utils';
|
|
25
21
|
|
|
22
|
+
notificationsClient.someEndpoint();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To bootstrap this API manually, you should create your own client via the `APIFactory` defined in the `@redhat-cloud-services/javascript-clients-shared` package. See below for an example:
|
|
26
|
+
```JS
|
|
27
|
+
import APIFactory from '@redhat-cloud-services/javascript-clients-shared/utils';
|
|
28
|
+
import exampleEndpoint from '@redhat-cloud-services/notifications-client/ExampleEndpoint';
|
|
26
29
|
|
|
27
30
|
// BASE_PATH should be set in your constants file
|
|
28
|
-
const notificationsApi = APIFactory(BASE_PATH, undefined, {
|
|
31
|
+
const notificationsApi = APIFactory(BASE_PATH, undefined, { exampleEndpoint });
|
|
29
32
|
export notificationsApi;
|
|
30
33
|
```
|
|
31
34
|
|
|
32
35
|
If you want to add some interceptors you can use axios build in interceptors
|
|
33
36
|
```JS
|
|
34
|
-
// api.js
|
|
35
37
|
import axios from 'axios';
|
|
36
|
-
import
|
|
38
|
+
import APIFactory from '@redhat-cloud-services/javascript-clients-shared/utils';
|
|
39
|
+
import exampleEndpoint from '@redhat-cloud-services/notifications-client/ExampleEndpoint';
|
|
40
|
+
|
|
37
41
|
const instance = axios.create();
|
|
38
42
|
|
|
39
43
|
// Request interceptor
|
|
@@ -52,17 +56,20 @@ instance.interceptors.response.use(null, (error) => {
|
|
|
52
56
|
});
|
|
53
57
|
|
|
54
58
|
// BASE_PATH should be set in your constants file
|
|
55
|
-
const notificationsApi = APIFactory(BASE_PATH, instance, {
|
|
59
|
+
const notificationsApi = APIFactory(BASE_PATH, instance, { exampleEndpoint });
|
|
56
60
|
export notificationsApi;
|
|
57
61
|
```
|
|
62
|
+
## Generating
|
|
63
|
+
|
|
64
|
+
Ensure you have the javascript-clients generator built first with `npm run build:generator`. Then, run `nx run @redhat-cloud-services/notifications-client:generate` to generate the package.
|
|
58
65
|
|
|
59
66
|
## Building
|
|
60
67
|
|
|
61
|
-
Run `nx
|
|
68
|
+
Run `nx run @redhat-cloud-services/notifications-client:build` to build the package. This creates the `dist` for publishing.
|
|
62
69
|
|
|
63
70
|
## Running unit tests
|
|
64
71
|
|
|
65
|
-
Run `nx
|
|
72
|
+
Run `nx run @redhat-cloud-services/notifications-client:test` to execute the unit tests via [Jest](https://jestjs.io).
|
|
66
73
|
|
|
67
74
|
## API documentation
|
|
68
75
|
|