Skip to content

Commit

Permalink
fix: conf upgrade + remove console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarflam authored and Julien Bouquillon committed Nov 5, 2021
1 parent a44dbf7 commit ccc1c86
Show file tree
Hide file tree
Showing 16 changed files with 10,641 additions and 4,421 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["es2015", "stage-0"]
"presets": ["@babel/env"],
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/**/*
dist/**/*
26 changes: 17 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"env": {
"browser": true,
"node": true
},
"rules": {

}
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": false
}
},
"extends": ["eslint:recommended"],
"env": {
"es6": true,
"browser": true,
"node": true
},
"rules": {
"indent": ["error", 4, { "SwitchCase": 1 }]
}
}
113 changes: 63 additions & 50 deletions dist/Customers.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,77 @@
'use strict';
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;

var _ERRORS = require('./ERRORS');
var _ERRORS = _interopRequireDefault(require("./ERRORS"));

var _ERRORS2 = _interopRequireDefault(_ERRORS);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Customers = function Customers(sellsy) {
var _this = this;
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

var Customers = /*#__PURE__*/function () {
function Customers(sellsy) {
_classCallCheck(this, Customers);

this.udpate = this.create;
this.sellsy = sellsy;
}

_classCallCheck(this, Customers);
_createClass(Customers, [{
key: "create",
value: function create(data) {
var _this = this;

this.create = function (data) {
var method = data.clientid ? 'update' : 'create';
return _this.sellsy.api({
method: 'Client.' + method,
params: data
}).then(function (data) {
if (data.status === 'success') {
// fetch created customer data
return _this.sellsy.api({
method: 'Client.getOne',
params: {
clientid: data.response.client_id
}
}).then(function (data) {
return data.response.client;
});
}
throw new Error(_ERRORS2.default.CUSTOMER_CREATE_ERROR);
});
};
var method = data.clientid ? "update" : "create";
return this.sellsy.api({
method: "Client.".concat(method),
params: data
}).then(function (data) {
if (data.status === "success") {
// fetch created customer data
return _this.sellsy.api({
method: "Client.getOne",
params: {
clientid: data.response.client_id
}
}).then(function (data) {
return data.response.client;
});
}

this.get = function (search) {
return _this.sellsy.api({
method: 'Client.getList',
params: {
search: search
}
}).then(function (data) {
if (data.response.infos.nbtotal !== '0') {
// always return first result
var keys = Object.keys(data.response.result);
return data.response.result[keys[0]];
} else {
throw new Error(_ERRORS2.default.CUSTOMER_NOT_FOUND);
}
}).catch(function (e) {
throw new Error(_ERRORS2.default.CUSTOMER_NOT_FOUND);
});
};
throw new Error(_ERRORS["default"].CUSTOMER_CREATE_ERROR);
});
}
}, {
key: "get",
value: function get(search) {
return this.sellsy.api({
method: "Client.getList",
params: {
search: search
}
}).then(function (data) {
if (data.response.infos.nbtotal !== "0") {
// always return first result
var keys = Object.keys(data.response.result);
return data.response.result[keys[0]];
} else {
throw new Error(_ERRORS["default"].CUSTOMER_NOT_FOUND);
}
})["catch"](function () {
throw new Error(_ERRORS["default"].CUSTOMER_NOT_FOUND);
});
}
}]);

this.udpate = this.create;
this.sellsy = sellsy;
};
return Customers;
}();

exports.default = Customers;
var _default = Customers;
exports["default"] = _default;
82 changes: 41 additions & 41 deletions dist/Documents.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
'use strict';
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _ERRORS = _interopRequireDefault(require("./ERRORS"));

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var _ERRORS = require('./ERRORS');
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

var _ERRORS2 = _interopRequireDefault(_ERRORS);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

var DEFAULT_GET_LIST_PAGINATION = {
nbperpage: 100,
pagenum: 1
};

var DEFAULT_GET_LIST_ORDER = {
direction: 'ASC',
order: 'doc_displayedDate'
direction: "ASC",
order: "doc_displayedDate"
};

