merchi_sdk_js 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/address.js +109 -0
- package/dist/assignment.js +175 -0
- package/dist/automatic_payment_relationship.js +72 -0
- package/dist/backup.js +32 -0
- package/dist/bank.js +25 -0
- package/dist/cart.js +133 -0
- package/dist/cart_item.js +71 -0
- package/dist/cart_shipment_group.js +23 -0
- package/dist/cart_shipment_quote.js +26 -0
- package/dist/category.js +68 -0
- package/dist/company.js +248 -0
- package/dist/company_invitation.js +70 -0
- package/dist/component.js +107 -0
- package/dist/component_tag.js +60 -0
- package/dist/component_version.js +21 -0
- package/dist/country_tax.js +93 -0
- package/dist/dictionary.js +130 -0
- package/dist/discount.js +22 -0
- package/dist/discount_group.js +18 -0
- package/dist/domain.js +245 -0
- package/dist/domain_invitation.js +17 -0
- package/dist/domain_tag.js +87 -0
- package/dist/domain_types.js +22 -0
- package/dist/draft.js +97 -0
- package/dist/draft_comment.js +45 -0
- package/dist/draft_template.js +39 -0
- package/dist/email_address.js +34 -0
- package/dist/email_counter.js +47 -0
- package/dist/enrolled_domain.js +88 -0
- package/dist/exchange_rate.js +66 -0
- package/dist/field_types.js +19 -0
- package/dist/helpers.js +86 -0
- package/dist/internal_tag.js +98 -0
- package/dist/inventory.js +100 -0
- package/dist/inventory_unit_variation.js +19 -0
- package/dist/invoice.js +225 -0
- package/dist/invoice_types.js +11 -0
- package/dist/item.js +25 -0
- package/dist/job.js +536 -0
- package/dist/job_comment.js +45 -0
- package/dist/job_status.js +47 -0
- package/dist/matching_inventory.js +21 -0
- package/dist/md5.js +149 -0
- package/dist/menu.js +37 -0
- package/dist/menu_item.js +24 -0
- package/dist/merchi.js +1004 -0
- package/dist/merchi_file.js +165 -0
- package/dist/model.js +753 -0
- package/dist/notification.js +151 -0
- package/dist/notification_types.js +199 -0
- package/dist/output.cjs.js +31317 -0
- package/dist/output.esm.js +31312 -0
- package/dist/page.js +41 -0
- package/dist/payment.js +32 -0
- package/dist/payment_device.js +21 -0
- package/dist/payment_types.js +20 -0
- package/dist/phone_number.js +37 -0
- package/dist/product.js +288 -0
- package/dist/product_types.js +32 -0
- package/dist/production_comment.js +44 -0
- package/dist/quote.js +91 -0
- package/dist/quote_item.js +59 -0
- package/dist/roles.js +29 -0
- package/dist/seo_domain_page.js +42 -0
- package/dist/session.js +103 -0
- package/dist/set.js +29 -0
- package/dist/shipment.js +181 -0
- package/dist/shipment_item.js +17 -0
- package/dist/shipment_item_fulfillment.js +17 -0
- package/dist/shipment_method.js +81 -0
- package/dist/shipment_method_variation.js +38 -0
- package/dist/subscription_plan.js +75 -0
- package/dist/supply_domain.js +65 -0
- package/dist/system_role.js +12 -0
- package/dist/theme.js +180 -0
- package/dist/theme_css_setting.js +61 -0
- package/dist/theme_status.js +11 -0
- package/dist/user.js +409 -0
- package/dist/user_company.js +19 -0
- package/dist/user_types.js +23 -0
- package/dist/uuid.js +12 -0
- package/dist/variation.js +233 -0
- package/dist/variation_field.js +233 -0
- package/dist/variation_fields_option.js +41 -0
- package/dist/variation_option.js +62 -0
- package/dist/variations_group.js +43 -0
- package/dist/white_label_accessibilities.js +11 -0
- package/package.json +30 -0
- package/src/address.js +107 -0
- package/src/assignment.js +165 -0
- package/src/automatic_payment_relationship.js +65 -0
- package/src/backup.js +29 -0
- package/src/bank.js +21 -0
- package/src/cart.js +131 -0
- package/src/cart_item.js +71 -0
- package/src/cart_shipment_group.js +20 -0
- package/src/cart_shipment_quote.js +23 -0
- package/src/category.js +62 -0
- package/src/company.js +267 -0
- package/src/company_invitation.js +63 -0
- package/src/component.js +100 -0
- package/src/component_tag.js +53 -0
- package/src/component_version.js +17 -0
- package/src/country_tax.js +89 -0
- package/src/dictionary.js +135 -0
- package/src/discount.js +19 -0
- package/src/discount_group.js +15 -0
- package/src/domain.js +254 -0
- package/src/domain_invitation.js +13 -0
- package/src/domain_tag.js +79 -0
- package/src/domain_types.js +18 -0
- package/src/draft.js +92 -0
- package/src/draft_comment.js +41 -0
- package/src/draft_template.js +35 -0
- package/src/email_address.js +27 -0
- package/src/email_counter.js +42 -0
- package/src/enrolled_domain.js +79 -0
- package/src/exchange_rate.js +61 -0
- package/src/field_types.js +15 -0
- package/src/helpers.js +81 -0
- package/src/internal_tag.js +90 -0
- package/src/inventory.js +99 -0
- package/src/inventory_unit_variation.js +18 -0
- package/src/invoice.js +224 -0
- package/src/invoice_types.js +7 -0
- package/src/item.js +22 -0
- package/src/job.js +616 -0
- package/src/job_comment.js +41 -0
- package/src/job_status.js +51 -0
- package/src/matching_inventory.js +17 -0
- package/src/md5.js +162 -0
- package/src/menu.js +32 -0
- package/src/menu_item.js +22 -0
- package/src/merchi.js +1074 -0
- package/src/merchi_file.js +163 -0
- package/src/model.js +820 -0
- package/src/notification.js +153 -0
- package/src/notification_types.js +246 -0
- package/src/page.js +38 -0
- package/src/payment.js +32 -0
- package/src/payment_device.js +17 -0
- package/src/payment_types.js +18 -0
- package/src/phone_number.js +30 -0
- package/src/product.js +309 -0
- package/src/product_types.js +28 -0
- package/src/production_comment.js +40 -0
- package/src/quote.js +89 -0
- package/src/quote_item.js +51 -0
- package/src/roles.js +27 -0
- package/src/seo_domain_page.js +35 -0
- package/src/session.js +102 -0
- package/src/set.js +28 -0
- package/src/shipment.js +191 -0
- package/src/shipment_item.js +13 -0
- package/src/shipment_item_fulfillment.js +13 -0
- package/src/shipment_method.js +73 -0
- package/src/shipment_method_variation.js +34 -0
- package/src/subscription_plan.js +68 -0
- package/src/supply_domain.js +60 -0
- package/src/system_role.js +8 -0
- package/src/theme.js +188 -0
- package/src/theme_css_setting.js +54 -0
- package/src/theme_status.js +6 -0
- package/src/user.js +442 -0
- package/src/user_company.js +15 -0
- package/src/user_types.js +19 -0
- package/src/uuid.js +3 -0
- package/src/variation.js +257 -0
- package/src/variation_field.js +261 -0
- package/src/variation_fields_option.js +41 -0
- package/src/variation_option.js +59 -0
- package/src/variations_group.js +43 -0
- package/src/white_label_accessibilities.js +6 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
import NodeFormData from 'form-data';
|
2
|
+
import { isBrowser, isJsDom } from "browser-or-node";
|
3
|
+
|
4
|
+
export function Dictionary() {
|
5
|
+
|
6
|
+
var store = {},
|
7
|
+
count = 0;
|
8
|
+
|
9
|
+
function noSuchKey(name) {
|
10
|
+
throw 'No such key "' + String(name) + '" in dictionary';
|
11
|
+
}
|
12
|
+
|
13
|
+
this.clone = function () {
|
14
|
+
return new Dictionary(store, count);
|
15
|
+
};
|
16
|
+
|
17
|
+
this.add = function (name, value) {
|
18
|
+
if (!this.has(name)) {
|
19
|
+
++count;
|
20
|
+
}
|
21
|
+
store[name] = value;
|
22
|
+
return this;
|
23
|
+
};
|
24
|
+
|
25
|
+
this.getArray = function (names) {
|
26
|
+
/** passing a array of keys return the values array
|
27
|
+
* corresponding to the keys **/
|
28
|
+
var i, returnArray = [];
|
29
|
+
for (i = 0; i < names.length; i++) {
|
30
|
+
if (this.has(names[i])) {
|
31
|
+
returnArray.push(store[names[i]]);
|
32
|
+
} else {
|
33
|
+
noSuchKey(names[i]);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return returnArray;
|
37
|
+
};
|
38
|
+
|
39
|
+
this.get = function (name, default_) {
|
40
|
+
if (this.has(name)) {
|
41
|
+
return store[name];
|
42
|
+
}
|
43
|
+
if (default_ !== undefined) {
|
44
|
+
return default_;
|
45
|
+
}
|
46
|
+
return noSuchKey(name);
|
47
|
+
};
|
48
|
+
|
49
|
+
this.has = function (name) {
|
50
|
+
return Object.prototype.hasOwnProperty.call(store, name) &&
|
51
|
+
Object.prototype.propertyIsEnumerable.call(store, name);
|
52
|
+
};
|
53
|
+
|
54
|
+
this.remove = function (name) {
|
55
|
+
if (this.has(name)) {
|
56
|
+
delete store[name];
|
57
|
+
--count;
|
58
|
+
return this;
|
59
|
+
}
|
60
|
+
return noSuchKey(name);
|
61
|
+
};
|
62
|
+
|
63
|
+
this.merge = function (other) {
|
64
|
+
var _this = this;
|
65
|
+
if (other.__proto__.constructor === Dictionary) {
|
66
|
+
other.each(function (name, value) {
|
67
|
+
_this.add(name, value);
|
68
|
+
});
|
69
|
+
} else {
|
70
|
+
for (var property in other) {
|
71
|
+
if (other.hasOwnProperty(property)) {
|
72
|
+
_this.add(property, other[property]);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return this;
|
77
|
+
};
|
78
|
+
|
79
|
+
this.each = function (procedure) {
|
80
|
+
var name;
|
81
|
+
for (name in store) {
|
82
|
+
if (Object.prototype.hasOwnProperty.call(store, name)) {
|
83
|
+
procedure(name, store[name]);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
return this;
|
87
|
+
};
|
88
|
+
|
89
|
+
this.keys = function () {
|
90
|
+
var result = [];
|
91
|
+
this.each(function (name) { result.push(name); });
|
92
|
+
return result;
|
93
|
+
};
|
94
|
+
|
95
|
+
this.values = function () {
|
96
|
+
var result = [];
|
97
|
+
this.each(function (ignore, value) { result.push(value); });
|
98
|
+
return result;
|
99
|
+
};
|
100
|
+
|
101
|
+
this.count = function () {
|
102
|
+
return count;
|
103
|
+
};
|
104
|
+
|
105
|
+
this.toFormData = function () {
|
106
|
+
var result;
|
107
|
+
if (isJsDom || isBrowser) {
|
108
|
+
result = new FormData();
|
109
|
+
} else {
|
110
|
+
result = new NodeFormData();
|
111
|
+
}
|
112
|
+
this.each(function (key, value) {
|
113
|
+
result.append(key, value);
|
114
|
+
});
|
115
|
+
return result;
|
116
|
+
};
|
117
|
+
|
118
|
+
this.toUriEncoding = function () {
|
119
|
+
var result = '';
|
120
|
+
this.each(function (key, value) {
|
121
|
+
if (typeof key === "object") {
|
122
|
+
throw "cannot URI encode object key";
|
123
|
+
}
|
124
|
+
if (typeof value === "object") {
|
125
|
+
throw "cannot URI encode object name";
|
126
|
+
}
|
127
|
+
result += encodeURIComponent(key);
|
128
|
+
result += '=';
|
129
|
+
result += encodeURIComponent(value);
|
130
|
+
result += '&';
|
131
|
+
});
|
132
|
+
return result.slice(0, -1);
|
133
|
+
};
|
134
|
+
|
135
|
+
}
|
package/src/discount.js
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
2
|
+
import { addPropertyTo } from './model.js';
|
3
|
+
|
4
|
+
export function Discount() {
|
5
|
+
this.resource = '/discounts';
|
6
|
+
this.json = 'discount';
|
7
|
+
this.temporaryId = generateUUID();
|
8
|
+
|
9
|
+
addPropertyTo(this, 'id');
|
10
|
+
addPropertyTo(this, 'lowerLimit');
|
11
|
+
addPropertyTo(this, 'amount');
|
12
|
+
|
13
|
+
this.discountedUnitCost = function (unitPrice) {
|
14
|
+
var unitCost = unitPrice ? unitPrice : 0,
|
15
|
+
amount = this.amount() ? this.amount() : 0,
|
16
|
+
discount = 100 - amount;
|
17
|
+
return parseFloat((unitCost / 100) * discount).toFixed(3);
|
18
|
+
};
|
19
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
2
|
+
import { addPropertyTo } from './model.js';
|
3
|
+
|
4
|
+
|
5
|
+
export function DiscountGroup() {
|
6
|
+
this.resource = '/discountGroups';
|
7
|
+
this.json = 'discountGroup';
|
8
|
+
this.temporaryId = generateUUID();
|
9
|
+
|
10
|
+
addPropertyTo(this, 'id');
|
11
|
+
addPropertyTo(this, 'discountType');
|
12
|
+
addPropertyTo(this, 'discounts');
|
13
|
+
addPropertyTo(this, 'name');
|
14
|
+
addPropertyTo(this, 'product');
|
15
|
+
}
|
package/src/domain.js
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
2
|
+
import { Dictionary } from './dictionary.js';
|
3
|
+
import { addPropertyTo, serialise, fromJson, getList, fromJsonList, patchOne,
|
4
|
+
getOne, create, enumerateFiles, Request } from './model.js';
|
5
|
+
import { SELLER, SELLER_PLUS, SUPPLIER, RESTRICTED_SUPPLIER } from './roles.js';
|
6
|
+
import { domainTypesInts } from './domain_types.js';
|
7
|
+
import { Company } from './company.js';
|
8
|
+
import { DomainTag } from './domain_tag.js';
|
9
|
+
import { DomainInvitation } from './domain_invitation.js';
|
10
|
+
import { Theme } from './theme.js';
|
11
|
+
import { MerchiFile } from './merchi_file.js';
|
12
|
+
import { Menu } from './menu.js';
|
13
|
+
import { SupplyDomain } from './supply_domain.js';
|
14
|
+
import { SeoDomainPage } from './seo_domain_page.js';
|
15
|
+
import { User, Users } from './user.js';
|
16
|
+
import { InternalTag } from './internal_tag.js';
|
17
|
+
|
18
|
+
export function Domain() {
|
19
|
+
this.resource = '/domains';
|
20
|
+
this.json = 'domain';
|
21
|
+
this.temporaryId = generateUUID();
|
22
|
+
|
23
|
+
addPropertyTo(this, 'id');
|
24
|
+
addPropertyTo(this, 'aiContext');
|
25
|
+
addPropertyTo(this, 'apiSecret');
|
26
|
+
addPropertyTo(this, 'webflowApiKey');
|
27
|
+
addPropertyTo(this, 'shopifyShopUrl');
|
28
|
+
addPropertyTo(this, 'shopifyIsActive');
|
29
|
+
addPropertyTo(this, 'country');
|
30
|
+
addPropertyTo(this, 'currency');
|
31
|
+
addPropertyTo(this, 'domain');
|
32
|
+
addPropertyTo(this, 'domainType');
|
33
|
+
addPropertyTo(this, 'activeThemeId');
|
34
|
+
addPropertyTo(this, 'activeTheme', Theme);
|
35
|
+
addPropertyTo(this, 'subDomain');
|
36
|
+
addPropertyTo(this, 'theme');
|
37
|
+
addPropertyTo(this, 'logoUrl');
|
38
|
+
addPropertyTo(this, 'smsName');
|
39
|
+
addPropertyTo(this, 'emailDomain');
|
40
|
+
addPropertyTo(this, 'trackingCodeGoogleConversion');
|
41
|
+
addPropertyTo(this, 'trackingCodeGoogleGlobal');
|
42
|
+
addPropertyTo(this, 'qrShopQrCode');
|
43
|
+
addPropertyTo(this, 'logo', MerchiFile);
|
44
|
+
addPropertyTo(this, 'favicon', MerchiFile);
|
45
|
+
addPropertyTo(this, 'company', Company);
|
46
|
+
addPropertyTo(this, 'ownedBy', Company);
|
47
|
+
addPropertyTo(this, 'accessibleClients', User);
|
48
|
+
addPropertyTo(this, 'accessibleClientCompanies', Company);
|
49
|
+
addPropertyTo(this, 'unltdAiApiOrganizationId');
|
50
|
+
addPropertyTo(this, 'unltdAiApiSecretKey');
|
51
|
+
addPropertyTo(this, 'menus', Menu);
|
52
|
+
|
53
|
+
addPropertyTo(this, 'socialBitchute');
|
54
|
+
addPropertyTo(this, 'socialDiscord');
|
55
|
+
addPropertyTo(this, 'socialFacebook');
|
56
|
+
addPropertyTo(this, 'socialGoogle');
|
57
|
+
addPropertyTo(this, 'socialInstagram');
|
58
|
+
addPropertyTo(this, 'socialLinkedin');
|
59
|
+
addPropertyTo(this, 'socialRumble');
|
60
|
+
addPropertyTo(this, 'socialTelegram');
|
61
|
+
addPropertyTo(this, 'socialTiktok');
|
62
|
+
addPropertyTo(this, 'socialX');
|
63
|
+
addPropertyTo(this, 'socialYoutube');
|
64
|
+
|
65
|
+
addPropertyTo(this, 'internalUseNotes');
|
66
|
+
addPropertyTo(this, 'internalUseAiContext');
|
67
|
+
|
68
|
+
addPropertyTo(this, 'showDomainPublicly');
|
69
|
+
addPropertyTo(this, 'publicAccessRestricted');
|
70
|
+
addPropertyTo(this, 'showDomainToAccessibleEntitiesOnly')
|
71
|
+
addPropertyTo(this, 'enableNotifications');
|
72
|
+
addPropertyTo(this, 'enableEmailNotifications');
|
73
|
+
addPropertyTo(this, 'enableSmsNotifications');
|
74
|
+
addPropertyTo(this, 'seoDomainPages', SeoDomainPage);
|
75
|
+
addPropertyTo(this, 'themes', Theme);
|
76
|
+
addPropertyTo(this, 'supplyProducts', SupplyDomain);
|
77
|
+
addPropertyTo(this, 'domainInvitations', DomainInvitation);
|
78
|
+
addPropertyTo(this, 'jobsAssignees', User);
|
79
|
+
addPropertyTo(this, 'tags', DomainTag);
|
80
|
+
addPropertyTo(this, 'internalTags', InternalTag);
|
81
|
+
|
82
|
+
this.create = function (success, error, embed, as_domain) {
|
83
|
+
var data = serialise(this),
|
84
|
+
self = this;
|
85
|
+
function handleResponse(result) {
|
86
|
+
success(fromJson(self, result[self.json]));
|
87
|
+
}
|
88
|
+
create({resource: this.resource,
|
89
|
+
parameters: data[0],
|
90
|
+
files: enumerateFiles(data[1]),
|
91
|
+
as_domain: as_domain,
|
92
|
+
success: handleResponse,
|
93
|
+
error: error,
|
94
|
+
embed: embed});
|
95
|
+
};
|
96
|
+
|
97
|
+
this.get = function (success, error, embed, withRights) {
|
98
|
+
var self = this;
|
99
|
+
function handleResponse(result) {
|
100
|
+
success(fromJson(self, result[self.json],
|
101
|
+
{makesDirty: false}));
|
102
|
+
}
|
103
|
+
getOne({resource: this.resource,
|
104
|
+
id: this.id(),
|
105
|
+
success: handleResponse,
|
106
|
+
error: error,
|
107
|
+
embed: embed,
|
108
|
+
withRights: withRights});
|
109
|
+
};
|
110
|
+
|
111
|
+
this.invite = function (invitationData, success, error, embed) {
|
112
|
+
var request = new Request(),
|
113
|
+
data = new Dictionary(),
|
114
|
+
self = this,
|
115
|
+
_id = self.id();
|
116
|
+
|
117
|
+
function handleResponse(status, data) {
|
118
|
+
var newInvitation = new DomainInvitation(),
|
119
|
+
invitation = data,
|
120
|
+
invitations = self.domainInvitations() ?
|
121
|
+
self.domainInvitations() : [];
|
122
|
+
newInvitation.id(invitation.id);
|
123
|
+
newInvitation.userEmail(invitation.userEmail);
|
124
|
+
newInvitation.userName(invitation.userName);
|
125
|
+
newInvitation.role(invitation.role);
|
126
|
+
invitations.push(newInvitation);
|
127
|
+
self.domainInvitations(invitations);
|
128
|
+
success(self);
|
129
|
+
}
|
130
|
+
|
131
|
+
data.add("inviteUserEmail", invitationData.emailAddress);
|
132
|
+
data.add("inviteUserName", invitationData.userName);
|
133
|
+
data.add("domainId", _id);
|
134
|
+
data.add("domainRole", invitationData.role);
|
135
|
+
request.resource('/domain_invite/').method('POST');
|
136
|
+
request.data().merge(data);
|
137
|
+
request.responseHandler(handleResponse);
|
138
|
+
request.errorHandler(error);
|
139
|
+
request.send();
|
140
|
+
}
|
141
|
+
this.getUsers = function (success, error, offset, limit,
|
142
|
+
q, embed, tab) {
|
143
|
+
var self = this,
|
144
|
+
users = new Users();
|
145
|
+
|
146
|
+
function handleResponse(result) {
|
147
|
+
success(fromJsonList(users, result));
|
148
|
+
}
|
149
|
+
getList(users.resource, handleResponse, error,
|
150
|
+
{inDomain: self.id(), tab: tab, offset: offset,
|
151
|
+
limit: limit, q: q, embed: embed});
|
152
|
+
};
|
153
|
+
|
154
|
+
this.getManagers = function (success, error, offset, limit, embed) {
|
155
|
+
var self = this;
|
156
|
+
self.getUsers(success, error, offset, limit,
|
157
|
+
null, embed, "manager");
|
158
|
+
};
|
159
|
+
|
160
|
+
this.getUsersWithRoles = function (success, error, roles, offset,
|
161
|
+
limit, embed) {
|
162
|
+
var self = this,
|
163
|
+
users = new Users();
|
164
|
+
|
165
|
+
function handleResponse(result) {
|
166
|
+
success(fromJsonList(users, result));
|
167
|
+
}
|
168
|
+
|
169
|
+
getList(users.resource, handleResponse, error,
|
170
|
+
{inDomain: self.id(), inDomainRoles: roles,
|
171
|
+
offset: offset, limit: limit, embed: embed});
|
172
|
+
};
|
173
|
+
|
174
|
+
this.patch = function (success, error, embed, as_domain) {
|
175
|
+
var data = data = serialise(this)[0],
|
176
|
+
self = this;
|
177
|
+
function handleResponse(result) {
|
178
|
+
success(fromJson(self, result[self.json]));
|
179
|
+
}
|
180
|
+
patchOne({resource: this.resource,
|
181
|
+
id: this.id(),
|
182
|
+
success: handleResponse,
|
183
|
+
as_domain: as_domain,
|
184
|
+
error: error,
|
185
|
+
data: data,
|
186
|
+
embed: embed});
|
187
|
+
};
|
188
|
+
|
189
|
+
this.update = function (success, error, embed) {
|
190
|
+
this.patch(success, error,
|
191
|
+
serialise(this, undefined, undefined,
|
192
|
+
undefined, {excludeOld: true})[0], embed);
|
193
|
+
};
|
194
|
+
|
195
|
+
this.mainMenu = function () {
|
196
|
+
var menus = this.menus(),
|
197
|
+
i = 0;
|
198
|
+
if (menus === undefined) {
|
199
|
+
return null;
|
200
|
+
}
|
201
|
+
for (i = 0; i < menus.length; ++i) {
|
202
|
+
if (menus[i].menuType() === 0) {
|
203
|
+
return menus[i];
|
204
|
+
}
|
205
|
+
}
|
206
|
+
return null;
|
207
|
+
};
|
208
|
+
|
209
|
+
this.domainLogoUrl = function () {
|
210
|
+
var logo = this.logo();
|
211
|
+
return logo && logo.viewUrl() ? logo.viewUrl() : null;
|
212
|
+
}
|
213
|
+
|
214
|
+
this.faviconLogoUrl = function () {
|
215
|
+
var favicon = this.favicon();
|
216
|
+
return favicon && favicon.viewUrl() ? favicon.viewUrl() : null;
|
217
|
+
}
|
218
|
+
|
219
|
+
this.isDomainType = function (typeName) {
|
220
|
+
return this.domainType() === domainTypesInts.get(typeName);
|
221
|
+
}
|
222
|
+
|
223
|
+
this.isSellerDomain = function () {
|
224
|
+
return this.isDomainType(SELLER);
|
225
|
+
}
|
226
|
+
|
227
|
+
this.isSellerOrSellerPlusDomain = function () {
|
228
|
+
return this.isSellerDomain() || this.isDomainType(SELLER_PLUS);
|
229
|
+
}
|
230
|
+
|
231
|
+
this.isSupplierOrRestrictedSupplierDomain = function () {
|
232
|
+
return this.isDomainType(SUPPLIER) ||
|
233
|
+
this.isDomainType(RESTRICTED_SUPPLIER);
|
234
|
+
}
|
235
|
+
|
236
|
+
this.isUnrestricted = function () {
|
237
|
+
return this.domainType() === domainTypesInts.get('Unrestricted');
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
export function Domains() {
|
242
|
+
this.resource = '/domains';
|
243
|
+
this.json = 'domains';
|
244
|
+
this.single = Domain;
|
245
|
+
|
246
|
+
this.get = function (success, error, parameters) {
|
247
|
+
var self = this;
|
248
|
+
function handleResponse(result) {
|
249
|
+
success(fromJsonList(self, result,
|
250
|
+
{makesDirty: false}));
|
251
|
+
}
|
252
|
+
getList(this.resource, handleResponse, error, parameters);
|
253
|
+
};
|
254
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
2
|
+
import { addPropertyTo } from './model.js';
|
3
|
+
|
4
|
+
export function DomainInvitation() {
|
5
|
+
this.resource = '/domain_invitations';
|
6
|
+
this.json = 'domainInvitation';
|
7
|
+
this.temporaryId = generateUUID();
|
8
|
+
|
9
|
+
addPropertyTo(this, 'id');
|
10
|
+
addPropertyTo(this, 'userName');
|
11
|
+
addPropertyTo(this, 'userEmail');
|
12
|
+
addPropertyTo(this, 'role');
|
13
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
2
|
+
import { addPropertyTo, serialise, create, fromJson, patchOne, deleteOne,
|
3
|
+
fromJsonList, getList, enumerateFiles, getOne } from './model.js';
|
4
|
+
import { Domain } from './domain.js';
|
5
|
+
import { Product } from './product.js';
|
6
|
+
|
7
|
+
export function DomainTag() {
|
8
|
+
this.resource = '/domain_tags';
|
9
|
+
this.json = 'domainTag';
|
10
|
+
this.temporaryId = generateUUID();
|
11
|
+
|
12
|
+
addPropertyTo(this, 'id');
|
13
|
+
addPropertyTo(this, 'name');
|
14
|
+
addPropertyTo(this, 'description');
|
15
|
+
addPropertyTo(this, 'colour');
|
16
|
+
addPropertyTo(this, 'showPublic');
|
17
|
+
addPropertyTo(this, 'domain', Domain);
|
18
|
+
addPropertyTo(this, 'products', Product);
|
19
|
+
|
20
|
+
this.create = function (success, error, embed, domainId) {
|
21
|
+
var data = serialise(this),
|
22
|
+
self = this;
|
23
|
+
function handleResponse(result) {
|
24
|
+
success(fromJson(self, result[self.json]));
|
25
|
+
}
|
26
|
+
create({resource: this.resource,
|
27
|
+
parameters: data[0],
|
28
|
+
files: enumerateFiles(data[1]),
|
29
|
+
success: handleResponse,
|
30
|
+
error: error,
|
31
|
+
embed: embed,
|
32
|
+
as_domain: domainId});
|
33
|
+
};
|
34
|
+
|
35
|
+
this.get = function (success, error) {
|
36
|
+
var self = this;
|
37
|
+
function handleResponse(result) {
|
38
|
+
success(fromJson(self, result[self.json],
|
39
|
+
{makesDirty: false}));
|
40
|
+
}
|
41
|
+
getOne({resource: this.resource,
|
42
|
+
id: this.id(),
|
43
|
+
success: handleResponse,
|
44
|
+
error: error});
|
45
|
+
};
|
46
|
+
|
47
|
+
this.patch = function (success, error, embed) {
|
48
|
+
var self = this,
|
49
|
+
data = serialise(this)[0];
|
50
|
+
function handleResponse(result) {
|
51
|
+
success(fromJson(self, result[self.json],
|
52
|
+
{makesDirty: false}));
|
53
|
+
}
|
54
|
+
patchOne({resource: this.resource,
|
55
|
+
id: this.id(),
|
56
|
+
success: handleResponse,
|
57
|
+
error: error,
|
58
|
+
data: data,
|
59
|
+
embed: embed});
|
60
|
+
};
|
61
|
+
|
62
|
+
this.destroy = function (success, error) {
|
63
|
+
deleteOne(this.resource + "/" + this.id(), success, error);
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
export function DomainTags() {
|
68
|
+
this.resource = '/domain_tags';
|
69
|
+
this.json = 'domainTags';
|
70
|
+
this.single = DomainTag;
|
71
|
+
|
72
|
+
this.get = function (success, error, parameters) {
|
73
|
+
var self = this;
|
74
|
+
function handleResponse(result) {
|
75
|
+
success(fromJsonList(self, result, {makesDirty: false}));
|
76
|
+
}
|
77
|
+
getList(this.resource, handleResponse, error, parameters);
|
78
|
+
};
|
79
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Dictionary } from './dictionary.js';
|
2
|
+
|
3
|
+
export const domainTypes = new Dictionary();
|
4
|
+
domainTypes.add(0, 'Unrestricted');
|
5
|
+
domainTypes.add(1, 'Seller');
|
6
|
+
domainTypes.add(2, 'Seller plus');
|
7
|
+
domainTypes.add(3, 'Supplier');
|
8
|
+
domainTypes.add(4, 'Restricted supplier');
|
9
|
+
domainTypes.add(5, 'Domain supplier');
|
10
|
+
domainTypes.add(6, 'Domain client catalogue');
|
11
|
+
domainTypes.add(7, 'Domain shopify seller');
|
12
|
+
domainTypes.add(8, 'Unrestricted shopify app');
|
13
|
+
domainTypes.add(9, 'Reserved');
|
14
|
+
|
15
|
+
export const domainTypesInts = new Dictionary();
|
16
|
+
domainTypes.each(function (key, value) {
|
17
|
+
domainTypesInts.add(value, parseInt(key, 10));
|
18
|
+
});
|
package/src/draft.js
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
import { addPropertyTo, serialise, fromJsonList, getList, getOne,
|
2
|
+
fromJson, patchOne } from './model.js';
|
3
|
+
import { sortArrayByObjectKeyDescending, isUndefined } from './helpers.js';
|
4
|
+
import { Job } from './job.js';
|
5
|
+
import { User } from './user.js';
|
6
|
+
import { DraftComment } from './draft_comment.js';
|
7
|
+
import { MerchiFile } from './merchi_file.js';
|
8
|
+
|
9
|
+
export function Draft() {
|
10
|
+
this.resource = '/drafts';
|
11
|
+
this.json = 'draft';
|
12
|
+
|
13
|
+
addPropertyTo(this, 'id');
|
14
|
+
addPropertyTo(this, 'job', Job);
|
15
|
+
addPropertyTo(this, 'sharedWithJob', Job);
|
16
|
+
addPropertyTo(this, 'designer', User);
|
17
|
+
addPropertyTo(this, 'file', MerchiFile);
|
18
|
+
addPropertyTo(this, 'date');
|
19
|
+
addPropertyTo(this, 'accepted');
|
20
|
+
addPropertyTo(this, 'changesRequested');
|
21
|
+
addPropertyTo(this, 'resendDate');
|
22
|
+
addPropertyTo(this, 'viewed');
|
23
|
+
addPropertyTo(this, 'justViewed');
|
24
|
+
addPropertyTo(this, 'comments', DraftComment);
|
25
|
+
addPropertyTo(this, 'commentsCount');
|
26
|
+
addPropertyTo(this, 'sendSms');
|
27
|
+
addPropertyTo(this, 'sendEmail');
|
28
|
+
|
29
|
+
this.get = function (success, error, embed, include_archived) {
|
30
|
+
var self = this;
|
31
|
+
function handleResponse(result) {
|
32
|
+
success(fromJson(self, result[self.json],
|
33
|
+
{makesDirty: false}));
|
34
|
+
}
|
35
|
+
getOne({resource: this.resource,
|
36
|
+
id: this.id(),
|
37
|
+
success: handleResponse,
|
38
|
+
error: error,
|
39
|
+
embed: embed,
|
40
|
+
includeArchived: include_archived});
|
41
|
+
};
|
42
|
+
|
43
|
+
this.patch = function (options) {
|
44
|
+
var self = this,
|
45
|
+
data = serialise(this, undefined, undefined, undefined,
|
46
|
+
{excludeOld: true})[0],
|
47
|
+
job = this.job(),
|
48
|
+
domain = job && job.domain() ? job.domain().id() : null,
|
49
|
+
asDomain = options.asDomain,
|
50
|
+
domainId = isUndefined(asDomain) ? domain : asDomain;
|
51
|
+
function handleResponse(result) {
|
52
|
+
options.success(fromJson(self, result[self.json]));
|
53
|
+
}
|
54
|
+
patchOne({resource: this.resource,
|
55
|
+
id: this.id(),
|
56
|
+
success: handleResponse,
|
57
|
+
error: options.error,
|
58
|
+
as_domain: domainId,
|
59
|
+
data: data,
|
60
|
+
embed: options.embed});
|
61
|
+
};
|
62
|
+
|
63
|
+
this.changesRequested = function () {
|
64
|
+
var comments = this.comments() ? this.comments() : [],
|
65
|
+
i;
|
66
|
+
for (i = 0; i < comments.length; i++) {
|
67
|
+
if (comments[i].changeRequest()) {
|
68
|
+
return true;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
return false;
|
72
|
+
}
|
73
|
+
|
74
|
+
this.commentsYoungestToEldest = function () {
|
75
|
+
return sortArrayByObjectKeyDescending(this.comments(), 'id');
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
export function Drafts() {
|
80
|
+
this.resource = '/drafts';
|
81
|
+
this.json = 'drafts';
|
82
|
+
this.single = Draft;
|
83
|
+
|
84
|
+
this.get = function (success, error, parameters) {
|
85
|
+
var self = this;
|
86
|
+
function handleResponse(result) {
|
87
|
+
success(fromJsonList(self, result,
|
88
|
+
{makesDirty: false}));
|
89
|
+
}
|
90
|
+
getList(this.resource, handleResponse, error, parameters);
|
91
|
+
};
|
92
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { addPropertyTo, serialise, create, enumerateFiles,
|
2
|
+
fromJson } from './model.js';
|
3
|
+
import { Draft } from './draft.js';
|
4
|
+
import { Job } from './job.js';
|
5
|
+
import { User } from './user.js';
|
6
|
+
import { Notification } from './notification.js';
|
7
|
+
import { MerchiFile } from './merchi_file.js';
|
8
|
+
|
9
|
+
export function DraftComment() {
|
10
|
+
this.resource = '/draft_comments';
|
11
|
+
this.json = 'draftComment';
|
12
|
+
|
13
|
+
addPropertyTo(this, 'id');
|
14
|
+
addPropertyTo(this, 'draft', Draft);
|
15
|
+
addPropertyTo(this, 'user', User);
|
16
|
+
addPropertyTo(this, 'file', MerchiFile);
|
17
|
+
addPropertyTo(this, 'notifications', Notification);
|
18
|
+
addPropertyTo(this, 'job', Job);
|
19
|
+
addPropertyTo(this, 'date');
|
20
|
+
addPropertyTo(this, 'text');
|
21
|
+
addPropertyTo(this, 'urgency');
|
22
|
+
addPropertyTo(this, 'subject');
|
23
|
+
addPropertyTo(this, 'sendSms');
|
24
|
+
addPropertyTo(this, 'sendEmail');
|
25
|
+
addPropertyTo(this, 'changeRequest');
|
26
|
+
|
27
|
+
this.create = function (options) {
|
28
|
+
var data = serialise(this),
|
29
|
+
self = this;
|
30
|
+
function handleResponse(result) {
|
31
|
+
options.success(fromJson(self, result[self.json]));
|
32
|
+
}
|
33
|
+
create({resource: this.resource,
|
34
|
+
parameters: data[0],
|
35
|
+
files: enumerateFiles(data[1]),
|
36
|
+
success: handleResponse,
|
37
|
+
as_domain: options.as_domain,
|
38
|
+
error: options.error,
|
39
|
+
embed: options.embed});
|
40
|
+
};
|
41
|
+
}
|