rerobe-js-orm 3.0.2 → 3.0.3

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.
@@ -9,6 +9,7 @@ export default class Product extends Base {
9
9
  toPartialObj(): ShopifyProduct;
10
10
  toObj(): CompleteProduct;
11
11
  toProductInputObjForShopify(location?: string): any;
12
+ toProductInputObjForShopifyV2(locationId: string, weightUnit?: string): any[];
12
13
  toObjForTextTranslation(): TranslatableAttributes;
13
14
  toObjForTypesense(): TypesenseProductObj;
14
15
  updateSelfFromTranslatedTextArray(translatedTextArray?: string[]): void;
@@ -220,6 +220,108 @@ class Product extends Base_1.default {
220
220
  }
221
221
  return productInputObj;
222
222
  }
223
+ toProductInputObjForShopifyV2(locationId, weightUnit) {
224
+ const shopifyId = this.attributes.shopifyId;
225
+ const productInputObj = {
226
+ title: this.attributes.title,
227
+ descriptionHtml: this.attributes.description,
228
+ productType: this.filterAttributes.productType,
229
+ vendor: this.attributes.vendorId,
230
+ tags: [
231
+ `gender_attribute:${this.filterAttributes.gender}`,
232
+ `productcategory_attribute:${this.filterAttributes.productCategory}`,
233
+ `producttype_attribute:${this.filterAttributes.productType}`,
234
+ `brand_attribute:${this.filterAttributes.brand}`,
235
+ `pricerange_attribute:${this.filterAttributes.priceRange}`,
236
+ `color_attribute:${this.filterAttributes.color}`,
237
+ `condition_attribute:${this.filterAttributes.condition}`,
238
+ `publishType:${this.consignmentAttributes.publishType}`,
239
+ this.filterAttributes.jeanSize ? `jeansize_attribute:${this.filterAttributes.jeanSize}` : null,
240
+ this.filterAttributes.shoeSize ? `shoesize_attribute:${this.filterAttributes.shoeSize}` : null,
241
+ this.filterAttributes.documentId ? `documentId:${this.filterAttributes.documentId}` : null,
242
+ this.consignmentAttributes.sellRequestId ? `sellRequestId:${this.consignmentAttributes.sellRequestId}` : null,
243
+ this.consignmentAttributes.reRobeCommission
244
+ ? `reRobeCommission:${this.consignmentAttributes.reRobeCommission}`
245
+ : null,
246
+ this.consignmentAttributes.suggestedResalePrice
247
+ ? `suggestedResalePrice:${this.consignmentAttributes.suggestedResalePrice}`
248
+ : null,
249
+ this.consignmentAttributes.nextAvailableSeason
250
+ ? `nextAvailableSeason:${this.consignmentAttributes.nextAvailableSeason}`
251
+ : null,
252
+ this.consignmentAttributes.notesForProductionTeam
253
+ ? `notesForProductionTeam:${this.consignmentAttributes.notesForProductionTeam}`
254
+ : null,
255
+ this.consignmentAttributes.reviewedBy ? `reviewedBy:${this.consignmentAttributes.reviewedBy}` : null,
256
+ this.consignmentAttributes.conditionRemarks
257
+ ? `conditionRemarks:${this.consignmentAttributes.conditionRemarks}`
258
+ : null,
259
+ this.consignmentAttributes.productRemarks
260
+ ? `productRemarks:${this.consignmentAttributes.productRemarks}`
261
+ : null,
262
+ this.consignmentAttributes.status ? `status:${this.consignmentAttributes.status}` : null,
263
+ this.consignmentAttributes.purchasePrice ? `purchasePrice:${this.consignmentAttributes.purchasePrice}` : null,
264
+ this.consignmentAttributes.yearPurchased ? `yearPurchased:${this.consignmentAttributes.yearPurchased}` : null,
265
+ this.consignmentAttributes.rejectedReason
266
+ ? `rejectedReason:${this.consignmentAttributes.rejectedReason}`
267
+ : null,
268
+ this.consignmentAttributes.dateSold ? `dateSold:${this.consignmentAttributes.dateSold}` : null,
269
+ this.consignmentAttributes.dateInQualityControl
270
+ ? `dateInQualityControl:${this.consignmentAttributes.dateInQualityControl}`
271
+ : null,
272
+ this.consignmentAttributes.dateInPendingPublication
273
+ ? `dateInPendingPublication:${this.consignmentAttributes.dateInPendingPublication}`
274
+ : null,
275
+ this.consignmentAttributes.dateListedOnline
276
+ ? `dateListedOnline:${this.consignmentAttributes.dateListedOnline}`
277
+ : null,
278
+ this.consignmentAttributes.sizeComment ? `sizeComment:${this.consignmentAttributes.sizeComment}` : null,
279
+ this.consignmentAttributes.salePrice ? `salePrice:${this.consignmentAttributes.salePrice}` : null,
280
+ this.consignmentAttributes.isOnSale ? `isOnSale:${this.consignmentAttributes.isOnSale}` : null,
281
+ this.consignmentAttributes.discountType ? `discountType:${this.consignmentAttributes.discountType}` : null,
282
+ this.consignmentAttributes.discountValue ? `discountValue:${this.consignmentAttributes.discountValue}` : null,
283
+ this.consignmentAttributes.selectedForClearance
284
+ ? `selectedForClearance:${this.consignmentAttributes.selectedForClearance}`
285
+ : null,
286
+ ]
287
+ .concat(this.filterAttributes.clothingSize.map((s) => `clothingsize_attribute:${s}`))
288
+ .concat(this.filterAttributes.productStyle.map((s) => `productstyle_attribute:${s}`))
289
+ .concat(this.materialCompTagsArrayForShopify().map((mc) => `materialcomposition_attribute:${mc}`))
290
+ .concat(this.consignmentAttributes.previousSellers.map((prevSellerGid) => `previousSeller:${prevSellerGid}`))
291
+ .concat(this.consignmentAttributes.salesChannel.map((s) => `salesChannel:${s}`))
292
+ .filter((t) => t),
293
+ variants: [
294
+ {
295
+ inventoryPolicy: 'DENY',
296
+ inventoryQuantities: [
297
+ {
298
+ availableQuantity: this.attributes.availableForSale ? 1 : 0,
299
+ locationId: `${locationId}`,
300
+ },
301
+ ],
302
+ price: this.attributes.price || '0',
303
+ taxable: false,
304
+ weight: parseFloat(this.attributes.weight) || parseFloat('999'),
305
+ weightUnit: weightUnit || 'GRAMS',
306
+ },
307
+ ],
308
+ };
309
+ if (shopifyId) {
310
+ // Todo: use getDecodedShopifyId here
311
+ productInputObj.id = shopifyId;
312
+ productInputObj.variants = [
313
+ Object.assign({}, productInputObj.variants[0]),
314
+ ];
315
+ }
316
+ if (this.attributes.imageUrls) {
317
+ const projectMediaObj = this.attributes.imageUrls.map((image) => ({
318
+ mediaContentType: 'IMAGE',
319
+ originalSource: image,
320
+ }));
321
+ return [productInputObj, projectMediaObj];
322
+ }
323
+ return [productInputObj];
324
+ }
223
325
  toObjForTextTranslation() {
224
326
  return {
225
327
  description: this.attributes.description || this.FIELD_NOT_TRANSLATABLE_KEY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",