autoinspector 2.0.2 → 2.0.3-beta.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/.env ADDED
@@ -0,0 +1,6 @@
1
+ AUTOINSPECTOR_API_BASE_URL=http://localhost:9001/api
2
+ AUTOINSPECTOR_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2MTQ3ODQzYmI5YTcwODAwNTUxODc4YmQiLCJpYXQiOjE2NDAyODI5NjcsImV4cCI6MzMxNjYzMjUzNjd9.Ikc2kIZRja8WBQ3QzWo7ztMAgFk-EFNyifjw_58sg3g
3
+ CI_CAR_TEMPLATE_ID=627157f565b79931f3d1dbac
4
+ CI_MACHINERY_TEMPLATE_ID=6274475b1996d60ec2803218
5
+ CI_PEOPLE_TEMPLATE_ID=6274475b1996d60ec2803218
6
+ CI_MOTO_TEMPLATE_ID=6274475b1996d60ec2803218
@@ -24,10 +24,11 @@ export declare class Inspections extends Products {
24
24
  * Get a specific inspection object.
25
25
  * @param input - An object that contains the essential information for upload the image.
26
26
  * @param {String} input.inspectionId - Represents the id of the inspection that you want to retrieve.
27
+ * @param {String} input.accessToken - Represents an oauth access token.
27
28
  * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
28
29
  * data or an Error with the problem.
29
30
  */
30
- retrieve(inspectionId: string): Promise<IInspection>;
31
+ retrieve(inspectionId: string, accessToken?: string): Promise<IInspection>;
31
32
  update(inspectionId: string, inspection: Partial<Pick<IInspectionCommonParamsV2<IProducer, Partial<IConsumer>>, 'inputs' | 'consumer' | 'metadata'>>): Promise<IAPISucessResponse>;
32
33
  /**
33
34
  * Get a list of n inspections with pagination.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Inspections = void 0;
4
+ const build_oauth_header_1 = require("../utils/build-oauth-header");
4
5
  const Helper_1 = require("./Helper");
5
6
  const Products_1 = require("./Products");
6
7
  /**
@@ -30,13 +31,15 @@ class Inspections extends Products_1.Products {
30
31
  * Get a specific inspection object.
31
32
  * @param input - An object that contains the essential information for upload the image.
32
33
  * @param {String} input.inspectionId - Represents the id of the inspection that you want to retrieve.
34
+ * @param {String} input.accessToken - Represents an oauth access token.
33
35
  * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
34
36
  * data or an Error with the problem.
35
37
  */
36
- retrieve(inspectionId) {
38
+ retrieve(inspectionId, accessToken) {
37
39
  return this.httpClient.makeRequest({
38
40
  method: 'GET',
39
41
  path: `/inspection/${inspectionId}`,
42
+ headers: (0, build_oauth_header_1.buildOAuthHeader)(accessToken),
40
43
  });
41
44
  }
42
45
  update(inspectionId, inspection) {
@@ -0,0 +1,3 @@
1
+ export declare const buildOAuthHeader: (accessToken?: string | undefined) => {
2
+ Authorization?: string | undefined;
3
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildOAuthHeader = void 0;
4
+ const buildOAuthHeader = (accessToken) => {
5
+ return Object.assign({}, (!!accessToken
6
+ ? {
7
+ Authorization: `Bearer ${accessToken}`,
8
+ }
9
+ : {}));
10
+ };
11
+ exports.buildOAuthHeader = buildOAuthHeader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autoinspector",
3
- "version": "2.0.2",
3
+ "version": "2.0.3-beta.1",
4
4
  "description": "Autoinspector API wrapper",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,9 @@
1
+ export const buildOAuthHeader = (accessToken?: string) => {
2
+ return {
3
+ ...(!!accessToken
4
+ ? {
5
+ Authorization: `Bearer ${accessToken}`,
6
+ }
7
+ : {}),
8
+ };
9
+ };