autoinspector 1.1.1 → 2.0.0-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.
Files changed (79) hide show
  1. package/.env +6 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +4 -0
  4. package/dist/package.json +57 -0
  5. package/dist/resources/Autoinspector.d.ts +22 -0
  6. package/dist/resources/Autoinspector.js +43 -0
  7. package/dist/resources/Car.d.ts +10 -0
  8. package/dist/resources/Car.js +41 -0
  9. package/dist/resources/Custom.d.ts +8 -0
  10. package/dist/resources/Custom.js +30 -0
  11. package/dist/resources/Goods.d.ts +24 -0
  12. package/dist/resources/Goods.js +43 -0
  13. package/dist/resources/HTTPClient.d.ts +32 -0
  14. package/dist/resources/HTTPClient.js +87 -0
  15. package/dist/resources/Helper.d.ts +18 -0
  16. package/dist/resources/Helper.js +84 -0
  17. package/dist/resources/Image.d.ts +21 -0
  18. package/dist/resources/Image.js +56 -0
  19. package/dist/resources/Inspections.d.ts +41 -0
  20. package/dist/resources/Inspections.js +69 -0
  21. package/dist/resources/Machinery.d.ts +28 -0
  22. package/dist/resources/Machinery.js +43 -0
  23. package/dist/resources/Memberships.d.ts +14 -0
  24. package/dist/resources/Memberships.js +24 -0
  25. package/dist/resources/Moto.d.ts +10 -0
  26. package/dist/resources/Moto.js +41 -0
  27. package/dist/resources/OAuth.d.ts +37 -0
  28. package/dist/resources/OAuth.js +52 -0
  29. package/dist/resources/People.d.ts +22 -0
  30. package/dist/resources/People.js +32 -0
  31. package/dist/resources/Products.d.ts +16 -0
  32. package/dist/resources/Products.js +20 -0
  33. package/dist/resources/Template.d.ts +8 -0
  34. package/dist/resources/Template.js +35 -0
  35. package/dist/resources/User.d.ts +35 -0
  36. package/dist/resources/User.js +47 -0
  37. package/dist/types/api.d.ts +12 -0
  38. package/dist/types/api.js +2 -0
  39. package/dist/types/authenticatedUser.d.ts +65 -0
  40. package/dist/types/authenticatedUser.js +2 -0
  41. package/dist/types/autoinspector.d.ts +15 -0
  42. package/dist/types/autoinspector.js +2 -0
  43. package/dist/types/car.d.ts +42 -0
  44. package/dist/types/car.js +2 -0
  45. package/dist/types/colors.d.ts +1 -0
  46. package/dist/types/colors.js +2 -0
  47. package/dist/types/configuration.d.ts +27 -0
  48. package/dist/types/configuration.js +2 -0
  49. package/dist/types/consumer.d.ts +14 -0
  50. package/dist/types/consumer.js +2 -0
  51. package/dist/types/goods.d.ts +51 -0
  52. package/dist/types/goods.js +2 -0
  53. package/dist/types/helper.d.ts +5 -0
  54. package/dist/types/helper.js +2 -0
  55. package/dist/types/http.d.ts +22 -0
  56. package/dist/types/http.js +2 -0
  57. package/dist/types/image.d.ts +15 -0
  58. package/dist/types/image.js +2 -0
  59. package/dist/types/inspection.d.ts +122 -0
  60. package/dist/types/inspection.js +2 -0
  61. package/dist/types/machinery.d.ts +64 -0
  62. package/dist/types/machinery.js +2 -0
  63. package/dist/types/moto.d.ts +10 -0
  64. package/dist/types/moto.js +2 -0
  65. package/dist/types/oauth20.d.ts +19 -0
  66. package/dist/types/oauth20.js +2 -0
  67. package/dist/types/pagination.d.ts +21 -0
  68. package/dist/types/pagination.js +2 -0
  69. package/dist/types/people.d.ts +45 -0
  70. package/dist/types/people.js +2 -0
  71. package/dist/types/producer.d.ts +4 -0
  72. package/dist/types/producer.js +2 -0
  73. package/dist/types/productMethods.d.ts +4 -0
  74. package/dist/types/productMethods.js +2 -0
  75. package/dist/types/template.d.ts +58 -0
  76. package/dist/types/template.js +2 -0
  77. package/dist/types/vehicle.d.ts +116 -0
  78. package/dist/types/vehicle.js +2 -0
  79. package/package.json +4 -5
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Inspections = void 0;
4
+ const Helper_1 = require("./Helper");
5
+ const Products_1 = require("./Products");
6
+ /**
7
+ * @classdesc Represents the class that contains the methods or actions that somebody can do using apikey and access_token.
8
+ * @class
9
+ */
10
+ class Inspections extends Products_1.Products {
11
+ constructor(httpClient) {
12
+ super(httpClient);
13
+ this.httpClient = httpClient;
14
+ }
15
+ /**
16
+ * Finish the inspection to indicate that it will not receive more photos/images.
17
+ * @param input - An object that contains the essential information for upload the image.
18
+ * @param {String} input.inspectionId - Represents the id of the inspection.
19
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
20
+ * data or an Error with the problem.
21
+ */
22
+ finish(input) {
23
+ return this.httpClient.makeRequest({
24
+ method: 'POST',
25
+ path: `/inspection/finish/${input.inspectionId}`,
26
+ body: {},
27
+ });
28
+ }
29
+ update(input) {
30
+ const { form } = Helper_1.Helper.buildFormData(input);
31
+ return this.httpClient.makeRequest({
32
+ method: 'PUT',
33
+ path: `/inspection/${input.inspectionId}`,
34
+ body: form,
35
+ headers: form.getHeaders(),
36
+ });
37
+ }
38
+ /**
39
+ * Get a specific inspection object.
40
+ * @param input - An object that contains the essential information for upload the image.
41
+ * @param {String} input.inspectionId - Represents the id of the inspection that you want to retrieve.
42
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
43
+ * data or an Error with the problem.
44
+ */
45
+ retrieve(input) {
46
+ return this.httpClient.makeRequest({
47
+ method: 'GET',
48
+ path: `/inspection/${input.inspectionId}`,
49
+ });
50
+ }
51
+ /**
52
+ * Get a list of n inspections with pagination.
53
+ * @param input - An object that contains filters for list the inspections.
54
+ * @param {Number} input.page - Represents the specific page that you want to retrieve the inspections.
55
+ * @param {Number} input.limit - Represents the limit of the quantity of records that you want to retrieve for page.
56
+ * @param {String} input.status - Represents the status that inspections retrieved should have.
57
+ * @param {String} input.type - Represents the type of the inspection.
58
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
59
+ * data or an Error with the problem.
60
+ */
61
+ list(input = {}) {
62
+ return this.httpClient.makeRequest({
63
+ method: 'GET',
64
+ path: `/inspection`,
65
+ params: input,
66
+ });
67
+ }
68
+ }
69
+ exports.Inspections = Inspections;
@@ -0,0 +1,28 @@
1
+ import { IUpdateResourceResponse } from '../types/api';
2
+ import { ICreateInspectionOutput } from '../types/inspection';
3
+ import { ICreateMachineryInspection, IUpdateMachineryInspection } from '../types/machinery';
4
+ import { IProductMethods } from '../types/productMethods';
5
+ import { HTTPClient } from './HTTPClient';
6
+ /**
7
+ * @classdesc Represents the class that handle all the requests related to an inspection of type machinery.
8
+ * @class
9
+ */
10
+ export declare class Machinery implements IProductMethods {
11
+ private readonly httpClient;
12
+ constructor(httpClient: HTTPClient);
13
+ /**
14
+ * Create an inspection of type machinery
15
+ * @param input - An object that contains the essential information for create an inspection.
16
+ * @param {Object} input.consumer - Represents the consumer who will do the inspection.
17
+ * @param {Object} input.machinery - Represents the machinery to be attached to the inspection.
18
+ * @param {String} input.mode - Represents the mode of the inspection. See more details: {@link https://www.autoinspector.com.ar/docs/api/start#inspection_mode}
19
+ * @param {Object} input.producer - Represents the entity that has the ownership of the inspection to be created.
20
+ * @param {String} input.kindOf - Represents the template that inspection will have. This only matters if the input.mode is normal.
21
+ * @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
22
+ * @param {Object} input.access_token - Represents the token that belongs to some user into Autoinspector and was generated thanks to OAuth 2.0. When pass this argument, the apikey will not being send.
23
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
24
+ * data or an Error with the problem.
25
+ */
26
+ create(input: ICreateMachineryInspection): Promise<ICreateInspectionOutput>;
27
+ update(input: Pick<IUpdateMachineryInspection, 'machinery' | 'productId'>): Promise<IUpdateResourceResponse>;
28
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Machinery = void 0;
4
+ const Helper_1 = require("./Helper");
5
+ /**
6
+ * @classdesc Represents the class that handle all the requests related to an inspection of type machinery.
7
+ * @class
8
+ */
9
+ class Machinery {
10
+ constructor(httpClient) {
11
+ this.httpClient = httpClient;
12
+ }
13
+ /**
14
+ * Create an inspection of type machinery
15
+ * @param input - An object that contains the essential information for create an inspection.
16
+ * @param {Object} input.consumer - Represents the consumer who will do the inspection.
17
+ * @param {Object} input.machinery - Represents the machinery to be attached to the inspection.
18
+ * @param {String} input.mode - Represents the mode of the inspection. See more details: {@link https://www.autoinspector.com.ar/docs/api/start#inspection_mode}
19
+ * @param {Object} input.producer - Represents the entity that has the ownership of the inspection to be created.
20
+ * @param {String} input.kindOf - Represents the template that inspection will have. This only matters if the input.mode is normal.
21
+ * @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
22
+ * @param {Object} input.access_token - Represents the token that belongs to some user into Autoinspector and was generated thanks to OAuth 2.0. When pass this argument, the apikey will not being send.
23
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
24
+ * data or an Error with the problem.
25
+ */
26
+ create(input) {
27
+ const { form } = Helper_1.Helper.buildFormData(input);
28
+ return this.httpClient.makeRequest({
29
+ method: 'POST',
30
+ path: `/inspection/machinery`,
31
+ body: form,
32
+ headers: Object.assign(Object.assign({}, Helper_1.Helper.buildOptionalHeaders(input === null || input === void 0 ? void 0 : input.access_token)), form.getHeaders()),
33
+ });
34
+ }
35
+ update(input) {
36
+ return this.httpClient.makeRequest({
37
+ method: 'PUT',
38
+ path: `/inspection/machinery/${input.productId}`,
39
+ body: input.machinery,
40
+ });
41
+ }
42
+ }
43
+ exports.Machinery = Machinery;
@@ -0,0 +1,14 @@
1
+ import { IListMemberships, IListMembershipsOutput } from '../types/authenticatedUser';
2
+ import { HTTPClient } from './HTTPClient';
3
+ export declare class Memberships {
4
+ private readonly httpClient;
5
+ constructor(httpClient: HTTPClient);
6
+ /**
7
+ * List all the memberships accepted by the user authenticated related with companies.
8
+ * @param input - An object that contains the information for make the request.
9
+ * @param {String} input.access_token - Represents the token that belongs to the authenticated user.
10
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
11
+ * data or an Error with the problem.
12
+ */
13
+ list(input: IListMemberships): Promise<IListMembershipsOutput>;
14
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Memberships = void 0;
4
+ const Helper_1 = require("./Helper");
5
+ class Memberships {
6
+ constructor(httpClient) {
7
+ this.httpClient = httpClient;
8
+ }
9
+ /**
10
+ * List all the memberships accepted by the user authenticated related with companies.
11
+ * @param input - An object that contains the information for make the request.
12
+ * @param {String} input.access_token - Represents the token that belongs to the authenticated user.
13
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
14
+ * data or an Error with the problem.
15
+ */
16
+ list(input) {
17
+ return this.httpClient.makeRequest({
18
+ method: 'GET',
19
+ path: `/account/membership/authenticated`,
20
+ headers: Helper_1.Helper.buildOptionalHeaders(input.access_token),
21
+ });
22
+ }
23
+ }
24
+ exports.Memberships = Memberships;
@@ -0,0 +1,10 @@
1
+ import { IUpdateResourceResponse } from '../types/api';
2
+ import { ICreateInspectionOutput } from '../types/inspection';
3
+ import { ICreateMotoInspection, IUpdateMotoInspection } from '../types/moto';
4
+ import { HTTPClient } from './HTTPClient';
5
+ export declare class Moto {
6
+ private readonly httpClient;
7
+ constructor(httpClient: HTTPClient);
8
+ create(input: ICreateMotoInspection): Promise<ICreateInspectionOutput>;
9
+ update(input: Pick<IUpdateMotoInspection, 'moto' | 'productId'>): Promise<IUpdateResourceResponse>;
10
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Moto = void 0;
13
+ const Helper_1 = require("./Helper");
14
+ class Moto {
15
+ constructor(httpClient) {
16
+ this.httpClient = httpClient;
17
+ }
18
+ create(input) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const { form } = Helper_1.Helper.buildFormData(input);
21
+ return yield this.httpClient.makeRequest({
22
+ method: 'POST',
23
+ path: `/inspection/moto`,
24
+ body: form,
25
+ headers: form.getHeaders(),
26
+ });
27
+ });
28
+ }
29
+ update(input) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return yield this.httpClient.makeRequest({
32
+ method: 'PUT',
33
+ path: `/inspection/moto/${input.productId}`,
34
+ body: {
35
+ moto: input.moto,
36
+ },
37
+ });
38
+ });
39
+ }
40
+ }
41
+ exports.Moto = Moto;
@@ -0,0 +1,37 @@
1
+ import { IExchangeCodeForAccessTokenOutput, IOAuth20Credentials, IRefreshAccessTokenOutput } from '../types/oauth20';
2
+ import { HTTPClient } from './HTTPClient';
3
+ import { User } from './User';
4
+ /**
5
+ * @classdesc Represents the class that has the responsability for make the request to every endpoint about oauth.
6
+ * @class
7
+ */
8
+ export declare class OAuth {
9
+ private readonly httpClient;
10
+ private credentials;
11
+ user: User;
12
+ /**
13
+ * Create OAuth20 instance to implement and execute methods in another class.
14
+ * @constructor
15
+ * @param httpClient - The httpClient that needs to be injected in the constructor. This is done by this way for inherit the http configuration from the Autoinspector constructor.
16
+ * @param credentials - An object with the neccessary credentials for interact with oauth endpoints.
17
+ * @param {String} credentials.client_app_id - Represents the identification value that is generated when register an application into Autoinspector Dashboard.
18
+ * @param {String} credentials.client_secret - Represents the token that is generated when register an application in Autoinspector Dashboard. It's an sensitive key. so it will only be exported/used in back channel.
19
+ */
20
+ constructor(httpClient: HTTPClient, credentials: Partial<IOAuth20Credentials>);
21
+ /**
22
+ * Exchange some authorization code for a valid access_token.
23
+ * @param input - An object that contains the essential information for make the trade.
24
+ * @param {String} input.code - Represents the code received from Autoinspector in callbackURL.
25
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
26
+ * data or an Error with the problem.
27
+ */
28
+ exchangeCodeForAccessToken(code: string): Promise<IExchangeCodeForAccessTokenOutput>;
29
+ /**
30
+ * Refresh some access_token for obtain a new one. This is useful for keep a long-term access_token.
31
+ * @param input - An object that contains the essential information refresh the token.
32
+ * @param {String} input.refresh_token - Represents the refresh token received when exchanged the code for an access_token.
33
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
34
+ * data or an Error with the problem.
35
+ */
36
+ refreshAccessToken(refreshToken: string): Promise<IRefreshAccessTokenOutput>;
37
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OAuth = void 0;
4
+ const User_1 = require("./User");
5
+ /**
6
+ * @classdesc Represents the class that has the responsability for make the request to every endpoint about oauth.
7
+ * @class
8
+ */
9
+ class OAuth {
10
+ /**
11
+ * Create OAuth20 instance to implement and execute methods in another class.
12
+ * @constructor
13
+ * @param httpClient - The httpClient that needs to be injected in the constructor. This is done by this way for inherit the http configuration from the Autoinspector constructor.
14
+ * @param credentials - An object with the neccessary credentials for interact with oauth endpoints.
15
+ * @param {String} credentials.client_app_id - Represents the identification value that is generated when register an application into Autoinspector Dashboard.
16
+ * @param {String} credentials.client_secret - Represents the token that is generated when register an application in Autoinspector Dashboard. It's an sensitive key. so it will only be exported/used in back channel.
17
+ */
18
+ constructor(httpClient, credentials) {
19
+ this.httpClient = httpClient;
20
+ this.credentials = credentials;
21
+ this.user = new User_1.User(httpClient);
22
+ }
23
+ /**
24
+ * Exchange some authorization code for a valid access_token.
25
+ * @param input - An object that contains the essential information for make the trade.
26
+ * @param {String} input.code - Represents the code received from Autoinspector in callbackURL.
27
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
28
+ * data or an Error with the problem.
29
+ */
30
+ exchangeCodeForAccessToken(code) {
31
+ return this.httpClient.makeRequest({
32
+ method: 'POST',
33
+ path: '/account/oauth/exchange_code',
34
+ body: Object.assign({ code }, this.credentials),
35
+ });
36
+ }
37
+ /**
38
+ * Refresh some access_token for obtain a new one. This is useful for keep a long-term access_token.
39
+ * @param input - An object that contains the essential information refresh the token.
40
+ * @param {String} input.refresh_token - Represents the refresh token received when exchanged the code for an access_token.
41
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
42
+ * data or an Error with the problem.
43
+ */
44
+ refreshAccessToken(refreshToken) {
45
+ return this.httpClient.makeRequest({
46
+ method: 'POST',
47
+ path: '/account/oauth/refresh_token',
48
+ body: Object.assign({ refresh_token: refreshToken }, this.credentials),
49
+ });
50
+ }
51
+ }
52
+ exports.OAuth = OAuth;
@@ -0,0 +1,22 @@
1
+ import { ICreateInspectionOutput } from '../types/inspection';
2
+ import { ICreatePeopleInspection } from '../types/people';
3
+ import { IProductMethods } from '../types/productMethods';
4
+ import { HTTPClient } from './HTTPClient';
5
+ export declare class People implements IProductMethods {
6
+ private readonly httpClient;
7
+ constructor(httpClient: HTTPClient);
8
+ /**
9
+ * Create an inspection of type people
10
+ * @param input - An object that contains the essential information for create an inspection.
11
+ * @param {Object} input.consumer - Represents the consumer who will do the inspection.
12
+ * @param {Object} input.people - Represents the people to be attached to the inspection.
13
+ * @param {String} input.mode - Represents the mode of the inspection. See more details: {@link https://www.autoinspector.com.ar/docs/api/start#inspection_mode}
14
+ * @param {String} input.kindOf - Represents the template that inspection will have. This only matters if the input.mode is normal.
15
+ * @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
16
+ * @param {Object} input.access_token - Represents the token that belongs to some user into Autoinspector and was generated thanks to OAuth 2.0. When pass this argument, the apikey will not being send.
17
+ * @param {Object} input.producer - Represents the entity that has the ownership of the inspection to be created.
18
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
19
+ * data or an Error with the problem.
20
+ */
21
+ create(input: ICreatePeopleInspection): Promise<ICreateInspectionOutput>;
22
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.People = void 0;
4
+ const Helper_1 = require("./Helper");
5
+ class People {
6
+ constructor(httpClient) {
7
+ this.httpClient = httpClient;
8
+ }
9
+ /**
10
+ * Create an inspection of type people
11
+ * @param input - An object that contains the essential information for create an inspection.
12
+ * @param {Object} input.consumer - Represents the consumer who will do the inspection.
13
+ * @param {Object} input.people - Represents the people to be attached to the inspection.
14
+ * @param {String} input.mode - Represents the mode of the inspection. See more details: {@link https://www.autoinspector.com.ar/docs/api/start#inspection_mode}
15
+ * @param {String} input.kindOf - Represents the template that inspection will have. This only matters if the input.mode is normal.
16
+ * @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
17
+ * @param {Object} input.access_token - Represents the token that belongs to some user into Autoinspector and was generated thanks to OAuth 2.0. When pass this argument, the apikey will not being send.
18
+ * @param {Object} input.producer - Represents the entity that has the ownership of the inspection to be created.
19
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
20
+ * data or an Error with the problem.
21
+ */
22
+ create(input) {
23
+ const { form } = Helper_1.Helper.buildFormData(input);
24
+ return this.httpClient.makeRequest({
25
+ method: 'POST',
26
+ path: `/inspection/people`,
27
+ body: form,
28
+ headers: Object.assign(Object.assign({}, Helper_1.Helper.buildOptionalHeaders(input.access_token)), form.getHeaders()),
29
+ });
30
+ }
31
+ }
32
+ exports.People = People;
@@ -0,0 +1,16 @@
1
+ import { Car } from './Car';
2
+ import { Custom } from './Custom';
3
+ import { Goods } from './Goods';
4
+ import { HTTPClient } from './HTTPClient';
5
+ import { Machinery } from './Machinery';
6
+ import { Moto } from './Moto';
7
+ import { People } from './People';
8
+ export declare class Products {
9
+ machinery: Machinery;
10
+ people: People;
11
+ goods: Goods;
12
+ car: Car;
13
+ moto: Moto;
14
+ custom: Custom;
15
+ constructor(httRef: HTTPClient);
16
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Products = void 0;
4
+ const Car_1 = require("./Car");
5
+ const Custom_1 = require("./Custom");
6
+ const Goods_1 = require("./Goods");
7
+ const Machinery_1 = require("./Machinery");
8
+ const Moto_1 = require("./Moto");
9
+ const People_1 = require("./People");
10
+ class Products {
11
+ constructor(httRef) {
12
+ this.machinery = new Machinery_1.Machinery(httRef);
13
+ this.people = new People_1.People(httRef);
14
+ this.goods = new Goods_1.Goods(httRef);
15
+ this.car = new Car_1.Car(httRef);
16
+ this.moto = new Moto_1.Moto(httRef);
17
+ this.custom = new Custom_1.Custom(httRef);
18
+ }
19
+ }
20
+ exports.Products = Products;
@@ -0,0 +1,8 @@
1
+ import { ITemplate, ITemplateListInput } from '../types/template';
2
+ import { HTTPClient } from './HTTPClient';
3
+ export declare class Template {
4
+ private readonly httpClient;
5
+ constructor(httpClient: HTTPClient);
6
+ list(input?: ITemplateListInput): Promise<ITemplate[]>;
7
+ retrieve(templateId: string): Promise<ITemplate[]>;
8
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Template = void 0;
13
+ class Template {
14
+ constructor(httpClient) {
15
+ this.httpClient = httpClient;
16
+ }
17
+ list(input = {}) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return yield this.httpClient.makeRequest({
20
+ method: 'GET',
21
+ path: '/inspection/template',
22
+ params: input,
23
+ });
24
+ });
25
+ }
26
+ retrieve(templateId) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ return yield this.httpClient.makeRequest({
29
+ method: 'GET',
30
+ path: '/inspection/template/' + templateId,
31
+ });
32
+ });
33
+ }
34
+ }
35
+ exports.Template = Template;
@@ -0,0 +1,35 @@
1
+ import { IAuthenticatedUserListInspections, IListAuthenticatedUserInspectionsOutput } from '../types/authenticatedUser';
2
+ import { HTTPClient } from './HTTPClient';
3
+ import { Memberships } from './Memberships';
4
+ import { Products } from './Products';
5
+ declare class UserInspections extends Products {
6
+ private readonly httpClient;
7
+ constructor(httpClient: HTTPClient);
8
+ /**
9
+ * List all the inspections with a couple of filters.
10
+ * @param input - An object that contains the information for make the request.
11
+ * @param {String} input.scope - Indicates if the inspections to retrieve will be where the user authenticated is the producer or where the users created by the user authenticated invite before.
12
+ * @param {String} input.accessToken - Represents the token that belongs to the authenticated user.
13
+ * @param input.params - An object that contains the filters.
14
+ * @param {String} input.params.from - Represents the base date in ISO format of the inspections to retrieve.
15
+ * @param {String} input.params.to - Represents the limit date in ISO format of the inspections to retrieve.
16
+ * @param {String} input.params.result - Represents the result that inspections to retrieve should have.
17
+ * @param {String} input.params.search - Represents a general search that will match with the consumer: identification, firstName and email.
18
+ * @param {String} input.params.status - Represents the status that inspections to retrieve should have.
19
+ * @param {Number} input.params.page - Represents the specific page that you want to retrieve the inspections.
20
+ * @param {Object} input.producer - Represents the entity that has the ownership of the inspection to be created.
21
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
22
+ * data or an Error with the problem.
23
+ */
24
+ list(input: IAuthenticatedUserListInspections): Promise<IListAuthenticatedUserInspectionsOutput>;
25
+ }
26
+ /**
27
+ * @classdesc Represents the class that contains the methods/actions availables that somebody can do using the access_token received in the oauth 2.0 authorization code flow.
28
+ * @class
29
+ */
30
+ export declare class User {
31
+ inspections: UserInspections;
32
+ memberships: Memberships;
33
+ constructor(httpClient: HTTPClient);
34
+ }
35
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.User = void 0;
4
+ const Helper_1 = require("./Helper");
5
+ const Memberships_1 = require("./Memberships");
6
+ const Products_1 = require("./Products");
7
+ class UserInspections extends Products_1.Products {
8
+ constructor(httpClient) {
9
+ super(httpClient);
10
+ this.httpClient = httpClient;
11
+ }
12
+ /**
13
+ * List all the inspections with a couple of filters.
14
+ * @param input - An object that contains the information for make the request.
15
+ * @param {String} input.scope - Indicates if the inspections to retrieve will be where the user authenticated is the producer or where the users created by the user authenticated invite before.
16
+ * @param {String} input.accessToken - Represents the token that belongs to the authenticated user.
17
+ * @param input.params - An object that contains the filters.
18
+ * @param {String} input.params.from - Represents the base date in ISO format of the inspections to retrieve.
19
+ * @param {String} input.params.to - Represents the limit date in ISO format of the inspections to retrieve.
20
+ * @param {String} input.params.result - Represents the result that inspections to retrieve should have.
21
+ * @param {String} input.params.search - Represents a general search that will match with the consumer: identification, firstName and email.
22
+ * @param {String} input.params.status - Represents the status that inspections to retrieve should have.
23
+ * @param {Number} input.params.page - Represents the specific page that you want to retrieve the inspections.
24
+ * @param {Object} input.producer - Represents the entity that has the ownership of the inspection to be created.
25
+ * @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
26
+ * data or an Error with the problem.
27
+ */
28
+ list(input) {
29
+ return this.httpClient.makeRequest({
30
+ method: 'GET',
31
+ path: `/inspection/${input.scope || 'me'}?membershipId=${input.membershipId}`,
32
+ params: input.params,
33
+ headers: Helper_1.Helper.buildOptionalHeaders(input.access_token),
34
+ });
35
+ }
36
+ }
37
+ /**
38
+ * @classdesc Represents the class that contains the methods/actions availables that somebody can do using the access_token received in the oauth 2.0 authorization code flow.
39
+ * @class
40
+ */
41
+ class User {
42
+ constructor(httpClient) {
43
+ this.inspections = new UserInspections(httpClient);
44
+ this.memberships = new Memberships_1.Memberships(httpClient);
45
+ }
46
+ }
47
+ exports.User = User;
@@ -0,0 +1,12 @@
1
+ export interface IAPISucessResponse {
2
+ message: string;
3
+ }
4
+ export interface IAutoinspectorError {
5
+ code: string;
6
+ status: number;
7
+ detail: string;
8
+ }
9
+ export declare type APIMethods = 'POST' | 'GET' | 'PUT' | 'DELETE';
10
+ export interface IUpdateResourceResponse {
11
+ message: string;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,65 @@
1
+ import { InspectionStatus, InspectionVeredict } from './inspection';
2
+ export interface IListInspections {
3
+ from: Date;
4
+ to: Date;
5
+ veredict: InspectionVeredict;
6
+ search: string;
7
+ status: InspectionStatus;
8
+ page: number;
9
+ }
10
+ export interface IAuthenticatedUserCommonParams {
11
+ access_token: string;
12
+ }
13
+ export interface IAuthenticatedUserListInspections extends IAuthenticatedUserCommonParams {
14
+ scope: 'all' | 'me';
15
+ params: IListInspections;
16
+ membershipId: string;
17
+ }
18
+ export interface IPaginationOutput {
19
+ hasNextPage: boolean;
20
+ hasPrevPage: boolean;
21
+ limit: number;
22
+ nextPage?: number;
23
+ page: number;
24
+ pagingCounter: number;
25
+ prevPage?: number;
26
+ totalDocs: number;
27
+ totalPages: number;
28
+ }
29
+ export interface IInspectionItemOutput {
30
+ accessCode: string;
31
+ consumer: {
32
+ firstName: string;
33
+ identification: string;
34
+ lastName: string;
35
+ };
36
+ createdAt: string;
37
+ id: string;
38
+ producer: {
39
+ companyId: string;
40
+ user: {
41
+ _id: string;
42
+ username: string;
43
+ };
44
+ userId: string;
45
+ };
46
+ status: string;
47
+ type: string;
48
+ _id: string;
49
+ }
50
+ export interface IListAuthenticatedUserInspectionsOutput {
51
+ pagination: IPaginationOutput;
52
+ inspections: IInspectionItemOutput[];
53
+ }
54
+ export interface IListMemberships extends IAuthenticatedUserCommonParams {
55
+ }
56
+ export interface ICompany {
57
+ logo: string;
58
+ societyReason: string;
59
+ }
60
+ export interface IMembershipItem {
61
+ role: string;
62
+ company: ICompany;
63
+ _id: string;
64
+ }
65
+ export declare type IListMembershipsOutput = IMembershipItem[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });