From 70b4254a56f0251bd7b966ab388fee77a3158056 Mon Sep 17 00:00:00 2001 From: David Ball Date: Thu, 18 Jul 2024 01:03:14 -0400 Subject: [PATCH] Refactored model/OfferListing. --- src/index.ts | 2 + src/model/OfferListing.ts | 192 +++++++++++++++--------------------- src/model/OfferPromotion.ts | 116 ++++++++-------------- 3 files changed, 123 insertions(+), 187 deletions(-) diff --git a/src/index.ts b/src/index.ts index cc7306e..08aad6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,10 +66,12 @@ import { OfferCondition } from "./model/OfferCondition"; import { OfferConditionNote } from "./model/OfferConditionNote"; import { OfferDeliveryInfo } from "./model/OfferDeliveryInfo"; import { OfferCount } from "./model/OfferCount"; +import { OfferListing } from "./model/OfferListing"; import { OfferMerchantInfo } from "./model/OfferMerchantInfo"; import { OfferLoyaltyPoints } from "./model/OfferLoyaltyPoints"; import { OfferPrice } from "./model/OfferPrice"; import { OfferProgramEligibility } from "./model/OfferProgramEligibility"; +import { OfferPromotion } from "./model/OfferPromotion"; import { OfferSavings } from "./model/OfferSavings"; import { OfferShippingCharge } from "./model/OfferShippingCharge"; import { OfferSubCondition } from "./model/OfferSubCondition"; diff --git a/src/model/OfferListing.ts b/src/model/OfferListing.ts index 0dfd60d..f5ba481 100644 --- a/src/model/OfferListing.ts +++ b/src/model/OfferListing.ts @@ -15,59 +15,82 @@ * permissions and limitations under the License. */ - /** +/** * ProductAdvertisingAPI * https://webservices.amazon.com/paapi5/documentation/index.html * */ -(function(root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['ApiClient', 'model/OfferAvailability', 'model/OfferCondition', 'model/OfferDeliveryInfo', 'model/OfferLoyaltyPoints', 'model/OfferMerchantInfo', 'model/OfferPrice', 'model/OfferProgramEligibility', 'model/OfferPromotion'], factory); - } else if (typeof module === 'object' && module.exports) { - // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient'), require('./OfferAvailability'), require('./OfferCondition'), require('./OfferDeliveryInfo'), require('./OfferLoyaltyPoints'), require('./OfferMerchantInfo'), require('./OfferPrice'), require('./OfferProgramEligibility'), require('./OfferPromotion')); - } else { - // Browser globals (root is window) - if (!root.ProductAdvertisingAPIv1) { - root.ProductAdvertisingAPIv1 = {}; - } - root.ProductAdvertisingAPIv1.OfferListing = factory(root.ProductAdvertisingAPIv1.ApiClient, root.ProductAdvertisingAPIv1.OfferAvailability, root.ProductAdvertisingAPIv1.OfferCondition, root.ProductAdvertisingAPIv1.OfferDeliveryInfo, root.ProductAdvertisingAPIv1.OfferLoyaltyPoints, root.ProductAdvertisingAPIv1.OfferMerchantInfo, root.ProductAdvertisingAPIv1.OfferPrice, root.ProductAdvertisingAPIv1.OfferProgramEligibility, root.ProductAdvertisingAPIv1.OfferPromotion); - } -}(this, function(ApiClient, OfferAvailability, OfferCondition, OfferDeliveryInfo, OfferLoyaltyPoints, OfferMerchantInfo, OfferPrice, OfferProgramEligibility, OfferPromotion) { - 'use strict'; - - +/** + * The OfferListing model module. + * @module model/OfferListing + * @version 1.0.0 + */ +import { ApiClient } from "../ApiClient"; +import { OfferAvailability } from "./OfferAvailability"; +import { OfferCondition } from "./OfferCondition"; +import { OfferDeliveryInfo } from "./OfferDeliveryInfo"; +import { OfferLoyaltyPoints } from "./OfferLoyaltyPoints"; +import { OfferMerchantInfo } from "./OfferMerchantInfo"; +import { OfferPrice } from "./OfferPrice"; +import { OfferProgramEligibility } from "./OfferProgramEligibility"; +import { OfferPromotion } from "./OfferPromotion"; +/** + * Constructs a new OfferListing. + * @alias module:model/OfferListing + * @class + */ +export class OfferListing { /** - * The OfferListing model module. - * @module model/OfferListing - * @version 1.0.0 + * @member {module:model/OfferAvailability} Availability */ - + public Availability?: OfferAvailability; /** - * Constructs a new OfferListing. - * @alias module:model/OfferListing - * @class + * @member {module:model/OfferCondition} Condition */ - var exports = function() { - var _this = this; - - - - - - - - - - - - - - }; + public Condition?: OfferCondition; + /** + * @member {module:model/OfferDeliveryInfo} DeliveryInfo + */ + public DeliveryInfo?: OfferDeliveryInfo; + /** + * @member {String} Id + */ + public Id?: string; + /** + * @member {Boolean} IsBuyBoxWinner + */ + public IsBuyBoxWinner?: boolean; + /** + * @member {module:model/OfferLoyaltyPoints} LoyaltyPoints + */ + public LoyaltyPoints?: OfferLoyaltyPoints; + /** + * @member {module:model/OfferMerchantInfo} MerchantInfo + */ + public MerchantInfo?: OfferMerchantInfo; + /** + * @member {module:model/OfferPrice} Price + */ + public Price?: OfferPrice; + /** + * @member {module:model/OfferProgramEligibility} ProgramEligibility + */ + public ProgramEligibility?: OfferProgramEligibility; + /** + * @member {Array.} Promotions + */ + public Promotions?: OfferPromotion + /** + * @member {module:model/OfferPrice} SavingBasis + */ + public SavingBasis?: OfferPrice; + /** + * @member {Boolean} ViolatesMAP + */ + public ViolatesMAP?: boolean; /** * Constructs a OfferListing from a plain JavaScript object, optionally creating a new instance. @@ -76,102 +99,47 @@ * @param {module:model/OfferListing} obj Optional instance to populate. * @return {module:model/OfferListing} The populated OfferListing instance. */ - exports.constructFromObject = function(data, obj) { + public static constructFromObject(data: any, obj?: OfferListing) { if (data) { - obj = obj || new exports(); + obj = obj || new OfferListing(); if (data.hasOwnProperty('Availability')) { - obj['Availability'] = OfferAvailability.constructFromObject(data['Availability']); + obj.Availability = OfferAvailability.constructFromObject(data['Availability']); } if (data.hasOwnProperty('Condition')) { - obj['Condition'] = OfferCondition.constructFromObject(data['Condition']); + obj.Condition = OfferCondition.constructFromObject(data['Condition']); } if (data.hasOwnProperty('DeliveryInfo')) { - obj['DeliveryInfo'] = OfferDeliveryInfo.constructFromObject(data['DeliveryInfo']); + obj.DeliveryInfo = OfferDeliveryInfo.constructFromObject(data['DeliveryInfo']); } if (data.hasOwnProperty('Id')) { - obj['Id'] = ApiClient.convertToType(data['Id'], 'String'); + obj.Id = ApiClient.convertToType(data['Id'], 'String'); } if (data.hasOwnProperty('IsBuyBoxWinner')) { - obj['IsBuyBoxWinner'] = ApiClient.convertToType(data['IsBuyBoxWinner'], 'Boolean'); + obj.IsBuyBoxWinner = ApiClient.convertToType(data['IsBuyBoxWinner'], 'Boolean'); } if (data.hasOwnProperty('LoyaltyPoints')) { - obj['LoyaltyPoints'] = OfferLoyaltyPoints.constructFromObject(data['LoyaltyPoints']); + obj.LoyaltyPoints = OfferLoyaltyPoints.constructFromObject(data['LoyaltyPoints']); } if (data.hasOwnProperty('MerchantInfo')) { - obj['MerchantInfo'] = OfferMerchantInfo.constructFromObject(data['MerchantInfo']); + obj.MerchantInfo = OfferMerchantInfo.constructFromObject(data['MerchantInfo']); } if (data.hasOwnProperty('Price')) { - obj['Price'] = OfferPrice.constructFromObject(data['Price']); + obj.Price = OfferPrice.constructFromObject(data['Price']); } if (data.hasOwnProperty('ProgramEligibility')) { - obj['ProgramEligibility'] = OfferProgramEligibility.constructFromObject(data['ProgramEligibility']); + obj.ProgramEligibility = OfferProgramEligibility.constructFromObject(data['ProgramEligibility']); } if (data.hasOwnProperty('Promotions')) { - obj['Promotions'] = ApiClient.convertToType(data['Promotions'], [OfferPromotion]); + obj.Promotions = ApiClient.convertToType(data['Promotions'], [OfferPromotion]); } if (data.hasOwnProperty('SavingBasis')) { - obj['SavingBasis'] = OfferPrice.constructFromObject(data['SavingBasis']); + obj.SavingBasis = OfferPrice.constructFromObject(data['SavingBasis']); } if (data.hasOwnProperty('ViolatesMAP')) { - obj['ViolatesMAP'] = ApiClient.convertToType(data['ViolatesMAP'], 'Boolean'); + obj.ViolatesMAP = ApiClient.convertToType(data['ViolatesMAP'], 'Boolean'); } } return obj; } - - /** - * @member {module:model/OfferAvailability} Availability - */ - exports.prototype['Availability'] = undefined; - /** - * @member {module:model/OfferCondition} Condition - */ - exports.prototype['Condition'] = undefined; - /** - * @member {module:model/OfferDeliveryInfo} DeliveryInfo - */ - exports.prototype['DeliveryInfo'] = undefined; - /** - * @member {String} Id - */ - exports.prototype['Id'] = undefined; - /** - * @member {Boolean} IsBuyBoxWinner - */ - exports.prototype['IsBuyBoxWinner'] = undefined; - /** - * @member {module:model/OfferLoyaltyPoints} LoyaltyPoints - */ - exports.prototype['LoyaltyPoints'] = undefined; - /** - * @member {module:model/OfferMerchantInfo} MerchantInfo - */ - exports.prototype['MerchantInfo'] = undefined; - /** - * @member {module:model/OfferPrice} Price - */ - exports.prototype['Price'] = undefined; - /** - * @member {module:model/OfferProgramEligibility} ProgramEligibility - */ - exports.prototype['ProgramEligibility'] = undefined; - /** - * @member {Array.} Promotions - */ - exports.prototype['Promotions'] = undefined; - /** - * @member {module:model/OfferPrice} SavingBasis - */ - exports.prototype['SavingBasis'] = undefined; - /** - * @member {Boolean} ViolatesMAP - */ - exports.prototype['ViolatesMAP'] = undefined; - - - - return exports; -})); - - +}; diff --git a/src/model/OfferPromotion.ts b/src/model/OfferPromotion.ts index 4429cb8..22c58e9 100644 --- a/src/model/OfferPromotion.ts +++ b/src/model/OfferPromotion.ts @@ -21,47 +21,44 @@ * */ -(function(root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['ApiClient'], factory); - } else if (typeof module === 'object' && module.exports) { - // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(require('../ApiClient')); - } else { - // Browser globals (root is window) - if (!root.ProductAdvertisingAPIv1) { - root.ProductAdvertisingAPIv1 = {}; - } - root.ProductAdvertisingAPIv1.OfferPromotion = factory(root.ProductAdvertisingAPIv1.ApiClient); - } -}(this, function(ApiClient) { - 'use strict'; - - +/** + * The OfferPromotion model module. + * @module model/OfferPromotion + * @version 1.0.0 + */ +import { ApiClient } from "../ApiClient"; +/** + * Constructs a new OfferPromotion. + * @alias module:model/OfferPromotion + * @class + */ +export class OfferPromotion { /** - * The OfferPromotion model module. - * @module model/OfferPromotion - * @version 1.0.0 + * @member {Number} Amount */ - + public Amount?: number; /** - * Constructs a new OfferPromotion. - * @alias module:model/OfferPromotion - * @class + * @member {String} Currency */ - var exports = function() { - var _this = this; - - - - - - - - }; + public Currency?: string; + /** + * @member {Number} DiscountPercent + */ + public DiscountPercent?: number; + /** + * @member {String} DisplayAmount + */ + public DisplayAmount?: string; + /** + * @member {Number} PricePerUnit + */ + public PricePerUnit?: number; + /** + * @member {String} Type + */ + public Type?: string; /** * Constructs a OfferPromotion from a plain JavaScript object, optionally creating a new instance. @@ -70,60 +67,29 @@ * @param {module:model/OfferPromotion} obj Optional instance to populate. * @return {module:model/OfferPromotion} The populated OfferPromotion instance. */ - exports.constructFromObject = function(data, obj) { + public static constructFromObject(data: any, obj?: OfferPromotion) { if (data) { - obj = obj || new exports(); + obj = obj || new OfferPromotion(); if (data.hasOwnProperty('Amount')) { - obj['Amount'] = ApiClient.convertToType(data['Amount'], 'Number'); + obj.Amount = ApiClient.convertToType(data['Amount'], 'Number'); } if (data.hasOwnProperty('Currency')) { - obj['Currency'] = ApiClient.convertToType(data['Currency'], 'String'); + obj.Currency = ApiClient.convertToType(data['Currency'], 'String'); } if (data.hasOwnProperty('DiscountPercent')) { - obj['DiscountPercent'] = ApiClient.convertToType(data['DiscountPercent'], 'Number'); + obj.DiscountPercent = ApiClient.convertToType(data['DiscountPercent'], 'Number'); } if (data.hasOwnProperty('DisplayAmount')) { - obj['DisplayAmount'] = ApiClient.convertToType(data['DisplayAmount'], 'String'); + obj.DisplayAmount = ApiClient.convertToType(data['DisplayAmount'], 'String'); } if (data.hasOwnProperty('PricePerUnit')) { - obj['PricePerUnit'] = ApiClient.convertToType(data['PricePerUnit'], 'Number'); + obj.PricePerUnit = ApiClient.convertToType(data['PricePerUnit'], 'Number'); } if (data.hasOwnProperty('Type')) { - obj['Type'] = ApiClient.convertToType(data['Type'], 'String'); + obj.Type = ApiClient.convertToType(data['Type'], 'String'); } } return obj; } - - /** - * @member {Number} Amount - */ - exports.prototype['Amount'] = undefined; - /** - * @member {String} Currency - */ - exports.prototype['Currency'] = undefined; - /** - * @member {Number} DiscountPercent - */ - exports.prototype['DiscountPercent'] = undefined; - /** - * @member {String} DisplayAmount - */ - exports.prototype['DisplayAmount'] = undefined; - /** - * @member {Number} PricePerUnit - */ - exports.prototype['PricePerUnit'] = undefined; - /** - * @member {String} Type - */ - exports.prototype['Type'] = undefined; - - - - return exports; -})); - - +};