addio-admin-sdk 1.7.102 → 1.7.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Interfaces/Algolia/index.d.ts +1 -0
- package/dist/Interfaces/Attribute/index.d.ts +1 -0
- package/dist/Interfaces/CMS/index.d.ts +3 -0
- package/dist/Interfaces/CMS/index.js +3 -0
- package/dist/Interfaces/CMS/index.js.map +1 -1
- package/dist/Interfaces/Cart/index.d.ts +1 -0
- package/dist/Interfaces/Cart/index.js +6 -2
- package/dist/Interfaces/Cart/index.js.map +1 -1
- package/dist/Interfaces/CartReservedQuantities/index.d.ts +2 -0
- package/dist/Interfaces/Customer/IStoreCredit.d.ts +1 -0
- package/dist/Interfaces/Customer/index.d.ts +7 -0
- package/dist/Interfaces/Customer/index.js +7 -0
- package/dist/Interfaces/Customer/index.js.map +1 -1
- package/dist/Interfaces/Declination/index.js +8 -2
- package/dist/Interfaces/Declination/index.js.map +1 -1
- package/dist/Interfaces/Email/IEmail.js +7 -3
- package/dist/Interfaces/Email/IEmail.js.map +1 -1
- package/dist/Interfaces/G2/index.js +2 -0
- package/dist/Interfaces/G2/index.js.map +1 -1
- package/dist/Interfaces/Indexed/Product/index.d.ts +3 -0
- package/dist/Interfaces/Indexed/Product/index.js +43 -2
- package/dist/Interfaces/Indexed/Product/index.js.map +1 -1
- package/dist/Interfaces/Menu/index.d.ts +11 -0
- package/dist/Interfaces/Product/IImportProduct.js +94 -3
- package/dist/Interfaces/Product/IImportProduct.js.map +1 -1
- package/dist/Interfaces/Product/IInventoryItem.d.ts +11 -27
- package/dist/Interfaces/Product/IInventoryItem.js +13 -4
- package/dist/Interfaces/Product/IInventoryItem.js.map +1 -1
- package/dist/Interfaces/Product/IPricing.js +6 -0
- package/dist/Interfaces/Product/IPricing.js.map +1 -1
- package/dist/Interfaces/Product/index.d.ts +8 -0
- package/dist/Interfaces/Product/index.js +8 -0
- package/dist/Interfaces/Product/index.js.map +1 -1
- package/dist/Interfaces/PromiseToPurchase/IIndexedBankUsed.js +1 -1
- package/dist/Interfaces/PromiseToPurchase/IIndexedBankUsed.js.map +1 -1
- package/dist/Interfaces/Rules/IDiscountRule.d.ts +18 -0
- package/dist/Interfaces/Rules/IDiscountRule.js +19 -0
- package/dist/Interfaces/Rules/IDiscountRule.js.map +1 -1
- package/dist/Interfaces/Services/IService.d.ts +4 -0
- package/dist/Interfaces/Shipping/Shiptime/order.js +23 -0
- package/dist/Interfaces/Shipping/Shiptime/order.js.map +1 -1
- package/dist/Interfaces/Space/index.d.ts +8 -0
- package/dist/Interfaces/Space/index.js +9 -0
- package/dist/Interfaces/Space/index.js.map +1 -1
- package/dist/Interfaces/TCG/index.d.ts +12 -1
- package/dist/Interfaces/TCG/index.js +11 -0
- package/dist/Interfaces/TCG/index.js.map +1 -1
- package/dist/Interfaces/TransferRequest/index.js +3 -0
- package/dist/Interfaces/TransferRequest/index.js.map +1 -1
- package/dist/constants/services.js +1 -0
- package/dist/constants/services.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/Attribute/index.js +43 -0
- package/dist/lib/Attribute/index.js.map +1 -1
- package/dist/lib/BGJob/index.js +5 -1
- package/dist/lib/BGJob/index.js.map +1 -1
- package/dist/lib/Booking/index.d.ts +15 -0
- package/dist/lib/Booking/index.js +20 -0
- package/dist/lib/Booking/index.js.map +1 -1
- package/dist/lib/Brand/index.d.ts +9 -0
- package/dist/lib/Brand/index.js +18 -0
- package/dist/lib/Brand/index.js.map +1 -1
- package/dist/lib/Cart/index.d.ts +99 -0
- package/dist/lib/Cart/index.js +498 -9
- package/dist/lib/Cart/index.js.map +1 -1
- package/dist/lib/CartReservedQuantities/index.d.ts +29 -0
- package/dist/lib/CartReservedQuantities/index.js +41 -0
- package/dist/lib/CartReservedQuantities/index.js.map +1 -1
- package/dist/lib/Catalogue/index.d.ts +6 -0
- package/dist/lib/Catalogue/index.js +9 -0
- package/dist/lib/Catalogue/index.js.map +1 -1
- package/dist/lib/Category/index.d.ts +6 -0
- package/dist/lib/Category/index.js +15 -0
- package/dist/lib/Category/index.js.map +1 -1
- package/dist/lib/Class/index.d.ts +4 -0
- package/dist/lib/Class/index.js +8 -0
- package/dist/lib/Class/index.js.map +1 -1
- package/dist/lib/Customer/index.d.ts +12 -0
- package/dist/lib/Customer/index.js +13 -0
- package/dist/lib/Customer/index.js.map +1 -1
- package/dist/lib/Declination/index.js +2 -0
- package/dist/lib/Declination/index.js.map +1 -1
- package/dist/lib/Discount/index.d.ts +9 -0
- package/dist/lib/Discount/index.js +23 -0
- package/dist/lib/Discount/index.js.map +1 -1
- package/dist/lib/ElasticSearch/index.d.ts +5 -0
- package/dist/lib/ElasticSearch/index.js +5 -0
- package/dist/lib/ElasticSearch/index.js.map +1 -1
- package/dist/lib/Elavon/index.js +5 -0
- package/dist/lib/Elavon/index.js.map +1 -1
- package/dist/lib/Email/AbandonedCartEmail.d.ts +8 -0
- package/dist/lib/Email/AbandonedCartEmail.js +8 -0
- package/dist/lib/Email/AbandonedCartEmail.js.map +1 -1
- package/dist/lib/Email/AccountConfirmationEmail.d.ts +8 -0
- package/dist/lib/Email/AccountConfirmationEmail.js +8 -0
- package/dist/lib/Email/AccountConfirmationEmail.js.map +1 -1
- package/dist/lib/Email/AdminOrderConfirmationEmail.d.ts +8 -0
- package/dist/lib/Email/AdminOrderConfirmationEmail.js +8 -0
- package/dist/lib/Email/AdminOrderConfirmationEmail.js.map +1 -1
- package/dist/lib/Email/ApplicationEmail.d.ts +8 -0
- package/dist/lib/Email/ApplicationEmail.js +8 -0
- package/dist/lib/Email/ApplicationEmail.js.map +1 -1
- package/dist/lib/Email/BackInStockEmail.d.ts +8 -0
- package/dist/lib/Email/BackInStockEmail.js +8 -0
- package/dist/lib/Email/BackInStockEmail.js.map +1 -1
- package/dist/lib/Email/ContactEmail.d.ts +8 -0
- package/dist/lib/Email/ContactEmail.js +8 -0
- package/dist/lib/Email/ContactEmail.js.map +1 -1
- package/dist/lib/Email/CustomerBookingAdminEmail.d.ts +8 -0
- package/dist/lib/Email/CustomerBookingAdminEmail.js +8 -0
- package/dist/lib/Email/CustomerBookingAdminEmail.js.map +1 -1
- package/dist/lib/Email/CustomerBookingEmail.d.ts +8 -0
- package/dist/lib/Email/CustomerBookingEmail.js +8 -0
- package/dist/lib/Email/CustomerBookingEmail.js.map +1 -1
- package/dist/lib/Email/OrderConfirmationEmail.d.ts +8 -0
- package/dist/lib/Email/OrderConfirmationEmail.js +8 -0
- package/dist/lib/Email/OrderConfirmationEmail.js.map +1 -1
- package/dist/lib/Email/OrderDenounciationEmail.d.ts +8 -0
- package/dist/lib/Email/OrderDenounciationEmail.js +8 -0
- package/dist/lib/Email/OrderDenounciationEmail.js.map +1 -1
- package/dist/lib/Email/OrderSampleEmail.d.ts +8 -0
- package/dist/lib/Email/OrderSampleEmail.js +8 -0
- package/dist/lib/Email/OrderSampleEmail.js.map +1 -1
- package/dist/lib/Email/OtherTypeEmails.d.ts +8 -0
- package/dist/lib/Email/OtherTypeEmails.js +8 -0
- package/dist/lib/Email/OtherTypeEmails.js.map +1 -1
- package/dist/lib/Email/PasswordResetEmail.d.ts +8 -0
- package/dist/lib/Email/PasswordResetEmail.js +8 -0
- package/dist/lib/Email/PasswordResetEmail.js.map +1 -1
- package/dist/lib/Email/PhotoShootEmail.d.ts +8 -0
- package/dist/lib/Email/PhotoShootEmail.js +8 -0
- package/dist/lib/Email/PhotoShootEmail.js.map +1 -1
- package/dist/lib/Email/PickUpConfirmation.d.ts +8 -0
- package/dist/lib/Email/PickUpConfirmation.js +8 -0
- package/dist/lib/Email/PickUpConfirmation.js.map +1 -1
- package/dist/lib/Email/ShippingConfirmation.d.ts +8 -0
- package/dist/lib/Email/ShippingConfirmation.js +8 -0
- package/dist/lib/Email/ShippingConfirmation.js.map +1 -1
- package/dist/lib/Email/WelcomeEmail.d.ts +8 -0
- package/dist/lib/Email/WelcomeEmail.js +8 -0
- package/dist/lib/Email/WelcomeEmail.js.map +1 -1
- package/dist/lib/Email/index.d.ts +8 -0
- package/dist/lib/Email/index.js +8 -0
- package/dist/lib/Email/index.js.map +1 -1
- package/dist/lib/ExternalService/Ebay.d.ts +12 -0
- package/dist/lib/ExternalService/Ebay.js +22 -0
- package/dist/lib/ExternalService/Ebay.js.map +1 -1
- package/dist/lib/Indexed/IndexedCart.js +5 -0
- package/dist/lib/Indexed/IndexedCart.js.map +1 -1
- package/dist/lib/Indexed/Product.js +50 -0
- package/dist/lib/Indexed/Product.js.map +1 -1
- package/dist/lib/Inventory/index.d.ts +59 -0
- package/dist/lib/Inventory/index.js +157 -9
- package/dist/lib/Inventory/index.js.map +1 -1
- package/dist/lib/Invoice/index.d.ts +11 -0
- package/dist/lib/Invoice/index.js +11 -0
- package/dist/lib/Invoice/index.js.map +1 -1
- package/dist/lib/MarketplacePublication/index.js +308 -0
- package/dist/lib/MarketplacePublication/index.js.map +1 -1
- package/dist/lib/Menu/index.js +2 -0
- package/dist/lib/Menu/index.js.map +1 -1
- package/dist/lib/Order/index.d.ts +20 -0
- package/dist/lib/Order/index.js +23 -0
- package/dist/lib/Order/index.js.map +1 -1
- package/dist/lib/Org/index.d.ts +41 -0
- package/dist/lib/Org/index.js +41 -0
- package/dist/lib/Org/index.js.map +1 -1
- package/dist/lib/PandaPay/index.js +6 -0
- package/dist/lib/PandaPay/index.js.map +1 -1
- package/dist/lib/Paysafe/index.js +1 -0
- package/dist/lib/Paysafe/index.js.map +1 -1
- package/dist/lib/Product/index.d.ts +25 -0
- package/dist/lib/Product/index.js +55 -1
- package/dist/lib/Product/index.js.map +1 -1
- package/dist/lib/PromiseToPurchase/index.d.ts +72 -0
- package/dist/lib/PromiseToPurchase/index.js +79 -0
- package/dist/lib/PromiseToPurchase/index.js.map +1 -1
- package/dist/lib/PurchaseOrder/index.d.ts +11 -0
- package/dist/lib/PurchaseOrder/index.js +12 -0
- package/dist/lib/PurchaseOrder/index.js.map +1 -1
- package/dist/lib/Service/index.d.ts +8 -0
- package/dist/lib/Service/index.js +8 -0
- package/dist/lib/Service/index.js.map +1 -1
- package/dist/lib/Shipment/index.js +13 -0
- package/dist/lib/Shipment/index.js.map +1 -1
- package/dist/lib/Slider/index.d.ts +6 -0
- package/dist/lib/Slider/index.js +6 -0
- package/dist/lib/Slider/index.js.map +1 -1
- package/dist/lib/Space/index.d.ts +178 -0
- package/dist/lib/Space/index.js +495 -6
- package/dist/lib/Space/index.js.map +1 -1
- package/dist/lib/Supplier/index.js +5 -0
- package/dist/lib/Supplier/index.js.map +1 -1
- package/dist/lib/Tags/index.js +5 -0
- package/dist/lib/Tags/index.js.map +1 -1
- package/dist/lib/TransferRequest/index.d.ts +178 -0
- package/dist/lib/TransferRequest/index.js +236 -4
- package/dist/lib/TransferRequest/index.js.map +1 -1
- package/dist/lib/User/index.d.ts +54 -0
- package/dist/lib/User/index.js +101 -21
- package/dist/lib/User/index.js.map +1 -1
- package/dist/lib/baseService.js +26 -0
- package/dist/lib/baseService.js.map +1 -1
- package/dist/rules/GR/constants/data.js +22 -0
- package/dist/rules/GR/constants/data.js.map +1 -1
- package/dist/rules/GR/constants/products.d.ts +3 -0
- package/dist/rules/GR/constants/products.js +16 -0
- package/dist/rules/GR/constants/products.js.map +1 -1
- package/dist/rules/GR/interfaces/data.js +7 -1
- package/dist/rules/GR/interfaces/data.js.map +1 -1
- package/dist/rules/GR/utils/cart.d.ts +41 -0
- package/dist/rules/GR/utils/cart.js +107 -1
- package/dist/rules/GR/utils/cart.js.map +1 -1
- package/dist/rules/GR/utils/data.js +4 -1
- package/dist/rules/GR/utils/data.js.map +1 -1
- package/dist/rules/GR/utils/expedition.d.ts +69 -0
- package/dist/rules/GR/utils/expedition.js +399 -11
- package/dist/rules/GR/utils/expedition.js.map +1 -1
- package/dist/rules/GR/utils/g2.d.ts +33 -0
- package/dist/rules/GR/utils/g2.js +135 -3
- package/dist/rules/GR/utils/g2.js.map +1 -1
- package/dist/rules/GR/utils/invoices.d.ts +27 -0
- package/dist/rules/GR/utils/invoices.js +41 -0
- package/dist/rules/GR/utils/invoices.js.map +1 -1
- package/dist/rules/GR/utils/products.d.ts +161 -0
- package/dist/rules/GR/utils/products.js +272 -1
- package/dist/rules/GR/utils/products.js.map +1 -1
- package/dist/rules/GR/utils/upsells.d.ts +32 -0
- package/dist/rules/GR/utils/upsells.js +32 -0
- package/dist/rules/GR/utils/upsells.js.map +1 -1
- package/dist/services/database/DatabaseService.d.ts +84 -0
- package/dist/services/database/DatabaseService.js +85 -0
- package/dist/services/database/DatabaseService.js.map +1 -1
- package/dist/services/database/FirebaseProvider.js +17 -0
- package/dist/services/database/FirebaseProvider.js.map +1 -1
- package/dist/services/database/NotFirebaseProvider.d.ts +14 -0
- package/dist/services/database/NotFirebaseProvider.js +19 -0
- package/dist/services/database/NotFirebaseProvider.js.map +1 -1
- package/dist/services/g2/G2OrderSlip.d.ts +7 -0
- package/dist/services/g2/G2OrderSlip.js +18 -0
- package/dist/services/g2/G2OrderSlip.js.map +1 -1
- package/dist/services/g2/utils.d.ts +10 -0
- package/dist/services/g2/utils.js +189 -3
- package/dist/services/g2/utils.js.map +1 -1
- package/dist/services/logs/index.d.ts +3 -0
- package/dist/services/logs/index.js +6 -1
- package/dist/services/logs/index.js.map +1 -1
- package/dist/services/products/BaseClass.js +2 -0
- package/dist/services/products/BaseClass.js.map +1 -1
- package/dist/services/products/TCGService.js +17 -1
- package/dist/services/products/TCGService.js.map +1 -1
- package/dist/services/products/utils.d.ts +22 -0
- package/dist/services/products/utils.js +50 -0
- package/dist/services/products/utils.js.map +1 -1
- package/dist/utils/anonymisation.d.ts +24 -0
- package/dist/utils/anonymisation.js +30 -0
- package/dist/utils/anonymisation.js.map +1 -1
- package/dist/utils/aws.d.ts +22 -0
- package/dist/utils/aws.js +28 -0
- package/dist/utils/aws.js.map +1 -1
- package/dist/utils/booking.d.ts +8 -0
- package/dist/utils/booking.js +9 -0
- package/dist/utils/booking.js.map +1 -1
- package/dist/utils/cart.d.ts +81 -0
- package/dist/utils/cart.js +175 -10
- package/dist/utils/cart.js.map +1 -1
- package/dist/utils/context.js +2 -2
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/currency.js +31 -1
- package/dist/utils/currency.js.map +1 -1
- package/dist/utils/data.js +2 -0
- package/dist/utils/data.js.map +1 -1
- package/dist/utils/discount.d.ts +118 -0
- package/dist/utils/discount.js +178 -1
- package/dist/utils/discount.js.map +1 -1
- package/dist/utils/file-admin.js +1 -0
- package/dist/utils/file-admin.js.map +1 -1
- package/dist/utils/file.js +9 -1
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/firebase-admin.d.ts +9 -0
- package/dist/utils/firebase-admin.js +12 -0
- package/dist/utils/firebase-admin.js.map +1 -1
- package/dist/utils/firebase.d.ts +17 -0
- package/dist/utils/firebase.js +17 -0
- package/dist/utils/firebase.js.map +1 -1
- package/dist/utils/inventories.d.ts +52 -0
- package/dist/utils/inventories.js +77 -2
- package/dist/utils/inventories.js.map +1 -1
- package/dist/utils/locale.d.ts +9 -0
- package/dist/utils/locale.js +9 -0
- package/dist/utils/locale.js.map +1 -1
- package/dist/utils/mailchimp.js +36 -0
- package/dist/utils/mailchimp.js.map +1 -1
- package/dist/utils/mathUtils.js +9 -0
- package/dist/utils/mathUtils.js.map +1 -1
- package/dist/utils/object.d.ts +19 -0
- package/dist/utils/object.js +21 -3
- package/dist/utils/object.js.map +1 -1
- package/dist/utils/products.d.ts +7 -0
- package/dist/utils/products.js +9 -0
- package/dist/utils/products.js.map +1 -1
- package/dist/utils/promiseToPurchase.d.ts +32 -0
- package/dist/utils/promiseToPurchase.js +34 -0
- package/dist/utils/promiseToPurchase.js.map +1 -1
- package/dist/utils/prosprsearch.d.ts +16 -0
- package/dist/utils/prosprsearch.js +34 -0
- package/dist/utils/prosprsearch.js.map +1 -1
- package/dist/utils/sdc.js +7 -0
- package/dist/utils/sdc.js.map +1 -1
- package/dist/utils/searchIndexes.d.ts +37 -0
- package/dist/utils/searchIndexes.js +37 -0
- package/dist/utils/searchIndexes.js.map +1 -1
- package/dist/utils/string.js +7 -6
- package/dist/utils/string.js.map +1 -1
- package/dist/utils/tools.d.ts +4 -0
- package/dist/utils/tools.js +4 -0
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/transferRequests.d.ts +24 -0
- package/dist/utils/transferRequests.js +24 -0
- package/dist/utils/transferRequests.js.map +1 -1
- package/dist/utils/update.js +12 -0
- package/dist/utils/update.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,42 @@ const DatabaseService_1 = __importDefault(require("../../services/database/Datab
|
|
|
11
11
|
class MarketplacePublication extends baseService_1.BaseServiceClass {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments);
|
|
14
|
+
/* private _createEbayInventoryLocation = async (ebay: eBayApi) => {
|
|
15
|
+
console.log('_createEbayInventoryLocation')
|
|
16
|
+
try {
|
|
17
|
+
await ebay.sell.inventory.createInventoryLocation('merchantLocationKey', {
|
|
18
|
+
location: {
|
|
19
|
+
address: {
|
|
20
|
+
addressLine1: '123 rue principale',
|
|
21
|
+
city: 'Québec',
|
|
22
|
+
country: CountryCode.CA,
|
|
23
|
+
postalCode: 'H3C2A3'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
} catch (error) {
|
|
28
|
+
errorMessage(`Error while creating ebay location`)
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
} */
|
|
32
|
+
/* public updateEbayInventoryLocation = async (space: Space) => {
|
|
33
|
+
try {
|
|
34
|
+
const ebay = MarketplacePublication.connectionToEbay(space)
|
|
35
|
+
await ebay.sell.inventory.updateInventoryLocation('merchantLocationKey', {})
|
|
36
|
+
} catch (error) {
|
|
37
|
+
errorMessage(`Error while deleting ebay location`)
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
} */
|
|
41
|
+
/* public deleteEbayInventoryLocation = async (space: Space) => {
|
|
42
|
+
try {
|
|
43
|
+
const ebay = MarketplacePublication.connectionToEbay(space)
|
|
44
|
+
await ebay.sell.inventory.deleteInventoryLocation('merchantLocationKey')
|
|
45
|
+
} catch (error) {
|
|
46
|
+
errorMessage(`Error while deleting ebay location`)
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
} */
|
|
14
50
|
this.createEbayPublication = async (space) => {
|
|
15
51
|
try {
|
|
16
52
|
const service = space
|
|
@@ -20,6 +56,7 @@ class MarketplacePublication extends baseService_1.BaseServiceClass {
|
|
|
20
56
|
throw new Error(`No ebay service found`);
|
|
21
57
|
if (!!!service.external_service_infos.token)
|
|
22
58
|
throw new Error(`No ebay token found`);
|
|
59
|
+
// const serviceToken = service.external_service_infos.token
|
|
23
60
|
const publicationsVerification = await MarketplacePublication.getAllMarketplacePublicationsObjs(this.data().sku, this._collection.path, this._user);
|
|
24
61
|
if (!!!publicationsVerification)
|
|
25
62
|
throw new Error('Publication not found');
|
|
@@ -47,10 +84,17 @@ class MarketplacePublication extends baseService_1.BaseServiceClass {
|
|
|
47
84
|
throw new Error(`No product web inventory quantity available found`);
|
|
48
85
|
if ((0, toNumber_1.default)(productInventory.web_inventory.available) < (0, toNumber_1.default)(this.data().quantity))
|
|
49
86
|
throw new Error(`Product web inventory quantity available is less than quantity`);
|
|
87
|
+
// call ebay service to create publication
|
|
88
|
+
// const ebay = MarketplacePublication.connectionToEbay(space)
|
|
89
|
+
// ebay.OAuth2.setCredentials(serviceToken)
|
|
50
90
|
console.log('ebay connection done');
|
|
91
|
+
// await this._createEbayInventoryLocation(ebay)
|
|
51
92
|
console.log('createEbayInventoryLocation done');
|
|
93
|
+
// await this._createEbayInventory(ebay, productInventory.web_inventory.available, parentProduct[0], product)
|
|
52
94
|
console.log('createEbayInventory done');
|
|
95
|
+
// await this._createEbayOffer(ebay)
|
|
53
96
|
console.log('createEbayOffer done');
|
|
97
|
+
// await this._publishEbayOffer(ebay)
|
|
54
98
|
console.log('publishEbayOffer done');
|
|
55
99
|
return true;
|
|
56
100
|
}
|
|
@@ -59,6 +103,270 @@ class MarketplacePublication extends baseService_1.BaseServiceClass {
|
|
|
59
103
|
throw error;
|
|
60
104
|
}
|
|
61
105
|
};
|
|
106
|
+
/* private _createEbayInventory = async (
|
|
107
|
+
ebay: eBayApi,
|
|
108
|
+
available: number,
|
|
109
|
+
parentProduct: IndexedProduct,
|
|
110
|
+
product: IIndexedDeclination
|
|
111
|
+
) => {
|
|
112
|
+
try {
|
|
113
|
+
const createInventory = await ebay.sell.inventory.createOrReplaceInventoryItem(this.data().sku, {
|
|
114
|
+
availability: {
|
|
115
|
+
shipToLocationAvailability: {
|
|
116
|
+
quantity: available
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
condition: Condition.USED_EXCELLENT,
|
|
120
|
+
product: {
|
|
121
|
+
title: MarketplacePublication.convertDictionnaryToEbay(parentProduct.data().name, ebay),
|
|
122
|
+
brand: parentProduct.data().brand,
|
|
123
|
+
imageUrls: product.images_path.map((image) => image.img_path),
|
|
124
|
+
description: MarketplacePublication.convertDictionnaryToEbay(parentProduct.data().description, ebay)
|
|
125
|
+
}
|
|
126
|
+
} as SellInventoryItem)
|
|
127
|
+
console.log('createInventory', createInventory)
|
|
128
|
+
await this.save({ ebay_inventory_payload: createInventory })
|
|
129
|
+
return createInventory
|
|
130
|
+
} catch (error) {
|
|
131
|
+
errorMessage(`Error while creating ebay inventory`)
|
|
132
|
+
return false
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
*/
|
|
136
|
+
/* private _createEbayOffer = async (ebay: eBayApi) => {
|
|
137
|
+
try {
|
|
138
|
+
const ebayOffer = await ebay.sell.inventory.createOffer({
|
|
139
|
+
sku: this.data().sku,
|
|
140
|
+
marketplaceId: ebay.config.marketplaceId as unknown as Marketplace,
|
|
141
|
+
format: FormatType.FIXED_PRICE,
|
|
142
|
+
listingPolicies: {
|
|
143
|
+
fulfillmentPolicyId: '',
|
|
144
|
+
paymentPolicyId: '',
|
|
145
|
+
returnPolicyId: ''
|
|
146
|
+
},
|
|
147
|
+
merchantLocationKey: '',
|
|
148
|
+
pricingSummary: {
|
|
149
|
+
price: {
|
|
150
|
+
value: this.data().price.toFixed(2)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
console.log('ebayoffer', ebayOffer)
|
|
155
|
+
await this.save({ ebay_offer_payload: ebayOffer })
|
|
156
|
+
return ebayOffer
|
|
157
|
+
} catch (error) {
|
|
158
|
+
errorMessage(`Error while publishing ebay publication`)
|
|
159
|
+
throw error
|
|
160
|
+
}
|
|
161
|
+
} */
|
|
162
|
+
/* private _updateEbayOffer = async (ebay: eBayApi) => {
|
|
163
|
+
try {
|
|
164
|
+
const updatedOffer = await ebay.sell.inventory.updateOffer(this.data().ebay_offer_payload.offerId, {
|
|
165
|
+
pricingSummary: {
|
|
166
|
+
price: {
|
|
167
|
+
value: this.data().price.toFixed(2)
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
listingPolicies: {
|
|
171
|
+
fulfillmentPolicyId: '',
|
|
172
|
+
paymentPolicyId: '',
|
|
173
|
+
returnPolicyId: ''
|
|
174
|
+
},
|
|
175
|
+
merchantLocationKey: ''
|
|
176
|
+
})
|
|
177
|
+
console.log('updatedOffer', updatedOffer)
|
|
178
|
+
await this.save({ ebay_offer_payload: updatedOffer })
|
|
179
|
+
return updatedOffer
|
|
180
|
+
} catch (error) {
|
|
181
|
+
errorMessage(`Error while deleting ebay publication`)
|
|
182
|
+
throw error
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private _deleteEbayOffer = async (ebay: eBayApi) => {
|
|
187
|
+
try {
|
|
188
|
+
const deleteOffer = await ebay.sell.inventory.deleteOffer(this.data().ebay_offer_payload.offerId)
|
|
189
|
+
console.log('deleteOffer', deleteOffer)
|
|
190
|
+
await this.save({ ebay_offer_payload: deleteOffer })
|
|
191
|
+
return deleteOffer
|
|
192
|
+
} catch (error) {
|
|
193
|
+
errorMessage(`Error while deleting ebay publication`)
|
|
194
|
+
throw error
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private _publishEbayOffer = async (ebay: eBayApi) => {
|
|
199
|
+
try {
|
|
200
|
+
const publishOffer = await ebay.sell.inventory.publishOffer(this.data().ebay_offer_payload.offerId)
|
|
201
|
+
console.log('publishOffer', publishOffer)
|
|
202
|
+
await this.save({ ebay_offer_payload: publishOffer })
|
|
203
|
+
return publishOffer
|
|
204
|
+
} catch (error) {
|
|
205
|
+
errorMessage(`Error while publishing ebay publication`)
|
|
206
|
+
throw error
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public updateEbayPublication = async (space: Space) => {
|
|
211
|
+
try {
|
|
212
|
+
const parentProduct = await space.indexedProducts.get({
|
|
213
|
+
query: [{ field: 'slug', operator: '==', value: this.data().parent_slug }]
|
|
214
|
+
})
|
|
215
|
+
if (!!!parentProduct) throw new Error(`No parent product found`)
|
|
216
|
+
if (!!!parentProduct[0]) throw new Error(`No parent product found`)
|
|
217
|
+
|
|
218
|
+
const product = parentProduct[0].data().declinations.find((declination) => declination.sku === this.data().sku)
|
|
219
|
+
if (!!!product) throw new Error(`No product found`)
|
|
220
|
+
|
|
221
|
+
const productInventory = await space.inventoryItems.getOne(product.sku)
|
|
222
|
+
if (!!!productInventory) throw new Error(`No product inventory found`)
|
|
223
|
+
if (!!!productInventory.web_inventory) throw new Error(`No product web inventory found`)
|
|
224
|
+
if (!!!productInventory.web_inventory.available)
|
|
225
|
+
throw new Error(`No product web inventory quantity available found`)
|
|
226
|
+
if (toNumber(productInventory.web_inventory.available) < toNumber(this.data().quantity))
|
|
227
|
+
throw new Error(`Product web inventory quantity available is less than quantity`)
|
|
228
|
+
|
|
229
|
+
// call ebay service to update publication
|
|
230
|
+
const ebay = MarketplacePublication.connectionToEbay(space)
|
|
231
|
+
await this._updateEbayOffer(ebay)
|
|
232
|
+
const updatePublication = await ebay.sell.inventory.createOrReplaceInventoryItem(this.data().sku, {
|
|
233
|
+
availability: {
|
|
234
|
+
shipToLocationAvailability: {
|
|
235
|
+
quantity: productInventory.web_inventory.available
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
condition: Condition.USED_EXCELLENT,
|
|
239
|
+
product: {
|
|
240
|
+
title: MarketplacePublication.convertDictionnaryToEbay(parentProduct[0].data().name, ebay),
|
|
241
|
+
brand: parentProduct[0].data().brand,
|
|
242
|
+
imageUrls: product.images_path.map((image) => image.img_path),
|
|
243
|
+
description: MarketplacePublication.convertDictionnaryToEbay(parentProduct[0].data().description, ebay)
|
|
244
|
+
}
|
|
245
|
+
} as SellInventoryItem)
|
|
246
|
+
|
|
247
|
+
console.log('updatePublication', updatePublication)
|
|
248
|
+
await this.save({ ebay_publication_payload: updatePublication })
|
|
249
|
+
return updatePublication
|
|
250
|
+
} catch (error) {
|
|
251
|
+
errorMessage(`Error while updating ebay publication`)
|
|
252
|
+
throw error
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public createOrderFromEbayPublication = async (space: Space) => {
|
|
257
|
+
try {
|
|
258
|
+
const parentProduct = await space.indexedProducts.get({
|
|
259
|
+
query: [{ field: 'slug', operator: '==', value: this.data().parent_slug }]
|
|
260
|
+
})
|
|
261
|
+
if (!!!parentProduct) throw new Error(`No parent product found`)
|
|
262
|
+
if (!!!parentProduct[0]) throw new Error(`No parent product found`)
|
|
263
|
+
|
|
264
|
+
const product = parentProduct[0].data().declinations.find((declination) => declination.sku === this.data().sku)
|
|
265
|
+
if (!!!product) throw new Error(`No product found`)
|
|
266
|
+
|
|
267
|
+
const cartObj = new Cart(
|
|
268
|
+
{
|
|
269
|
+
cart_type: CartTypeEnum.WEB,
|
|
270
|
+
items: [
|
|
271
|
+
{
|
|
272
|
+
qte: this.data().quantity
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
this._collection,
|
|
277
|
+
this._user
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
cartObj.save()
|
|
281
|
+
|
|
282
|
+
// call ebay service to create order
|
|
283
|
+
|
|
284
|
+
return true
|
|
285
|
+
} catch (error) {
|
|
286
|
+
errorMessage(`Error while creating ebay publication order`)
|
|
287
|
+
throw error
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public removeEbayPublication = async (space: Space) => {
|
|
292
|
+
try {
|
|
293
|
+
const parentProduct = await space.indexedProducts.get({
|
|
294
|
+
query: [{ field: 'slug', operator: '==', value: this.data().parent_slug }]
|
|
295
|
+
})
|
|
296
|
+
if (!!!parentProduct) throw new Error(`No parent product found`)
|
|
297
|
+
if (!!!parentProduct[0]) throw new Error(`No parent product found`)
|
|
298
|
+
|
|
299
|
+
const product = parentProduct[0].data().declinations.find((declination) => declination.sku === this.data().sku)
|
|
300
|
+
if (!!!product) throw new Error(`No product found`)
|
|
301
|
+
|
|
302
|
+
const ebay = MarketplacePublication.connectionToEbay(space)
|
|
303
|
+
await this._deleteEbayOffer(ebay)
|
|
304
|
+
await ebay.sell.inventory.deleteInventoryItem(product.sku)
|
|
305
|
+
|
|
306
|
+
return true
|
|
307
|
+
} catch (error) {
|
|
308
|
+
errorMessage(`Error while removing ebay publication`)
|
|
309
|
+
throw error
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public static connectionToEbay = (space: Space) => {
|
|
314
|
+
try {
|
|
315
|
+
const service = space
|
|
316
|
+
.data()
|
|
317
|
+
.external_services.find((service) => service.external_service_name === 'ebay' && !!service.is_active)
|
|
318
|
+
if (!!!service) throw new Error(`No ebay service found`)
|
|
319
|
+
|
|
320
|
+
const { appId, certId, sandbox = true, language, marketplaceId } = service.external_service_infos
|
|
321
|
+
|
|
322
|
+
const eBay = new eBayApi({
|
|
323
|
+
appId,
|
|
324
|
+
certId,
|
|
325
|
+
sandbox,
|
|
326
|
+
contentLanguage: language,
|
|
327
|
+
marketplaceId
|
|
328
|
+
})
|
|
329
|
+
console.log('connectionToEbay', eBay)
|
|
330
|
+
|
|
331
|
+
return eBay
|
|
332
|
+
} catch (error) {
|
|
333
|
+
throw error
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public static convertDictionnaryToEbay = (dictionnary: ITranslation[], ebay: eBayApi) => {
|
|
338
|
+
return getLocaleOfDictionnary(
|
|
339
|
+
dictionnary,
|
|
340
|
+
!!ebay.config.contentLanguage ? ebay.config.contentLanguage.slice(0, 2) : undefined
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
public static generateOAuth2EbayTokenUrl = (ebay: eBayApi) => {
|
|
345
|
+
try {
|
|
346
|
+
//generate token
|
|
347
|
+
ebay.OAuth2.setScope([
|
|
348
|
+
'https://api.ebay.com/oauth/api_scope',
|
|
349
|
+
'https://api.ebay.com/oauth/api_scope/buy.order.readonly',
|
|
350
|
+
'https://api.ebay.com/oauth/api_scope/sell.marketing',
|
|
351
|
+
'https://api.ebay.com/oauth/api_scope/sell.inventory',
|
|
352
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
|
|
353
|
+
'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
|
|
354
|
+
'https://api.ebay.com/oauth/api_scope/sell.item'
|
|
355
|
+
])
|
|
356
|
+
return ebay.OAuth2.generateAuthUrl()
|
|
357
|
+
} catch (error) {
|
|
358
|
+
throw error
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
public static getEbayTokenFromEbayCode = async (eBay: eBayApi, code: string) => {
|
|
363
|
+
try {
|
|
364
|
+
const token = await eBay.OAuth2.getToken(code)
|
|
365
|
+
return token
|
|
366
|
+
} catch (e) {
|
|
367
|
+
console.error(e)
|
|
368
|
+
}
|
|
369
|
+
} */
|
|
62
370
|
}
|
|
63
371
|
}
|
|
64
372
|
exports.default = MarketplacePublication;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/MarketplacePublication/index.tsx"],"names":[],"mappings":";;;;;;AACA,iDAAkD;AAElD,+DAAsC;AACtC,gDAAiD;AACjD,8FAAqE;AAErE,MAAqB,sBAAuB,SAAQ,8BAAyC;IAA7F;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/MarketplacePublication/index.tsx"],"names":[],"mappings":";;;;;;AACA,iDAAkD;AAElD,+DAAsC;AACtC,gDAAiD;AACjD,8FAAqE;AAErE,MAAqB,sBAAuB,SAAQ,8BAAyC;IAA7F;;QAuEC;;;;;;;;;;;;;;;;;YAiBI;QAEJ;;;;;;;;YAQI;QAEJ;;;;;;;;YAQI;QAEG,0BAAqB,GAAG,KAAK,EAAE,KAAY,EAAE,EAAE;YACrD,IAAI;gBACH,MAAM,OAAO,GAAG,KAAK;qBACnB,IAAI,EAAE;qBACN,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,qBAAqB,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;gBACtG,IAAI,CAAC,CAAC,CAAC,OAAO;oBAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;gBACxD,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK;oBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;gBAEnF,4DAA4D;gBAE5D,MAAM,wBAAwB,GAAG,MAAM,sBAAsB,CAAC,iCAAiC,CAC9F,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EACf,IAAI,CAAC,WAAW,CAAC,IAAI,EACrB,IAAI,CAAC,KAAK,CACV,CAAA;gBACD,IAAI,CAAC,CAAC,CAAC,wBAAwB;oBAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;gBACzE,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,MAAM;oBAAE,MAAM,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AAE,GACL,EAC5B;YACC,IAAI,EAAE,UAAU;SAChB,EACD,IAAI,CACJ,CAAA;QACD,OAAO,yBAAyB,CAAA;KAChC;IAAC,OAAO,KAAK,EAAE;QACf,IAAA,sBAAY,EAAC,sDAAsD,CAAC,CAAA;QACpE,OAAO,KAAK,CAAA;KACZ;AACF,CAAC,CAAA;AAEa,wDAAiC,GAAG,KAAK,EAAE,GAAW,EAAE,UAAkB,EAAE,IAAY,EAAE,EAAE;IACzG,IAAI;QACH,MAAM,0BAA0B,GAAG,MAAM,yBAAe,CAAC,YAAY,CAAC,UAAU,EAAE;YACjF,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;SACrD,CAAC,CAAA;QACF,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QACtD,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAC,yBAAyB,EAAE,EAAE;YACnE,OAAO,IAAI,sBAAsB,CAChC,gCACI,yBAAyB,CAAC,IAAI,KACjC,EAAE,EAAE,yBAAyB,CAAC,EAAE,GACL,EAC5B;gBACC,IAAI,EAAE,UAAU;aAChB,EACD,IAAI,CACJ,CAAA;QACF,CAAC,CAAC,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACf,IAAA,sBAAY,EAAC,+CAA+C,CAAC,CAAA;QAC7D,OAAO,KAAK,CAAA;KACZ;AACF,CAAC,CAAA"}
|
package/dist/lib/Menu/index.js
CHANGED
|
@@ -23,6 +23,7 @@ class Menu extends baseService_1.BaseServiceClass {
|
|
|
23
23
|
}
|
|
24
24
|
this._data = (await this._updateDependancies(this._data));
|
|
25
25
|
const superSave = await super.save();
|
|
26
|
+
// si actif => désactiver les autres menus avec le même slug
|
|
26
27
|
if (this._data.active) {
|
|
27
28
|
await this._deactivateOtherMenusWithSameSlug();
|
|
28
29
|
}
|
|
@@ -68,6 +69,7 @@ class Menu extends baseService_1.BaseServiceClass {
|
|
|
68
69
|
(0, console_1.errorMessage)(`Error while uploading menu entry image: ${e}`);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
72
|
+
// Sous-menus
|
|
71
73
|
const sub_menu = ((_a = entry.sub_menu) === null || _a === void 0 ? void 0 : _a.length)
|
|
72
74
|
? await this._processEntriesRecursive(entry.sub_menu, `${basePath}/entries/${i}`, useService)
|
|
73
75
|
: [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Menu/index.ts"],"names":[],"mappings":";;;;;AACA,2CAAmD;AACnD,iDAAkE;AAClE,iDAAkD;AAClD,qDAA4B;AAC5B,8FAAqE;AACrE,gDAAiD;AAEjD,MAAqB,IAAK,SAAQ,8BAAuB;IAAzD;;QACQ,SAAI,GAAG,GAAU,EAAE,CAAC,IAAI,CAAC,KAAc,CAAA;QAEvC,SAAI,GAAG,KAAK,EAAE,WAA4B,EAAE,EAAE;YACpD,IAAI,CAAC,KAAK,mCACN,IAAI,CAAC,KAAK,GACV,WAAW,CACd,CAAA;YACD,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;YAC/B,IAAI,QAAQ,EAAE;gBACb,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;gBAC7B,IAAI,OAAO,EAAE,KAAK,QAAQ;oBAAE,IAAI,CAAC,KAAK,mCAAQ,IAAI,CAAC,KAAK,KAAE,EAAE,EAAE,EAAE,GAAE,CAAA;aAClE;YAED,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAU,CAAA;YAElE,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Menu/index.ts"],"names":[],"mappings":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AC,EAAE,GAAW,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;gBAErG,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAChC,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI;oBACjC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,IAAI;oBACxB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CACjD,CAAA;gBAED,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;oBAC7B,IAAI;wBACH,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;qBAC/B;oBAAC,OAAO,CAAC,EAAE;wBACX,IAAA,sBAAY,EAAC,iCAAiC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;wBAClE,SAAQ;qBACR;iBACD;aACD;YAAC,OAAO,KAAK,EAAE;gBACf,IAAA,sBAAY,EAAC,wDAAwD,KAAK,EAAE,CAAC,CAAA;aAC7E;QACF,CAAC,CAAA;IACF,CAAC;CAAA;AAlID,uBAkIC"}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order class.
|
|
3
|
+
*
|
|
4
|
+
* @link ecomm.gitngin.com/wiki/models/products
|
|
5
|
+
* @file This files defines the Order class. An order is a successful paid cart, waiting for a shipping/picking instruction.
|
|
6
|
+
* Once the instruction is defined, it's an invoice
|
|
7
|
+
* @author Alexandre Hébert-Vincent.
|
|
8
|
+
* @since 01-01-2020
|
|
9
|
+
*/
|
|
1
10
|
import Invoice from '../Invoice';
|
|
2
11
|
import IOrder from '../../Interfaces/Order';
|
|
3
12
|
import { BaseServiceClass } from '../baseService';
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
4
16
|
export default class Order extends BaseServiceClass<IOrder> {
|
|
17
|
+
/**
|
|
18
|
+
* Return an unsaved invoice
|
|
19
|
+
* @param warehouseCode String representing warehouse code where the pickup needs to be done
|
|
20
|
+
*/
|
|
5
21
|
defineIsPickup: (warehouseCode: string) => Invoice;
|
|
22
|
+
/**
|
|
23
|
+
* Return an unsaved invoice
|
|
24
|
+
* @param trackingInfo Tracking payload
|
|
25
|
+
*/
|
|
6
26
|
addTrackingInfo: (trackingInfo: any) => Invoice;
|
|
7
27
|
}
|
package/dist/lib/Order/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Order class.
|
|
4
|
+
*
|
|
5
|
+
* @link ecomm.gitngin.com/wiki/models/products
|
|
6
|
+
* @file This files defines the Order class. An order is a successful paid cart, waiting for a shipping/picking instruction.
|
|
7
|
+
* Once the instruction is defined, it's an invoice
|
|
8
|
+
* @author Alexandre Hébert-Vincent.
|
|
9
|
+
* @since 01-01-2020
|
|
10
|
+
*/
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -6,9 +15,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
15
|
const Invoice_1 = __importDefault(require("../Invoice"));
|
|
7
16
|
const baseService_1 = require("../baseService");
|
|
8
17
|
const DatabaseService_1 = __importDefault(require("../../services/database/DatabaseService"));
|
|
18
|
+
//#endregion
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated
|
|
21
|
+
*/
|
|
9
22
|
class Order extends baseService_1.BaseServiceClass {
|
|
10
23
|
constructor() {
|
|
24
|
+
//#region METHODS
|
|
11
25
|
super(...arguments);
|
|
26
|
+
/**
|
|
27
|
+
* Return an unsaved invoice
|
|
28
|
+
* @param warehouseCode String representing warehouse code where the pickup needs to be done
|
|
29
|
+
*/
|
|
12
30
|
this.defineIsPickup = (warehouseCode) => {
|
|
13
31
|
if (DatabaseService_1.default.getPathParent(this._collection.path) == '/')
|
|
14
32
|
throw new Error(`Can't access invoices collection`);
|
|
@@ -20,6 +38,10 @@ class Order extends baseService_1.BaseServiceClass {
|
|
|
20
38
|
invoice.save();
|
|
21
39
|
return invoice;
|
|
22
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Return an unsaved invoice
|
|
43
|
+
* @param trackingInfo Tracking payload
|
|
44
|
+
*/
|
|
23
45
|
this.addTrackingInfo = (trackingInfo) => {
|
|
24
46
|
if (DatabaseService_1.default.getPathParent(this._collection.path) == '/')
|
|
25
47
|
throw new Error(`Can't access invoices collection`);
|
|
@@ -28,6 +50,7 @@ class Order extends baseService_1.BaseServiceClass {
|
|
|
28
50
|
invoice.save();
|
|
29
51
|
return invoice;
|
|
30
52
|
};
|
|
53
|
+
//#endregion
|
|
31
54
|
}
|
|
32
55
|
}
|
|
33
56
|
exports.default = Order;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Order/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/Order/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;AAKH,yDAAgC;AAEhC,gDAAiD;AACjD,8FAAqE;AAErE,YAAY;AAEZ;;GAEG;AACH,MAAqB,KAAM,SAAQ,8BAAwB;IAA3D;QACC,iBAAiB;;QAEjB;;;WAGG;QACI,mBAAc,GAAG,CAAC,aAAqB,EAAW,EAAE;YAC1D,IAAI,yBAAe,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,GAAG;gBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;YAEpH,MAAM,OAAO,GAAG,IAAI,iBAAO,CAC1B,gCACI,IAAI,CAAC,KAAK,KACb,gBAAgB,EAAE;oBACjB,eAAe,EAAE,QAAQ;oBACzB,cAAc,EAAE,aAAa;iBAC7B,GACW,EACb,yBAAe,CAAC,kBAAkB,CAAC,yBAAe,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EACpG,IAAI,CAAC,KAAK,CACV,CAAA;YACD,IAAI,CAAC,MAAM,EAAE,CAAA;YACb,OAAO,CAAC,IAAI,EAAE,CAAA;YACd,OAAO,OAAO,CAAA;QACf,CAAC,CAAA;QAED;;;WAGG;QACI,oBAAe,GAAG,CAAC,YAAiB,EAAE,EAAE;YAC9C,IAAI,yBAAe,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,GAAG;gBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;YAEpH,MAAM,OAAO,GAAG,IAAI,iBAAO,CAC1B,gCAAK,IAAI,CAAC,KAAK,KAAE,gBAAgB,EAAE,YAAY,GAAc,EAC7D,yBAAe,CAAC,kBAAkB,CAAC,yBAAe,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EACpG,IAAI,CAAC,KAAK,CACV,CAAA;YAED,IAAI,CAAC,MAAM,EAAE,CAAA;YACb,OAAO,CAAC,IAAI,EAAE,CAAA;YAEd,OAAO,OAAO,CAAA;QACf,CAAC,CAAA;QAED,YAAY;IACb,CAAC;CAAA;AA9CD,wBA8CC"}
|
package/dist/lib/Org/index.d.ts
CHANGED
|
@@ -4,18 +4,59 @@ import User from '../User';
|
|
|
4
4
|
import Space from '../Space';
|
|
5
5
|
import IUser from '../../Interfaces/User/IUser';
|
|
6
6
|
import { IRefObject } from '../../services/database/DatabaseService';
|
|
7
|
+
/**
|
|
8
|
+
* Class Org - Organization
|
|
9
|
+
* Represent an organization created by a user. An organization can have multiple space.
|
|
10
|
+
*/
|
|
7
11
|
export default class Org {
|
|
8
12
|
private _org;
|
|
9
13
|
private _org_ref;
|
|
10
14
|
private _user?;
|
|
15
|
+
/**
|
|
16
|
+
* Organization constructor
|
|
17
|
+
* @param org Organization to construct
|
|
18
|
+
* @param org_ref Reference to the organization
|
|
19
|
+
* @param user Authfificated user
|
|
20
|
+
*/
|
|
11
21
|
constructor(org: IOrg, org_ref: IRefObject, user: IUser);
|
|
22
|
+
/**
|
|
23
|
+
* Update org data. Called on new space/org initialisation.
|
|
24
|
+
* @param data Partial org data object
|
|
25
|
+
* @param saveToDatabase Optionnal, defaults to true.
|
|
26
|
+
*/
|
|
12
27
|
updateOrgData: (data: Partial<IOrg>, saveToDatabase?: boolean) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a Space : Space by ID
|
|
30
|
+
* @param space_id Firestore ID of the space to get
|
|
31
|
+
*/
|
|
13
32
|
space: (space_id?: string) => Promise<Space>;
|
|
33
|
+
/**
|
|
34
|
+
* Access authentificated user
|
|
35
|
+
*/
|
|
14
36
|
user: () => User;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the most up to date user data from db
|
|
39
|
+
* Sets this._user's value
|
|
40
|
+
* @return the updated user
|
|
41
|
+
*/
|
|
15
42
|
getUpdatedUser: () => Promise<IUser | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Get the organization properties
|
|
45
|
+
*/
|
|
16
46
|
getData: () => IOrg;
|
|
47
|
+
/**
|
|
48
|
+
* Get the organization slug - Name without spaces if slug is not set
|
|
49
|
+
*/
|
|
17
50
|
getSlug: () => string;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch all spaces or the organization.
|
|
53
|
+
* No query options, query must be done browser side.
|
|
54
|
+
*/
|
|
18
55
|
spaces: () => Promise<Space[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Create a new space under this organization
|
|
58
|
+
* @param space Space : Space to create
|
|
59
|
+
*/
|
|
19
60
|
addSpace: (space: ISpace) => Promise<void>;
|
|
20
61
|
getAllReps: () => Promise<{
|
|
21
62
|
name: string;
|
package/dist/lib/Org/index.js
CHANGED
|
@@ -7,8 +7,23 @@ const User_1 = __importDefault(require("../User"));
|
|
|
7
7
|
const Space_1 = __importDefault(require("../Space"));
|
|
8
8
|
const console_1 = require("../../utils/console");
|
|
9
9
|
const DatabaseService_1 = __importDefault(require("../../services/database/DatabaseService"));
|
|
10
|
+
/**
|
|
11
|
+
* Class Org - Organization
|
|
12
|
+
* Represent an organization created by a user. An organization can have multiple space.
|
|
13
|
+
*/
|
|
10
14
|
class Org {
|
|
15
|
+
/**
|
|
16
|
+
* Organization constructor
|
|
17
|
+
* @param org Organization to construct
|
|
18
|
+
* @param org_ref Reference to the organization
|
|
19
|
+
* @param user Authfificated user
|
|
20
|
+
*/
|
|
11
21
|
constructor(org, org_ref, user) {
|
|
22
|
+
/**
|
|
23
|
+
* Update org data. Called on new space/org initialisation.
|
|
24
|
+
* @param data Partial org data object
|
|
25
|
+
* @param saveToDatabase Optionnal, defaults to true.
|
|
26
|
+
*/
|
|
12
27
|
this.updateOrgData = async (data, saveToDatabase = true) => {
|
|
13
28
|
try {
|
|
14
29
|
if (!!!this._user)
|
|
@@ -22,6 +37,10 @@ class Org {
|
|
|
22
37
|
console.log('error on updating orgData: ', e.toString());
|
|
23
38
|
}
|
|
24
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Get a Space : Space by ID
|
|
42
|
+
* @param space_id Firestore ID of the space to get
|
|
43
|
+
*/
|
|
25
44
|
this.space = async (space_id) => {
|
|
26
45
|
try {
|
|
27
46
|
if (!!!this._user)
|
|
@@ -38,12 +57,20 @@ class Org {
|
|
|
38
57
|
throw _e;
|
|
39
58
|
}
|
|
40
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Access authentificated user
|
|
62
|
+
*/
|
|
41
63
|
this.user = () => {
|
|
42
64
|
if (!!!this._user) {
|
|
43
65
|
throw `Can't access user. Please login`;
|
|
44
66
|
}
|
|
45
67
|
return this._user;
|
|
46
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Gets the most up to date user data from db
|
|
71
|
+
* Sets this._user's value
|
|
72
|
+
* @return the updated user
|
|
73
|
+
*/
|
|
47
74
|
this.getUpdatedUser = async () => {
|
|
48
75
|
if (!!!this._user) {
|
|
49
76
|
throw `Can't access user. Please login`;
|
|
@@ -63,7 +90,13 @@ class Org {
|
|
|
63
90
|
console.error(e);
|
|
64
91
|
}
|
|
65
92
|
};
|
|
93
|
+
/**
|
|
94
|
+
* Get the organization properties
|
|
95
|
+
*/
|
|
66
96
|
this.getData = () => this._org;
|
|
97
|
+
/**
|
|
98
|
+
* Get the organization slug - Name without spaces if slug is not set
|
|
99
|
+
*/
|
|
67
100
|
this.getSlug = () => {
|
|
68
101
|
if (!!this._org.slug)
|
|
69
102
|
return this._org.slug;
|
|
@@ -71,6 +104,10 @@ class Org {
|
|
|
71
104
|
return this._org.name.toLocaleLowerCase().replace(/ /, '-');
|
|
72
105
|
return '';
|
|
73
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Fetch all spaces or the organization.
|
|
109
|
+
* No query options, query must be done browser side.
|
|
110
|
+
*/
|
|
74
111
|
this.spaces = async () => {
|
|
75
112
|
if (!!!this._user)
|
|
76
113
|
throw 'Invalid or unauthenticated user';
|
|
@@ -98,6 +135,10 @@ class Org {
|
|
|
98
135
|
return [];
|
|
99
136
|
}
|
|
100
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Create a new space under this organization
|
|
140
|
+
* @param space Space : Space to create
|
|
141
|
+
*/
|
|
101
142
|
this.addSpace = async (space) => {
|
|
102
143
|
if (!!!this._user) {
|
|
103
144
|
const error = `User must be authentificated for creating a new space`;
|