Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0e81193
Showing
34 changed files
with
6,148 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"env" | ||
] | ||
} |
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,5 @@ | ||
.idea | ||
.vscode | ||
node_modules | ||
config.js | ||
yarn-error.log |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Robert Tajnšek | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,36 @@ | ||
# spaceinvoices-api-client | ||
|
||
### Instalation | ||
|
||
``` | ||
yarn | ||
``` | ||
OR | ||
``` | ||
npm i | ||
``` | ||
|
||
### Usage | ||
|
||
Include module | ||
```javascript | ||
import SpaceInvoices from "./spaceInvoices"; | ||
let spaceInvoices = new SpaceInvoices(${host}, ${accountId}, ${apiToken}); | ||
|
||
// List Organizations | ||
spaceInvoices.organization.list().then(organizations => { | ||
console.log("organizations", organizations); | ||
}).catch((err) => { | ||
console.error("ERROR", err); | ||
}); | ||
``` | ||
|
||
### Test | ||
|
||
``` | ||
yarn run test | ||
``` | ||
OR | ||
``` | ||
npm run test | ||
``` |
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,7 @@ | ||
export default { | ||
accountId: null, | ||
apiToken: null, | ||
host: null, | ||
email: null, | ||
password: null, | ||
}; |
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,89 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
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; }; }(); | ||
|
||
var _baseModel = require("./baseModel"); | ||
|
||
var _baseModel2 = _interopRequireDefault(_baseModel); | ||
|
||
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"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var Account = function (_BaseModel) { | ||
_inherits(Account, _BaseModel); | ||
|
||
function Account() { | ||
_classCallCheck(this, Account); | ||
|
||
return _possibleConstructorReturn(this, (Account.__proto__ || Object.getPrototypeOf(Account)).apply(this, arguments)); | ||
} | ||
|
||
_createClass(Account, null, [{ | ||
key: "get", | ||
|
||
/** | ||
* | ||
* @param {string} accountId | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
value: function get(accountId) { | ||
return this.call("/accounts/" + accountId); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} email | ||
* @param {string} password | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: "authenticate", | ||
value: function authenticate(email, password) { | ||
return this.call("/accounts/login", "POST", { email: email, password: password }); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} email | ||
* @param {string} password | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: "authenticate", | ||
value: function authenticate(email, password) { | ||
return this.call("/accounts", "POST", { email: email, password: password }); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} email | ||
* @returns {Promise<boolean>} | ||
*/ | ||
|
||
}, { | ||
key: "isEmailUnique", | ||
value: function isEmailUnique(email) { | ||
return this.call("/accounts/is-unique?email=" + email).then(function (data) { | ||
return data.isUnique; | ||
}); | ||
} | ||
}]); | ||
|
||
return Account; | ||
}(_baseModel2.default); | ||
|
||
exports.default = Account; |
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,40 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
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; }; }(); | ||
|
||
var _requestService = require("../requestService"); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var BaseModel = function () { | ||
function BaseModel() { | ||
_classCallCheck(this, BaseModel); | ||
} | ||
|
||
_createClass(BaseModel, null, [{ | ||
key: "call", | ||
|
||
/** | ||
* | ||
* @param {string} method | ||
* @param {string} endpoint | ||
* @param {object} data | ||
* | ||
* @returns {Promise<any>} | ||
*/ | ||
value: function call(endpoint) { | ||
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "GET"; | ||
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
|
||
return _requestService.rs.call(endpoint, method, data); | ||
} | ||
}]); | ||
|
||
return BaseModel; | ||
}(); | ||
|
||
exports.default = BaseModel; |
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,93 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
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; }; }(); | ||
|
||
var _baseModel = require("./baseModel"); | ||
|
||
var _baseModel2 = _interopRequireDefault(_baseModel); | ||
|
||
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"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var Client = function (_BaseModel) { | ||
_inherits(Client, _BaseModel); | ||
|
||
function Client() { | ||
_classCallCheck(this, Client); | ||
|
||
return _possibleConstructorReturn(this, (Client.__proto__ || Object.getPrototypeOf(Client)).apply(this, arguments)); | ||
} | ||
|
||
_createClass(Client, null, [{ | ||
key: "list", | ||
|
||
/** | ||
* | ||
* @returns {Promise<object[]>} | ||
*/ | ||
value: function list(organizationId) { | ||
return this.call("/organizations/" + organizationId + "/clients"); | ||
} | ||
|
||
/** | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: "get", | ||
value: function get(clientId) { | ||
return this.call("/clients/" + clientId); | ||
} | ||
|
||
/** | ||
* @param {object} data | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: "create", | ||
value: function create(organizationId, data) { | ||
return this.call("/organizations/" + organizationId + "/clients", "POST", data); | ||
} | ||
|
||
/** | ||
* @param {string} clientId | ||
* @param {object} data | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: "update", | ||
value: function update(clientId, data) { | ||
return this.call("/clients/" + clientId, "PUT", data); | ||
} | ||
|
||
/** | ||
* @param {string} clientId | ||
* | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
}, { | ||
key: "delete", | ||
value: function _delete(clientId) { | ||
return this.call("/clients/" + clientId, "DELETE"); | ||
} | ||
}]); | ||
|
||
return Client; | ||
}(_baseModel2.default); | ||
|
||
exports.default = Client; |
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,56 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
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; }; }(); | ||
|
||
var _baseModel = require("./baseModel"); | ||
|
||
var _baseModel2 = _interopRequireDefault(_baseModel); | ||
|
||
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"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
var Company = function (_BaseModel) { | ||
_inherits(Company, _BaseModel); | ||
|
||
function Company() { | ||
_classCallCheck(this, Company); | ||
|
||
return _possibleConstructorReturn(this, (Company.__proto__ || Object.getPrototypeOf(Company)).apply(this, arguments)); | ||
} | ||
|
||
_createClass(Company, null, [{ | ||
key: "list", | ||
|
||
/** | ||
* | ||
* @returns {Promise<object[]>} | ||
*/ | ||
value: function list(organizationId) { | ||
return this.call("/companies"); | ||
} | ||
|
||
/** | ||
* | ||
* @returns {Promise<object[]>} | ||
*/ | ||
|
||
}, { | ||
key: "search", | ||
value: function search(term) { | ||
return this.call("/companies/search?term=" + term); | ||
} | ||
}]); | ||
|
||
return Company; | ||
}(_baseModel2.default); | ||
|
||
exports.default = Company; |
Oops, something went wrong.