-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conf upgrade + remove console.log
- Loading branch information
Showing
16 changed files
with
10,641 additions
and
4,421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/**/* | ||
dist/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.