var Documents = function () {
var Documents = /*#__PURE__*/function () {
function Documents(sellsy) {
_classCallCheck(this, Documents);

this.sellsy = sellsy;
}

_createClass(Documents, [{
key: 'create',
key: "create",
value: function create(data) {
var _this = this;

var method = data.docid ? 'update' : 'create';
var method = data.docid ? "update" : "create";
return this.sellsy.api({
method: 'Document.' + method,
method: "Document.".concat(method),
params: data
}).then(function (result) {
if (result.status === 'success') {
if (result.status === "success") {
return _this.getById(data.document.doctype, result.response.doc_id);
}
throw new Error(_ERRORS2.default.DOCUMENT_CREATE_ERROR);
}).catch(function (e) {
console.log(e);

throw new Error(_ERRORS["default"].DOCUMENT_CREATE_ERROR);
})["catch"](function (e) {
throw new Error(e);
});
}
}, {
key: 'updateStep',
key: "updateStep",
value: function updateStep(docType, docId, step) {
return this.sellsy.api({
method: 'Document.updateStep',
method: "Document.updateStep",
params: {
document: {
doctype: docType,
Expand All @@ -66,54 +70,50 @@ var Documents = function () {
}
}).then(function (data) {
return data.response;
}).catch(function (e) {
console.log(e);
throw new Error(_ERRORS2.default.DOCUMENT_UPDATESTEP_ERROR);
})["catch"](function (e) {
throw new Error(_ERRORS["default"].DOCUMENT_UPDATESTEP_ERROR);
});
}
}, {
key: 'createPayment',
key: "createPayment",
value: function createPayment(docType, docId, paymentData) {
return this.sellsy.api({
method: 'Document.createPayment',
method: "Document.createPayment",
params: {
payment: _extends({
payment: _objectSpread({
doctype: docType,
docid: docId
}, paymentData)
}
}).then(function (data) {
return data.response;
}).catch(function (e) {
console.log(e);
throw new Error(_ERRORS2.default.DOCUMENT_CREATEPAYMENT_ERROR);
})["catch"](function (e) {
throw new Error(_ERRORS["default"].DOCUMENT_CREATEPAYMENT_ERROR);
});
}
}, {
key: 'getById',
key: "getById",
value: function getById(docType, docId) {
return this.sellsy.api({
method: 'Document.getOne',
method: "Document.getOne",
params: {
doctype: docType,
docid: docId
}
}).then(function (data) {
return data.response;
}).catch(function (e) {
console.log(e);
throw new Error(_ERRORS2.default.DOCUMENT_NOT_FOUND);
})["catch"](function (e) {
throw new Error(_ERRORS["default"].DOCUMENT_NOT_FOUND);
});
}
}, {
key: 'getList',
key: "getList",
value: function getList(docType, search) {
var pagination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_GET_LIST_PAGINATION;
var includePayments = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'N';
var includePayments = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "N";
var order = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : DEFAULT_GET_LIST_ORDER;

return this.sellsy.api({
method: 'Document.getList',
method: "Document.getList",
params: {
doctype: docType,
search: search,
Expand All @@ -123,14 +123,14 @@ var Documents = function () {
}
}).then(function (data) {
return data.response;
}).catch(function (e) {
console.log(e);
throw new Error(_ERRORS2.default.DOCUMENT_NOT_FOUND);
})["catch"](function (e) {
throw new Error(_ERRORS["default"].DOCUMENT_NOT_FOUND);
});
}
}]);

return Documents;
}();

exports.default = Documents;
var _default = Documents;
exports["default"] = _default;
21 changes: 11 additions & 10 deletions dist/ERRORS.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'use strict';
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var ERRORS = {
CUSTOMER_NOT_FOUND: 'CUSTOMER_NOT_FOUND',
CUSTOMERS_MULTIPLE_FOUND: 'CUSTOMERS_MULTIPLE_FOUND',
DOCUMENT_NOT_FOUND: 'DOCUMENT_NOT_FOUND',
DOCUMENT_CREATE_ERROR: 'DOCUMENT_CREATE_ERROR',
CUSTOMER_CREATE_ERROR: 'CUSTOMER_CREATE_ERROR',
DOCUMENT_UPDATESTEP_ERROR: 'DOCUMENT_UPDATESTEP_ERROR',
DOCUMENT_CREATEPAYMENT_ERROR: 'DOCUMENT_CREATEPAYMENT_ERROR'
CUSTOMER_NOT_FOUND: "CUSTOMER_NOT_FOUND",
CUSTOMERS_MULTIPLE_FOUND: "CUSTOMERS_MULTIPLE_FOUND",
DOCUMENT_NOT_FOUND: "DOCUMENT_NOT_FOUND",
DOCUMENT_CREATE_ERROR: "DOCUMENT_CREATE_ERROR",
CUSTOMER_CREATE_ERROR: "CUSTOMER_CREATE_ERROR",
DOCUMENT_UPDATESTEP_ERROR: "DOCUMENT_UPDATESTEP_ERROR",
DOCUMENT_CREATEPAYMENT_ERROR: "DOCUMENT_CREATEPAYMENT_ERROR"
};

exports.default = ERRORS;
var _default = ERRORS;
exports["default"] = _default;
Loading

0 comments on commit ccc1c86

Please sign in to comment.