starta.apiclient 1.0.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.
Files changed (49) hide show
  1. package/lib/factory.d.ts +4 -0
  2. package/lib/factory.js +8 -0
  3. package/lib/index.d.ts +5 -0
  4. package/lib/index.js +7 -0
  5. package/lib/request.d.ts +3 -0
  6. package/lib/request.js +60 -0
  7. package/lib/services/_helpers.d.ts +1 -0
  8. package/lib/services/_helpers.js +26 -0
  9. package/lib/services/accounts.d.ts +61 -0
  10. package/lib/services/accounts.js +163 -0
  11. package/lib/services/emailConfirmations.d.ts +7 -0
  12. package/lib/services/emailConfirmations.js +24 -0
  13. package/lib/services/healthcheck.d.ts +6 -0
  14. package/lib/services/healthcheck.js +15 -0
  15. package/lib/services/index.d.ts +21 -0
  16. package/lib/services/index.js +73 -0
  17. package/lib/services/organizations/customers.d.ts +47 -0
  18. package/lib/services/organizations/customers.js +87 -0
  19. package/lib/services/organizations/dashboard.d.ts +11 -0
  20. package/lib/services/organizations/dashboard.js +28 -0
  21. package/lib/services/organizations/index.d.ts +74 -0
  22. package/lib/services/organizations/index.js +222 -0
  23. package/lib/services/organizations/integrations.d.ts +10 -0
  24. package/lib/services/organizations/integrations.js +17 -0
  25. package/lib/services/organizations/members.d.ts +6 -0
  26. package/lib/services/organizations/members.js +16 -0
  27. package/lib/services/organizations/orders.d.ts +45 -0
  28. package/lib/services/organizations/orders.js +74 -0
  29. package/lib/services/organizations/payments.d.ts +16 -0
  30. package/lib/services/organizations/payments.js +33 -0
  31. package/lib/services/organizations/public.d.ts +14 -0
  32. package/lib/services/organizations/public.js +41 -0
  33. package/lib/services/organizations/rooms.d.ts +17 -0
  34. package/lib/services/organizations/rooms.js +45 -0
  35. package/lib/services/organizations/seminars.d.ts +38 -0
  36. package/lib/services/organizations/seminars.js +67 -0
  37. package/lib/services/organizations/services.d.ts +22 -0
  38. package/lib/services/organizations/services.js +31 -0
  39. package/lib/services/passwordResets.d.ts +15 -0
  40. package/lib/services/passwordResets.js +25 -0
  41. package/lib/services/sessions.d.ts +17 -0
  42. package/lib/services/sessions.js +37 -0
  43. package/lib/services/system.d.ts +6 -0
  44. package/lib/services/system.js +20 -0
  45. package/lib/services/webhooks.d.ts +6 -0
  46. package/lib/services/webhooks.js +21 -0
  47. package/lib/types.d.ts +25 -0
  48. package/lib/types.js +2 -0
  49. package/package.json +26 -0
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Rooms = /** @class */ (function () {
4
+ function Rooms(request) {
5
+ this._request = request;
6
+ }
7
+ Rooms.prototype.add = function (organizationLogin, _a) {
8
+ var name = _a.name, pricePerHour = _a.pricePerHour, description = _a.description;
9
+ return this._request({
10
+ url: "accounts/".concat(organizationLogin, "/rooms"),
11
+ method: 'POST',
12
+ body: {
13
+ name: name,
14
+ pricePerHour: pricePerHour,
15
+ description: description,
16
+ },
17
+ });
18
+ };
19
+ Rooms.prototype.update = function (organizationLogin, roomId, _a) {
20
+ var name = _a.name, pricePerHour = _a.pricePerHour, description = _a.description;
21
+ return this._request({
22
+ url: "accounts/".concat(organizationLogin, "/rooms/").concat(roomId),
23
+ method: 'PUT',
24
+ body: {
25
+ name: name,
26
+ pricePerHour: pricePerHour,
27
+ description: description,
28
+ },
29
+ });
30
+ };
31
+ Rooms.prototype.delete = function (organizationLogin, roomId) {
32
+ return this._request({
33
+ url: "accounts/".concat(organizationLogin, "/rooms/").concat(roomId),
34
+ method: 'DELETE',
35
+ });
36
+ };
37
+ Rooms.prototype.getSchedule = function (organizationLogin, date /* YYYY-MM-DD */) {
38
+ return this._request({
39
+ url: "accounts/".concat(organizationLogin, "/rooms/schedule/").concat(date),
40
+ method: 'GET',
41
+ });
42
+ };
43
+ return Rooms;
44
+ }());
45
+ exports.default = Rooms;
@@ -0,0 +1,38 @@
1
+ import { StartaRequest } from '../../types';
2
+ export default class Services {
3
+ private _request;
4
+ constructor(request: StartaRequest);
5
+ index(organizationLogin: any, { from, to, status }?: {
6
+ from?: string;
7
+ to?: string;
8
+ status?: string;
9
+ }): Promise<import("../../types").StartaResponse>;
10
+ get(organizationLogin: any, seminarId: any): Promise<import("../../types").StartaResponse>;
11
+ add(organizationLogin: any, { name, starttime, endtime, experts, price, description, status, location: { online, description: locationDescription }, }: {
12
+ name: any;
13
+ starttime: any;
14
+ endtime: any;
15
+ experts?: never[] | undefined;
16
+ price: any;
17
+ description: any;
18
+ status?: string | undefined;
19
+ location?: {
20
+ online: null;
21
+ description: null;
22
+ } | undefined;
23
+ }): Promise<import("../../types").StartaResponse>;
24
+ update(organizationLogin: any, seminarId: any, { name, starttime, endtime, experts, price, description, status, location: { online, description: locationDescription }, }: {
25
+ name: any;
26
+ starttime: any;
27
+ endtime: any;
28
+ experts?: never[] | undefined;
29
+ price: any;
30
+ description: any;
31
+ status?: string | undefined;
32
+ location: {
33
+ online: any;
34
+ description: any;
35
+ };
36
+ }): Promise<import("../../types").StartaResponse>;
37
+ delete(organizationLogin: any, seminarId: any): Promise<import("../../types").StartaResponse>;
38
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _helpers_1 = require("../_helpers");
4
+ var Services = /** @class */ (function () {
5
+ function Services(request) {
6
+ this._request = request;
7
+ }
8
+ Services.prototype.index = function (organizationLogin, _a) {
9
+ var _b = _a === void 0 ? {} : _a, from = _b.from, to = _b.to, status = _b.status;
10
+ return this._request({
11
+ url: "accounts/".concat(organizationLogin, "/seminars").concat((0, _helpers_1.buildQuery)({
12
+ from: from,
13
+ to: to,
14
+ status: status,
15
+ })),
16
+ method: 'GET',
17
+ });
18
+ };
19
+ Services.prototype.get = function (organizationLogin, seminarId) {
20
+ return this._request({
21
+ url: "accounts/".concat(organizationLogin, "/seminars/").concat(seminarId),
22
+ method: 'GET',
23
+ });
24
+ };
25
+ Services.prototype.add = function (organizationLogin, _a) {
26
+ var name = _a.name, starttime = _a.starttime, endtime = _a.endtime, _b = _a.experts, experts = _b === void 0 ? [] : _b, price = _a.price, description = _a.description, _c = _a.status, status = _c === void 0 ? 'new' : _c, _d = _a.location, _e = _d === void 0 ? { online: null, description: null } : _d, online = _e.online, locationDescription = _e.description;
27
+ return this._request({
28
+ url: "accounts/".concat(organizationLogin, "/seminars"),
29
+ method: 'POST',
30
+ body: {
31
+ name: name,
32
+ starttime: starttime,
33
+ endtime: endtime,
34
+ experts: experts,
35
+ price: price,
36
+ description: description,
37
+ status: status,
38
+ location: { online: online, description: locationDescription },
39
+ },
40
+ });
41
+ };
42
+ Services.prototype.update = function (organizationLogin, seminarId, _a) {
43
+ var name = _a.name, starttime = _a.starttime, endtime = _a.endtime, _b = _a.experts, experts = _b === void 0 ? [] : _b, price = _a.price, description = _a.description, _c = _a.status, status = _c === void 0 ? 'new' : _c, _d = _a.location, online = _d.online, locationDescription = _d.description;
44
+ return this._request({
45
+ url: "accounts/".concat(organizationLogin, "/seminars/").concat(seminarId),
46
+ method: 'PUT',
47
+ body: {
48
+ name: name,
49
+ starttime: starttime,
50
+ endtime: endtime,
51
+ experts: experts,
52
+ price: price,
53
+ description: description,
54
+ status: status,
55
+ location: { online: online, description: locationDescription },
56
+ },
57
+ });
58
+ };
59
+ Services.prototype.delete = function (organizationLogin, seminarId) {
60
+ return this._request({
61
+ url: "accounts/".concat(organizationLogin, "/seminars/").concat(seminarId),
62
+ method: 'DELETE',
63
+ });
64
+ };
65
+ return Services;
66
+ }());
67
+ exports.default = Services;
@@ -0,0 +1,22 @@
1
+ import { StartaRequest } from '../../types';
2
+ export default class Services {
3
+ private _request;
4
+ constructor(request: StartaRequest);
5
+ add(organizationLogin: any, { name, image, price, duration, executors, translations }: {
6
+ name: any;
7
+ image: any;
8
+ price: any;
9
+ duration: any;
10
+ executors: any;
11
+ translations: any;
12
+ }): Promise<import("../../types").StartaResponse>;
13
+ update(organizationLogin: any, serviceId: any, { name, image, price, duration, executors, translations }: {
14
+ name: any;
15
+ image: any;
16
+ price: any;
17
+ duration: any;
18
+ executors: any;
19
+ translations: any;
20
+ }): Promise<import("../../types").StartaResponse>;
21
+ delete(organizationLogin: any, serviceId: any): Promise<import("../../types").StartaResponse>;
22
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Services = /** @class */ (function () {
4
+ function Services(request) {
5
+ this._request = request;
6
+ }
7
+ Services.prototype.add = function (organizationLogin, _a) {
8
+ var name = _a.name, image = _a.image, price = _a.price, duration = _a.duration, executors = _a.executors, translations = _a.translations;
9
+ return this._request({
10
+ url: "accounts/".concat(organizationLogin, "/services"),
11
+ method: 'POST',
12
+ body: { name: name, image: image, price: price, duration: duration, executors: executors, translations: translations },
13
+ });
14
+ };
15
+ Services.prototype.update = function (organizationLogin, serviceId, _a) {
16
+ var name = _a.name, image = _a.image, price = _a.price, duration = _a.duration, executors = _a.executors, translations = _a.translations;
17
+ return this._request({
18
+ url: "accounts/".concat(organizationLogin, "/services/").concat(serviceId),
19
+ method: 'PUT',
20
+ body: { name: name, image: image, price: price, duration: duration, executors: executors, translations: translations },
21
+ });
22
+ };
23
+ Services.prototype.delete = function (organizationLogin, serviceId) {
24
+ return this._request({
25
+ url: "accounts/".concat(organizationLogin, "/services/").concat(serviceId),
26
+ method: 'DELETE',
27
+ });
28
+ };
29
+ return Services;
30
+ }());
31
+ exports.default = Services;
@@ -0,0 +1,15 @@
1
+ import { StartaRequest } from '../types';
2
+ export default class EmailConfirmations {
3
+ private _request;
4
+ constructor(request: StartaRequest);
5
+ create({ email, recaptchaToken }: {
6
+ email: any;
7
+ recaptchaToken: any;
8
+ }): Promise<import("../types").StartaResponse>;
9
+ setPassword({ token, password, passwordConfirm, recaptchaToken }: {
10
+ token: any;
11
+ password: any;
12
+ passwordConfirm: any;
13
+ recaptchaToken: any;
14
+ }): Promise<import("../types").StartaResponse>;
15
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var EmailConfirmations = /** @class */ (function () {
4
+ function EmailConfirmations(request) {
5
+ this._request = request;
6
+ }
7
+ EmailConfirmations.prototype.create = function (_a) {
8
+ var email = _a.email, recaptchaToken = _a.recaptchaToken;
9
+ return this._request({
10
+ url: "passwordResets",
11
+ method: 'POST',
12
+ body: { email: email, recaptchaToken: recaptchaToken },
13
+ });
14
+ };
15
+ EmailConfirmations.prototype.setPassword = function (_a) {
16
+ var token = _a.token, password = _a.password, passwordConfirm = _a.passwordConfirm, recaptchaToken = _a.recaptchaToken;
17
+ return this._request({
18
+ url: "passwordResets/".concat(token),
19
+ method: 'PUT',
20
+ body: { password: password, passwordConfirm: passwordConfirm, recaptchaToken: recaptchaToken },
21
+ });
22
+ };
23
+ return EmailConfirmations;
24
+ }());
25
+ exports.default = EmailConfirmations;
@@ -0,0 +1,17 @@
1
+ import { StartaRequest } from '../types';
2
+ export default class Sessions {
3
+ private _request;
4
+ constructor(request: StartaRequest);
5
+ current(): Promise<import("../types").StartaResponse>;
6
+ create({ login, password, authMethod, recaptchaToken }: {
7
+ login: any;
8
+ password: any;
9
+ authMethod?: string | undefined;
10
+ recaptchaToken: any;
11
+ }): Promise<import("../types").StartaResponse>;
12
+ createSocial({ token, sn }: {
13
+ token: any;
14
+ sn: any;
15
+ }): Promise<import("../types").StartaResponse>;
16
+ delete(): Promise<import("../types").StartaResponse>;
17
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Sessions = /** @class */ (function () {
4
+ function Sessions(request) {
5
+ this._request = request;
6
+ }
7
+ Sessions.prototype.current = function () {
8
+ return this._request({
9
+ url: "sessions/current",
10
+ method: 'GET',
11
+ });
12
+ };
13
+ Sessions.prototype.create = function (_a) {
14
+ var login = _a.login, password = _a.password, _b = _a.authMethod, authMethod = _b === void 0 ? 'cookie' : _b, recaptchaToken = _a.recaptchaToken;
15
+ return this._request({
16
+ url: "sessions",
17
+ method: 'POST',
18
+ body: { login: login, password: password, authMethod: authMethod, recaptchaToken: recaptchaToken },
19
+ });
20
+ };
21
+ Sessions.prototype.createSocial = function (_a) {
22
+ var token = _a.token, sn = _a.sn;
23
+ return this._request({
24
+ url: "sessions/social",
25
+ method: 'POST',
26
+ body: { token: token, sn: sn },
27
+ });
28
+ };
29
+ Sessions.prototype.delete = function () {
30
+ return this._request({
31
+ url: "sessions/current",
32
+ method: 'DELETE',
33
+ });
34
+ };
35
+ return Sessions;
36
+ }());
37
+ exports.default = Sessions;
@@ -0,0 +1,6 @@
1
+ import { StartaRequest } from '../types';
2
+ export default class EmailConfirmations {
3
+ private _request;
4
+ constructor(request: StartaRequest);
5
+ configjs(): Promise<import("../types").StartaResponse>;
6
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var EmailConfirmations = /** @class */ (function () {
4
+ function EmailConfirmations(request) {
5
+ this._request = request;
6
+ }
7
+ EmailConfirmations.prototype.configjs = function () {
8
+ return this._request({
9
+ url: "config.js",
10
+ method: 'GET',
11
+ config: {
12
+ rewriteBaseUrl: function (url) {
13
+ return url.replace('/api', '/');
14
+ },
15
+ },
16
+ });
17
+ };
18
+ return EmailConfirmations;
19
+ }());
20
+ exports.default = EmailConfirmations;
@@ -0,0 +1,6 @@
1
+ import { StartaRequest } from '../types';
2
+ export default class EmailConfirmations {
3
+ private _request;
4
+ constructor(request: StartaRequest);
5
+ stripe(body: any, signature: string): Promise<import("../types").StartaResponse>;
6
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var EmailConfirmations = /** @class */ (function () {
4
+ function EmailConfirmations(request) {
5
+ this._request = request;
6
+ }
7
+ EmailConfirmations.prototype.stripe = function (body, signature) {
8
+ return this._request({
9
+ url: "webhooks/stripe",
10
+ method: 'POST',
11
+ body: body,
12
+ config: {
13
+ headers: {
14
+ 'stripe-signature': signature,
15
+ },
16
+ },
17
+ });
18
+ };
19
+ return EmailConfirmations;
20
+ }());
21
+ exports.default = EmailConfirmations;
package/lib/types.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
2
+ declare type StartaRequest = (requestData: StartaRequestData) => Promise<StartaResponse>;
3
+ declare type StartaRequestData = {
4
+ url: string;
5
+ method: Method;
6
+ body?: any;
7
+ urlParams?: any;
8
+ config?: StartaRequestConfig;
9
+ };
10
+ declare type StartaResponse = {
11
+ httpResponse?: AxiosResponse<any, any>;
12
+ success: boolean;
13
+ data: any;
14
+ axiosError?: AxiosError;
15
+ };
16
+ interface StartaRequestConfig extends AxiosRequestConfig {
17
+ rewriteBaseUrl?: (baseUrl: string) => string;
18
+ }
19
+ declare type StartaRequestMiddlewares = {
20
+ onForbidden?: (response: StartaResponse) => void;
21
+ onUnauthorized?: (response: StartaResponse) => void;
22
+ logger?: (...args: any[]) => void;
23
+ cookieFactory?: () => string | null;
24
+ };
25
+ export { StartaRequestData, StartaRequest, StartaResponse, StartaRequestConfig, StartaRequestMiddlewares };
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "starta.apiclient",
3
+ "version": "1.0.0",
4
+ "main": "./lib/index.js",
5
+ "description": "Wrapper for starta.one api",
6
+ "author": "Collaboracia OÜ",
7
+ "license": "ISC",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
11
+ "lint": "tslint -p tsconfig.json",
12
+ "prepare": "npm run build"
13
+ },
14
+ "files": [
15
+ "lib/**/*"
16
+ ],
17
+ "dependencies": {
18
+ "axios": "^0.25.0"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "^4.0.2",
22
+ "prettier": "^2.5.1",
23
+ "tslint": "^6.1.3",
24
+ "tslint-config-prettier": "^1.18.0"
25
+ }
26
+ }