autoinspector 1.1.2 → 2.0.0-beta.0
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/dist/package.json +4 -5
- package/dist/resources/Autoinspector.d.ts +4 -2
- package/dist/resources/Autoinspector.js +4 -2
- package/dist/resources/Car.d.ts +3 -1
- package/dist/resources/Car.js +13 -28
- package/dist/resources/Custom.d.ts +8 -0
- package/dist/resources/Custom.js +30 -0
- package/dist/resources/Goods.d.ts +5 -15
- package/dist/resources/Goods.js +11 -16
- package/dist/resources/Helper.d.ts +10 -0
- package/dist/resources/Helper.js +54 -0
- package/dist/resources/Image.d.ts +4 -9
- package/dist/resources/Image.js +23 -20
- package/dist/resources/Inspections.d.ts +2 -1
- package/dist/resources/Inspections.js +10 -0
- package/dist/resources/Machinery.d.ts +3 -13
- package/dist/resources/Machinery.js +4 -13
- package/dist/resources/Moto.d.ts +10 -0
- package/dist/resources/Moto.js +41 -0
- package/dist/resources/OAuth.d.ts +3 -3
- package/dist/resources/OAuth.js +4 -4
- package/dist/resources/People.d.ts +3 -13
- package/dist/resources/People.js +3 -17
- package/dist/resources/Products.d.ts +6 -2
- package/dist/resources/Products.js +6 -2
- package/dist/resources/Template.d.ts +2 -1
- package/dist/resources/Template.js +10 -2
- package/dist/types/car.d.ts +6 -3
- package/dist/types/goods.d.ts +3 -7
- package/dist/types/helper.d.ts +5 -0
- package/dist/types/helper.js +2 -0
- package/dist/types/inspection.d.ts +11 -1
- package/dist/types/machinery.d.ts +4 -4
- package/dist/types/moto.d.ts +10 -0
- package/dist/types/moto.js +2 -0
- package/dist/types/people.d.ts +3 -4
- package/dist/types/producer.d.ts +1 -1
- package/dist/types/productMethods.d.ts +2 -2
- package/dist/types/template.d.ts +2 -0
- package/package.json +4 -5
- package/dist/resources/Vehicle.d.ts +0 -33
- package/dist/resources/Vehicle.js +0 -47
- package/index.ts +0 -3
package/dist/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autoinspector",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "Autoinspector API wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "jest --config ./jest.config.js",
|
|
8
|
+
"test": "./node_modules/.bin/jest --config ./jest.config.js",
|
|
9
|
+
"test:watch": "jest --watch --runInBand --detectOpenHandles",
|
|
9
10
|
"build": "tsc",
|
|
10
11
|
"semantic-release": "semantic-release",
|
|
11
12
|
"commit": "git-cz"
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
38
39
|
"@typescript-eslint/parser": "^5.10.0",
|
|
39
40
|
"cz-conventional-changelog": "^3.3.0",
|
|
41
|
+
"dotenv": "^16.0.0",
|
|
40
42
|
"eslint": "^8.7.0",
|
|
41
43
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
42
44
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -51,8 +53,5 @@
|
|
|
51
53
|
"commitizen": {
|
|
52
54
|
"path": "./node_modules/cz-conventional-changelog"
|
|
53
55
|
}
|
|
54
|
-
},
|
|
55
|
-
"publishConfig": {
|
|
56
|
-
"registry": "https://registry.npmjs.org/"
|
|
57
56
|
}
|
|
58
57
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { IAutoinspector } from '../types/autoinspector';
|
|
2
|
-
import { Image } from './Image';
|
|
3
2
|
import { Inspections } from './Inspections';
|
|
4
3
|
import { OAuth } from './OAuth';
|
|
4
|
+
import { Template } from './Template';
|
|
5
|
+
import { Image } from './Image';
|
|
5
6
|
/**
|
|
6
7
|
* @classdesc Represents the Autoinspector SDK. It allows the user to make every call to the API with a single function.
|
|
7
8
|
* @class
|
|
8
9
|
*/
|
|
9
10
|
export declare class Autoinspector {
|
|
10
11
|
oauth: OAuth;
|
|
11
|
-
images: Image;
|
|
12
12
|
inspections: Inspections;
|
|
13
|
+
templates: Template;
|
|
14
|
+
images: Image;
|
|
13
15
|
/**
|
|
14
16
|
* Create Autoinspector SDK.
|
|
15
17
|
* @constructor
|
|
@@ -4,11 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Autoinspector = void 0;
|
|
7
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
8
7
|
const HTTPClient_1 = require("./HTTPClient");
|
|
9
|
-
const
|
|
8
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
10
9
|
const Inspections_1 = require("./Inspections");
|
|
11
10
|
const OAuth_1 = require("./OAuth");
|
|
11
|
+
const Template_1 = require("./Template");
|
|
12
|
+
const Image_1 = require("./Image");
|
|
12
13
|
/**
|
|
13
14
|
* @classdesc Represents the Autoinspector SDK. It allows the user to make every call to the API with a single function.
|
|
14
15
|
* @class
|
|
@@ -35,6 +36,7 @@ class Autoinspector {
|
|
|
35
36
|
});
|
|
36
37
|
this.oauth = new OAuth_1.OAuth(httpClient, input.oauthCredentials || {});
|
|
37
38
|
this.inspections = new Inspections_1.Inspections(httpClient);
|
|
39
|
+
this.templates = new Template_1.Template(httpClient);
|
|
38
40
|
this.images = new Image_1.Image(httpClient);
|
|
39
41
|
}
|
|
40
42
|
}
|
package/dist/resources/Car.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IUpdateResourceResponse } from '../types/api';
|
|
2
|
+
import { ICreateCarInspection, IUpdateCarInspection } from '../types/car';
|
|
2
3
|
import { ICreateInspectionOutput } from '../types/inspection';
|
|
3
4
|
import { HTTPClient } from './HTTPClient';
|
|
4
5
|
export declare class Car {
|
|
5
6
|
private readonly httpClient;
|
|
6
7
|
constructor(httpClient: HTTPClient);
|
|
7
8
|
create(input: ICreateCarInspection): Promise<ICreateInspectionOutput>;
|
|
9
|
+
update(input: Pick<IUpdateCarInspection, 'car' | 'productId'>): Promise<IUpdateResourceResponse>;
|
|
8
10
|
}
|
package/dist/resources/Car.js
CHANGED
|
@@ -8,23 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
12
|
exports.Car = void 0;
|
|
27
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
28
13
|
const Helper_1 = require("./Helper");
|
|
29
14
|
class Car {
|
|
30
15
|
constructor(httpClient) {
|
|
@@ -32,25 +17,25 @@ class Car {
|
|
|
32
17
|
}
|
|
33
18
|
create(input) {
|
|
34
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const form =
|
|
36
|
-
const { inputValues } = input, rest = __rest(input, ["inputValues"]);
|
|
37
|
-
const inputValuesNonFiles = [];
|
|
38
|
-
for (const inputValue of inputValues) {
|
|
39
|
-
const isFile = inputValue.value instanceof Buffer || Helper_1.Helper.isFile(inputValue.value);
|
|
40
|
-
if (isFile) {
|
|
41
|
-
form.append(inputValue.label, inputValue.value instanceof Buffer ? inputValue.value : Helper_1.Helper.readFile(inputValue.value));
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
inputValuesNonFiles.push(inputValue);
|
|
45
|
-
}
|
|
46
|
-
form.append('data', JSON.stringify(Object.assign(Object.assign({}, rest), { inputValues: inputValuesNonFiles })));
|
|
20
|
+
const { form } = Helper_1.Helper.buildFormData(input);
|
|
47
21
|
return yield this.httpClient.makeRequest({
|
|
48
22
|
method: 'POST',
|
|
49
23
|
path: `/inspection/car`,
|
|
50
|
-
body:
|
|
24
|
+
body: form,
|
|
51
25
|
headers: form.getHeaders(),
|
|
52
26
|
});
|
|
53
27
|
});
|
|
54
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/car/${input.productId}`,
|
|
34
|
+
body: {
|
|
35
|
+
car: input.car,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
55
40
|
}
|
|
56
41
|
exports.Car = Car;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICreateInspectionOutput } from '../types/inspection';
|
|
2
|
+
import { ICreatePeopleInspection } from '../types/people';
|
|
3
|
+
import { HTTPClient } from './HTTPClient';
|
|
4
|
+
export declare class Custom {
|
|
5
|
+
private readonly httpClient;
|
|
6
|
+
constructor(httpClient: HTTPClient);
|
|
7
|
+
create(input: ICreatePeopleInspection): Promise<ICreateInspectionOutput>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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.Custom = void 0;
|
|
13
|
+
const Helper_1 = require("./Helper");
|
|
14
|
+
class Custom {
|
|
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/custom`,
|
|
24
|
+
body: form,
|
|
25
|
+
headers: form.getHeaders(),
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Custom = Custom;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ICreateGoodsInspection, IUpdateGoodsInspection } from '../types/goods';
|
|
1
|
+
import { ICreateGoodsInspection } from '../types/goods';
|
|
3
2
|
import { ICreateInspectionGoodsOutput } from '../types/inspection';
|
|
4
|
-
import { IProductService } from '../types/productMethods';
|
|
5
3
|
import { HTTPClient } from './HTTPClient';
|
|
6
|
-
export declare class Goods
|
|
4
|
+
export declare class Goods {
|
|
7
5
|
private readonly httpClient;
|
|
8
6
|
constructor(httpClient: HTTPClient);
|
|
9
7
|
/**
|
|
@@ -20,15 +18,7 @@ export declare class Goods implements IProductService {
|
|
|
20
18
|
* data or an Error with the problem.
|
|
21
19
|
*/
|
|
22
20
|
create(input: ICreateGoodsInspection): Promise<ICreateInspectionGoodsOutput>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @param {String} input.productId - Represents the product unique identifier.
|
|
27
|
-
* @param {Object} input.consumer - Represents the consumer who will do the inspection.
|
|
28
|
-
* @param {Object} input.good - The information to update of the product.
|
|
29
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
30
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
31
|
-
* data or an Error with the problem.
|
|
32
|
-
*/
|
|
33
|
-
update(input: IUpdateGoodsInspection): Promise<IUpdateResourceResponse>;
|
|
21
|
+
addGoodItem(input: Pick<ICreateGoodsInspection, 'goods' | 'access_token'> & {
|
|
22
|
+
inspectionId: string;
|
|
23
|
+
}): Promise<ICreateInspectionGoodsOutput>;
|
|
34
24
|
}
|
package/dist/resources/Goods.js
CHANGED
|
@@ -20,28 +20,23 @@ class Goods {
|
|
|
20
20
|
* data or an Error with the problem.
|
|
21
21
|
*/
|
|
22
22
|
create(input) {
|
|
23
|
+
const { form } = Helper_1.Helper.buildFormData(input);
|
|
23
24
|
return this.httpClient.makeRequest({
|
|
24
25
|
method: 'POST',
|
|
25
26
|
path: `/inspection/goods`,
|
|
26
|
-
body:
|
|
27
|
-
headers: Helper_1.Helper.buildOptionalHeaders(input.access_token),
|
|
27
|
+
body: form,
|
|
28
|
+
headers: Object.assign(Object.assign({}, Helper_1.Helper.buildOptionalHeaders(input.access_token)), form.getHeaders()),
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @param input - An object that contains information that .
|
|
33
|
-
* @param {String} input.productId - Represents the product unique identifier.
|
|
34
|
-
* @param {Object} input.consumer - Represents the consumer who will do the inspection.
|
|
35
|
-
* @param {Object} input.good - The information to update of the product.
|
|
36
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
37
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
38
|
-
* data or an Error with the problem.
|
|
39
|
-
*/
|
|
40
|
-
update(input) {
|
|
31
|
+
addGoodItem(input) {
|
|
32
|
+
const { goods, inspectionId } = input;
|
|
41
33
|
return this.httpClient.makeRequest({
|
|
42
|
-
method: '
|
|
43
|
-
path: `/inspection/goods/${
|
|
44
|
-
body:
|
|
34
|
+
method: 'POST',
|
|
35
|
+
path: `/inspection/goods/${inspectionId}`,
|
|
36
|
+
body: {
|
|
37
|
+
goods,
|
|
38
|
+
},
|
|
39
|
+
headers: Object.assign({}, Helper_1.Helper.buildOptionalHeaders(input.access_token)),
|
|
45
40
|
});
|
|
46
41
|
}
|
|
47
42
|
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
import { IFilterInputValuesOutput } from '../types/helper';
|
|
2
4
|
import { IHeaders } from '../types/http';
|
|
5
|
+
import { IInputValue } from '../types/inspection';
|
|
3
6
|
export declare class Helper {
|
|
4
7
|
static buildOptionalHeaders(access_token?: string): IHeaders | undefined;
|
|
5
8
|
static isNode(): boolean;
|
|
6
9
|
static isFile(path: string): boolean;
|
|
7
10
|
static readFile(path: string): Buffer;
|
|
11
|
+
static filterInputs(inputs: IInputValue[]): IFilterInputValuesOutput;
|
|
12
|
+
static buildFormData(input: {
|
|
13
|
+
inputs?: IInputValue[];
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}): {
|
|
16
|
+
form: FormData;
|
|
17
|
+
};
|
|
8
18
|
}
|
package/dist/resources/Helper.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.Helper = void 0;
|
|
18
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
4
19
|
const fs_1 = require("fs");
|
|
5
20
|
class Helper {
|
|
6
21
|
static buildOptionalHeaders(access_token) {
|
|
@@ -26,5 +41,44 @@ class Helper {
|
|
|
26
41
|
static readFile(path) {
|
|
27
42
|
return (0, fs_1.readFileSync)(path);
|
|
28
43
|
}
|
|
44
|
+
static filterInputs(inputs) {
|
|
45
|
+
const inputValuesNonFiles = [];
|
|
46
|
+
const inputValuesFiles = [];
|
|
47
|
+
for (const inputValue of inputs) {
|
|
48
|
+
const isFile = inputValue.value instanceof Buffer || Helper.isFile(inputValue.value);
|
|
49
|
+
if (isFile) {
|
|
50
|
+
inputValuesFiles.push({
|
|
51
|
+
label: inputValue.label,
|
|
52
|
+
value: inputValue.value instanceof Buffer
|
|
53
|
+
? inputValue.value
|
|
54
|
+
: Helper.readFile(inputValue.value),
|
|
55
|
+
});
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
inputValuesNonFiles.push(inputValue);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
inputValuesFiles,
|
|
62
|
+
inputValuesNonFiles,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
static buildFormData(input) {
|
|
66
|
+
const form = new form_data_1.default();
|
|
67
|
+
if (!input.inputs) {
|
|
68
|
+
form.append('data', JSON.stringify(input));
|
|
69
|
+
return {
|
|
70
|
+
form,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const { inputs } = input, rest = __rest(input, ["inputs"]);
|
|
74
|
+
const { inputValuesFiles, inputValuesNonFiles } = this.filterInputs(inputs);
|
|
75
|
+
for (const inputFile of inputValuesFiles) {
|
|
76
|
+
form.append(inputFile.label, inputFile.value);
|
|
77
|
+
}
|
|
78
|
+
form.append('data', JSON.stringify(Object.assign(Object.assign({}, rest), { inputs: inputValuesNonFiles })));
|
|
79
|
+
return {
|
|
80
|
+
form,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
29
83
|
}
|
|
30
84
|
exports.Helper = Helper;
|
|
@@ -3,14 +3,9 @@ import { IUploadImage } from '../types/image';
|
|
|
3
3
|
import { HTTPClient } from './HTTPClient';
|
|
4
4
|
import { IImageToken } from '../types/inspection';
|
|
5
5
|
export declare class Image {
|
|
6
|
-
private readonly
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
* Generates an image token.
|
|
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
|
-
generateToken(): Promise<IImageToken>;
|
|
6
|
+
private readonly httpClient;
|
|
7
|
+
constructor(httpClient: HTTPClient);
|
|
8
|
+
generateToken(input: Omit<IUploadImage, 'image' | 'imageToken'>): Promise<IImageToken>;
|
|
14
9
|
/**
|
|
15
10
|
* Upload an image for specific product inspection item. For the moment, this method is only available for the inspection with mode full_control.
|
|
16
11
|
* @param input - An object that contains the essential information for upload the image.
|
|
@@ -22,5 +17,5 @@ export declare class Image {
|
|
|
22
17
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
23
18
|
* data or an Error with the problem.
|
|
24
19
|
*/
|
|
25
|
-
|
|
20
|
+
upload(input: IUploadImage): Promise<IAPISucessResponse>;
|
|
26
21
|
}
|
package/dist/resources/Image.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -6,18 +17,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
17
|
exports.Image = void 0;
|
|
7
18
|
const form_data_1 = __importDefault(require("form-data"));
|
|
8
19
|
class Image {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
20
|
+
constructor(httpClient) {
|
|
21
|
+
this.httpClient = httpClient;
|
|
11
22
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* data or an Error with the problem.
|
|
16
|
-
*/
|
|
17
|
-
generateToken() {
|
|
18
|
-
return this.httpRef.makeRequest({
|
|
23
|
+
generateToken(input) {
|
|
24
|
+
const { productId } = input, restImage = __rest(input, ["productId"]);
|
|
25
|
+
return this.httpClient.makeRequest({
|
|
19
26
|
method: 'POST',
|
|
20
|
-
path: `/inspection/image
|
|
27
|
+
path: `/inspection/image/${productId}`,
|
|
28
|
+
body: restImage,
|
|
21
29
|
});
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
@@ -31,17 +39,12 @@ class Image {
|
|
|
31
39
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
32
40
|
* data or an Error with the problem.
|
|
33
41
|
*/
|
|
34
|
-
|
|
42
|
+
upload(input) {
|
|
35
43
|
const form = new form_data_1.default();
|
|
36
|
-
|
|
37
|
-
form.append('image',
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (input.date) {
|
|
42
|
-
form.append('date', input.date.toISOString());
|
|
43
|
-
}
|
|
44
|
-
return this.httpRef.makeRequest({
|
|
44
|
+
const { image } = input, restImage = __rest(input, ["image"]);
|
|
45
|
+
form.append('image', image);
|
|
46
|
+
form.append('data', JSON.stringify(restImage));
|
|
47
|
+
return this.httpClient.makeRequest({
|
|
45
48
|
method: 'POST',
|
|
46
49
|
path: `/inspection/image/${input.productId}`,
|
|
47
50
|
body: form,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAPISucessResponse } from '../types/api';
|
|
2
|
-
import { IFinishInspection, IGetInspection, IInspection } from '../types/inspection';
|
|
2
|
+
import { IFinishInspection, IGetInspection, IInspection, IUpdateInspection } from '../types/inspection';
|
|
3
3
|
import { IPagination, IPaginationResponse } from '../types/pagination';
|
|
4
4
|
import { HTTPClient } from './HTTPClient';
|
|
5
5
|
import { Products } from './Products';
|
|
@@ -18,6 +18,7 @@ export declare class Inspections extends Products {
|
|
|
18
18
|
* data or an Error with the problem.
|
|
19
19
|
*/
|
|
20
20
|
finish(input: IFinishInspection): Promise<IAPISucessResponse>;
|
|
21
|
+
update(input: IUpdateInspection): Promise<IAPISucessResponse>;
|
|
21
22
|
/**
|
|
22
23
|
* Get a specific inspection object.
|
|
23
24
|
* @param input - An object that contains the essential information for upload the image.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Inspections = void 0;
|
|
4
|
+
const Helper_1 = require("./Helper");
|
|
4
5
|
const Products_1 = require("./Products");
|
|
5
6
|
/**
|
|
6
7
|
* @classdesc Represents the class that contains the methods or actions that somebody can do using apikey and access_token.
|
|
@@ -25,6 +26,15 @@ class Inspections extends Products_1.Products {
|
|
|
25
26
|
body: {},
|
|
26
27
|
});
|
|
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
|
+
}
|
|
28
38
|
/**
|
|
29
39
|
* Get a specific inspection object.
|
|
30
40
|
* @param input - An object that contains the essential information for upload the image.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IUpdateResourceResponse } from '../types/api';
|
|
2
2
|
import { ICreateInspectionOutput } from '../types/inspection';
|
|
3
3
|
import { ICreateMachineryInspection, IUpdateMachineryInspection } from '../types/machinery';
|
|
4
|
-
import {
|
|
4
|
+
import { IProductMethods } from '../types/productMethods';
|
|
5
5
|
import { HTTPClient } from './HTTPClient';
|
|
6
6
|
/**
|
|
7
7
|
* @classdesc Represents the class that handle all the requests related to an inspection of type machinery.
|
|
8
8
|
* @class
|
|
9
9
|
*/
|
|
10
|
-
export declare class Machinery implements
|
|
10
|
+
export declare class Machinery implements IProductMethods {
|
|
11
11
|
private readonly httpClient;
|
|
12
12
|
constructor(httpClient: HTTPClient);
|
|
13
13
|
/**
|
|
@@ -24,15 +24,5 @@ export declare class Machinery implements IProductService {
|
|
|
24
24
|
* data or an Error with the problem.
|
|
25
25
|
*/
|
|
26
26
|
create(input: ICreateMachineryInspection): Promise<ICreateInspectionOutput>;
|
|
27
|
-
|
|
28
|
-
* Update a machinery inspection.
|
|
29
|
-
* @param input - An object with the values to update.
|
|
30
|
-
* @param {Object} input.consumer - Represents the consumer who will do the inspection.
|
|
31
|
-
* @param {String} input.productId - Represents the unique identifier of the machinery.
|
|
32
|
-
* @param {Object} input.machinery - Represents the machinery to be attached to the inspection.
|
|
33
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
34
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
35
|
-
* data or an Error with the problem.
|
|
36
|
-
*/
|
|
37
|
-
update(input: IUpdateMachineryInspection): Promise<IUpdateResourceResponse>;
|
|
27
|
+
update(input: Pick<IUpdateMachineryInspection, 'machinery' | 'productId'>): Promise<IUpdateResourceResponse>;
|
|
38
28
|
}
|
|
@@ -24,28 +24,19 @@ class Machinery {
|
|
|
24
24
|
* data or an Error with the problem.
|
|
25
25
|
*/
|
|
26
26
|
create(input) {
|
|
27
|
+
const { form } = Helper_1.Helper.buildFormData(input);
|
|
27
28
|
return this.httpClient.makeRequest({
|
|
28
29
|
method: 'POST',
|
|
29
30
|
path: `/inspection/machinery`,
|
|
30
|
-
body:
|
|
31
|
-
headers: Helper_1.Helper.buildOptionalHeaders(input === null || input === void 0 ? void 0 : input.access_token),
|
|
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()),
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Update a machinery inspection.
|
|
36
|
-
* @param input - An object with the values to update.
|
|
37
|
-
* @param {Object} input.consumer - Represents the consumer who will do the inspection.
|
|
38
|
-
* @param {String} input.productId - Represents the unique identifier of the machinery.
|
|
39
|
-
* @param {Object} input.machinery - Represents the machinery to be attached to the inspection.
|
|
40
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
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
35
|
update(input) {
|
|
45
36
|
return this.httpClient.makeRequest({
|
|
46
37
|
method: 'PUT',
|
|
47
38
|
path: `/inspection/machinery/${input.productId}`,
|
|
48
|
-
body: input,
|
|
39
|
+
body: input.machinery,
|
|
49
40
|
});
|
|
50
41
|
}
|
|
51
42
|
}
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IExchangeCodeForAccessTokenOutput, IOAuth20Credentials, IRefreshAccessTokenOutput } from '../types/oauth20';
|
|
2
2
|
import { HTTPClient } from './HTTPClient';
|
|
3
3
|
import { User } from './User';
|
|
4
4
|
/**
|
|
@@ -25,7 +25,7 @@ export declare class OAuth {
|
|
|
25
25
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
26
26
|
* data or an Error with the problem.
|
|
27
27
|
*/
|
|
28
|
-
exchangeCodeForAccessToken(
|
|
28
|
+
exchangeCodeForAccessToken(code: string): Promise<IExchangeCodeForAccessTokenOutput>;
|
|
29
29
|
/**
|
|
30
30
|
* Refresh some access_token for obtain a new one. This is useful for keep a long-term access_token.
|
|
31
31
|
* @param input - An object that contains the essential information refresh the token.
|
|
@@ -33,5 +33,5 @@ export declare class OAuth {
|
|
|
33
33
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
34
34
|
* data or an Error with the problem.
|
|
35
35
|
*/
|
|
36
|
-
refreshAccessToken(
|
|
36
|
+
refreshAccessToken(refreshToken: string): Promise<IRefreshAccessTokenOutput>;
|
|
37
37
|
}
|
package/dist/resources/OAuth.js
CHANGED
|
@@ -27,11 +27,11 @@ class OAuth {
|
|
|
27
27
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
28
28
|
* data or an Error with the problem.
|
|
29
29
|
*/
|
|
30
|
-
exchangeCodeForAccessToken(
|
|
30
|
+
exchangeCodeForAccessToken(code) {
|
|
31
31
|
return this.httpClient.makeRequest({
|
|
32
32
|
method: 'POST',
|
|
33
33
|
path: '/account/oauth/exchange_code',
|
|
34
|
-
body: Object.assign(
|
|
34
|
+
body: Object.assign({ code }, this.credentials),
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -41,11 +41,11 @@ class OAuth {
|
|
|
41
41
|
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
42
42
|
* data or an Error with the problem.
|
|
43
43
|
*/
|
|
44
|
-
refreshAccessToken(
|
|
44
|
+
refreshAccessToken(refreshToken) {
|
|
45
45
|
return this.httpClient.makeRequest({
|
|
46
46
|
method: 'POST',
|
|
47
47
|
path: '/account/oauth/refresh_token',
|
|
48
|
-
body: Object.assign(
|
|
48
|
+
body: Object.assign({ refresh_token: refreshToken }, this.credentials),
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { IUpdateResourceResponse } from '../types/api';
|
|
2
1
|
import { ICreateInspectionOutput } from '../types/inspection';
|
|
3
|
-
import { ICreatePeopleInspection
|
|
4
|
-
import {
|
|
2
|
+
import { ICreatePeopleInspection } from '../types/people';
|
|
3
|
+
import { IProductMethods } from '../types/productMethods';
|
|
5
4
|
import { HTTPClient } from './HTTPClient';
|
|
6
|
-
export declare class People implements
|
|
5
|
+
export declare class People implements IProductMethods {
|
|
7
6
|
private readonly httpClient;
|
|
8
7
|
constructor(httpClient: HTTPClient);
|
|
9
8
|
/**
|
|
@@ -20,13 +19,4 @@ export declare class People implements IProductService {
|
|
|
20
19
|
* data or an Error with the problem.
|
|
21
20
|
*/
|
|
22
21
|
create(input: ICreatePeopleInspection): Promise<ICreateInspectionOutput>;
|
|
23
|
-
/**
|
|
24
|
-
* Update an inspection of type people
|
|
25
|
-
* @param input - An object that contains the essential information for create an inspection.
|
|
26
|
-
* @param {Object} input.consumer - Represents the user who do the inspection.
|
|
27
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
28
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
29
|
-
* data or an Error with the problem.
|
|
30
|
-
*/
|
|
31
|
-
update(input: IUpdatePeopleInspection): Promise<IUpdateResourceResponse>;
|
|
32
22
|
}
|
package/dist/resources/People.js
CHANGED
|
@@ -20,26 +20,12 @@ class People {
|
|
|
20
20
|
* data or an Error with the problem.
|
|
21
21
|
*/
|
|
22
22
|
create(input) {
|
|
23
|
+
const { form } = Helper_1.Helper.buildFormData(input);
|
|
23
24
|
return this.httpClient.makeRequest({
|
|
24
25
|
method: 'POST',
|
|
25
26
|
path: `/inspection/people`,
|
|
26
|
-
body:
|
|
27
|
-
headers: Helper_1.Helper.buildOptionalHeaders(input.access_token),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Update an inspection of type people
|
|
32
|
-
* @param input - An object that contains the essential information for create an inspection.
|
|
33
|
-
* @param {Object} input.consumer - Represents the user who do the inspection.
|
|
34
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
35
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
36
|
-
* data or an Error with the problem.
|
|
37
|
-
*/
|
|
38
|
-
update(input) {
|
|
39
|
-
return this.httpClient.makeRequest({
|
|
40
|
-
method: 'PUT',
|
|
41
|
-
path: `/inspection/people/${input.productId}`,
|
|
42
|
-
body: input,
|
|
27
|
+
body: form,
|
|
28
|
+
headers: Object.assign(Object.assign({}, Helper_1.Helper.buildOptionalHeaders(input.access_token)), form.getHeaders()),
|
|
43
29
|
});
|
|
44
30
|
}
|
|
45
31
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { Car } from './Car';
|
|
2
|
+
import { Custom } from './Custom';
|
|
1
3
|
import { Goods } from './Goods';
|
|
2
4
|
import { HTTPClient } from './HTTPClient';
|
|
3
5
|
import { Machinery } from './Machinery';
|
|
6
|
+
import { Moto } from './Moto';
|
|
4
7
|
import { People } from './People';
|
|
5
|
-
import { Vehicle } from './Vehicle';
|
|
6
8
|
export declare class Products {
|
|
7
9
|
machinery: Machinery;
|
|
8
10
|
people: People;
|
|
9
11
|
goods: Goods;
|
|
10
|
-
|
|
12
|
+
car: Car;
|
|
13
|
+
moto: Moto;
|
|
14
|
+
custom: Custom;
|
|
11
15
|
constructor(httRef: HTTPClient);
|
|
12
16
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Products = void 0;
|
|
4
|
+
const Car_1 = require("./Car");
|
|
5
|
+
const Custom_1 = require("./Custom");
|
|
4
6
|
const Goods_1 = require("./Goods");
|
|
5
7
|
const Machinery_1 = require("./Machinery");
|
|
8
|
+
const Moto_1 = require("./Moto");
|
|
6
9
|
const People_1 = require("./People");
|
|
7
|
-
const Vehicle_1 = require("./Vehicle");
|
|
8
10
|
class Products {
|
|
9
11
|
constructor(httRef) {
|
|
10
12
|
this.machinery = new Machinery_1.Machinery(httRef);
|
|
11
13
|
this.people = new People_1.People(httRef);
|
|
12
14
|
this.goods = new Goods_1.Goods(httRef);
|
|
13
|
-
this.
|
|
15
|
+
this.car = new Car_1.Car(httRef);
|
|
16
|
+
this.moto = new Moto_1.Moto(httRef);
|
|
17
|
+
this.custom = new Custom_1.Custom(httRef);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
exports.Products = Products;
|
|
@@ -3,5 +3,6 @@ import { HTTPClient } from './HTTPClient';
|
|
|
3
3
|
export declare class Template {
|
|
4
4
|
private readonly httpClient;
|
|
5
5
|
constructor(httpClient: HTTPClient);
|
|
6
|
-
list(input
|
|
6
|
+
list(input?: ITemplateListInput): Promise<ITemplate[]>;
|
|
7
|
+
retrieve(templateId: string): Promise<ITemplate[]>;
|
|
7
8
|
}
|
|
@@ -14,14 +14,22 @@ class Template {
|
|
|
14
14
|
constructor(httpClient) {
|
|
15
15
|
this.httpClient = httpClient;
|
|
16
16
|
}
|
|
17
|
-
list(input) {
|
|
17
|
+
list(input = {}) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
return yield this.httpClient.makeRequest({
|
|
20
20
|
method: 'GET',
|
|
21
|
-
path: '/inspection/template
|
|
21
|
+
path: '/inspection/template',
|
|
22
22
|
params: input,
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
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
|
+
}
|
|
26
34
|
}
|
|
27
35
|
exports.Template = Template;
|
package/dist/types/car.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Colors } from './colors';
|
|
2
|
-
import {
|
|
2
|
+
import { ICreateInspectionParamsV2, IUpdateInspectionParamsV2 } from './inspection';
|
|
3
3
|
export interface ICar {
|
|
4
4
|
/**
|
|
5
5
|
* Plate: The plate of the vehicle.
|
|
@@ -20,7 +20,7 @@ export interface ICar {
|
|
|
20
20
|
/**
|
|
21
21
|
* Year: The year of the vehicle.
|
|
22
22
|
*/
|
|
23
|
-
year?:
|
|
23
|
+
year?: number;
|
|
24
24
|
/**
|
|
25
25
|
* make: The make/brand of the vehicle.
|
|
26
26
|
*/
|
|
@@ -34,6 +34,9 @@ export interface ICar {
|
|
|
34
34
|
*/
|
|
35
35
|
chassis?: string;
|
|
36
36
|
}
|
|
37
|
-
export interface ICreateCarInspection extends
|
|
37
|
+
export interface ICreateCarInspection extends ICreateInspectionParamsV2 {
|
|
38
38
|
car: ICar;
|
|
39
39
|
}
|
|
40
|
+
export interface IUpdateCarInspection extends IUpdateInspectionParamsV2 {
|
|
41
|
+
car?: Partial<ICar>;
|
|
42
|
+
}
|
package/dist/types/goods.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IConfiguration, IConfigurationCommonValidations } from './configuration';
|
|
2
|
-
import {
|
|
2
|
+
import { ICreateInspectionParamsV2, IUpdateInspectionParamsV2 } from './inspection';
|
|
3
3
|
export interface IGoodConfiguration extends IConfigurationCommonValidations {
|
|
4
4
|
/**
|
|
5
5
|
* object: `Validation that verifies the serial number that appears in the serialNumber photo is the same as declared.`
|
|
@@ -36,20 +36,16 @@ export interface IGood {
|
|
|
36
36
|
* price: `The price of the good item.`
|
|
37
37
|
*/
|
|
38
38
|
price: string;
|
|
39
|
-
/**
|
|
40
|
-
* configuration: `Validation Configuration Template to be attached to the Good Inspection Item. If it not setted, the default configuration will be applied.`
|
|
41
|
-
*/
|
|
42
|
-
configuration?: Partial<IGoodConfiguration>;
|
|
43
39
|
}
|
|
44
40
|
/**
|
|
45
41
|
* Represents the object to be sended when create an inspection of type vehicle.
|
|
46
42
|
*/
|
|
47
|
-
export interface ICreateGoodsInspection extends
|
|
43
|
+
export interface ICreateGoodsInspection extends ICreateInspectionParamsV2 {
|
|
48
44
|
goods: IGood[];
|
|
49
45
|
}
|
|
50
46
|
/**
|
|
51
47
|
* Represents the object to be sended when create an inspection of type vehicle.
|
|
52
48
|
*/
|
|
53
|
-
export interface IUpdateGoodsInspection extends
|
|
49
|
+
export interface IUpdateGoodsInspection extends IUpdateInspectionParamsV2 {
|
|
54
50
|
good?: Partial<IGood>;
|
|
55
51
|
}
|
|
@@ -55,8 +55,11 @@ export interface IInputValue {
|
|
|
55
55
|
label: string;
|
|
56
56
|
value: string | Buffer;
|
|
57
57
|
}
|
|
58
|
+
export interface IUpdateInspection extends Pick<IIInspectionCommonParamsV2, 'inputs' | 'consumer'> {
|
|
59
|
+
inspectionId: string;
|
|
60
|
+
}
|
|
58
61
|
export interface IIInspectionCommonParamsV2<P = IProducer> {
|
|
59
|
-
|
|
62
|
+
inputs: IInputValue[];
|
|
60
63
|
consumer: IConsumer;
|
|
61
64
|
producer: P;
|
|
62
65
|
templateId: string;
|
|
@@ -64,6 +67,12 @@ export interface IIInspectionCommonParamsV2<P = IProducer> {
|
|
|
64
67
|
metadata?: object;
|
|
65
68
|
access_token?: string;
|
|
66
69
|
}
|
|
70
|
+
export interface IUpdateInspectionParamsV2 {
|
|
71
|
+
productId: string;
|
|
72
|
+
inputs?: IInputValue[];
|
|
73
|
+
consumer?: Partial<IConsumer>;
|
|
74
|
+
metadata?: object;
|
|
75
|
+
}
|
|
67
76
|
export interface IFinishInspection extends IGetInspection {
|
|
68
77
|
}
|
|
69
78
|
export interface ICreateInspectionGoodsOutput extends ICreateInspectionOutputCommon {
|
|
@@ -110,3 +119,4 @@ export interface IInspection {
|
|
|
110
119
|
}
|
|
111
120
|
export interface IInspectionHandler {
|
|
112
121
|
}
|
|
122
|
+
export declare type ICreateInspectionParamsV2 = IIInspectionCommonParamsV2<ICreateInspectionProducer>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Colors } from './colors';
|
|
2
2
|
import { IConfiguration, IConfigurationCommonValidations } from './configuration';
|
|
3
|
-
import {
|
|
3
|
+
import { ICreateInspectionParamsV2, IUpdateInspectionParamsV2 } from './inspection';
|
|
4
4
|
export declare type MachineryPurpose = 'Agrícola' | 'Vial' | 'Industrial';
|
|
5
5
|
export declare type MachineryUse = 'OFICIAL' | 'PRIVADO' | 'PÚBLICO';
|
|
6
6
|
export declare type MachineryType = 'tractor' | 'combine_harvester' | 'sprayer' | 'seeder' | 'fumigator' | 'baler' | 'round_baler' | 'paver' | 'leveler' | 'crane' | 'excavator' | 'carts' | 'grader' | 'loader' | 'scrapers' | 'compacting_machine' | 'machine_soil_treatment' | 'forklift' | 'motor_vehicle_with_coupling_device' | 'fertilizer' | 'backhoe' | 'bulldozer' | 'compactor' | 'hidrogua' | 'trencher' | 'mixer' | 'hopper' | 'mechanical_shovel';
|
|
@@ -34,7 +34,7 @@ export interface IMachinery {
|
|
|
34
34
|
/**
|
|
35
35
|
* year: `The year of the machinery.`
|
|
36
36
|
*/
|
|
37
|
-
year?:
|
|
37
|
+
year?: number;
|
|
38
38
|
/**
|
|
39
39
|
* model: `The model of the machinery.`
|
|
40
40
|
*/
|
|
@@ -56,9 +56,9 @@ export interface IMachinery {
|
|
|
56
56
|
*/
|
|
57
57
|
configuration?: Partial<IMachineryConfiguration>;
|
|
58
58
|
}
|
|
59
|
-
export interface ICreateMachineryInspection extends
|
|
59
|
+
export interface ICreateMachineryInspection extends ICreateInspectionParamsV2 {
|
|
60
60
|
machinery: IMachinery;
|
|
61
61
|
}
|
|
62
|
-
export interface IUpdateMachineryInspection extends
|
|
62
|
+
export interface IUpdateMachineryInspection extends IUpdateInspectionParamsV2 {
|
|
63
63
|
machinery?: Partial<IMachinery>;
|
|
64
64
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ICar } from './car';
|
|
2
|
+
import { ICreateInspectionParamsV2, IUpdateInspectionParamsV2 } from './inspection';
|
|
3
|
+
export interface IMoto extends ICar {
|
|
4
|
+
}
|
|
5
|
+
export interface ICreateMotoInspection extends ICreateInspectionParamsV2 {
|
|
6
|
+
moto: IMoto;
|
|
7
|
+
}
|
|
8
|
+
export interface IUpdateMotoInspection extends IUpdateInspectionParamsV2 {
|
|
9
|
+
moto?: Partial<IMoto>;
|
|
10
|
+
}
|
package/dist/types/people.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IConfiguration, IConfigurationCommonValidations } from './configuration';
|
|
2
|
-
import {
|
|
2
|
+
import { ICreateInspectionParamsV2, IUpdateInspectionParamsV2 } from './inspection';
|
|
3
3
|
export declare type PeopleType = 'person';
|
|
4
4
|
export interface IPeopleConfiguration extends IConfigurationCommonValidations {
|
|
5
5
|
/**
|
|
@@ -39,8 +39,7 @@ export interface IPeople {
|
|
|
39
39
|
/**
|
|
40
40
|
* Represents the object to be sended when create an inspection of type vehicle.
|
|
41
41
|
*/
|
|
42
|
-
export interface ICreatePeopleInspection extends
|
|
43
|
-
people: IPeople;
|
|
42
|
+
export interface ICreatePeopleInspection extends ICreateInspectionParamsV2 {
|
|
44
43
|
}
|
|
45
|
-
export interface IUpdatePeopleInspection extends
|
|
44
|
+
export interface IUpdatePeopleInspection extends IUpdateInspectionParamsV2 {
|
|
46
45
|
}
|
package/dist/types/producer.d.ts
CHANGED
package/dist/types/template.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export interface ITemplate {
|
|
|
51
51
|
inputs: ITemplateInput[];
|
|
52
52
|
features: ITemplateFeature[];
|
|
53
53
|
}
|
|
54
|
+
export declare type TemplateType = 'built-in' | 'created';
|
|
54
55
|
export interface ITemplateListInput {
|
|
55
56
|
inspectionType?: InspectionType;
|
|
57
|
+
type?: TemplateType;
|
|
56
58
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autoinspector",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "Autoinspector API wrapper",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "jest --config ./jest.config.js",
|
|
8
|
+
"test": "./node_modules/.bin/jest --config ./jest.config.js",
|
|
9
|
+
"test:watch": "jest --watch --runInBand --detectOpenHandles",
|
|
9
10
|
"build": "tsc",
|
|
10
11
|
"semantic-release": "semantic-release",
|
|
11
12
|
"commit": "git-cz"
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
38
39
|
"@typescript-eslint/parser": "^5.10.0",
|
|
39
40
|
"cz-conventional-changelog": "^3.3.0",
|
|
41
|
+
"dotenv": "^16.0.0",
|
|
40
42
|
"eslint": "^8.7.0",
|
|
41
43
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
42
44
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -51,8 +53,5 @@
|
|
|
51
53
|
"commitizen": {
|
|
52
54
|
"path": "./node_modules/cz-conventional-changelog"
|
|
53
55
|
}
|
|
54
|
-
},
|
|
55
|
-
"publishConfig": {
|
|
56
|
-
"registry": "https://registry.npmjs.org/"
|
|
57
56
|
}
|
|
58
57
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { IUpdateResourceResponse } from '../types/api';
|
|
2
|
-
import { ICreateInspectionOutput } from '../types/inspection';
|
|
3
|
-
import { IProductService } from '../types/productMethods';
|
|
4
|
-
import { ICreateVehicleInspection, IUpdateVehicleInspection } from '../types/vehicle';
|
|
5
|
-
import { HTTPClient } from './HTTPClient';
|
|
6
|
-
export declare class Vehicle implements IProductService {
|
|
7
|
-
private readonly httpClient;
|
|
8
|
-
constructor(httpClient: HTTPClient);
|
|
9
|
-
/**
|
|
10
|
-
* Create an inspection of type vehicle
|
|
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.vehicle - Represents the vehicle 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.producer - Represents the entity that has the ownership of the inspection to be created.
|
|
18
|
-
* @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.
|
|
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: ICreateVehicleInspection): Promise<ICreateInspectionOutput>;
|
|
23
|
-
/**
|
|
24
|
-
* Update an inspection of type vehicle.
|
|
25
|
-
* @param input - An object that contains the essential information for create an inspection.
|
|
26
|
-
* @param {Object} input.consumer - Represents the consumer who will do the inspection.
|
|
27
|
-
* @param {Object} input.vehicle - Represents the vehicle to be attached to the inspection.
|
|
28
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
29
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
30
|
-
* data or an Error with the problem.
|
|
31
|
-
*/
|
|
32
|
-
update(input: IUpdateVehicleInspection): Promise<IUpdateResourceResponse>;
|
|
33
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Vehicle = void 0;
|
|
4
|
-
const Helper_1 = require("./Helper");
|
|
5
|
-
class Vehicle {
|
|
6
|
-
constructor(httpClient) {
|
|
7
|
-
this.httpClient = httpClient;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Create an inspection of type vehicle
|
|
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.vehicle - Represents the vehicle 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.producer - Represents the entity that has the ownership of the inspection to be created.
|
|
18
|
-
* @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.
|
|
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
|
-
return this.httpClient.makeRequest({
|
|
24
|
-
method: 'POST',
|
|
25
|
-
path: `/inspection/vehicle`,
|
|
26
|
-
body: input,
|
|
27
|
-
headers: Helper_1.Helper.buildOptionalHeaders(input.access_token),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Update an inspection of type vehicle.
|
|
32
|
-
* @param input - An object that contains the essential information for create an inspection.
|
|
33
|
-
* @param {Object} input.consumer - Represents the consumer who will do the inspection.
|
|
34
|
-
* @param {Object} input.vehicle - Represents the vehicle to be attached to the inspection.
|
|
35
|
-
* @param {Object} input.metadata - Represents a dinamic object where you can store any key-value pairs.
|
|
36
|
-
* @return {Promise} - Returns a Promise that, when fulfilled, will either return an JSON Object with the requested
|
|
37
|
-
* data or an Error with the problem.
|
|
38
|
-
*/
|
|
39
|
-
update(input) {
|
|
40
|
-
return this.httpClient.makeRequest({
|
|
41
|
-
method: 'PUT',
|
|
42
|
-
path: `/inspection/vehicle/${input.productId}`,
|
|
43
|
-
body: input,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.Vehicle = Vehicle;
|
package/index.ts
DELETED