merchi_sdk_js 0.0.2 → 0.0.4

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 (88) hide show
  1. package/package.json +4 -3
  2. package/dist/address.js +0 -109
  3. package/dist/assignment.js +0 -175
  4. package/dist/automatic_payment_relationship.js +0 -72
  5. package/dist/backup.js +0 -32
  6. package/dist/bank.js +0 -25
  7. package/dist/cart.js +0 -133
  8. package/dist/cart_item.js +0 -71
  9. package/dist/cart_shipment_group.js +0 -23
  10. package/dist/cart_shipment_quote.js +0 -26
  11. package/dist/category.js +0 -68
  12. package/dist/company.js +0 -248
  13. package/dist/company_invitation.js +0 -70
  14. package/dist/component.js +0 -107
  15. package/dist/component_tag.js +0 -60
  16. package/dist/component_version.js +0 -21
  17. package/dist/country_tax.js +0 -93
  18. package/dist/dictionary.js +0 -130
  19. package/dist/discount.js +0 -22
  20. package/dist/discount_group.js +0 -18
  21. package/dist/domain.js +0 -245
  22. package/dist/domain_invitation.js +0 -17
  23. package/dist/domain_tag.js +0 -87
  24. package/dist/domain_types.js +0 -22
  25. package/dist/draft.js +0 -97
  26. package/dist/draft_comment.js +0 -45
  27. package/dist/draft_template.js +0 -39
  28. package/dist/email_address.js +0 -34
  29. package/dist/email_counter.js +0 -47
  30. package/dist/enrolled_domain.js +0 -88
  31. package/dist/exchange_rate.js +0 -66
  32. package/dist/field_types.js +0 -19
  33. package/dist/helpers.js +0 -86
  34. package/dist/internal_tag.js +0 -98
  35. package/dist/inventory.js +0 -100
  36. package/dist/inventory_unit_variation.js +0 -19
  37. package/dist/invoice.js +0 -225
  38. package/dist/invoice_types.js +0 -11
  39. package/dist/item.js +0 -25
  40. package/dist/job.js +0 -536
  41. package/dist/job_comment.js +0 -45
  42. package/dist/job_status.js +0 -47
  43. package/dist/matching_inventory.js +0 -21
  44. package/dist/md5.js +0 -149
  45. package/dist/menu.js +0 -37
  46. package/dist/menu_item.js +0 -24
  47. package/dist/merchi.js +0 -1004
  48. package/dist/merchi_file.js +0 -165
  49. package/dist/model.js +0 -753
  50. package/dist/notification.js +0 -151
  51. package/dist/notification_types.js +0 -199
  52. package/dist/output.cjs.js +0 -31317
  53. package/dist/output.esm.js +0 -31312
  54. package/dist/page.js +0 -41
  55. package/dist/payment.js +0 -32
  56. package/dist/payment_device.js +0 -21
  57. package/dist/payment_types.js +0 -20
  58. package/dist/phone_number.js +0 -37
  59. package/dist/product.js +0 -288
  60. package/dist/product_types.js +0 -32
  61. package/dist/production_comment.js +0 -44
  62. package/dist/quote.js +0 -91
  63. package/dist/quote_item.js +0 -59
  64. package/dist/roles.js +0 -29
  65. package/dist/seo_domain_page.js +0 -42
  66. package/dist/session.js +0 -103
  67. package/dist/set.js +0 -29
  68. package/dist/shipment.js +0 -181
  69. package/dist/shipment_item.js +0 -17
  70. package/dist/shipment_item_fulfillment.js +0 -17
  71. package/dist/shipment_method.js +0 -81
  72. package/dist/shipment_method_variation.js +0 -38
  73. package/dist/subscription_plan.js +0 -75
  74. package/dist/supply_domain.js +0 -65
  75. package/dist/system_role.js +0 -12
  76. package/dist/theme.js +0 -180
  77. package/dist/theme_css_setting.js +0 -61
  78. package/dist/theme_status.js +0 -11
  79. package/dist/user.js +0 -409
  80. package/dist/user_company.js +0 -19
  81. package/dist/user_types.js +0 -23
  82. package/dist/uuid.js +0 -12
  83. package/dist/variation.js +0 -233
  84. package/dist/variation_field.js +0 -233
  85. package/dist/variation_fields_option.js +0 -41
  86. package/dist/variation_option.js +0 -62
  87. package/dist/variations_group.js +0 -43
  88. package/dist/white_label_accessibilities.js +0 -11
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "merchi_sdk_js",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
- "main": "dist/merchi.js",
5
+ "main": "src/merchi.js",
6
+ "module": "src/merchi.js",
6
7
  "license": "GPL-3.0-only",
7
8
  "files": [
8
- "dist/", "src/"
9
+ "src/"
9
10
  ],
10
11
  "dependencies": {
11
12
  "axios": "^0.27.2",
package/dist/address.js DELETED
@@ -1,109 +0,0 @@
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
- }
@@ -1,175 +0,0 @@
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
- }
@@ -1,72 +0,0 @@
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 DELETED
@@ -1,32 +0,0 @@
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 DELETED
@@ -1,25 +0,0 @@
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 DELETED
@@ -1,133 +0,0 @@
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
- }
package/dist/cart_item.js DELETED
@@ -1,71 +0,0 @@
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
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- }