merchi_sdk_js 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. package/dist/address.js +109 -0
  2. package/dist/assignment.js +175 -0
  3. package/dist/automatic_payment_relationship.js +72 -0
  4. package/dist/backup.js +32 -0
  5. package/dist/bank.js +25 -0
  6. package/dist/cart.js +133 -0
  7. package/dist/cart_item.js +71 -0
  8. package/dist/cart_shipment_group.js +23 -0
  9. package/dist/cart_shipment_quote.js +26 -0
  10. package/dist/category.js +68 -0
  11. package/dist/company.js +248 -0
  12. package/dist/company_invitation.js +70 -0
  13. package/dist/component.js +107 -0
  14. package/dist/component_tag.js +60 -0
  15. package/dist/component_version.js +21 -0
  16. package/dist/country_tax.js +93 -0
  17. package/dist/dictionary.js +130 -0
  18. package/dist/discount.js +22 -0
  19. package/dist/discount_group.js +18 -0
  20. package/dist/domain.js +245 -0
  21. package/dist/domain_invitation.js +17 -0
  22. package/dist/domain_tag.js +87 -0
  23. package/dist/domain_types.js +22 -0
  24. package/dist/draft.js +97 -0
  25. package/dist/draft_comment.js +45 -0
  26. package/dist/draft_template.js +39 -0
  27. package/dist/email_address.js +34 -0
  28. package/dist/email_counter.js +47 -0
  29. package/dist/enrolled_domain.js +88 -0
  30. package/dist/exchange_rate.js +66 -0
  31. package/dist/field_types.js +19 -0
  32. package/dist/helpers.js +86 -0
  33. package/dist/internal_tag.js +98 -0
  34. package/dist/inventory.js +100 -0
  35. package/dist/inventory_unit_variation.js +19 -0
  36. package/dist/invoice.js +225 -0
  37. package/dist/invoice_types.js +11 -0
  38. package/dist/item.js +25 -0
  39. package/dist/job.js +536 -0
  40. package/dist/job_comment.js +45 -0
  41. package/dist/job_status.js +47 -0
  42. package/dist/matching_inventory.js +21 -0
  43. package/dist/md5.js +149 -0
  44. package/dist/menu.js +37 -0
  45. package/dist/menu_item.js +24 -0
  46. package/dist/merchi.js +1004 -0
  47. package/dist/merchi_file.js +165 -0
  48. package/dist/model.js +753 -0
  49. package/dist/notification.js +151 -0
  50. package/dist/notification_types.js +199 -0
  51. package/dist/output.cjs.js +31317 -0
  52. package/dist/output.esm.js +31312 -0
  53. package/dist/page.js +41 -0
  54. package/dist/payment.js +32 -0
  55. package/dist/payment_device.js +21 -0
  56. package/dist/payment_types.js +20 -0
  57. package/dist/phone_number.js +37 -0
  58. package/dist/product.js +288 -0
  59. package/dist/product_types.js +32 -0
  60. package/dist/production_comment.js +44 -0
  61. package/dist/quote.js +91 -0
  62. package/dist/quote_item.js +59 -0
  63. package/dist/roles.js +29 -0
  64. package/dist/seo_domain_page.js +42 -0
  65. package/dist/session.js +103 -0
  66. package/dist/set.js +29 -0
  67. package/dist/shipment.js +181 -0
  68. package/dist/shipment_item.js +17 -0
  69. package/dist/shipment_item_fulfillment.js +17 -0
  70. package/dist/shipment_method.js +81 -0
  71. package/dist/shipment_method_variation.js +38 -0
  72. package/dist/subscription_plan.js +75 -0
  73. package/dist/supply_domain.js +65 -0
  74. package/dist/system_role.js +12 -0
  75. package/dist/theme.js +180 -0
  76. package/dist/theme_css_setting.js +61 -0
  77. package/dist/theme_status.js +11 -0
  78. package/dist/user.js +409 -0
  79. package/dist/user_company.js +19 -0
  80. package/dist/user_types.js +23 -0
  81. package/dist/uuid.js +12 -0
  82. package/dist/variation.js +233 -0
  83. package/dist/variation_field.js +233 -0
  84. package/dist/variation_fields_option.js +41 -0
  85. package/dist/variation_option.js +62 -0
  86. package/dist/variations_group.js +43 -0
  87. package/dist/white_label_accessibilities.js +11 -0
  88. package/package.json +30 -0
  89. package/src/address.js +107 -0
  90. package/src/assignment.js +165 -0
  91. package/src/automatic_payment_relationship.js +65 -0
  92. package/src/backup.js +29 -0
  93. package/src/bank.js +21 -0
  94. package/src/cart.js +131 -0
  95. package/src/cart_item.js +71 -0
  96. package/src/cart_shipment_group.js +20 -0
  97. package/src/cart_shipment_quote.js +23 -0
  98. package/src/category.js +62 -0
  99. package/src/company.js +267 -0
  100. package/src/company_invitation.js +63 -0
  101. package/src/component.js +100 -0
  102. package/src/component_tag.js +53 -0
  103. package/src/component_version.js +17 -0
  104. package/src/country_tax.js +89 -0
  105. package/src/dictionary.js +135 -0
  106. package/src/discount.js +19 -0
  107. package/src/discount_group.js +15 -0
  108. package/src/domain.js +254 -0
  109. package/src/domain_invitation.js +13 -0
  110. package/src/domain_tag.js +79 -0
  111. package/src/domain_types.js +18 -0
  112. package/src/draft.js +92 -0
  113. package/src/draft_comment.js +41 -0
  114. package/src/draft_template.js +35 -0
  115. package/src/email_address.js +27 -0
  116. package/src/email_counter.js +42 -0
  117. package/src/enrolled_domain.js +79 -0
  118. package/src/exchange_rate.js +61 -0
  119. package/src/field_types.js +15 -0
  120. package/src/helpers.js +81 -0
  121. package/src/internal_tag.js +90 -0
  122. package/src/inventory.js +99 -0
  123. package/src/inventory_unit_variation.js +18 -0
  124. package/src/invoice.js +224 -0
  125. package/src/invoice_types.js +7 -0
  126. package/src/item.js +22 -0
  127. package/src/job.js +616 -0
  128. package/src/job_comment.js +41 -0
  129. package/src/job_status.js +51 -0
  130. package/src/matching_inventory.js +17 -0
  131. package/src/md5.js +162 -0
  132. package/src/menu.js +32 -0
  133. package/src/menu_item.js +22 -0
  134. package/src/merchi.js +1074 -0
  135. package/src/merchi_file.js +163 -0
  136. package/src/model.js +820 -0
  137. package/src/notification.js +153 -0
  138. package/src/notification_types.js +246 -0
  139. package/src/page.js +38 -0
  140. package/src/payment.js +32 -0
  141. package/src/payment_device.js +17 -0
  142. package/src/payment_types.js +18 -0
  143. package/src/phone_number.js +30 -0
  144. package/src/product.js +309 -0
  145. package/src/product_types.js +28 -0
  146. package/src/production_comment.js +40 -0
  147. package/src/quote.js +89 -0
  148. package/src/quote_item.js +51 -0
  149. package/src/roles.js +27 -0
  150. package/src/seo_domain_page.js +35 -0
  151. package/src/session.js +102 -0
  152. package/src/set.js +28 -0
  153. package/src/shipment.js +191 -0
  154. package/src/shipment_item.js +13 -0
  155. package/src/shipment_item_fulfillment.js +13 -0
  156. package/src/shipment_method.js +73 -0
  157. package/src/shipment_method_variation.js +34 -0
  158. package/src/subscription_plan.js +68 -0
  159. package/src/supply_domain.js +60 -0
  160. package/src/system_role.js +8 -0
  161. package/src/theme.js +188 -0
  162. package/src/theme_css_setting.js +54 -0
  163. package/src/theme_status.js +6 -0
  164. package/src/user.js +442 -0
  165. package/src/user_company.js +15 -0
  166. package/src/user_types.js +19 -0
  167. package/src/uuid.js +3 -0
  168. package/src/variation.js +257 -0
  169. package/src/variation_field.js +261 -0
  170. package/src/variation_fields_option.js +41 -0
  171. package/src/variation_option.js +59 -0
  172. package/src/variations_group.js +43 -0
  173. package/src/white_label_accessibilities.js +6 -0
