merchi_sdk_js 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/address.js +109 -0
- package/dist/assignment.js +175 -0
- package/dist/automatic_payment_relationship.js +72 -0
- package/dist/backup.js +32 -0
- package/dist/bank.js +25 -0
- package/dist/cart.js +133 -0
- package/dist/cart_item.js +71 -0
- package/dist/cart_shipment_group.js +23 -0
- package/dist/cart_shipment_quote.js +26 -0
- package/dist/category.js +68 -0
- package/dist/company.js +248 -0
- package/dist/company_invitation.js +70 -0
- package/dist/component.js +107 -0
- package/dist/component_tag.js +60 -0
- package/dist/component_version.js +21 -0
- package/dist/country_tax.js +93 -0
- package/dist/dictionary.js +130 -0
- package/dist/discount.js +22 -0
- package/dist/discount_group.js +18 -0
- package/dist/domain.js +245 -0
- package/dist/domain_invitation.js +17 -0
- package/dist/domain_tag.js +87 -0
- package/dist/domain_types.js +22 -0
- package/dist/draft.js +97 -0
- package/dist/draft_comment.js +45 -0
- package/dist/draft_template.js +39 -0
- package/dist/email_address.js +34 -0
- package/dist/email_counter.js +47 -0
- package/dist/enrolled_domain.js +88 -0
- package/dist/exchange_rate.js +66 -0
- package/dist/field_types.js +19 -0
- package/dist/helpers.js +86 -0
- package/dist/internal_tag.js +98 -0
- package/dist/inventory.js +100 -0
- package/dist/inventory_unit_variation.js +19 -0
- package/dist/invoice.js +225 -0
- package/dist/invoice_types.js +11 -0
- package/dist/item.js +25 -0
- package/dist/job.js +536 -0
- package/dist/job_comment.js +45 -0
- package/dist/job_status.js +47 -0
- package/dist/matching_inventory.js +21 -0
- package/dist/md5.js +149 -0
- package/dist/menu.js +37 -0
- package/dist/menu_item.js +24 -0
- package/dist/merchi.js +1004 -0
- package/dist/merchi_file.js +165 -0
- package/dist/model.js +753 -0
- package/dist/notification.js +151 -0
- package/dist/notification_types.js +199 -0
- package/dist/output.cjs.js +31317 -0
- package/dist/output.esm.js +31312 -0
- package/dist/page.js +41 -0
- package/dist/payment.js +32 -0
- package/dist/payment_device.js +21 -0
- package/dist/payment_types.js +20 -0
- package/dist/phone_number.js +37 -0
- package/dist/product.js +288 -0
- package/dist/product_types.js +32 -0
- package/dist/production_comment.js +44 -0
- package/dist/quote.js +91 -0
- package/dist/quote_item.js +59 -0
- package/dist/roles.js +29 -0
- package/dist/seo_domain_page.js +42 -0
- package/dist/session.js +103 -0
- package/dist/set.js +29 -0
- package/dist/shipment.js +181 -0
- package/dist/shipment_item.js +17 -0
- package/dist/shipment_item_fulfillment.js +17 -0
- package/dist/shipment_method.js +81 -0
- package/dist/shipment_method_variation.js +38 -0
- package/dist/subscription_plan.js +75 -0
- package/dist/supply_domain.js +65 -0
- package/dist/system_role.js +12 -0
- package/dist/theme.js +180 -0
- package/dist/theme_css_setting.js +61 -0
- package/dist/theme_status.js +11 -0
- package/dist/user.js +409 -0
- package/dist/user_company.js +19 -0
- package/dist/user_types.js +23 -0
- package/dist/uuid.js +12 -0
- package/dist/variation.js +233 -0
- package/dist/variation_field.js +233 -0
- package/dist/variation_fields_option.js +41 -0
- package/dist/variation_option.js +62 -0
- package/dist/variations_group.js +43 -0
- package/dist/white_label_accessibilities.js +11 -0
- package/package.json +30 -0
- package/src/address.js +107 -0
- package/src/assignment.js +165 -0
- package/src/automatic_payment_relationship.js +65 -0
- package/src/backup.js +29 -0
- package/src/bank.js +21 -0
- package/src/cart.js +131 -0
- package/src/cart_item.js +71 -0
- package/src/cart_shipment_group.js +20 -0
- package/src/cart_shipment_quote.js +23 -0
- package/src/category.js +62 -0
- package/src/company.js +267 -0
- package/src/company_invitation.js +63 -0
- package/src/component.js +100 -0
- package/src/component_tag.js +53 -0
- package/src/component_version.js +17 -0
- package/src/country_tax.js +89 -0
- package/src/dictionary.js +135 -0
- package/src/discount.js +19 -0
- package/src/discount_group.js +15 -0
- package/src/domain.js +254 -0
- package/src/domain_invitation.js +13 -0
- package/src/domain_tag.js +79 -0
- package/src/domain_types.js +18 -0
- package/src/draft.js +92 -0
- package/src/draft_comment.js +41 -0
- package/src/draft_template.js +35 -0
- package/src/email_address.js +27 -0
- package/src/email_counter.js +42 -0
- package/src/enrolled_domain.js +79 -0
- package/src/exchange_rate.js +61 -0
- package/src/field_types.js +15 -0
- package/src/helpers.js +81 -0
- package/src/internal_tag.js +90 -0
- package/src/inventory.js +99 -0
- package/src/inventory_unit_variation.js +18 -0
- package/src/invoice.js +224 -0
- package/src/invoice_types.js +7 -0
- package/src/item.js +22 -0
- package/src/job.js +616 -0
- package/src/job_comment.js +41 -0
- package/src/job_status.js +51 -0
- package/src/matching_inventory.js +17 -0
- package/src/md5.js +162 -0
- package/src/menu.js +32 -0
- package/src/menu_item.js +22 -0
- package/src/merchi.js +1074 -0
- package/src/merchi_file.js +163 -0
- package/src/model.js +820 -0
- package/src/notification.js +153 -0
- package/src/notification_types.js +246 -0
- package/src/page.js +38 -0
- package/src/payment.js +32 -0
- package/src/payment_device.js +17 -0
- package/src/payment_types.js +18 -0
- package/src/phone_number.js +30 -0
- package/src/product.js +309 -0
- package/src/product_types.js +28 -0
- package/src/production_comment.js +40 -0
- package/src/quote.js +89 -0
- package/src/quote_item.js +51 -0
- package/src/roles.js +27 -0
- package/src/seo_domain_page.js +35 -0
- package/src/session.js +102 -0
- package/src/set.js +28 -0
- package/src/shipment.js +191 -0
- package/src/shipment_item.js +13 -0
- package/src/shipment_item_fulfillment.js +13 -0
- package/src/shipment_method.js +73 -0
- package/src/shipment_method_variation.js +34 -0
- package/src/subscription_plan.js +68 -0
- package/src/supply_domain.js +60 -0
- package/src/system_role.js +8 -0
- package/src/theme.js +188 -0
- package/src/theme_css_setting.js +54 -0
- package/src/theme_status.js +6 -0
- package/src/user.js +442 -0
- package/src/user_company.js +15 -0
- package/src/user_types.js +19 -0
- package/src/uuid.js +3 -0
- package/src/variation.js +257 -0
- package/src/variation_field.js +261 -0
- package/src/variation_fields_option.js +41 -0
- package/src/variation_option.js +59 -0
- package/src/variations_group.js +43 -0
- package/src/white_label_accessibilities.js +6 -0
package/dist/address.js
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Address = Address;
|
7
|
+
exports.Addresses = Addresses;
|
8
|
+
var _uuid = require("./uuid.js");
|
9
|
+
var _model = require("./model.js");
|
10
|
+
var _helpers = require("./helpers.js");
|
11
|
+
var _dictionary = require("./dictionary.js");
|
12
|
+
function Address() {
|
13
|
+
this.resource = '/addresses';
|
14
|
+
this.json = 'address';
|
15
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
16
|
+
(0, _model.addPropertyTo)(this, 'id');
|
17
|
+
(0, _model.addPropertyTo)(this, 'lineOne');
|
18
|
+
(0, _model.addPropertyTo)(this, 'lineTwo');
|
19
|
+
(0, _model.addPropertyTo)(this, 'city');
|
20
|
+
(0, _model.addPropertyTo)(this, 'state');
|
21
|
+
(0, _model.addPropertyTo)(this, 'country');
|
22
|
+
(0, _model.addPropertyTo)(this, 'postcode');
|
23
|
+
this.get = function (success, error) {
|
24
|
+
var self = this;
|
25
|
+
function handleResponse(result) {
|
26
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
27
|
+
makesDirty: false
|
28
|
+
}));
|
29
|
+
}
|
30
|
+
(0, _model.getOne)({
|
31
|
+
resource: this.resource,
|
32
|
+
id: this.id(),
|
33
|
+
success: handleResponse,
|
34
|
+
error: error
|
35
|
+
});
|
36
|
+
};
|
37
|
+
this.fullAddressString = function () {
|
38
|
+
var self = this,
|
39
|
+
a = '',
|
40
|
+
space = ' ',
|
41
|
+
noSpace = '';
|
42
|
+
function attributeHasValue(attr, before, after) {
|
43
|
+
var value = self[attr]();
|
44
|
+
return !(0, _helpers.isUndefinedOrNull)(value) ? before + value + after : '';
|
45
|
+
}
|
46
|
+
a = attributeHasValue('lineOne', noSpace, noSpace);
|
47
|
+
a += attributeHasValue('lineTwo', space, ',');
|
48
|
+
a += attributeHasValue('city', space, space);
|
49
|
+
a += attributeHasValue('state', noSpace, space);
|
50
|
+
a += attributeHasValue('postcode', noSpace, space);
|
51
|
+
a += attributeHasValue('country', noSpace, noSpace);
|
52
|
+
return a;
|
53
|
+
};
|
54
|
+
this.stateAndCountryString = function () {
|
55
|
+
var addressString = '';
|
56
|
+
addressString += this.state() + " ";
|
57
|
+
addressString += this.country();
|
58
|
+
return addressString;
|
59
|
+
};
|
60
|
+
this.cityStateCountryPostcode = function () {
|
61
|
+
return this.city() + " " + this.stateAndCountryString() + ", " + this.postcode();
|
62
|
+
};
|
63
|
+
this.isValid = function () {
|
64
|
+
return Boolean(this.lineOne() && this.city() && this.state() && this.country());
|
65
|
+
};
|
66
|
+
}
|
67
|
+
function Addresses() {
|
68
|
+
this.resource = '/addresses';
|
69
|
+
this.json = 'addresses';
|
70
|
+
this.single = Address;
|
71
|
+
this.getRelated = function (options) {
|
72
|
+
var request = new _model.Request(),
|
73
|
+
query = new _dictionary.Dictionary(),
|
74
|
+
self = this,
|
75
|
+
success = options.success,
|
76
|
+
error = options.error,
|
77
|
+
userId = options.userId,
|
78
|
+
companyId = options.companyId,
|
79
|
+
jobId = options.jobId;
|
80
|
+
if (userId) {
|
81
|
+
query.add('user_id', userId);
|
82
|
+
}
|
83
|
+
if (companyId) {
|
84
|
+
query.add('company_id', companyId);
|
85
|
+
}
|
86
|
+
if (jobId) {
|
87
|
+
query.add('job_id', jobId);
|
88
|
+
}
|
89
|
+
request.resource('/related-addresses/');
|
90
|
+
request.method('GET');
|
91
|
+
request.query().merge(query);
|
92
|
+
function handleResponse(status, data) {
|
93
|
+
if (status === 200) {
|
94
|
+
success((0, _model.fromJsonList)(self, data));
|
95
|
+
} else {
|
96
|
+
error(data);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
function handleError(status, data) {
|
100
|
+
var responseData = data ? data : {
|
101
|
+
message: 'could not connect to server',
|
102
|
+
errorCode: 0
|
103
|
+
};
|
104
|
+
error(status, responseData);
|
105
|
+
}
|
106
|
+
request.responseHandler(handleResponse).errorHandler(handleError);
|
107
|
+
request.send();
|
108
|
+
};
|
109
|
+
}
|
@@ -0,0 +1,175 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Assignment = Assignment;
|
7
|
+
exports.Assignments = Assignments;
|
8
|
+
var _uuid = require("./uuid.js");
|
9
|
+
var _model = require("./model.js");
|
10
|
+
var _notification_types = require("./notification_types.js");
|
11
|
+
var _job = require("./job.js");
|
12
|
+
var _user = require("./user.js");
|
13
|
+
var _notification = require("./notification.js");
|
14
|
+
var _quote = require("./quote.js");
|
15
|
+
var _shipment = require("./shipment.js");
|
16
|
+
var _supply_domain = require("./supply_domain.js");
|
17
|
+
var _production_comment = require("./production_comment.js");
|
18
|
+
function Assignment() {
|
19
|
+
this.resource = '/assignments';
|
20
|
+
this.json = 'assignment';
|
21
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
22
|
+
(0, _model.addPropertyTo)(this, 'id');
|
23
|
+
(0, _model.addPropertyTo)(this, 'managerAccepts');
|
24
|
+
(0, _model.addPropertyTo)(this, 'supplierRefused');
|
25
|
+
(0, _model.addPropertyTo)(this, 'productionDeadline');
|
26
|
+
(0, _model.addPropertyTo)(this, 'assignmentDeadline');
|
27
|
+
(0, _model.addPropertyTo)(this, 'needsDrafting');
|
28
|
+
(0, _model.addPropertyTo)(this, 'needsShipping');
|
29
|
+
(0, _model.addPropertyTo)(this, 'archived');
|
30
|
+
(0, _model.addPropertyTo)(this, 'job', _job.Job);
|
31
|
+
(0, _model.addPropertyTo)(this, 'supplyJob', _job.Job);
|
32
|
+
(0, _model.addPropertyTo)(this, 'supplier', _user.User);
|
33
|
+
(0, _model.addPropertyTo)(this, 'quote', _quote.Quote);
|
34
|
+
(0, _model.addPropertyTo)(this, 'shipment', _shipment.Shipment);
|
35
|
+
(0, _model.addPropertyTo)(this, 'supplyDomain', _supply_domain.SupplyDomain);
|
36
|
+
(0, _model.addPropertyTo)(this, 'comments', _production_comment.ProductionComment);
|
37
|
+
(0, _model.addPropertyTo)(this, 'notifications', _notification.Notification);
|
38
|
+
this.get = function (success, error, embed) {
|
39
|
+
var self = this;
|
40
|
+
function handleResponse(result) {
|
41
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
42
|
+
makesDirty: false
|
43
|
+
}));
|
44
|
+
}
|
45
|
+
(0, _model.getOne)({
|
46
|
+
resource: this.resource,
|
47
|
+
id: this.id(),
|
48
|
+
success: handleResponse,
|
49
|
+
error: error,
|
50
|
+
embed: embed
|
51
|
+
});
|
52
|
+
};
|
53
|
+
this.agreedDeadline = function () {
|
54
|
+
var self = this,
|
55
|
+
quote = self.quote();
|
56
|
+
if (Boolean(quote)) {
|
57
|
+
return quote.agreedDeadline();
|
58
|
+
}
|
59
|
+
return null;
|
60
|
+
};
|
61
|
+
this.create = function (success, error, embed, asDomainId) {
|
62
|
+
var data = (0, _model.serialise)(this),
|
63
|
+
self = this;
|
64
|
+
function handleResponse(result) {
|
65
|
+
success((0, _model.fromJson)(self, result[self.json]));
|
66
|
+
}
|
67
|
+
(0, _model.create)({
|
68
|
+
resource: this.resource,
|
69
|
+
parameters: data[0],
|
70
|
+
as_domain: asDomainId,
|
71
|
+
files: (0, _model.enumerateFiles)(data[1]),
|
72
|
+
success: handleResponse,
|
73
|
+
error: error,
|
74
|
+
embed: embed
|
75
|
+
});
|
76
|
+
};
|
77
|
+
this.patch = function (success, error, embed, asDomain) {
|
78
|
+
var self = this,
|
79
|
+
data = (0, _model.serialise)(this, undefined, undefined, undefined, {
|
80
|
+
excludeOld: true
|
81
|
+
})[0],
|
82
|
+
domainId = Boolean(asDomain) ? asDomain.id() : null;
|
83
|
+
function handleResponse(result) {
|
84
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
85
|
+
makesDirty: false
|
86
|
+
}));
|
87
|
+
}
|
88
|
+
(0, _model.patchOne)({
|
89
|
+
resource: this.resource,
|
90
|
+
id: this.id(),
|
91
|
+
success: handleResponse,
|
92
|
+
error: error,
|
93
|
+
as_domain: domainId,
|
94
|
+
data: data,
|
95
|
+
embed: embed
|
96
|
+
});
|
97
|
+
};
|
98
|
+
this.setManagerAccepts = function () {
|
99
|
+
var acceptDate = Date.now();
|
100
|
+
this.managerAccepts(acceptDate / 1000);
|
101
|
+
};
|
102
|
+
this.agreedDeadline = function () {
|
103
|
+
var self = this,
|
104
|
+
quote = self.quote();
|
105
|
+
if (Boolean(quote) && Boolean(quote.agreedDeadline())) {
|
106
|
+
return quote.agreedDeadline();
|
107
|
+
}
|
108
|
+
return null;
|
109
|
+
};
|
110
|
+
this.unseenNotifications = function (currentUser) {
|
111
|
+
var notifications = (0, _notification_types.notificationRecieverIsCurrentUserFilter)(currentUser, this.notifications());
|
112
|
+
return (0, _notification_types.notificationsFilter)(notifications, [{
|
113
|
+
'seen': false
|
114
|
+
}]);
|
115
|
+
};
|
116
|
+
this.unseenNotificationCount = function (currentUser) {
|
117
|
+
return this.unseenNotifications(currentUser).length;
|
118
|
+
};
|
119
|
+
this.unseenCommentNotifications = function (currentUser) {
|
120
|
+
var noteType = _notification_types.notificationTypes.get('PRODUCTION_COMMENT'),
|
121
|
+
notifications = this.unseenNotifications(currentUser);
|
122
|
+
return (0, _notification_types.notificationsFilter)(notifications, [{
|
123
|
+
'notificationType': noteType
|
124
|
+
}]);
|
125
|
+
};
|
126
|
+
this.unseenCommentNotificationsCount = function (currentUser) {
|
127
|
+
return this.unseenCommentNotifications(currentUser).length;
|
128
|
+
};
|
129
|
+
this.unseenQuoteNotifications = function (currentUser) {
|
130
|
+
var approved = _notification_types.notificationTypes.get('QUOTE_APPROVED'),
|
131
|
+
supplierRefused = _notification_types.notificationTypes.get('SUPPLIER_REFUSED'),
|
132
|
+
refused = _notification_types.notificationTypes.get('QUOTE_REFUSED'),
|
133
|
+
submitted = _notification_types.notificationTypes.get('QUOTE_SUBMITTED'),
|
134
|
+
failed = _notification_types.notificationTypes.get('QUOTE_FAILED'),
|
135
|
+
commenced = _notification_types.notificationTypes.get('QUOTE_COMMENCED'),
|
136
|
+
expired = _notification_types.notificationTypes.get('QUOTE_EXPIRED'),
|
137
|
+
notifications = this.unseenNotifications(currentUser);
|
138
|
+
return (0, _notification_types.notificationsFilter)(notifications, [{
|
139
|
+
'notificationType': approved
|
140
|
+
}, {
|
141
|
+
'notificationType': refused
|
142
|
+
}, {
|
143
|
+
'notificationType': submitted
|
144
|
+
}, {
|
145
|
+
'notificationType': failed
|
146
|
+
}, {
|
147
|
+
'notificationType': commenced
|
148
|
+
}, {
|
149
|
+
'notificationType': expired
|
150
|
+
}, {
|
151
|
+
'notificationType': supplierRefused
|
152
|
+
}]);
|
153
|
+
};
|
154
|
+
this.isUserSupplier = function (user) {
|
155
|
+
var self = this;
|
156
|
+
if (Boolean(self.supplier()) && self.supplier().id() === user.id()) {
|
157
|
+
return true;
|
158
|
+
}
|
159
|
+
return false;
|
160
|
+
};
|
161
|
+
}
|
162
|
+
function Assignments() {
|
163
|
+
this.resource = '/assignments';
|
164
|
+
this.json = 'assignments';
|
165
|
+
this.single = Assignment;
|
166
|
+
this.get = function (success, error, parameters, withUpdates) {
|
167
|
+
var self = this;
|
168
|
+
function handleResponse(result) {
|
169
|
+
success((0, _model.fromJsonList)(self, result, {
|
170
|
+
makesDirty: false
|
171
|
+
}));
|
172
|
+
}
|
173
|
+
(0, _model.getList)(this.resource, handleResponse, error, parameters, withUpdates);
|
174
|
+
};
|
175
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.AutomaticPaymentRelationship = AutomaticPaymentRelationship;
|
7
|
+
exports.AutomaticPaymentRelationships = AutomaticPaymentRelationships;
|
8
|
+
var _company = require("./company.js");
|
9
|
+
var _uuid = require("./uuid.js");
|
10
|
+
var _model = require("./model.js");
|
11
|
+
function AutomaticPaymentRelationship() {
|
12
|
+
this.resource = '/automatic_payment_relationships';
|
13
|
+
this.json = 'automaticPaymentRelationship';
|
14
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
15
|
+
(0, _model.addPropertyTo)(this, 'archived');
|
16
|
+
(0, _model.addPropertyTo)(this, 'id');
|
17
|
+
(0, _model.addPropertyTo)(this, 'creationDate');
|
18
|
+
(0, _model.addPropertyTo)(this, 'stripeCustomerId');
|
19
|
+
(0, _model.addPropertyTo)(this, 'companyCustomer', _company.Company);
|
20
|
+
(0, _model.addPropertyTo)(this, 'companySupplier', _company.Company);
|
21
|
+
this.create = function (success, error, embed, as_domain) {
|
22
|
+
var data = (0, _model.serialise)(this),
|
23
|
+
self = this;
|
24
|
+
function handleResponse(result) {
|
25
|
+
success((0, _model.fromJson)(self, result[self.json]));
|
26
|
+
}
|
27
|
+
(0, _model.create)({
|
28
|
+
resource: this.resource,
|
29
|
+
parameters: data[0],
|
30
|
+
as_domain: as_domain,
|
31
|
+
files: (0, _model.enumerateFiles)(data[1]),
|
32
|
+
success: handleResponse,
|
33
|
+
data: error,
|
34
|
+
embed: embed
|
35
|
+
});
|
36
|
+
};
|
37
|
+
this.get = function (success, error) {
|
38
|
+
var self = this;
|
39
|
+
function handleResponse(result) {
|
40
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
41
|
+
makesDirty: false
|
42
|
+
}));
|
43
|
+
}
|
44
|
+
(0, _model.getOne)({
|
45
|
+
resource: this.resource,
|
46
|
+
id: this.id(),
|
47
|
+
success: handleResponse,
|
48
|
+
error: error
|
49
|
+
});
|
50
|
+
};
|
51
|
+
this.destroy = function (success, error) {
|
52
|
+
(0, _model.deleteOne)(this.resource + "/" + this.id(), success, error);
|
53
|
+
};
|
54
|
+
}
|
55
|
+
function AutomaticPaymentRelationships() {
|
56
|
+
this.resource = '/automatic_payment_relationships';
|
57
|
+
this.json = 'automaticPaymentRelationships';
|
58
|
+
this.single = AutomaticPaymentRelationship;
|
59
|
+
this.get = function (success, error, offset, limit, q) {
|
60
|
+
var self = this;
|
61
|
+
function handleResponse(result) {
|
62
|
+
success((0, _model.fromJsonList)(self, result, {
|
63
|
+
makesDirty: false
|
64
|
+
}));
|
65
|
+
}
|
66
|
+
(0, _model.getList)(this.resource, handleResponse, error, {
|
67
|
+
offset: offset,
|
68
|
+
limit: limit,
|
69
|
+
q: q
|
70
|
+
});
|
71
|
+
};
|
72
|
+
}
|
package/dist/backup.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Backup = Backup;
|
7
|
+
exports.Backups = Backups;
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _merchi_file = require("./merchi_file.js");
|
10
|
+
function Backup() {
|
11
|
+
this.resource = '/backups';
|
12
|
+
this.json = 'backup';
|
13
|
+
(0, _model.addPropertyTo)(this, 'id');
|
14
|
+
(0, _model.addPropertyTo)(this, 'file', _merchi_file.MerchiFile);
|
15
|
+
this.destroy = function (success, error) {
|
16
|
+
(0, _model.deleteOne)(this.resource + "/" + this.id(), success, error);
|
17
|
+
};
|
18
|
+
}
|
19
|
+
function Backups() {
|
20
|
+
this.resource = '/backups';
|
21
|
+
this.json = 'backups';
|
22
|
+
this.single = Backup;
|
23
|
+
this.get = function (success, error, parameters) {
|
24
|
+
var self = this;
|
25
|
+
function handleResponse(result) {
|
26
|
+
success((0, _model.fromJsonList)(self, result, {
|
27
|
+
makesDirty: false
|
28
|
+
}));
|
29
|
+
}
|
30
|
+
(0, _model.getList)(this.resource, handleResponse, error, parameters);
|
31
|
+
};
|
32
|
+
}
|
package/dist/bank.js
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Bank = Bank;
|
7
|
+
var _uuid = require("./uuid.js");
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _address = require("./address.js");
|
10
|
+
var _company = require("./company.js");
|
11
|
+
function Bank() {
|
12
|
+
this.resource = '/banks';
|
13
|
+
this.json = 'bank';
|
14
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
15
|
+
(0, _model.addPropertyTo)(this, 'id');
|
16
|
+
(0, _model.addPropertyTo)(this, 'bankName');
|
17
|
+
(0, _model.addPropertyTo)(this, 'accountNumber');
|
18
|
+
(0, _model.addPropertyTo)(this, 'accountName');
|
19
|
+
(0, _model.addPropertyTo)(this, 'bsb');
|
20
|
+
(0, _model.addPropertyTo)(this, 'swiftCode');
|
21
|
+
(0, _model.addPropertyTo)(this, 'iban');
|
22
|
+
(0, _model.addPropertyTo)(this, 'bankCode');
|
23
|
+
(0, _model.addPropertyTo)(this, 'bankAddress', _address.Address);
|
24
|
+
(0, _model.addPropertyTo)(this, 'company', _company.Companies);
|
25
|
+
}
|
package/dist/cart.js
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Cart = Cart;
|
7
|
+
var _uuid = require("./uuid.js");
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _address = require("./address.js");
|
10
|
+
var _cart_item = require("./cart_item.js");
|
11
|
+
var _cart_shipment_group = require("./cart_shipment_group.js");
|
12
|
+
var _company = require("./company.js");
|
13
|
+
var _domain = require("./domain.js");
|
14
|
+
var _invoice = require("./invoice.js");
|
15
|
+
var _shipment = require("./shipment.js");
|
16
|
+
var _user = require("./user.js");
|
17
|
+
function Cart() {
|
18
|
+
this.resource = '/carts';
|
19
|
+
this.json = 'cart';
|
20
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
21
|
+
(0, _model.addPropertyTo)(this, 'id');
|
22
|
+
(0, _model.addPropertyTo)(this, 'token');
|
23
|
+
(0, _model.addPropertyTo)(this, 'ip');
|
24
|
+
(0, _model.addPropertyTo)(this, 'client', _user.User);
|
25
|
+
(0, _model.addPropertyTo)(this, 'clientCompany', _company.Company);
|
26
|
+
(0, _model.addPropertyTo)(this, 'creationDate');
|
27
|
+
(0, _model.addPropertyTo)(this, 'domain', _domain.Domain);
|
28
|
+
(0, _model.addPropertyTo)(this, 'subtotalCost');
|
29
|
+
(0, _model.addPropertyTo)(this, 'taxAmount');
|
30
|
+
(0, _model.addPropertyTo)(this, 'totalCost');
|
31
|
+
(0, _model.addPropertyTo)(this, 'cartItems', _cart_item.CartItem);
|
32
|
+
(0, _model.addPropertyTo)(this, 'cartItemsSubtotalCost');
|
33
|
+
(0, _model.addPropertyTo)(this, 'cartItemsTaxAmount');
|
34
|
+
(0, _model.addPropertyTo)(this, 'cartItemsTotalCost');
|
35
|
+
(0, _model.addPropertyTo)(this, 'shipmentSubtotalCost');
|
36
|
+
(0, _model.addPropertyTo)(this, 'shipmentTaxAmount');
|
37
|
+
(0, _model.addPropertyTo)(this, 'shipmentTotalCost');
|
38
|
+
(0, _model.addPropertyTo)(this, 'currency');
|
39
|
+
(0, _model.addPropertyTo)(this, 'receiverNotes');
|
40
|
+
(0, _model.addPropertyTo)(this, 'shipmentGroups', _cart_shipment_group.CartShipmentGroup);
|
41
|
+
(0, _model.addPropertyTo)(this, 'invoice', _invoice.Invoice);
|
42
|
+
(0, _model.addPropertyTo)(this, 'shipment', _shipment.Shipment);
|
43
|
+
(0, _model.addPropertyTo)(this, 'receiverAddress', _address.Address);
|
44
|
+
this.create = function (success, error, embed, asDomain) {
|
45
|
+
var self = this,
|
46
|
+
data = (0, _model.serialise)(self);
|
47
|
+
function handleResponse(result) {
|
48
|
+
success((0, _model.fromJson)(self, result[self.json]));
|
49
|
+
}
|
50
|
+
(0, _model.create)({
|
51
|
+
resource: this.resource,
|
52
|
+
parameters: data[0],
|
53
|
+
as_domain: asDomain,
|
54
|
+
files: (0, _model.enumerateFiles)(data[1]),
|
55
|
+
success: handleResponse,
|
56
|
+
error: error,
|
57
|
+
embed: embed
|
58
|
+
});
|
59
|
+
};
|
60
|
+
this.get = function (success, error, embed, includeArchived, withRights) {
|
61
|
+
var self = this,
|
62
|
+
parameters = {
|
63
|
+
cartToken: this.token(),
|
64
|
+
embed: embed,
|
65
|
+
error: error,
|
66
|
+
id: this.id(),
|
67
|
+
includeArchived: includeArchived,
|
68
|
+
withRights: withRights,
|
69
|
+
resource: this.resource
|
70
|
+
};
|
71
|
+
function handleResponse(result) {
|
72
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
73
|
+
makesDirty: false
|
74
|
+
}));
|
75
|
+
}
|
76
|
+
parameters.success = handleResponse;
|
77
|
+
(0, _model.getOne)(parameters);
|
78
|
+
};
|
79
|
+
this.patch = function (success, error, embed) {
|
80
|
+
var self = this,
|
81
|
+
data = (0, _model.serialise)(this, undefined, undefined, undefined, {
|
82
|
+
excludeOld: true
|
83
|
+
})[0];
|
84
|
+
function handleResponse(result) {
|
85
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
86
|
+
makesDirty: false
|
87
|
+
}));
|
88
|
+
}
|
89
|
+
(0, _model.patchOne)({
|
90
|
+
cartToken: this.token(),
|
91
|
+
resource: this.resource,
|
92
|
+
id: this.id(),
|
93
|
+
success: handleResponse,
|
94
|
+
error: error,
|
95
|
+
data: data,
|
96
|
+
embed: embed
|
97
|
+
});
|
98
|
+
};
|
99
|
+
this.getShipmentGroupsAndQuotes = function (success, error) {
|
100
|
+
var self = this,
|
101
|
+
request = new Request();
|
102
|
+
request.resource("/generate-cart-shipment-quotes/".concat(self.id(), "/"));
|
103
|
+
request.method('GET');
|
104
|
+
request.query().add('cart_token', this.token());
|
105
|
+
function handleResponse(status, data) {
|
106
|
+
if (status === 200) {
|
107
|
+
success((0, _model.fromJson)(self, data, {
|
108
|
+
makesDirty: false
|
109
|
+
}));
|
110
|
+
} else {
|
111
|
+
error(status, data);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
request.responseHandler(handleResponse).errorHandler(error);
|
115
|
+
request.send();
|
116
|
+
};
|
117
|
+
this.requiresShipment = function () {
|
118
|
+
var cartItems = this.cartItems() ? this.cartItems() : [],
|
119
|
+
i;
|
120
|
+
for (i = 0; i < cartItems.length; i++) {
|
121
|
+
if (cartItems[i].requiresShipment()) {
|
122
|
+
return true;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
};
|
126
|
+
this.stripePublishableKey = function () {
|
127
|
+
return this.domain().company() ? this.domain().company().stripePublishableKey() : null;
|
128
|
+
};
|
129
|
+
this.stripeIsValidAndActive = function () {
|
130
|
+
var company = this.domain().company();
|
131
|
+
return this.stripePublishableKey() && company && company.acceptStripe();
|
132
|
+
};
|
133
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CartItem = CartItem;
|
7
|
+
var _uuid = require("./uuid.js");
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _cart = require("./cart.js");
|
10
|
+
var _country_tax = require("./country_tax.js");
|
11
|
+
var _product = require("./product.js");
|
12
|
+
var _variation = require("./variation.js");
|
13
|
+
var _variations_group = require("./variations_group.js");
|
14
|
+
function CartItem() {
|
15
|
+
this.resource = '/cart_items';
|
16
|
+
this.json = 'cartItem';
|
17
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
18
|
+
(0, _model.addPropertyTo)(this, 'id');
|
19
|
+
(0, _model.addPropertyTo)(this, 'creationDate');
|
20
|
+
(0, _model.addPropertyTo)(this, 'cart', _cart.Cart);
|
21
|
+
(0, _model.addPropertyTo)(this, 'currency');
|
22
|
+
(0, _model.addPropertyTo)(this, 'quantity');
|
23
|
+
(0, _model.addPropertyTo)(this, 'currency');
|
24
|
+
(0, _model.addPropertyTo)(this, 'product', _product.Product);
|
25
|
+
(0, _model.addPropertyTo)(this, 'variations', _variation.Variation);
|
26
|
+
(0, _model.addPropertyTo)(this, 'variationsGroups', _variations_group.VariationsGroup);
|
27
|
+
(0, _model.addPropertyTo)(this, 'taxType', _country_tax.CountryTax);
|
28
|
+
(0, _model.addPropertyTo)(this, 'subtotalCost');
|
29
|
+
(0, _model.addPropertyTo)(this, 'totalCost');
|
30
|
+
this.hasVariationsGroups = function () {
|
31
|
+
var groups = this.variationsGroups();
|
32
|
+
return groups && groups.length > 0;
|
33
|
+
};
|
34
|
+
this.create = function (success, error, embed, asDomain) {
|
35
|
+
var self = this,
|
36
|
+
data = (0, _model.serialise)(self);
|
37
|
+
function handleResponse(result) {
|
38
|
+
success((0, _model.fromJson)(self, result[self.json]));
|
39
|
+
}
|
40
|
+
(0, _model.create)({
|
41
|
+
resource: this.resource,
|
42
|
+
parameters: data[0],
|
43
|
+
as_domain: asDomain,
|
44
|
+
files: (0, _model.enumerateFiles)(data[1]),
|
45
|
+
success: handleResponse,
|
46
|
+
error: error,
|
47
|
+
embed: embed
|
48
|
+
});
|
49
|
+
};
|
50
|
+
this.calculate = function (success, error, embed) {
|
51
|
+
var request = new Request(),
|
52
|
+
data = (0, _model.serialise)(this)[0];
|
53
|
+
request.resource('/cart-item-cost-estimate/');
|
54
|
+
request.method('POST');
|
55
|
+
request.query().add('skip_rights', true);
|
56
|
+
request.data().merge(data);
|
57
|
+
function handleResponse(status, data) {
|
58
|
+
if (status === 201) {
|
59
|
+
success((0, _model.fromJson)(new CartItem(), data));
|
60
|
+
} else {
|
61
|
+
error(data);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
request.responseHandler(handleResponse).errorHandler(error);
|
65
|
+
request.send();
|
66
|
+
};
|
67
|
+
this.requiresShipment = function () {
|
68
|
+
var product = this.product();
|
69
|
+
return product ? product.needsShipping() : false;
|
70
|
+
};
|
71
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CartShipmentGroup = CartShipmentGroup;
|
7
|
+
var _uuid = require("./uuid.js");
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _cart_item = require("./cart_item.js");
|
10
|
+
var _cart_shipment_quote = require("./cart_shipment_quote.js");
|
11
|
+
function CartShipmentGroup() {
|
12
|
+
this.resource = '/cart_shipment_groups';
|
13
|
+
this.json = 'cartShipmentGroup';
|
14
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
15
|
+
(0, _model.addPropertyTo)(this, 'id');
|
16
|
+
(0, _model.addPropertyTo)(this, 'cartItems', _cart_item.CartItem);
|
17
|
+
(0, _model.addPropertyTo)(this, 'quotes', _cart_shipment_quote.CartShipmentQuote);
|
18
|
+
(0, _model.addPropertyTo)(this, 'selectedQuote', _cart_shipment_quote.CartShipmentQuote);
|
19
|
+
this.selectedQuoteName = function () {
|
20
|
+
var selectedQuote = this.selectedQuote();
|
21
|
+
return selectedQuote ? selectedQuote.name() : null;
|
22
|
+
};
|
23
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CartShipmentQuote = CartShipmentQuote;
|
7
|
+
var _uuid = require("./uuid.js");
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _shipment_method = require("./shipment_method.js");
|
10
|
+
function CartShipmentQuote() {
|
11
|
+
this.resource = '/cart_shipment_quotes';
|
12
|
+
this.json = 'cartShipmentQuote';
|
13
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
14
|
+
(0, _model.addPropertyTo)(this, 'id');
|
15
|
+
(0, _model.addPropertyTo)(this, 'name');
|
16
|
+
(0, _model.addPropertyTo)(this, 'subtotalCost');
|
17
|
+
(0, _model.addPropertyTo)(this, 'taxAmount');
|
18
|
+
(0, _model.addPropertyTo)(this, 'totalCost');
|
19
|
+
(0, _model.addPropertyTo)(this, 'shipmentMethod', _shipment_method.ShipmentMethod);
|
20
|
+
(0, _model.addPropertyTo)(this, 'shipmentServiceQuote');
|
21
|
+
(0, _model.addPropertyTo)(this, 'shipmentService');
|
22
|
+
this.name = function () {
|
23
|
+
var shipmentMethod = this.shipmentMethod();
|
24
|
+
return shipmentMethod ? shipmentMethod.name() : null;
|
25
|
+
};
|
26
|
+
}
|