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
@@ -0,0 +1,153 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, serialise, patchOne, enumerateFiles, getList,
3
+ fromJson, getOne, create, fromJsonList } from './model.js';
4
+ import { isAvatarTypeInNotificationAvatar, notificationTypesKeys,
5
+ notificationSectionIconClass } from './notification_types.js';
6
+ import { User } from './user.js';
7
+ import { Domain } from './domain.js';
8
+ import { Job } from './job.js';
9
+ import { MerchiFile } from './merchi_file.js';
10
+ import { DraftComment } from './draft_comment.js';
11
+ import { JobComment } from './job_comment.js';
12
+ import { ProductionComment } from './production_comment.js';
13
+ import { Invoice } from './invoice.js';
14
+
15
+ export function Notification() {
16
+ this.resource = '/notifications';
17
+ this.json = 'notification';
18
+ this.temporaryId = generateUUID();
19
+
20
+ addPropertyTo(this, 'id');
21
+ addPropertyTo(this, 'recipient', User);
22
+ addPropertyTo(this, 'sender', User);
23
+ addPropertyTo(this, 'date');
24
+ addPropertyTo(this, 'domain', Domain);
25
+ addPropertyTo(this, 'relatedJob', Job);
26
+ addPropertyTo(this, 'attachment', MerchiFile);
27
+ addPropertyTo(this, 'seen');
28
+ addPropertyTo(this, 'htmlMessage');
29
+ addPropertyTo(this, 'description');
30
+ addPropertyTo(this, 'urgency');
31
+ addPropertyTo(this, 'subject');
32
+ addPropertyTo(this, 'message');
33
+ addPropertyTo(this, 'link');
34
+ addPropertyTo(this, 'section');
35
+ addPropertyTo(this, 'sendSms');
36
+ addPropertyTo(this, 'sendEmail');
37
+ addPropertyTo(this, 'notificationType');
38
+ addPropertyTo(this, 'relatedJobComment', JobComment);
39
+ addPropertyTo(this, 'relatedDraftComment', DraftComment);
40
+ addPropertyTo(this, 'relatedProductionComment', ProductionComment);
41
+ addPropertyTo(this, 'relatedInvoice', Invoice);
42
+
43
+ this.title = function () {
44
+ if (this.subject() && this.subject() !== 'None') {
45
+ if (this.relatedJob()) {
46
+ return this.subject() + " - " + this.domain().emailDomain();
47
+ }
48
+ return this.subject();
49
+ }
50
+ return this.description();
51
+ };
52
+
53
+ this.create = function (success, error, embed, as_domain) {
54
+ var data = serialise(this),
55
+ self = this;
56
+ function handleResponse(result) {
57
+ success(fromJson(self, result[self.json]));
58
+ }
59
+ create({resource: this.resource,
60
+ parameters: data[0],
61
+ files: enumerateFiles(data[1]),
62
+ success: handleResponse,
63
+ as_domain: as_domain,
64
+ error: error,
65
+ embed: embed});
66
+ };
67
+
68
+ this.get = function (success, error, embed) {
69
+ var self = this;
70
+ function handleResponse(result) {
71
+ success(fromJson(self, result[self.json],
72
+ {makesDirty: false}));
73
+ }
74
+ getOne({resource: this.resource,
75
+ id: this.id(),
76
+ success: handleResponse,
77
+ error: error,
78
+ embed: embed});
79
+ };
80
+
81
+ this.patch = function (success, error, embed, asDomain) {
82
+ var self = this,
83
+ data = serialise(this, undefined, undefined, undefined,
84
+ {excludeOld: true})[0],
85
+ domainId = Boolean(asDomain) ? asDomain.id() : null;
86
+ function handleResponse(result) {
87
+ success(fromJson(self, result[self.json],
88
+ {makesDirty: false}));
89
+ }
90
+ patchOne({resource: this.resource,
91
+ id: this.id(),
92
+ success: handleResponse,
93
+ error: error,
94
+ as_domain: domainId,
95
+ data: data,
96
+ embed: embed});
97
+ };
98
+ this.avatarUrl = function () {
99
+ var noteType = this.notificationType(),
100
+ sender = this.sender(),
101
+ senderAvatarUri = sender && sender.profilePicture() ?
102
+ sender.profilePictureUrl() : null,
103
+ domain = this.domain(),
104
+ domainAvatarUri = domain && domain.logo() ?
105
+ domain.logo().viewUrl() : null;
106
+ if (isAvatarTypeInNotificationAvatar('SHOW_USER_AVATAR', noteType)) {
107
+ return senderAvatarUri;
108
+ } else if (isAvatarTypeInNotificationAvatar('SHOW_DOMAIN_AVATAR',
109
+ noteType)) {
110
+ return domainAvatarUri;
111
+ } else if (isAvatarTypeInNotificationAvatar(
112
+ 'SHOW_USER_OR_DOMAIN_AVATAR', noteType)) {
113
+ return sender ? senderAvatarUri : domainAvatarUri;
114
+ } else if (isAvatarTypeInNotificationAvatar(
115
+ 'SHOW_DOMAIN_OR_USER_AVATAR', noteType)) {
116
+ return domain ? domainAvatarUri : senderAvatarUri;
117
+ }
118
+ return domainAvatarUri;
119
+ };
120
+
121
+ this.iconClass = function () {
122
+ return notificationSectionIconClass.get(this.section());
123
+ };
124
+
125
+ this.checkKeyValue = function (key, value) {
126
+ var self = this;
127
+ if (self[key]() === value) {
128
+ return self;
129
+ }
130
+ return null;
131
+ };
132
+
133
+ this.notificationTypeKey = function () {
134
+ var noteType = this.notificationType();
135
+ return noteType ? notificationTypesKeys.get(noteType) : null;
136
+ };
137
+ }
138
+
139
+ export function Notifications() {
140
+ this.resource = '/notifications';
141
+ this.json = 'notifications';
142
+ this.single = Notification;
143
+
144
+ this.get = function (success, error, queryObject) {
145
+ var self = this;
146
+
147
+ function handleResponse(result) {
148
+ success(fromJsonList(self, result, {makesDirty: false}));
149
+ }
150
+
151
+ getList(this.resource, handleResponse, error, queryObject);
152
+ };
153
+ }
@@ -0,0 +1,246 @@
1
+ import { Dictionary } from './dictionary.js';
2
+ import { any } from './helpers.js';
3
+
4
+
5
+ export const showUserAvatarArray =
6
+ ['DRAFT_SENT', 'DRAFT_CHANGE_REQUEST', 'DRAFT_APPROVED',
7
+ 'DRAFT_COMMENT', 'JOB_COMMENT', 'PRODUCTION_COMMENT',
8
+ 'PRODUCTION_FILE_UPLOADED', 'PRODUCTION_FINISHED',
9
+ 'PRODUCTION_COMMENCED', 'QUOTE_APPROVED', 'SHIPMENT_UPDATE',
10
+ 'JOB_FILE_UPLOADED'];
11
+
12
+ export const showDomainAvatarArray =
13
+ ['NO_TYPE', 'DESIGNER_ASSIGNED', 'DESIGNER_CHANGED',
14
+ 'SEND_INVOICE', 'JOB_STALE', 'MANAGER_ASSIGNED', 'ORDER_RECEIVED',
15
+ 'CLIENT_CHANGED', 'PRODUCTION_CANCELLED', 'QUOTE_FAILED',
16
+ 'QUOTE_COMMENCED', 'QUOTE_EXPIRED', 'SUPPLIER_ASSIGNED',
17
+ 'READY_FOR_SHIPPING', 'SIGN_UP_CONFIRMATION', 'CRASH_EVENT',
18
+ 'MANAGER_SUMMARY', 'PASSWORD_RESET', 'MANAGER_REASSIGNED',
19
+ 'EMAIL_RESPONSE', 'SHIPMENT_EXPECTED_DATE_PAST',
20
+ 'DOMAIN_INVITATION', 'MOD_SELLER_SUMMARY', 'MOD_SUPPLIER_SUMMARY'];
21
+
22
+ export const showUserOrDomainAvatarArray =
23
+ ['JOB_PAID', 'INVOICE_PAID', 'PAYMENT_ACCEPTED',
24
+ 'AUTOMATIC_JOB_RESPONSE', 'JOB_NOTIFICATION', 'JOB_REMINDER',
25
+ 'GENERAL_REMINDER', 'INVOICE_EMAIL_RESPONSE',
26
+ 'AUTOMATIC_INVOICE_RESPONSE', 'JOB_ADDED_TO_SHIPMENT',
27
+ 'JOB_REMOVED_FROM_SHIPMENT', 'ASSIGNMENT_REMOVED_FROM_SHIPMENT',
28
+ 'SHIPMENT_EXPECTED_DATE_PAST', 'ASSIGNMENT_ADDED_TO_SHIPMENT'];
29
+
30
+ export const showDomainOrUserAvatarArray =
31
+ ['SHIPMENT_DISPATCH_CLOSE', 'SHIPMENT_NOT_DISPATCHED',
32
+ 'SHIPMENT_EXPECTED_DATE_WARNING', 'SHIPMENT_EXPECTED_DATE_PAST'];
33
+
34
+ export const notificationTypes = new Dictionary();
35
+
36
+ notificationTypes.add("NO_TYPE", 0);
37
+ notificationTypes.add("DRAFT_SENT", 1);
38
+ notificationTypes.add("DRAFT_CHANGE_REQUEST", 2);
39
+ notificationTypes.add("DRAFT_APPROVED", 3);
40
+ notificationTypes.add("DESIGNER_ASSIGNED", 4);
41
+ notificationTypes.add("DESIGNER_CHANGED", 5);
42
+ notificationTypes.add("DRAFT_COMMENT", 6);
43
+ notificationTypes.add("JOB_PAID", 7);
44
+ notificationTypes.add("INVOICE_PAID", 8);
45
+ notificationTypes.add("PAYMENT_ACCEPTED", 9);
46
+ notificationTypes.add("SEND_INVOICE", 10);
47
+ notificationTypes.add("JOB_COMMENT", 11);
48
+ notificationTypes.add("PRODUCTION_COMMENT", 12);
49
+ notificationTypes.add("JOB_STALE", 13);
50
+ notificationTypes.add("MANAGER_ASSIGNED", 14);
51
+ notificationTypes.add("ORDER_RECEIVED", 15);
52
+ notificationTypes.add("CLIENT_CHANGED", 16);
53
+ notificationTypes.add("PRODUCTION_FILE_UPLOADED", 17);
54
+ notificationTypes.add("PRODUCTION_CANCELLED", 18);
55
+ notificationTypes.add("PRODUCTION_FINISHED", 19);
56
+ notificationTypes.add("PRODUCTION_COMMENCED", 20);
57
+ notificationTypes.add("QUOTE_APPROVED", 21);
58
+ notificationTypes.add("QUOTE_REFUSED", 22);
59
+ notificationTypes.add("QUOTE_SUBMITTED", 23);
60
+ notificationTypes.add("QUOTE_FAILED", 24);
61
+ notificationTypes.add("QUOTE_COMMENCED", 25);
62
+ notificationTypes.add("QUOTE_EXPIRED", 26);
63
+ notificationTypes.add("SUPPLIER_ASSIGNED", 27);
64
+ notificationTypes.add("SUPPLIER_REFUSED", 28);
65
+ notificationTypes.add("READY_FOR_SHIPPING", 29);
66
+ notificationTypes.add("SHIPMENT_UPDATE", 30);
67
+ notificationTypes.add("SIGN_UP_CONFIRMATION", 31);
68
+ notificationTypes.add("AUTOMATIC_JOB_RESPONSE", 32);
69
+ notificationTypes.add("CRASH_EVENT", 33);
70
+ notificationTypes.add("MANAGER_SUMMARY", 34);
71
+ notificationTypes.add("PASSWORD_RESET", 35);
72
+ notificationTypes.add("MANAGER_REASSIGNED", 36);
73
+ notificationTypes.add("EMAIL_RESPONSE", 37);
74
+ notificationTypes.add("JOB_NOTIFICATION", 38);
75
+ notificationTypes.add("JOB_REMINDER", 39);
76
+ notificationTypes.add("GENERAL_REMINDER", 40);
77
+ notificationTypes.add("INVOICE_EMAIL_RESPONSE", 41);
78
+ notificationTypes.add("AUTOMATIC_INVOICE_RESPONSE", 42);
79
+ notificationTypes.add("SHIPMENT_DISPATCH_CLOSE", 43);
80
+ notificationTypes.add("SHIPMENT_NOT_DISPATCHED", 44);
81
+ notificationTypes.add("SHIPMENT_EXPECTED_DATE_WARNING", 45);
82
+ notificationTypes.add("JOB_ADDED_TO_SHIPMENT", 46);
83
+ notificationTypes.add("JOB_REMOVED_FROM_SHIPMENT", 47);
84
+ notificationTypes.add("ASSIGNMENT_REMOVED_FROM_SHIPMENT", 48);
85
+ notificationTypes.add("ASSIGNMENT_ADDED_TO_SHIPMENT", 49);
86
+ notificationTypes.add("SHIPMENT_EXPECTED_DATE_PAST", 50);
87
+ notificationTypes.add("JOB_FILE_UPLOADED", 51);
88
+ notificationTypes.add("DOMAIN_INVITATION", 52);
89
+ notificationTypes.add("QUOTE_JOB_SUBMITTED", 53);
90
+ notificationTypes.add("QUOTE_JOB_RECEIVED", 54);
91
+ notificationTypes.add("QUOTE_JOB_UPDATED", 55);
92
+ notificationTypes.add("QUOTE_JOB_UPDATED_SENT", 56);
93
+ notificationTypes.add("QUOTE_JOB_APPROVED", 57);
94
+ notificationTypes.add("QUOTE_JOB_APPROVED_SENT", 58);
95
+ notificationTypes.add("JOB_NOTIFICATION_COMMENT", 59);
96
+ notificationTypes.add("PRODUCTION_SHIPPED", 60);
97
+ notificationTypes.add("SELLER_STORE_CREATED", 61);
98
+ notificationTypes.add("WEB_FORM", 62);
99
+ notificationTypes.add("CREATE_DOMAIN_FOR_MOD_PRODUCT", 63);
100
+ notificationTypes.add("RESELL_REQUEST_SUBMITTED", 64);
101
+ notificationTypes.add("RESELL_REQUEST_RECEIVED", 65);
102
+ notificationTypes.add("MOD_PRODUCT_READY_FOR_SALE", 66);
103
+ notificationTypes.add("ADDED_TO_COMPANY", 67);
104
+ notificationTypes.add("PRODUCTION_COMPLETED", 68);
105
+ notificationTypes.add("SUPPLIER_PRODUCT_READY_FOR_SALE", 69);
106
+ notificationTypes.add("STORE_ASSIGNED_TO_YOU", 70);
107
+ notificationTypes.add("CLIENT_STORE_CREATED", 71);
108
+ notificationTypes.add("MOD_SELLER_SUMMARY", 72);
109
+ notificationTypes.add("MOD_SUPPLIER_SUMMARY", 73);
110
+
111
+ export const notificationTypesKeys = new Dictionary();
112
+
113
+ notificationTypes.each(function (key, value) {
114
+ notificationTypesKeys.add(value, key);
115
+ });
116
+
117
+ export const notificationAvatar = new Dictionary();
118
+
119
+ function makeNotificationAvatarArray(listOfAvatarKeys) {
120
+ var avatarIdArray = [],
121
+ i;
122
+ for (i = 0; i < listOfAvatarKeys.length; i++) {
123
+ avatarIdArray.push(notificationTypes.get(listOfAvatarKeys[i]));
124
+ }
125
+ return avatarIdArray;
126
+ }
127
+
128
+ notificationAvatar.add('SHOW_USER_AVATAR',
129
+ makeNotificationAvatarArray(showUserAvatarArray));
130
+ notificationAvatar.add('SHOW_DOMAIN_AVATAR',
131
+ makeNotificationAvatarArray(showDomainAvatarArray));
132
+ notificationAvatar.add('SHOW_USER_OR_DOMAIN_AVATAR',
133
+ makeNotificationAvatarArray(
134
+ showUserOrDomainAvatarArray));
135
+ notificationAvatar.add('SHOW_DOMAIN_OR_USER_AVATAR',
136
+ makeNotificationAvatarArray(
137
+ showDomainOrUserAvatarArray));
138
+
139
+ export function notificationsFilter(notificationsArray, filterObjectArray) {
140
+ /* Takes an array of notifications and a filter, loops over
141
+ the notifications array and checks to see
142
+ if any of the filters in the filter object apply.
143
+ */
144
+ var notifications = Boolean(notificationsArray) ?
145
+ notificationsArray : [],
146
+ updatedArray = [],
147
+ filterObject,
148
+ key,
149
+ i;
150
+
151
+ function checkNotifications(attributeString, attributeValue) {
152
+ var i, notification;
153
+ for (i = 0; i < notifications.length; i++) {
154
+ notification = notifications[i].
155
+ checkKeyValue(attributeString, attributeValue);
156
+ if (Boolean(notification)) {
157
+ updatedArray.push(notification);
158
+ }
159
+ }
160
+ }
161
+
162
+ for (i = 0; i < filterObjectArray.length; i++) {
163
+ filterObject = filterObjectArray[i];
164
+ for (key in filterObject) {
165
+ if (Object.prototype.hasOwnProperty.call(filterObject, key)) {
166
+ checkNotifications(key, filterObject[key]);
167
+ }
168
+ }
169
+ }
170
+ return updatedArray;
171
+ }
172
+
173
+ export function notificationRecieverIsCurrentUserFilter(currentUser,
174
+ notificationsArray) {
175
+ var notifications = Boolean(notificationsArray) ?
176
+ notificationsArray : [],
177
+ updatedArray = [],
178
+ i;
179
+ for (i = 0; i < notifications.length; i++) {
180
+ if (Boolean(notifications[i].recipient()) &&
181
+ notifications[i].recipient().id() === currentUser.id()) {
182
+ updatedArray.push(notifications[i]);
183
+ }
184
+ }
185
+ return updatedArray;
186
+ }
187
+
188
+ export function isAvatarTypeInNotificationAvatar(avatarTypeString, noteType) {
189
+ var avatarType = notificationAvatar.get(avatarTypeString);
190
+ return any(avatarType, function (type) { return type === noteType; });
191
+ }
192
+
193
+ export const notificationSection = new Dictionary();
194
+
195
+ notificationSection.add(0, "system");
196
+ notificationSection.add(1, "user");
197
+ notificationSection.add(2, "info");
198
+ notificationSection.add(3, "design");
199
+ notificationSection.add(4, "production");
200
+ notificationSection.add(5, "invoicing");
201
+ notificationSection.add(6, "shipping");
202
+ notificationSection.add(7, "invoice");
203
+ notificationSection.add(8, "notifications");
204
+ notificationSection.add(9, "reminder");
205
+ notificationSection.add(10, "web form");
206
+
207
+ export const notificationSectionKey = new Dictionary();
208
+
209
+ notificationSection.each(function (key, value) {
210
+ notificationSectionKey.add(value, key);
211
+ });
212
+
213
+ export const notificationSectionClass = new Dictionary();
214
+
215
+ notificationSectionClass.add(0, "default");
216
+ notificationSectionClass.add(1, "danger");
217
+ notificationSectionClass.add(2, "dark");
218
+ notificationSectionClass.add(3, "success");
219
+ notificationSectionClass.add(4, "warning");
220
+ notificationSectionClass.add(5, "primary");
221
+ notificationSectionClass.add(6, "info");
222
+ notificationSectionClass.add(7, "primary");
223
+ notificationSectionClass.add(8, "dark");
224
+ notificationSectionClass.add(9, "default");
225
+ notificationSectionClass.add(10, "default");
226
+
227
+ export const notificationSectionIconClass = new Dictionary();
228
+
229
+ notificationSectionIconClass.add(0, "fa fa-server");
230
+ notificationSectionIconClass.add(1, "icon_m_single_user");
231
+ notificationSectionIconClass.add(2, "icon_m_job_singular");
232
+ notificationSectionIconClass.add(3, "icon_m_design");
233
+ notificationSectionIconClass.add(4, "icon_m_manufacturing");
234
+ notificationSectionIconClass.add(5, "icon_m_invoice");
235
+ notificationSectionIconClass.add(6, "icon_m_shipping");
236
+ notificationSectionIconClass.add(7, "icon_m_invoice");
237
+ notificationSectionIconClass.add(8, "icon_m_inbox");
238
+ notificationSectionIconClass.add(9, "icon_m_reminder");
239
+ notificationSectionIconClass.add(10, "fa fa-server");
240
+
241
+ export const notificationSectionCodes = new Dictionary();
242
+
243
+ notificationSection.each(function (key, value) {
244
+ notificationSectionCodes.add(value, parseInt(key, 10));
245
+ });
246
+
package/src/page.js ADDED
@@ -0,0 +1,38 @@
1
+ import { addPropertyTo, serialise, enumerateFiles, fromJson,
2
+ create } from './model.js';
3
+ import { isUndefinedOrNull } from './helpers.js';
4
+ import { Theme } from './theme.js';
5
+
6
+ export function Page() {
7
+ this.resource = '/pages';
8
+ this.json = 'page';
9
+
10
+ addPropertyTo(this, 'id');
11
+ addPropertyTo(this, 'name');
12
+ addPropertyTo(this, 'slug');
13
+ addPropertyTo(this, 'template');
14
+ addPropertyTo(this, 'theme', Theme);
15
+
16
+ this.text = function (text) {
17
+ if (!isUndefinedOrNull(text)) {
18
+ this.template(text);
19
+ } else {
20
+ return this.template();
21
+ }
22
+ };
23
+
24
+ this.create = function (success, error, embed, domainId) {
25
+ var data = serialise(this),
26
+ self = this;
27
+ function handleResponse(result) {
28
+ success(fromJson(self, result[self.json]));
29
+ }
30
+ create({resource: this.resource,
31
+ parameters: data[0],
32
+ files: enumerateFiles(data[1]),
33
+ success: handleResponse,
34
+ error: error,
35
+ embed: embed,
36
+ as_domain: domainId});
37
+ };
38
+ }
package/src/payment.js ADDED
@@ -0,0 +1,32 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo } from './model.js';
3
+ import { paymentTypes } from './payment_types.js';
4
+ import { AutomaticPaymentRelationship } from './automatic_payment_relationship.js';
5
+ import { User } from './user.js';
6
+
7
+ export function Payment() {
8
+ this.resource = '/payments';
9
+ this.json = 'payments';
10
+ this.temporaryId = generateUUID();
11
+
12
+ addPropertyTo(this, 'id');
13
+ addPropertyTo(this, 'note');
14
+ addPropertyTo(this, 'paymentType');
15
+ addPropertyTo(this, 'payDate');
16
+ addPropertyTo(this, 'amount');
17
+ addPropertyTo(this, 'sendSms');
18
+ addPropertyTo(this, 'sendEmail');
19
+ addPropertyTo(this, 'autoRefundable');
20
+ addPropertyTo(this, 'refunded');
21
+ addPropertyTo(this, 'refundIssuer', User);
22
+ addPropertyTo(this, 'paymentRecorder', User);
23
+ addPropertyTo(
24
+ this,
25
+ 'chargedByPaymentRelationship',
26
+ AutomaticPaymentRelationship);
27
+
28
+ this.paymentTypeText = function () {
29
+ var paymentType = this.paymentType();
30
+ return paymentType ? paymentTypes.get(paymentType) : 'Unknown';
31
+ }
32
+ }
@@ -0,0 +1,17 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo } from './model.js';
3
+ import { Company } from './company.js';
4
+
5
+ export function PaymentDevice() {
6
+ this.resource = '/payment_devices';
7
+ this.json = 'paymentDevices';
8
+ this.temporaryId = generateUUID();
9
+
10
+ addPropertyTo(this, 'id');
11
+ addPropertyTo(this, 'code');
12
+ addPropertyTo(this, 'deviceId');
13
+ addPropertyTo(this, 'squareId');
14
+ addPropertyTo(this, 'deviceData');
15
+ addPropertyTo(this, 'company', Company);
16
+ addPropertyTo(this, 'description');
17
+ }
@@ -0,0 +1,18 @@
1
+ import { Dictionary } from './dictionary.js';
2
+
3
+ export const paymentTypes = new Dictionary();
4
+
5
+ paymentTypes.add(1, 'Online');
6
+ paymentTypes.add(2, 'PayPal');
7
+ paymentTypes.add(3, 'Bank Transfer');
8
+ paymentTypes.add(4, 'Cash');
9
+ paymentTypes.add(5, 'Cheque');
10
+ paymentTypes.add(6, 'Phone');
11
+ paymentTypes.add(7, 'Credit Card');
12
+ paymentTypes.add(8, 'Utrust');
13
+
14
+ export const paymentTypeIds = new Dictionary();
15
+
16
+ paymentTypes.each(function (key, value) {
17
+ paymentTypeIds.add(value, parseInt(key, 10));
18
+ });
@@ -0,0 +1,30 @@
1
+ import { generateUUID } from './uuid.js';
2
+ import { addPropertyTo, getList, fromJsonList } from './model.js';
3
+
4
+ export function PhoneNumber() {
5
+ this.resource = '/phone_numbers';
6
+ this.json = 'phoneNumber';
7
+ this.temporaryId = generateUUID();
8
+
9
+ addPropertyTo(this, 'id');
10
+ addPropertyTo(this, 'number');
11
+ addPropertyTo(this, 'code');
12
+ addPropertyTo(this, 'localFormatNumber');
13
+ addPropertyTo(this, 'internationalFormatNumber');
14
+ }
15
+
16
+ export function PhoneNumbers() {
17
+ this.resource = '/phone_numbers';
18
+ this.json = 'phoneNumbers';
19
+ this.single = PhoneNumber;
20
+
21
+ this.get = function (success, error, offset, limit, q) {
22
+ var self = this;
23
+ function handleResponse(result) {
24
+ success(fromJsonList(self, result,
25
+ {makesDirty: false}));
26
+ }
27
+ getList(this.resource, handleResponse, error,
28
+ {offset: offset, limit: limit, q: q});
29
+ };
30
+ }