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
package/dist/invoice.js
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Invoice = Invoice;
|
7
|
+
exports.Invoices = Invoices;
|
8
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
9
|
+
var _uuid = require("./uuid.js");
|
10
|
+
var _model = require("./model.js");
|
11
|
+
var _helpers = require("./helpers.js");
|
12
|
+
var _address = require("./address.js");
|
13
|
+
var _email_address = require("./email_address.js");
|
14
|
+
var _domain = require("./domain.js");
|
15
|
+
var _domain_tag = require("./domain_tag.js");
|
16
|
+
var _item = require("./item.js");
|
17
|
+
var _company = require("./company.js");
|
18
|
+
var _phone_number = require("./phone_number.js");
|
19
|
+
var _user = require("./user.js");
|
20
|
+
var _shipment = require("./shipment.js");
|
21
|
+
var _merchi_file = require("./merchi_file.js");
|
22
|
+
var _quote = require("./quote.js");
|
23
|
+
var _payment = require("./payment.js");
|
24
|
+
var _job = require("./job.js");
|
25
|
+
var _internal_tag = require("./internal_tag.js");
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
27
|
+
function Invoice() {
|
28
|
+
this.resource = '/invoices';
|
29
|
+
this.json = 'invoice';
|
30
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
31
|
+
(0, _model.addPropertyTo)(this, 'id');
|
32
|
+
(0, _model.addPropertyTo)(this, 'note');
|
33
|
+
(0, _model.addPropertyTo)(this, 'creationDate');
|
34
|
+
(0, _model.addPropertyTo)(this, 'paymentDeadline');
|
35
|
+
(0, _model.addPropertyTo)(this, 'sendSms');
|
36
|
+
(0, _model.addPropertyTo)(this, 'sendEmail');
|
37
|
+
(0, _model.addPropertyTo)(this, 'unpaid');
|
38
|
+
(0, _model.addPropertyTo)(this, 'totalCost');
|
39
|
+
(0, _model.addPropertyTo)(this, 'subtotalCost');
|
40
|
+
(0, _model.addPropertyTo)(this, 'taxAmount');
|
41
|
+
(0, _model.addPropertyTo)(this, 'invoiceToken');
|
42
|
+
(0, _model.addPropertyTo)(this, 'canAutoPay');
|
43
|
+
(0, _model.addPropertyTo)(this, 'responsibleManager', _user.User);
|
44
|
+
(0, _model.addPropertyTo)(this, 'creator', _user.User);
|
45
|
+
(0, _model.addPropertyTo)(this, 'client', _user.User);
|
46
|
+
(0, _model.addPropertyTo)(this, 'clientEmail', _email_address.EmailAddress);
|
47
|
+
(0, _model.addPropertyTo)(this, 'clientPhone', _phone_number.PhoneNumber);
|
48
|
+
(0, _model.addPropertyTo)(this, 'clientCompany', _company.Company);
|
49
|
+
(0, _model.addPropertyTo)(this, 'clientCompanyEmail', _email_address.EmailAddress);
|
50
|
+
(0, _model.addPropertyTo)(this, 'clientCompanyPhone', _phone_number.PhoneNumber);
|
51
|
+
(0, _model.addPropertyTo)(this, 'jobs', _job.Job);
|
52
|
+
(0, _model.addPropertyTo)(this, 'quotes', _quote.Quote);
|
53
|
+
(0, _model.addPropertyTo)(this, 'items', _item.Item);
|
54
|
+
(0, _model.addPropertyTo)(this, 'shipping', _address.Address);
|
55
|
+
(0, _model.addPropertyTo)(this, 'domain', _domain.Domain);
|
56
|
+
(0, _model.addPropertyTo)(this, 'pdf', _merchi_file.MerchiFile);
|
57
|
+
(0, _model.addPropertyTo)(this, 'receipt', _merchi_file.MerchiFile);
|
58
|
+
(0, _model.addPropertyTo)(this, 'payments', _payment.Payment);
|
59
|
+
(0, _model.addPropertyTo)(this, 'currency');
|
60
|
+
(0, _model.addPropertyTo)(this, 'acceptSquare');
|
61
|
+
(0, _model.addPropertyTo)(this, 'acceptStripe');
|
62
|
+
(0, _model.addPropertyTo)(this, 'acceptPaypal');
|
63
|
+
(0, _model.addPropertyTo)(this, 'acceptUtrust');
|
64
|
+
(0, _model.addPropertyTo)(this, 'acceptBankTransfer');
|
65
|
+
(0, _model.addPropertyTo)(this, 'acceptPhonePayment');
|
66
|
+
(0, _model.addPropertyTo)(this, 'tags', _domain_tag.DomainTag);
|
67
|
+
(0, _model.addPropertyTo)(this, 'reminderMessage');
|
68
|
+
(0, _model.addPropertyTo)(this, 'reminded');
|
69
|
+
(0, _model.addPropertyTo)(this, 'isRemindable');
|
70
|
+
(0, _model.addPropertyTo)(this, 'forceReminders');
|
71
|
+
(0, _model.addPropertyTo)(this, 'owedMoney');
|
72
|
+
(0, _model.addPropertyTo)(this, 'paidMoney');
|
73
|
+
(0, _model.addPropertyTo)(this, 'isCompletelyPaid');
|
74
|
+
(0, _model.addPropertyTo)(this, 'shipments', _shipment.Shipment);
|
75
|
+
(0, _model.addPropertyTo)(this, 'shopifyOrderId');
|
76
|
+
(0, _model.addPropertyTo)(this, 'internalTags', _internal_tag.InternalTag);
|
77
|
+
this.create = function (success, error, embed, asDomain) {
|
78
|
+
var data = (0, _model.serialise)(this),
|
79
|
+
self = this,
|
80
|
+
domain = self.domain() ? self.domain().id() : null,
|
81
|
+
domainId = (0, _helpers.isUndefinedOrNull)(asDomain) ? domain : asDomain;
|
82
|
+
function handleResponse(result) {
|
83
|
+
success((0, _model.fromJson)(self, result[self.json]));
|
84
|
+
}
|
85
|
+
(0, _model.create)({
|
86
|
+
resource: this.resource,
|
87
|
+
parameters: data[0],
|
88
|
+
as_domain: domainId,
|
89
|
+
files: (0, _model.enumerateFiles)(data[1]),
|
90
|
+
success: handleResponse,
|
91
|
+
error: error,
|
92
|
+
embed: embed
|
93
|
+
});
|
94
|
+
};
|
95
|
+
this.patch = function (success, error, embed, asDomain) {
|
96
|
+
var self = this,
|
97
|
+
data = (0, _model.serialise)(this, undefined, undefined, undefined, {
|
98
|
+
excludeOld: true
|
99
|
+
})[0],
|
100
|
+
domain = self.domain() ? self.domain().id() : null,
|
101
|
+
domainId = (0, _helpers.isUndefinedOrNull)(asDomain) ? domain : asDomain;
|
102
|
+
function handleResponse(result) {
|
103
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
104
|
+
makesDirty: false
|
105
|
+
}));
|
106
|
+
}
|
107
|
+
(0, _model.patchOne)({
|
108
|
+
resource: this.resource,
|
109
|
+
id: this.id(),
|
110
|
+
success: handleResponse,
|
111
|
+
error: error,
|
112
|
+
as_domain: domainId,
|
113
|
+
data: data,
|
114
|
+
embed: embed
|
115
|
+
});
|
116
|
+
};
|
117
|
+
this.publicCreate = function (success, error) {
|
118
|
+
var data = (0, _model.serialise)(this),
|
119
|
+
self = this,
|
120
|
+
request = new _model.Request();
|
121
|
+
request.data().merge(data[0]);
|
122
|
+
request.resource('/public-invoice-create/');
|
123
|
+
request.method('POST');
|
124
|
+
function handleResponse(status, data) {
|
125
|
+
if (status === 201) {
|
126
|
+
success((0, _model.fromJson)(self, data[self.json]));
|
127
|
+
} else {
|
128
|
+
error(status, data);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
function handleError(status, data) {
|
132
|
+
error(status, data);
|
133
|
+
}
|
134
|
+
request.responseHandler(handleResponse).errorHandler(handleError);
|
135
|
+
request.send();
|
136
|
+
};
|
137
|
+
this.get = function (success, error, embed) {
|
138
|
+
var self = this;
|
139
|
+
function handleResponse(result) {
|
140
|
+
success((0, _model.fromJson)(self, result[self.json], {
|
141
|
+
makesDirty: false
|
142
|
+
}));
|
143
|
+
}
|
144
|
+
(0, _model.getOne)({
|
145
|
+
resource: this.resource,
|
146
|
+
id: this.id(),
|
147
|
+
success: handleResponse,
|
148
|
+
error: error,
|
149
|
+
embed: embed
|
150
|
+
});
|
151
|
+
};
|
152
|
+
this.destroy = function (success, error) {
|
153
|
+
(0, _model.deleteOne)(this.resource + "/" + this.id(), success, error);
|
154
|
+
};
|
155
|
+
this.company = function () {
|
156
|
+
return this.domain() ? this.domain().company() : null;
|
157
|
+
};
|
158
|
+
this.paymentPhoneNumbers = function () {
|
159
|
+
return this.company() ? this.company().paymentPhoneNumbers() : null;
|
160
|
+
};
|
161
|
+
this.paymentBanks = function () {
|
162
|
+
return this.company() ? this.company().banks() : null;
|
163
|
+
};
|
164
|
+
this.stripePublishableKey = function () {
|
165
|
+
return this.company() ? this.company().stripePublishableKey() : null;
|
166
|
+
};
|
167
|
+
this.calculate = function (success, error, embed) {
|
168
|
+
var self = this,
|
169
|
+
request = new _model.Request(),
|
170
|
+
data = (0, _model.serialise)(this)[0];
|
171
|
+
request.resource('/invoice-cost-estimate/');
|
172
|
+
request.method('POST');
|
173
|
+
request.query().add("as_domain", self.domain().id());
|
174
|
+
request.query().add('skip_rights', true);
|
175
|
+
request.data().merge(data);
|
176
|
+
function handleResponse(status, data) {
|
177
|
+
if (status === 201) {
|
178
|
+
success((0, _model.fromJson)(self, data));
|
179
|
+
} else {
|
180
|
+
error(data);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
function handleError() {
|
184
|
+
error({
|
185
|
+
message: 'could not connect to server',
|
186
|
+
errorCode: 0
|
187
|
+
});
|
188
|
+
}
|
189
|
+
request.responseHandler(handleResponse).errorHandler(handleError);
|
190
|
+
request.send();
|
191
|
+
};
|
192
|
+
this.amountPaid = function () {
|
193
|
+
var payments = this.payments() ? this.payments() : [],
|
194
|
+
total = 0,
|
195
|
+
i;
|
196
|
+
for (i = 0; i < payments.length; i++) {
|
197
|
+
var amount = payments[i].amount();
|
198
|
+
total += amount ? amount : 0;
|
199
|
+
}
|
200
|
+
return total;
|
201
|
+
};
|
202
|
+
this.amountOwed = function () {
|
203
|
+
var total = this.totalCost();
|
204
|
+
return total - this.amountPaid();
|
205
|
+
};
|
206
|
+
this.isOverdue = function () {
|
207
|
+
var unpaid = this.unpaid(),
|
208
|
+
now = (0, _momentTimezone["default"])().unix();
|
209
|
+
return unpaid && now > this.paymentDeadline();
|
210
|
+
};
|
211
|
+
}
|
212
|
+
function Invoices() {
|
213
|
+
this.resource = '/invoices';
|
214
|
+
this.json = 'invoices';
|
215
|
+
this.single = Invoice;
|
216
|
+
this.get = function (success, error, parameters) {
|
217
|
+
var self = this;
|
218
|
+
function handleResponse(result) {
|
219
|
+
success((0, _model.fromJsonList)(self, result, {
|
220
|
+
makesDirty: false
|
221
|
+
}));
|
222
|
+
}
|
223
|
+
(0, _model.getList)(this.resource, handleResponse, error, parameters);
|
224
|
+
};
|
225
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.invoiceTypes = void 0;
|
7
|
+
var _dictionary = require("./dictionary.js");
|
8
|
+
var invoiceTypes = exports.invoiceTypes = new _dictionary.Dictionary();
|
9
|
+
invoiceTypes.add("ORDER", 1);
|
10
|
+
invoiceTypes.add("SUBSCRIPTION_BILL", 2);
|
11
|
+
invoiceTypes.add("AUTO_SUPPLY_BILL", 3);
|
package/dist/item.js
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Item = Item;
|
7
|
+
var _uuid = require("./uuid.js");
|
8
|
+
var _model = require("./model.js");
|
9
|
+
var _country_tax = require("./country_tax.js");
|
10
|
+
function Item() {
|
11
|
+
this.resource = '/items';
|
12
|
+
this.json = 'items';
|
13
|
+
this.temporaryId = (0, _uuid.generateUUID)();
|
14
|
+
(0, _model.addPropertyTo)(this, 'id');
|
15
|
+
(0, _model.addPropertyTo)(this, 'quantity');
|
16
|
+
(0, _model.addPropertyTo)(this, 'taxType', _country_tax.CountryTax);
|
17
|
+
(0, _model.addPropertyTo)(this, 'taxAmount');
|
18
|
+
(0, _model.addPropertyTo)(this, 'cost');
|
19
|
+
(0, _model.addPropertyTo)(this, 'description');
|
20
|
+
this.totalCost = function () {
|
21
|
+
var quantity = this.quantity() ? this.quantity() : 0,
|
22
|
+
cost = this.cost() ? this.cost() : 0;
|
23
|
+
return quantity * cost;
|
24
|
+
};
|
25
|
+
}
|