package/dist/page.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Page = Page;
7
+ var _model = require("./model.js");
8
+ var _helpers = require("./helpers.js");
9
+ var _theme = require("./theme.js");
10
+ function Page() {
11
+ this.resource = '/pages';
12
+ this.json = 'page';
13
+ (0, _model.addPropertyTo)(this, 'id');
14
+ (0, _model.addPropertyTo)(this, 'name');
15
+ (0, _model.addPropertyTo)(this, 'slug');
16
+ (0, _model.addPropertyTo)(this, 'template');
17
+ (0, _model.addPropertyTo)(this, 'theme', _theme.Theme);
18
+ this.text = function (text) {
19
+ if (!(0, _helpers.isUndefinedOrNull)(text)) {
20
+ this.template(text);
21
+ } else {
22
+ return this.template();
23
+ }
24
+ };
25
+ this.create = function (success, error, embed, domainId) {
26
+ var data = (0, _model.serialise)(this),
27
+ self = this;
28
+ function handleResponse(result) {
29
+ success((0, _model.fromJson)(self, result[self.json]));
30
+ }
31
+ (0, _model.create)({
32
+ resource: this.resource,
33
+ parameters: data[0],
34
+ files: (0, _model.enumerateFiles)(data[1]),
35
+ success: handleResponse,
36
+ error: error,
37
+ embed: embed,
38
+ as_domain: domainId
39
+ });
40
+ };
41
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Payment = Payment;
7
+ var _uuid = require("./uuid.js");
8
+ var _model = require("./model.js");
9
+ var _payment_types = require("./payment_types.js");
10
+ var _automatic_payment_relationship = require("./automatic_payment_relationship.js");
11
+ var _user = require("./user.js");
12
+ function Payment() {
13
+ this.resource = '/payments';
14
+ this.json = 'payments';
15
+ this.temporaryId = (0, _uuid.generateUUID)();
16
+ (0, _model.addPropertyTo)(this, 'id');
17
+ (0, _model.addPropertyTo)(this, 'note');
18
+ (0, _model.addPropertyTo)(this, 'paymentType');
19
+ (0, _model.addPropertyTo)(this, 'payDate');
20
+ (0, _model.addPropertyTo)(this, 'amount');
21
+ (0, _model.addPropertyTo)(this, 'sendSms');
22
+ (0, _model.addPropertyTo)(this, 'sendEmail');
23
+ (0, _model.addPropertyTo)(this, 'autoRefundable');
24
+ (0, _model.addPropertyTo)(this, 'refunded');
25
+ (0, _model.addPropertyTo)(this, 'refundIssuer', _user.User);
26
+ (0, _model.addPropertyTo)(this, 'paymentRecorder', _user.User);
27
+ (0, _model.addPropertyTo)(this, 'chargedByPaymentRelationship', _automatic_payment_relationship.AutomaticPaymentRelationship);
28
+ this.paymentTypeText = function () {
29
+ var paymentType = this.paymentType();
30
+ return paymentType ? _payment_types.paymentTypes.get(paymentType) : 'Unknown';
31
+ };
32
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PaymentDevice = PaymentDevice;
7
+ var _uuid = require("./uuid.js");
8
+ var _model = require("./model.js");
9
+ var _company = require("./company.js");
10
+ function PaymentDevice() {
11
+ this.resource = '/payment_devices';
12
+ this.json = 'paymentDevices';
13
+ this.temporaryId = (0, _uuid.generateUUID)();
14
+ (0, _model.addPropertyTo)(this, 'id');
15
+ (0, _model.addPropertyTo)(this, 'code');
16
+ (0, _model.addPropertyTo)(this, 'deviceId');
17
+ (0, _model.addPropertyTo)(this, 'squareId');
18
+ (0, _model.addPropertyTo)(this, 'deviceData');
19
+ (0, _model.addPropertyTo)(this, 'company', _company.Company);
20
+ (0, _model.addPropertyTo)(this, 'description');
21
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.paymentTypes = exports.paymentTypeIds = void 0;
7
+ var _dictionary = require("./dictionary.js");
8
+ var paymentTypes = exports.paymentTypes = new _dictionary.Dictionary();
9
+ paymentTypes.add(1, 'Online');
10
+ paymentTypes.add(2, 'PayPal');
11
+ paymentTypes.add(3, 'Bank Transfer');
12
+ paymentTypes.add(4, 'Cash');
13
+ paymentTypes.add(5, 'Cheque');
14
+ paymentTypes.add(6, 'Phone');
15
+ paymentTypes.add(7, 'Credit Card');
16
+ paymentTypes.add(8, 'Utrust');
17
+ var paymentTypeIds = exports.paymentTypeIds = new _dictionary.Dictionary();
18
+ paymentTypes.each(function (key, value) {
19
+ paymentTypeIds.add(value, parseInt(key, 10));
20
+ });
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PhoneNumber = PhoneNumber;
7
+ exports.PhoneNumbers = PhoneNumbers;
8
+ var _uuid = require("./uuid.js");
9
+ var _model = require("./model.js");
10
+ function PhoneNumber() {
11
+ this.resource = '/phone_numbers';
12
+ this.json = 'phoneNumber';
13
+ this.temporaryId = (0, _uuid.generateUUID)();
14
+ (0, _model.addPropertyTo)(this, 'id');
15
+ (0, _model.addPropertyTo)(this, 'number');
16
+ (0, _model.addPropertyTo)(this, 'code');
17
+ (0, _model.addPropertyTo)(this, 'localFormatNumber');
18
+ (0, _model.addPropertyTo)(this, 'internationalFormatNumber');
19
+ }
20
+ function PhoneNumbers() {
21
+ this.resource = '/phone_numbers';
22
+ this.json = 'phoneNumbers';
23
+ this.single = PhoneNumber;
24
+ this.get = function (success, error, offset, limit, q) {
25
+ var self = this;
26
+ function handleResponse(result) {
27
+ success((0, _model.fromJsonList)(self, result, {
28
+ makesDirty: false
29
+ }));
30
+ }
31
+ (0, _model.getList)(this.resource, handleResponse, error, {
32
+ offset: offset,
33
+ limit: limit,
34
+ q: q
35
+ });
36
+ };
37
+ }
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Product = Product;
7
+ exports.Products = Products;
8
+ var _uuid = require("./uuid.js");
9
+ var _helpers = require("./helpers.js");
10
+ var _model = require("./model.js");
11
+ var _product_types = require("./product_types.js");
12
+ var _category = require("./category.js");
13
+ var _component = require("./component.js");
14
+ var _company = require("./company.js");
15
+ var _country_tax = require("./country_tax.js");
16
+ var _draft_template = require("./draft_template.js");
17
+ var _domain_tag = require("./domain_tag.js");
18
+ var _discount_group = require("./discount_group.js");
19
+ var _domain = require("./domain.js");
20
+ var _inventory = require("./inventory.js");
21
+ var _shipment_method = require("./shipment_method.js");
22
+ var _variation_field = require("./variation_field.js");
23
+ var _variations_group = require("./variations_group.js");
24
+ var _merchi_file = require("./merchi_file.js");
25
+ var _supply_domain = require("./supply_domain.js");
26
+ var _user = require("./user.js");
27
+ var _job = require("./job.js");
28
+ var _seo_domain_page = require("./seo_domain_page.js");
29
+ var _internal_tag = require("./internal_tag.js");
30
+ function Product() {
31
+ this.resource = '/products';
32
+ this.json = 'product';
33
+ this.temporaryId = (0, _uuid.generateUUID)();
34
+ (0, _model.addPropertyTo)(this, 'id');
35
+ (0, _model.addPropertyTo)(this, 'name');
36
+ (0, _model.addPropertyTo)(this, 'created');
37
+ (0, _model.addPropertyTo)(this, 'updated');
38
+ (0, _model.addPropertyTo)(this, 'country');
39
+ (0, _model.addPropertyTo)(this, 'currency');
40
+ (0, _model.addPropertyTo)(this, 'createdBy', _user.User);
41
+ (0, _model.addPropertyTo)(this, 'updatedBy', _user.User);
42
+ (0, _model.addPropertyTo)(this, 'independent');
43
+ (0, _model.addPropertyTo)(this, 'productType');
44
+ (0, _model.addPropertyTo)(this, 'description');
45
+ (0, _model.addPropertyTo)(this, 'notes');
46
+ (0, _model.addPropertyTo)(this, 'shopifyProductId');
47
+ (0, _model.addPropertyTo)(this, 'minimum');
48
+ (0, _model.addPropertyTo)(this, 'minimumPerGroup');
49
+ (0, _model.addPropertyTo)(this, 'deliveryDaysNormal');
50
+ (0, _model.addPropertyTo)(this, 'unitPrice');
51
+ (0, _model.addPropertyTo)(this, 'unitPriceDiscountGroup', _discount_group.DiscountGroup);
52
+ (0, _model.addPropertyTo)(this, 'bestPrice');
53
+ (0, _model.addPropertyTo)(this, 'unitWeight');
54
+ (0, _model.addPropertyTo)(this, 'unitHeight');
55
+ (0, _model.addPropertyTo)(this, 'unitWidth');
56
+ (0, _model.addPropertyTo)(this, 'unitDepth');
57
+ (0, _model.addPropertyTo)(this, 'unitVolume');
58
+ (0, _model.addPropertyTo)(this, 'showGroupBuyStatus');
59
+ (0, _model.addPropertyTo)(this, 'groupBuyStatus');
60
+ (0, _model.addPropertyTo)(this, 'needsDrafting');
61
+ (0, _model.addPropertyTo)(this, 'needsProduction');
62
+ (0, _model.addPropertyTo)(this, 'needsShipping');
63
+ (0, _model.addPropertyTo)(this, 'needsInvoicing');
64
+ (0, _model.addPropertyTo)(this, 'needsInventory');
65
+ (0, _model.addPropertyTo)(this, 'showFeatureDeadline');
66
+ (0, _model.addPropertyTo)(this, 'featureDeadline');
67
+ (0, _model.addPropertyTo)(this, 'suppliers', _user.User);
68
+ (0, _model.addPropertyTo)(this, 'groupVariationFields', _variation_field.VariationField);
69
+ (0, _model.addPropertyTo)(this, 'independentVariationFields', _variation_field.VariationField);
70
+ (0, _model.addPropertyTo)(this, 'originalProduct', Product);
71
+ (0, _model.addPropertyTo)(this, 'clonedFromProduct', Product);
72
+ (0, _model.addPropertyTo)(this, 'chainedSupplierProduct', Product);
73
+ (0, _model.addPropertyTo)(this, 'chainedSellerProducts', Product);
74
+ (0, _model.addPropertyTo)(this, 'chainedInventorySupplierProduct', Product);
75
+ (0, _model.addPropertyTo)(this, 'chainedInventorySellerProducts', Product);
76
+ (0, _model.addPropertyTo)(this, 'component', _component.Component);
77
+ (0, _model.addPropertyTo)(this, 'domain', _domain.Domain);
78
+ (0, _model.addPropertyTo)(this, 'suppliedByDomains', _supply_domain.SupplyDomain);
79
+ (0, _model.addPropertyTo)(this, 'autoAssignProductionOnAction');
80
+ (0, _model.addPropertyTo)(this, 'supplyDomains', _supply_domain.SupplyDomain);
81
+ (0, _model.addPropertyTo)(this, 'images', _merchi_file.MerchiFile);
82
+ (0, _model.addPropertyTo)(this, 'featureImage', _merchi_file.MerchiFile);
83
+ (0, _model.addPropertyTo)(this, 'publicFiles', _merchi_file.MerchiFile);
84
+ (0, _model.addPropertyTo)(this, 'productionFiles', _merchi_file.MerchiFile);
85
+ (0, _model.addPropertyTo)(this, 'showPublic');
86
+ (0, _model.addPropertyTo)(this, 'acceptSquare');
87
+ (0, _model.addPropertyTo)(this, 'acceptStripe');
88
+ (0, _model.addPropertyTo)(this, 'acceptPaypal');
89
+ (0, _model.addPropertyTo)(this, 'acceptUtrust');
90
+ (0, _model.addPropertyTo)(this, 'acceptBankTransfer');
91
+ (0, _model.addPropertyTo)(this, 'acceptPhonePayment');
92
+ (0, _model.addPropertyTo)(this, 'supplyChainDisabled');
93
+ (0, _model.addPropertyTo)(this, 'allowAutomaticPaymentSupply');
94
+ (0, _model.addPropertyTo)(this, 'allowGroupBuy');
95
+ (0, _model.addPropertyTo)(this, 'allowPaymentUpfront');
96
+ (0, _model.addPropertyTo)(this, 'allowQuotation');
97
+ (0, _model.addPropertyTo)(this, 'allowChainedInventoryCreation');
98
+ (0, _model.addPropertyTo)(this, 'allowClientDraftContribution');
99
+ (0, _model.addPropertyTo)(this, 'chainedInventoryHandlingUnitPrice');
100
+ (0, _model.addPropertyTo)(this, 'savedByUsers', _user.User);
101
+ (0, _model.addPropertyTo)(this, 'savedByCompanies', _company.Company);
102
+ (0, _model.addPropertyTo)(this, 'tags', _domain_tag.DomainTag);
103
+ (0, _model.addPropertyTo)(this, 'inventories', _inventory.Inventory);
104
+ (0, _model.addPropertyTo)(this, 'inventoriesOpen');
105
+ (0, _model.addPropertyTo)(this, 'discountGroups', _discount_group.DiscountGroup);
106
+ (0, _model.addPropertyTo)(this, 'categories', _category.Category);
107
+ (0, _model.addPropertyTo)(this, 'taxType', _country_tax.CountryTax);
108
+ (0, _model.addPropertyTo)(this, 'defaultJob', _job.Job);
109
+ (0, _model.addPropertyTo)(this, 'supplyChainRequestJobs', _job.Job);
110
+ (0, _model.addPropertyTo)(this, 'draftTemplates', _draft_template.DraftTemplate);
111
+ (0, _model.addPropertyTo)(this, 'shipmentMethods', _shipment_method.ShipmentMethod);
112
+ (0, _model.addPropertyTo)(this, 'seoDomainPages', _seo_domain_page.SeoDomainPage);
113
+ (0, _model.addPropertyTo)(this, 'aiContext');
114
+ (0, _model.addPropertyTo)(this, 'internalUseNotes');
115
+ (0, _model.addPropertyTo)(this, 'internalUseAiContext');
116
+ (0, _model.addPropertyTo)(this, 'internalTags', _internal_tag.InternalTag);
117
+ this.create = function (success, error, embed, asDomain) {
118
+ var data = (0, _model.serialise)(this),
119
+ self = this,
120
+ domain = self.domain() ? self.domain().id() : null,
121
+ domainId = (0, _helpers.isUndefinedOrNull)(asDomain) ? domain : asDomain;
122
+ function handleResponse(result) {
123
+ success((0, _model.fromJson)(self, result[self.json]));
124
+ }
125
+ (0, _model.create)({
126
+ resource: this.resource,
127
+ parameters: data[0],
128
+ as_domain: domainId,
129
+ files: (0, _model.enumerateFiles)(data[1]),
130
+ success: handleResponse,
131
+ error: error,
132
+ embed: embed
133
+ });
134
+ };
135
+ this.get = function (success, error, embed) {
136
+ var self = this;
137
+ function handleResponse(result) {
138
+ success((0, _model.fromJson)(self, result[self.json], {
139
+ makesDirty: false
140
+ }));
141
+ }
142
+ (0, _model.getOne)({
143
+ resource: this.resource,
144
+ id: this.id(),
145
+ success: handleResponse,
146
+ error: error,
147
+ embed: embed
148
+ });
149
+ };
150
+ this.patch = function (success, error, embed) {
151
+ var self = this,
152
+ data = (0, _model.serialise)(this, undefined, undefined, undefined, {
153
+ excludeOld: true
154
+ })[0];
155
+ function handleResponse(result) {
156
+ success((0, _model.fromJson)(self, result[self.json], {
157
+ makesDirty: false
158
+ }));
159
+ }
160
+ (0, _model.patchOne)({
161
+ resource: this.resource,
162
+ id: this.id(),
163
+ success: handleResponse,
164
+ error: error,
165
+ data: data,
166
+ embed: embed
167
+ });
168
+ };
169
+ this.destroy = function (success, error) {
170
+ (0, _model.deleteOne)(this.resource + '/' + this.id(), success, error);
171
+ };
172
+ this.duplicate = function (success, error) {
173
+ var self = this,
174
+ request = new _model.Request();
175
+ request.resource('/products/' + self.id() + '/copy/');
176
+ request.method('POST');
177
+ function handleResponse(status, data) {
178
+ if (status === 201) {
179
+ success((0, _model.fromJson)(self, data[self.json]));
180
+ } else {
181
+ error(null, data);
182
+ }
183
+ }
184
+ request.responseHandler(handleResponse).errorHandler(error);
185
+ request.send();
186
+ };
187
+ this.company = function () {
188
+ return this.domain() ? this.domain().company() : null;
189
+ };
190
+ this.variationFields = function () {
191
+ var variationFields = [];
192
+ if ((0, _helpers.notEmptyArray)(this.groupVariationFields())) {
193
+ variationFields = variationFields.concat(this.groupVariationFields());
194
+ }
195
+ if ((0, _helpers.notEmptyArray)(this.independentVariationFields())) {
196
+ variationFields = variationFields.concat(this.independentVariationFields());
197
+ }
198
+ return variationFields;
199
+ };
200
+ this.removeVariation = function (variation) {
201
+ var variations = !variation.independent() ? this.groupVariationFields() : this.independentVariationFields();
202
+ return (0, _helpers.removeObjectFromArrayWithIntegerValue)(variations, 'id', variation.id());
203
+ };
204
+ this.primaryImage = function () {
205
+ var feature = this.featureImage(),
206
+ images = this.images(),
207
+ firstImage = images && images[0] ? images[0] : null;
208
+ return feature ? feature : firstImage;
209
+ };
210
+ this.productPrimaryImage = function () {
211
+ return this.primaryImage() ? this.primaryImage().viewUrl() : null;
212
+ };
213
+ this.productCurrency = function () {
214
+ var domain = this.domain();
215
+ return domain && domain.company() ? domain.company().defaultCurrency() : null;
216
+ };
217
+ this.hasGroupVariationFields = function () {
218
+ return (0, _helpers.notEmptyArray)(this.groupVariationFields());
219
+ };
220
+ this.hasIndependentVariationFields = function () {
221
+ return (0, _helpers.notEmptyArray)(this.independentVariationFields());
222
+ };
223
+ this.buildEmptyVariationGroup = function () {
224
+ var variationsGroupBuilt = new _variations_group.VariationsGroup(),
225
+ groupVariationFields = this.groupVariationFields(),
226
+ emptyGroupCost = 0,
227
+ variations = [],
228
+ i,
229
+ emptyVariation;
230
+ variationsGroupBuilt.quantity('0');
231
+ for (i = 0; i < groupVariationFields.length; i++) {
232
+ emptyVariation = groupVariationFields[i].buildEmptyVariation();
233
+ variations.push(emptyVariation);
234
+ emptyGroupCost += parseFloat(emptyVariation.cost(), 10);
235
+ }
236
+ variationsGroupBuilt.groupCost(emptyGroupCost.toString());
237
+ variationsGroupBuilt.variations(variations);
238
+ return variationsGroupBuilt;
239
+ };
240
+ this.buildEmptyVariations = function () {
241
+ var emptyVariations = [],
242
+ emptyVariation,
243
+ independentVariationFields = this.independentVariationFields(),
244
+ i;
245
+ for (i = 0; i < independentVariationFields.length; i++) {
246
+ emptyVariation = independentVariationFields[i].buildEmptyVariation();
247
+ emptyVariations.push(emptyVariation);
248
+ }
249
+ return emptyVariations;
250
+ };
251
+ this.tax = function () {
252
+ return this.taxType();
253
+ };
254
+ this.previewImages = function (maxImages) {
255
+ var files = this.images();
256
+ if (Boolean(files)) {
257
+ return files.slice(0, maxImages);
258
+ }
259
+ return [];
260
+ };
261
+ this.stripePublishableKey = function () {
262
+ return this.domain().company() ? this.domain().company().stripePublishableKey() : null;
263
+ };
264
+ this.stripeIsValidAndActive = function () {
265
+ var company = this.domain().company();
266
+ return this.stripePublishableKey() && company && company.acceptStripe();
267
+ };
268
+ this.isSupplierMOD = function () {
269
+ return this.productType() === _product_types.productTypesInts.get('Supplier MOD (made on demand)');
270
+ };
271
+ this.isResell = function () {
272
+ return this.isSupplierMOD();
273
+ };
274
+ }
275
+ function Products() {
276
+ this.resource = '/products';
277
+ this.json = 'products';
278
+ this.single = Product;
279
+ this.get = function (success, error, parameters) {
280
+ var self = this;
281
+ function handleResponse(result) {
282
+ success((0, _model.fromJsonList)(self, result, {
283
+ makesDirty: false
284
+ }));
285
+ }
286
+ (0, _model.getList)(this.resource, handleResponse, error, parameters);
287
+ };
288
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.productTypesInts = exports.productTypes = void 0;
7
+ var _dictionary = require("./dictionary.js");
8
+ var productTypes = exports.productTypes = new _dictionary.Dictionary();
9
+ productTypes.add(0, 'supplier MOD (made on demand)');
10
+ productTypes.add(1, 'supplier');
11
+ productTypes.add(2, 'seller');
12
+ productTypes.add(3, 'seller MOD (made on demand)');
13
+ productTypes.add(4, 'cloned MOD (made on demand)');
14
+ productTypes.add(5, 'seller cloned MOD (made on demand)');
15
+ productTypes.add(6, 'production MOD (made on demand)');
16
+ productTypes.add(7, 'cloned supplier');
17
+ productTypes.add(8, 'seller inventory');
18
+ productTypes.add(9, 'supplir inventory');
19
+ productTypes.add(10, 'seller group buy');
20
+ productTypes.add(11, 'supplier resell MOD (made on demand)');
21
+ productTypes.add(12, 'supplier resell');
22
+ productTypes.add(14, 'supplier group buy inventory');
23
+ productTypes.add(14, 'seller inventory cloned');
24
+ productTypes.add(15, 'seller group buy inventory cloned');
25
+ productTypes.add(16, 'supply seller MOD(made on demand) cloned');
26
+ productTypes.add(17, 'supplier to supplier resell MOD(made on demand)');
27
+ productTypes.add(18, 'supplier resell cloned');
28
+ productTypes.add(19, 'supply domain reference');
29
+ var productTypesInts = exports.productTypesInts = new _dictionary.Dictionary();
30
+ productTypes.each(function (key, value) {
31
+ productTypesInts.add(value, parseInt(key, 10));
32
+ });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ProductionComment = ProductionComment;
7
+ var _model = require("./model.js");
8
+ var _assignment = require("./assignment.js");
9
+ var _user = require("./user.js");
10
+ var _merchi_file = require("./merchi_file.js");
11
+ var _notification = require("./notification.js");
12
+ function ProductionComment() {
13
+ this.resource = '/production_comments';
14
+ this.json = 'productionComment';
15
+ (0, _model.addPropertyTo)(this, 'id');
16
+ (0, _model.addPropertyTo)(this, 'user', _user.User);
17
+ (0, _model.addPropertyTo)(this, 'file', _merchi_file.MerchiFile);
18
+ (0, _model.addPropertyTo)(this, 'notifications', _notification.Notification);
19
+ (0, _model.addPropertyTo)(this, 'assignment', _assignment.Assignment);
20
+ (0, _model.addPropertyTo)(this, 'date');
21
+ (0, _model.addPropertyTo)(this, 'text');
22
+ (0, _model.addPropertyTo)(this, 'urgency');
23
+ (0, _model.addPropertyTo)(this, 'subject');
24
+ (0, _model.addPropertyTo)(this, 'sendSms');
25
+ (0, _model.addPropertyTo)(this, 'sendEmail');
26
+ (0, _model.addPropertyTo)(this, 'isUrgentQuestion');
27
+ this.create = function (options) {
28
+ var data = (0, _model.serialise)(this),
29
+ self = this,
30
+ embed = options.embed ? options.embed : {};
31
+ function handleResponse(result) {
32
+ options.success((0, _model.fromJson)(self, result[self.json]));
33
+ }
34
+ (0, _model.create)({
35
+ resource: this.resource,
36
+ parameters: data[0],
37
+ files: (0, _model.enumerateFiles)(data[1]),
38
+ success: handleResponse,
39
+ as_domain: options.asDomain,
40
+ error: options.error,
41
+ embed: embed
42
+ });
43
+ };
44
+ }
package/dist/quote.js ADDED
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Quote = Quote;
7
+ exports.Quotes = Quotes;
8
+ var _uuid = require("./uuid.js");
9
+ var _model = require("./model.js");
10
+ var _quote_item = require("./quote_item.js");
11
+ var _assignment = require("./assignment.js");
12
+ var _invoice = require("./invoice.js");
13
+ function Quote() {
14
+ this.resource = '/quotes';
15
+ this.json = 'quote';
16
+ this.temporaryId = (0, _uuid.generateUUID)();
17
+ (0, _model.addPropertyTo)(this, 'id');
18
+ (0, _model.addPropertyTo)(this, 'agreedDeadline');
19
+ (0, _model.addPropertyTo)(this, 'quoteItems', _quote_item.QuoteItem);
20
+ (0, _model.addPropertyTo)(this, 'assignments', _assignment.Assignment);
21
+ (0, _model.addPropertyTo)(this, 'currency');
22
+ (0, _model.addPropertyTo)(this, 'invoice', _invoice.Invoice);
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.quoteTotal = function () {
38
+ var self = this,
39
+ items = Boolean(self.quoteItems()) ? self.quoteItems() : [],
40
+ total = parseFloat(0.000),
41
+ i;
42
+ for (i = 0; i < items.length; i++) {
43
+ total += parseFloat(items[i].total());
44
+ }
45
+ return total;
46
+ };
47
+ this.deadlineTimeDifference = function () {
48
+ var self = this,
49
+ proposedDeadline = Boolean(self.agreedDeadline()) ? self.agreedDeadline() : null,
50
+ assignments = Boolean(self.assignments()) ? self.assignments() : null,
51
+ assignment = Boolean(assignments) && assignments.length > 0 ? assignments[0] : null,
52
+ productionDeadline = Boolean(assignment) ? assignment.productionDeadline() : null;
53
+ if (Boolean(proposedDeadline) && Boolean(productionDeadline)) {
54
+ return productionDeadline - proposedDeadline;
55
+ }
56
+ return null;
57
+ };
58
+ this.findQuoteItemIndex = function (quoteItemId) {
59
+ var self = this,
60
+ quoteItems = Boolean(self.quoteItems()) ? self.quoteItems() : [];
61
+ return quoteItems.findIndex(function (arrayElement) {
62
+ return String(arrayElement.id()) === String(quoteItemId);
63
+ });
64
+ };
65
+ this.removeQuoteItem = function (quoteItem) {
66
+ var self = this,
67
+ itemIndex = self.findQuoteItemIndex(quoteItem.id()),
68
+ quoteItems = self.quoteItems();
69
+ if (Boolean(quoteItems) && itemIndex >= 0) {
70
+ quoteItems.splice(itemIndex, 1);
71
+ }
72
+ };
73
+ }
74
+ function Quotes() {
75
+ this.resource = '/quotes';
76
+ this.json = 'quotes';
77
+ this.single = Quote;
78
+ this.get = function (success, error, offset, limit, q) {
79
+ var self = this;
80
+ function handleResponse(result) {
81
+ success((0, _model.fromJsonList)(self, result, {
82
+ makesDirty: false
83
+ }));
84
+ }
85
+ (0, _model.getList)(this.resource, handleResponse, error, {
86
+ offset: offset,
87
+ limit: limit,
88
+ q: q
89
+ });
90
+ };
91
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.QuoteItem = QuoteItem;
7
+ exports.QuoteItems = QuoteItems;
8
+ var _uuid = require("./uuid.js");
9
+ var _model = require("./model.js");
10
+ function QuoteItem() {
11
+ this.resource = '/quote_items';
12
+ this.json = 'quoteItem';
13
+ this.temporaryId = (0, _uuid.generateUUID)();
14
+ (0, _model.addPropertyTo)(this, 'id');
15
+ (0, _model.addPropertyTo)(this, 'type');
16
+ (0, _model.addPropertyTo)(this, 'quantity');
17
+ (0, _model.addPropertyTo)(this, 'description');
18
+ (0, _model.addPropertyTo)(this, 'unitPrice');
19
+ this.get = function (success, error) {
20
+ var self = this;
21
+ function handleResponse(result) {
22
+ success((0, _model.fromJson)(self, result[self.json], {
23
+ makesDirty: false
24
+ }));
25
+ }
26
+ (0, _model.getOne)({
27
+ resource: this.resource,
28
+ id: this.id(),
29
+ success: handleResponse,
30
+ error: error
31
+ });
32
+ };
33
+ this.total = function () {
34
+ var self = this,
35
+ quantity = Boolean(self.quantity()) ? self.quantity() : 0,
36
+ unitPrice = Boolean(self.unitPrice()) ? self.unitPrice() : 0,
37
+ total;
38
+ total = quantity * unitPrice;
39
+ return total.toFixed(3);
40
+ };
41
+ }
42
+ function QuoteItems() {
43
+ this.resource = '/quote_items';
44
+ this.json = 'quoteItems';
45
+ this.single = QuoteItem;
46
+ this.get = function (success, error, offset, limit, q) {
47
+ var self = this;
48
+ function handleResponse(result) {
49
+ success((0, _model.fromJsonList)(self, result, {
50
+ makesDirty: false
51
+ }));
52
+ }
53
+ (0, _model.getList)(this.resource, handleResponse, error, {
54
+ offset: offset,
55
+ limit: limit,
56
+ q: q
57
+ });
58
+ };
59
+ }