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/src/set.js ADDED
@@ -0,0 +1,28 @@
1
+ import { Dictionary } from './dictionary.js';
2
+
3
+ export function Set() {
4
+
5
+ var store = new Dictionary();
6
+
7
+ this.add = function (value) {
8
+ store.add(value, value);
9
+ };
10
+
11
+ this.has = function (value) {
12
+ return store.has(value);
13
+ };
14
+
15
+ this.each = function (procedure) {
16
+ store.each(function (name, value) { procedure(value); });
17
+ return this;
18
+ };
19
+
20
+ this.values = function () {
21
+ return store.values();
22
+ };
23
+
24
+ this.remove = function (value) {
25
+ store.remove(value);
26
+ return this;
27
+ };
28
+ }
@@ -0,0 +1,191 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, getOne, fromJson, enumerateFiles, serialise, patchOne,
3
+ deleteOne, fromJsonList, getList, create } from './model.js';
4
+ import { removeObjectFromArrayWithIntegerValue } from './helpers.js';
5
+ import { Address } from './address.js';
6
+ import { Assignment } from './assignment.js';
7
+ import { CountryTax } from './country_tax.js';
8
+ import { DomainTag } from './domain_tag.js';
9
+ import { User } from './user.js';
10
+ import { Company } from './company.js';
11
+ import { Invoice } from './invoice.js';
12
+ import { Job } from './job.js';
13
+ import { MerchiFile } from './merchi_file.js';
14
+ import { ShipmentItem } from './shipment_item.js';
15
+ import { ShipmentMethod } from './shipment_method.js';
16
+ import { InternalTag } from './internal_tag.js';
17
+
18
+ export function Shipment() {
19
+ this.resource = '/shipments';
20
+ this.json = 'shipment';
21
+ this.temporaryId = generateUUID();
22
+
23
+ addPropertyTo(this, 'id');
24
+ addPropertyTo(this, 'name');
25
+ addPropertyTo(this, 'pickUp');
26
+ addPropertyTo(this, 'shipmentServiceBookingInfo');
27
+ addPropertyTo(this, 'shipmentServiceQuote');
28
+ addPropertyTo(this, 'shipmentLabel', MerchiFile);
29
+ addPropertyTo(this, 'creationDate');
30
+ addPropertyTo(this, 'dispatchDate');
31
+ addPropertyTo(this, 'dispatchedDate');
32
+ addPropertyTo(this, 'expectedReceiveDate');
33
+ addPropertyTo(this, 'receivedDate');
34
+ addPropertyTo(this, 'sender', User);
35
+ addPropertyTo(this, 'senderCompany', Company);
36
+ addPropertyTo(this, 'senderAddress', Address);
37
+ addPropertyTo(this, 'senderNotes');
38
+ addPropertyTo(this, 'blindShipTo');
39
+ addPropertyTo(this, 'receiver', User);
40
+ addPropertyTo(this, 'receiverCompany', Company);
41
+ addPropertyTo(this, 'receiverAddress', Address);
42
+ addPropertyTo(this, 'receiverNotes');
43
+ addPropertyTo(this, 'invoices', Invoice);
44
+ addPropertyTo(this, 'jobs', Job);
45
+ addPropertyTo(this, 'assignments', Assignment);
46
+ addPropertyTo(this, 'trackingNumber');
47
+ addPropertyTo(this, 'transportCompany');
48
+ addPropertyTo(this, 'transportCompanyName');
49
+ addPropertyTo(this, 'sendSms');
50
+ addPropertyTo(this, 'sendEmail');
51
+ addPropertyTo(this, 'cost');
52
+ addPropertyTo(this, 'taxAmount');
53
+ addPropertyTo(this, 'maxWeight');
54
+ addPropertyTo(this, 'maxVolume');
55
+ addPropertyTo(this, 'taxType', CountryTax);
56
+ addPropertyTo(this, 'senderResponsible');
57
+ addPropertyTo(this, 'tags', DomainTag);
58
+ addPropertyTo(this, 'shipmentItems', ShipmentItem)
59
+ addPropertyTo(this, 'shipmentMethod', ShipmentMethod);
60
+ addPropertyTo(this, 'internalTags', InternalTag);
61
+
62
+ this.get = function (success, error, embed) {
63
+ var self = this;
64
+ function handleResponse(result) {
65
+ success(fromJson(self, result[self.json],
66
+ {makesDirty: false}));
67
+ }
68
+ getOne({resource: this.resource,
69
+ id: this.id(),
70
+ success: handleResponse,
71
+ error: error,
72
+ embed: embed});
73
+ };
74
+
75
+ this.create = function (options) {
76
+ var data = serialise(this),
77
+ self = this;
78
+ function handleResponse(result) {
79
+ options.success(fromJson(self, result[self.json]));
80
+ }
81
+ create({resource: this.resource,
82
+ parameters: data[0],
83
+ files: enumerateFiles(data[1]),
84
+ success: handleResponse,
85
+ error: options.error,
86
+ embed: options.embed});
87
+ };
88
+
89
+ this.patch = function (success, error, data, embed) {
90
+ var self = this;
91
+ function handleResponse(result) {
92
+ success(fromJson(self, result[self.json],
93
+ {makesDirty: false}));
94
+ }
95
+ patchOne({resource: this.resource,
96
+ id: this.id(),
97
+ success: handleResponse,
98
+ error: error,
99
+ data: data,
100
+ embed: embed});
101
+ };
102
+
103
+ this.update = function (options) {
104
+ var self = this;
105
+ this.patch(options.success,
106
+ options.error,
107
+ serialise(self, undefined, undefined, undefined,
108
+ {excludeOld: true})[0],
109
+ options.embed);
110
+ };
111
+
112
+ this.destroy = function (success, error) {
113
+ deleteOne(this.resource + "/" + this.id(), success, error);
114
+ };
115
+
116
+ this.hasJobs = function () {
117
+ return Boolean(this.jobs()) && this.jobs().length > 0;
118
+ };
119
+
120
+ this.hasJob = function (job) {
121
+ var jobIndex = this.jobs().findIndex(function (shipmentJob) {
122
+ return shipmentJob.id() === job.id();
123
+ });
124
+ return jobIndex >= 0;
125
+ };
126
+
127
+ this.hasAssignments = function () {
128
+ return Boolean(this.assignments()) && this.assignments().length > 0;
129
+ };
130
+
131
+ this.hasAssignment = function (assignment) {
132
+ var assignments = this.assignments(),
133
+ assignmentIndex;
134
+ if (Boolean(assignments)) {
135
+ assignmentIndex = assignments.findIndex(
136
+ function (shipmentAssignment) {
137
+ return shipmentAssignment.id() === assignment.id();
138
+ });
139
+ return assignmentIndex >= 0;
140
+ }
141
+ return false;
142
+ };
143
+
144
+ this.removeAssignment = function (assignmentId) {
145
+ var self = this;
146
+ if (Boolean(assignmentId) && assignmentId !== '') {
147
+ removeObjectFromArrayWithIntegerValue(self.assignments(),
148
+ 'id', assignmentId);
149
+ }
150
+ };
151
+
152
+ this.removeJob = function (jobId) {
153
+ var self = this;
154
+ if (Boolean(jobId) && jobId !== '') {
155
+ removeObjectFromArrayWithIntegerValue(self.jobs(), 'id', jobId);
156
+ }
157
+ };
158
+
159
+ this.readyForDispatchedNotification = function () {
160
+ var self = this;
161
+ return Boolean(self.id() && self.trackingNumber() &&
162
+ self.transportCompany() && self.dispatchedDate());
163
+ };
164
+
165
+ this.userIsResponsible = function (user) {
166
+ var senderResponsible = this.senderResponsible(),
167
+ shipmentUser = senderResponsible ?
168
+ this.sender() : this.receiver();
169
+ return shipmentUser && shipmentUser.id() === user.id();
170
+ };
171
+
172
+ this.responsibleCompany = function () {
173
+ return this.senderResponsible() ?
174
+ this.senderCompany() : this.receiverCompany();
175
+ };
176
+ }
177
+
178
+ export function Shipments() {
179
+ this.resource = '/shipments';
180
+ this.json = 'shipments';
181
+ this.single = Shipment;
182
+
183
+ this.get = function (success, error, parameters) {
184
+ var self = this;
185
+ function handleResponse(result) {
186
+ success(fromJsonList(self, result, {makesDirty: false}));
187
+ }
188
+ getList(this.resource, handleResponse, error,
189
+ parameters);
190
+ };
191
+ }
@@ -0,0 +1,13 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo } from './model.js';
3
+ import { ShipmentItemFulfillment } from './shipment_item_fulfillment.js';
4
+ import { Job } from './job.js';
5
+
6
+ export function ShipmentItem() {
7
+ this.resource = '/shipment_items';
8
+ this.json = 'shipmentItem';
9
+ this.temporaryId = generateUUID();
10
+
11
+ addPropertyTo(this, 'job', Job);
12
+ addPropertyTo(this, 'fulfillments', ShipmentItemFulfillment);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo } from './model.js';
3
+ import { Assignment } from './assignment.js';
4
+ import { Job } from './job.js';
5
+
6
+ export function ShipmentItemFulfillment() {
7
+ this.resource = '/shipment_item_fulfillments';
8
+ this.json = 'shipmentItemFulfillment';
9
+ this.temporaryId = generateUUID();
10
+
11
+ addPropertyTo(this, 'assignment', Assignment);
12
+ addPropertyTo(this, 'job', Job);
13
+ }
@@ -0,0 +1,73 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, create, serialise, fromJson, enumerateFiles, patchOne,
3
+ fromJsonList, getList } from './model.js';
4
+ import { Address } from './address.js';
5
+ import { CountryTax } from './country_tax.js';
6
+ import { Company } from './company.js';
7
+ import { ShipmentMethodVariation } from './shipment_method_variation.js';
8
+
9
+ export function ShipmentMethod() {
10
+ this.resource = '/shipment_methods';
11
+ this.json = 'shipmentMethod';
12
+ this.temporaryId = generateUUID();
13
+
14
+ addPropertyTo(this, 'id');
15
+ addPropertyTo(this, 'name');
16
+ addPropertyTo(this, 'shipmentService');
17
+ addPropertyTo(this, 'pickUp');
18
+ addPropertyTo(this, 'originAddress', Address);
19
+ addPropertyTo(this, 'company', Company);
20
+ addPropertyTo(this, 'companyDefault');
21
+ addPropertyTo(this, 'defaultCost');
22
+ addPropertyTo(this, 'maxCost');
23
+ addPropertyTo(this, 'currency');
24
+ addPropertyTo(this, 'transportCompany');
25
+ addPropertyTo(this, 'transportCompanyName');
26
+ addPropertyTo(this, 'variations', ShipmentMethodVariation);
27
+ addPropertyTo(this, 'taxType', CountryTax);
28
+
29
+ this.create = function (success, error, embed, domainId) {
30
+ var data = serialise(this),
31
+ self = this;
32
+ function handleResponse(result) {
33
+ success(fromJson(self, result[self.json]));
34
+ }
35
+ create({resource: this.resource,
36
+ parameters: data[0],
37
+ files: enumerateFiles(data[1]),
38
+ success: handleResponse,
39
+ error: error,
40
+ embed: embed,
41
+ as_domain: domainId});
42
+ };
43
+ this.patch = function (success, error, embed) {
44
+ var self = this,
45
+ data = serialise(this, undefined, undefined, undefined,
46
+ {excludeOld: true})[0];
47
+ function handleResponse(result) {
48
+ success(fromJson(self, result[self.json],
49
+ {makesDirty: false}));
50
+ }
51
+ patchOne({resource: this.resource,
52
+ id: this.id(),
53
+ success: handleResponse,
54
+ error: error,
55
+ data: data,
56
+ embed: embed});
57
+ };
58
+ }
59
+
60
+ export function ShipmentMethods() {
61
+ this.resource = '/shipment_methods';
62
+ this.json = 'shipmentMethods';
63
+ this.single = ShipmentMethod;
64
+
65
+ this.get = function (success, error, parameters) {
66
+ var self = this;
67
+ function handleResponse(result) {
68
+ success(fromJsonList(self, result, {makesDirty: false}));
69
+ }
70
+ getList(this.resource, handleResponse, error,
71
+ parameters);
72
+ };
73
+ }
@@ -0,0 +1,34 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, fromJsonList, getList } from './model.js';
3
+ import { CountryTax } from './country_tax.js';
4
+ import { ShipmentMethod } from './shipment_method.js';
5
+
6
+ export function ShipmentMethodVariation() {
7
+ this.resource = '/shipment_method_variations';
8
+ this.json = 'shipmentMethodVariation';
9
+ this.temporaryId = generateUUID();
10
+
11
+ addPropertyTo(this, 'id');
12
+ addPropertyTo(this, 'destinationCountry');
13
+ addPropertyTo(this, 'destinationState');
14
+ addPropertyTo(this, 'cost');
15
+ addPropertyTo(this, 'currency');
16
+ addPropertyTo(this, 'maxWeight');
17
+ addPropertyTo(this, 'shipmentMethod', ShipmentMethod);
18
+ addPropertyTo(this, 'taxType', CountryTax);
19
+ }
20
+
21
+ export function ShipmentMethodVariations() {
22
+ this.resource = '/shipment_method_variations';
23
+ this.json = 'shipmentMethodVariations';
24
+ this.single = ShipmentMethodVariation;
25
+
26
+ this.get = function (success, error, parameters) {
27
+ var self = this;
28
+ function handleResponse(result) {
29
+ success(fromJsonList(self, result, {makesDirty: false}));
30
+ }
31
+ getList(this.resource, handleResponse, error,
32
+ parameters);
33
+ };
34
+ }
@@ -0,0 +1,68 @@
1
+ import { addPropertyTo, serialise, fromJson, create, enumerateFiles, getList,
2
+ fromJsonList, getOne } from './model.js';
3
+ import { User } from './user.js';
4
+ import { CountryTax } from './country_tax.js';
5
+
6
+ export function SubscriptionPlan() {
7
+ this.resource = '/subscription_plans';
8
+ this.json = 'subscriptionPlan';
9
+
10
+ addPropertyTo(this, 'id');
11
+ addPropertyTo(this, 'created');
12
+ addPropertyTo(this, 'updated');
13
+ addPropertyTo(this, 'createdBy', User);
14
+ addPropertyTo(this, 'updatedBy', User);
15
+ addPropertyTo(this, 'name');
16
+ addPropertyTo(this, 'currency');
17
+ addPropertyTo(this, 'tax', CountryTax);
18
+ addPropertyTo(this, 'baseCost');
19
+ addPropertyTo(this, 'whiteLabelDomainCost');
20
+ addPropertyTo(this, 'perSmsCost');
21
+ addPropertyTo(this, 'perUserCost');
22
+ addPropertyTo(this, 'perDomainCost');
23
+ addPropertyTo(this, 'baseUserCount');
24
+ addPropertyTo(this, 'baseDomainCount');
25
+ addPropertyTo(this, 'billingCycleDays');
26
+ addPropertyTo(this, 'isPrivate');
27
+
28
+ this.create = function (success, error, embed, as_domain) {
29
+ var data = serialise(this),
30
+ self = this;
31
+ function handleResponse(result) {
32
+ success(fromJson(self, result[self.json]));
33
+ }
34
+ create({resource: this.resource,
35
+ parameters: data[0],
36
+ as_domain: as_domain,
37
+ files: enumerateFiles(data[1]),
38
+ success: handleResponse,
39
+ error: error,
40
+ embed: embed});
41
+ };
42
+
43
+ this.get = function (success, error) {
44
+ var self = this;
45
+ function handleResponse(result) {
46
+ success(fromJson(self, result[self.json],
47
+ {makesDirty: false}));
48
+ }
49
+ getOne({resource: this.resource,
50
+ id: this.id(),
51
+ success: handleResponse,
52
+ error: error});
53
+ };
54
+ }
55
+
56
+ export function SubscriptionPlans() {
57
+ this.resource = '/subscription_plans';
58
+ this.json = 'subscriptionPlans';
59
+ this.single = SubscriptionPlan;
60
+
61
+ this.get = function (success, error, parameters) {
62
+ var self = this;
63
+ function handleResponse(result) {
64
+ success(fromJsonList(self, result, {makesDirty: false}));
65
+ }
66
+ getList(this.resource, handleResponse, error, parameters);
67
+ };
68
+ }
@@ -0,0 +1,60 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, fromJson, getOne, getList, serialise, create,
3
+ fromJsonList, enumerateFiles } from './model.js';
4
+ import { Product } from './product.js';
5
+ import { Domain } from './domain.js';
6
+
7
+ export function SupplyDomain() {
8
+ this.resource = '/supply_domains';
9
+ this.json = 'supplyDomain';
10
+ this.temporaryId = generateUUID();
11
+
12
+ addPropertyTo(this, 'id');
13
+ addPropertyTo(this, 'needsDrafting');
14
+ addPropertyTo(this, 'product', Product);
15
+ addPropertyTo(this, 'supplyProduct', Product);
16
+ addPropertyTo(this, 'domain', Domain);
17
+
18
+ this.get = function (success, error) {
19
+ var self = this;
20
+ function handleResponse(result) {
21
+ success(fromJson(self, result[self.json],
22
+ {makesDirty: false}));
23
+ }
24
+ getOne({resource: this.resource,
25
+ id: this.id(),
26
+ success: handleResponse,
27
+ error: error});
28
+ };
29
+
30
+ this.create = function (success, error, embed, as_domain) {
31
+ var data = serialise(this),
32
+ self = this;
33
+ function handleResponse(result) {
34
+ success(fromJson(self, result[self.json]));
35
+ }
36
+
37
+ create({resource: this.resource,
38
+ parameters: data[0],
39
+ as_domain: as_domain,
40
+ files: enumerateFiles(data[1]),
41
+ success: handleResponse,
42
+ data: error,
43
+ embed: embed});
44
+ };
45
+ }
46
+
47
+ export function SupplyDomains() {
48
+ this.resource = '/supply_domains';
49
+ this.json = 'supplyDomain';
50
+ this.single = SupplyDomain;
51
+
52
+ this.get = function (success, error, parameters) {
53
+ var self = this;
54
+ function handleResponse(result) {
55
+ success(fromJsonList(self, result,
56
+ {makesDirty: false}));
57
+ }
58
+ getList(this.resource, handleResponse, error, parameters);
59
+ };
60
+ }
@@ -0,0 +1,8 @@
1
+ import { addPropertyTo } from './model.js';
2
+
3
+ export function SystemRole() {
4
+ this.resource = '/system_roles';
5
+ this.json = 'systemRole';
6
+
7
+ addPropertyTo(this, 'role');
8
+ }
package/src/theme.js ADDED
@@ -0,0 +1,188 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, serialise, create, fromJson, enumerateFiles, getOne,
3
+ patchOne, fromJsonList, getList } from './model.js';
4
+ import { themeStatus } from './theme_status.js';
5
+ import { MerchiFile } from './merchi_file.js';
6
+ import { Component } from './component.js';
7
+ import { Domain } from './domain.js';
8
+ import { Page } from './page.js';
9
+ import { User } from './user.js';
10
+ import { InternalTag } from './internal_tag.js';
11
+
12
+ export function Theme() {
13
+ this.resource = '/themes';
14
+ this.json = 'theme';
15
+ this.temporaryId = generateUUID();
16
+
17
+ addPropertyTo(this, 'id');
18
+ addPropertyTo(this, 'aiContext');
19
+ addPropertyTo(this, 'jsBundle');
20
+ addPropertyTo(this, 'name');
21
+ addPropertyTo(this, 'description');
22
+ addPropertyTo(this, 'foundation');
23
+ addPropertyTo(this, 'public');
24
+ addPropertyTo(this, 'lastUpdated');
25
+
26
+ addPropertyTo(this, 'components', Component);
27
+ addPropertyTo(this, 'contextComponents', Component);
28
+ addPropertyTo(this, 'featureImage', MerchiFile);
29
+ addPropertyTo(this, 'images', MerchiFile);
30
+ addPropertyTo(this, 'cssImageFiles', MerchiFile);
31
+ addPropertyTo(this, 'pages', Page);
32
+
33
+ addPropertyTo(this, 'headerTemplate');
34
+ addPropertyTo(this, 'headerHtml');
35
+ addPropertyTo(this, 'footerTemplate');
36
+ addPropertyTo(this, 'footerHtml');
37
+ addPropertyTo(this, 'indexPageTemplate');
38
+ addPropertyTo(this, 'indexHtml');
39
+ addPropertyTo(this, 'domainInvitePageTemplate');
40
+ addPropertyTo(this, 'domainInviteHtml');
41
+ addPropertyTo(this, 'resetPasswordPageTemplate');
42
+ addPropertyTo(this, 'passwordResetHtml');
43
+ addPropertyTo(this, 'passwordChangePageTemplate');
44
+ addPropertyTo(this, 'passwordChangeHtml');
45
+ addPropertyTo(this, 'jobDraftingPageTemplate');
46
+ addPropertyTo(this, 'jobDraftingHtml');
47
+ addPropertyTo(this, 'jobQuoteRequestedPageTemplate');
48
+ addPropertyTo(this, 'jobQuoteRequestedHtml');
49
+ addPropertyTo(this, 'draftPreviewPageTemplate');
50
+ addPropertyTo(this, 'draftPreviewHtml');
51
+ addPropertyTo(this, 'invoicePageTemplate');
52
+ addPropertyTo(this, 'invoiceHtml');
53
+ addPropertyTo(this, 'productPageTemplate');
54
+ addPropertyTo(this, 'productHtml');
55
+ addPropertyTo(this, 'invoicePaidPageTemplate');
56
+ addPropertyTo(this, 'invoicePaidHtml');
57
+ addPropertyTo(this, 'loginPageTemplate');
58
+ addPropertyTo(this, 'loginPageHtml');
59
+ addPropertyTo(this, 'errorPageTemplate');
60
+ addPropertyTo(this, 'errorPageHtml');
61
+
62
+ addPropertyTo(this, 'footerError');
63
+ addPropertyTo(this, 'headerError');
64
+ addPropertyTo(this, 'indexPageError');
65
+ addPropertyTo(this, 'productsPageError');
66
+ addPropertyTo(this, 'domainInvitePageError');
67
+ addPropertyTo(this, 'resetPasswordPageError');
68
+ addPropertyTo(this, 'passwordChangePageError');
69
+ addPropertyTo(this, 'jobDraftingPageError');
70
+ addPropertyTo(this, 'jobQuoteRequestedPageError');
71
+ addPropertyTo(this, 'invoicePageError');
72
+
73
+ addPropertyTo(this, 'productPageError');
74
+ addPropertyTo(this, 'invoicePaidPageError');
75
+ addPropertyTo(this, 'loginPageError');
76
+ addPropertyTo(this, 'errorPageError');
77
+
78
+ addPropertyTo(this, 'mainCssErrorMessage');
79
+ addPropertyTo(this, 'mainCssStatus');
80
+ addPropertyTo(this, 'mainCss');
81
+ addPropertyTo(this, 'mainCssTemplateEditing');
82
+ addPropertyTo(this, 'mainCssTemplateUsing');
83
+
84
+ addPropertyTo(this, 'emailCssErrorMessage');
85
+ addPropertyTo(this, 'emailCssStatus');
86
+ addPropertyTo(this, 'emailCss');
87
+ addPropertyTo(this, 'emailCssTemplateEditing');
88
+ addPropertyTo(this, 'emailCssTemplateUsing');
89
+
90
+ addPropertyTo(this, 'author', User);
91
+ addPropertyTo(this, 'domain', Domain);
92
+ addPropertyTo(this, 'defaultForDomainType');
93
+ addPropertyTo(this, 'internalTags', InternalTag);
94
+
95
+ this.create = function (success, error, embed, as_domain) {
96
+ var self = this,
97
+ data = serialise(this);
98
+ function handleResponse(result) {
99
+ success(fromJson(self, result[self.json]));
100
+ }
101
+ create({resource: this.resource,
102
+ parameters: data[0],
103
+ as_domain: as_domain,
104
+ files: enumerateFiles(data[1]),
105
+ success: handleResponse,
106
+ error: error,
107
+ embed: embed});
108
+ };
109
+
110
+ this.get = function (success, error, embed) {
111
+ var self = this;
112
+
113
+ function handleResponse(result) {
114
+ success(fromJson(self, result[self.json],
115
+ {makesDirty: false}));
116
+ }
117
+
118
+ getOne({resource: this.resource,
119
+ id: this.id(),
120
+ success: handleResponse,
121
+ error: error,
122
+ embed: embed});
123
+ };
124
+
125
+ this.patch = function (success, error, embed) {
126
+ var self = this,
127
+ data = serialise(this)[0];
128
+ function handleResponse(result) {
129
+ success(fromJson(self, result[self.json],
130
+ {makesDirty: false}));
131
+ }
132
+ patchOne({resource: this.resource,
133
+ id: this.id(),
134
+ success: handleResponse,
135
+ error: error,
136
+ data: data,
137
+ embed: embed});
138
+ };
139
+
140
+ this.canBeActivated = function () {
141
+ var validStatus = themeStatus.get("VALID_BUT_NOT_UPDATED");
142
+ return this.mainCssStatus() >= validStatus &&
143
+ this.emailCssStatus() >= validStatus;
144
+ };
145
+
146
+ this.isActiveOnDomain = function (domainId) {
147
+ var domain = this.domain();
148
+ return domain && domain.id() === parseInt(domainId, 10) &&
149
+ domain.activeThemeId() === this.id();
150
+ };
151
+
152
+ this.getPageBySlug = function (slug) {
153
+ var pages = this.pages() ? this.pages() : [],
154
+ i;
155
+ for (i = 0; i < pages.length; i++) {
156
+ var page = pages[i];
157
+ if (page.slug() === slug) {
158
+ return page;
159
+ }
160
+ }
161
+ return null;
162
+ };
163
+
164
+ this.updateTemplateByName = function (name, text) {
165
+ var page = this.getPageBySlug(name);
166
+ if (page) {
167
+ page.template(text);
168
+ } else {
169
+ this[name](text);
170
+ }
171
+ };
172
+ }
173
+
174
+ export function Themes() {
175
+ this.resource = '/themes';
176
+ this.json = 'themes';
177
+ this.single = Theme;
178
+
179
+ this.get = function (success, error, parameters) {
180
+ var self = this;
181
+ function handleResponse(result) {
182
+ success(fromJsonList(self, result,
183
+ {makesDirty: false}));
184
+ }
185
+ getList(this.resource, handleResponse, error, parameters);
186
+ };
187
+
188
+ }