Class: InventoryManagementAndItemManagementAndOrderManagementAndPriceManagement::BaseModel
- Inherits:
-
CoreLibrary::BaseModel
- Object
- CoreLibrary::BaseModel
- InventoryManagementAndItemManagementAndOrderManagementAndPriceManagement::BaseModel
- Defined in:
- lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb
Overview
Base model. rubocop:disable all
Direct Known Subclasses
AdditionalAttributes, Asn, AssignunassignitemstofromrepricerstrategyRequest, Association, AvailToSellQty, BadRequest7, Badrequest1, Badrequest11, CancelOrderLinesRequest, CarrierName, CatalogSearchRequest, Cause, Charge, Charge12, Charge2, Charges, CreaterepricerstrategyRequest, CurrentPrice, CurrentTrackingInfo, Department, DestinationItem, DestinationItem1, DuplicateItemInfo, DuplicateItemdetails, Elements, Elements1, Error, Error1, Error11, Error2, Error3, ErrorIdentifiers, ErrorIdentifiers1, ErrorIdentifiers2, ErrorIdentifiers3, Filter, Filter1, Fulfillment, GetItemAssociationsRequest, GetPricingInsightsRequest, GetSpecRequest, GroupingAttributes, Headers, Image, IncentivesEnrollment, InputQty, InternalServerError1, Invalidparameter1, Invalidparameter3, Inventories, Inventories1, Inventory, Item, Item1, Item11, Item2, Item3, Item4, ItemFeedHeader, ItemPriceResponse, ItemResponse, ItemTaxonomy, Json1, List, MPItem, MPItemFeedHeader, Meta, Meta1, Name, NameValueAttribute, Node, Node1, Node2, Node3, NotFound1, Order, Order4, OrderCancellation, OrderLine, OrderLine1, OrderLine2, OrderLine4, OrderLine8, OrderLineQuantity, OrderLineStatus, OrderLineStatus1, OrderLineStatus3, OrderLineStatuses, OrderLineStatuses1, OrderLineStatuses3, OrderLines, OrderLines1, OrderLines2, OrderLines4, OrderLines8, OrderRefund, OrderShipment, OrderSubTotal, OrderSummary, PageContext, Partialresponsereceived, Payload, Payload1, Payload11, Payload2, Phone, PhoneValidity, PickupPerson, PostalAddress, Price1, Pricing, PricingInsightsResponseList, ProductType, ProductTypeGroup, ProgramAction, ProgramAction1, ProgramActionFeedHeader, Programs, Programs1, PromoDiscount, Properties, Properties1, PublishedStatus, Quantity, Query, Refund, Refund1, Refund6, RefundCharge, RefundCharge1, RefundCharge6, RefundCharges, RefundCharges1, RefundCharges6, RefundOrderLinesRequest, Refunds, ReservedQty, ResponseRecord, ReturnCenterAddress, Schema, SearchCriteria, SetupCAPSKUAllLegacyRequest, ShipNode, ShipOrderLinesRequest, ShippingInfo, ShippingTemplate, Sort, Sort1, StatusInfo, StatusQuantity, Strategy, Strategy5, StrategyCollection, Subcategory, SuccessfulOperation, SuccessfulOperation1, SuccessfulOperation10, SuccessfulOperation11, SuccessfulOperation111, SuccessfulOperation12, SuccessfulOperation121, SuccessfulOperation13, SuccessfulOperation2, SuccessfulOperation21, SuccessfulOperation3, SuccessfulOperation31, SuccessfulOperation32, SuccessfulOperation4, SuccessfulOperation41, SuccessfulOperation42, SuccessfulOperation43, SuccessfulOperation5, SuccessfulOperation51, SuccessfulOperation52, SuccessfulOperation53, SuccessfulOperation6, SuccessfulOperation61, SuccessfulOperation62, SuccessfulOperation7, SuccessfulOperation71, SuccessfulOperation8, SuccessfulOperation81, SuccessfulOperation9, Tax, Tax2, TotalAmount, TrackingInfo, UnpublishedReasons, UpdateItemInventoryperShipNodeRequest, UpdateRepricerStrategyRequest, UpdateinventoryRequest, UpdatepricingforasingleitemRequest, UpdatepricingformultipleitemsinbulkNewRequest, UpdatereducedreferralfeeincentivesenrollmentRequest, UpdatewalmartFundedincentivesenrollmentforspecificitemsRequest, Value, VariantDatum, VariantGroupInfo, VariantMetum, VariantValue, Variants, WalmartFundedIncentivesEnrollment, Weight, Xml1
Instance Method Summary collapse
-
#check_for_conflict(name, existing_prop_names) ⇒ Object
Checks if an additional property conflicts with a model’s existing property.
-
#process_additional_properties(additional_properties, existing_prop_names) ⇒ Object
Processes additional properties, ensuring no conflicts with existing properties.
-
#process_array(value) ⇒ Object
Processes an array of values, recursively calling ‘to_hash` on BaseModel objects.
-
#process_basic_value(value) ⇒ Object
Processes a basic value (non-array, non-hash).
-
#process_hash(value) ⇒ Object
Processes a hash of values, recursively calling ‘to_hash` on BaseModel objects.
-
#to_hash ⇒ Object
Returns a Hash representation of the current object.
-
#to_json(options = {}) ⇒ Object
Returns a JSON representation of the curent object.
Instance Method Details
#check_for_conflict(name, existing_prop_names) ⇒ Object
Checks if an additional property conflicts with a model’s existing property.
81 82 83 84 85 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 81 def check_for_conflict(name, existing_prop_names) return unless existing_prop_names.key?(name) raise ArgumentError, "An additional property key, '#{name}' conflicts with one of the model's properties" end |
#process_additional_properties(additional_properties, existing_prop_names) ⇒ Object
Processes additional properties, ensuring no conflicts with existing properties.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 64 def process_additional_properties(additional_properties, existing_prop_names) hash = {} additional_properties.each do |name, value| check_for_conflict(name, existing_prop_names) hash[name] = if value.is_a?(Array) process_array(value) elsif value.is_a?(Hash) process_hash(value) else process_basic_value(value) end end hash end |
#process_array(value) ⇒ Object
Processes an array of values, recursively calling ‘to_hash` on BaseModel objects.
88 89 90 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 88 def process_array(value) value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v } end |
#process_basic_value(value) ⇒ Object
Processes a basic value (non-array, non-hash).
100 101 102 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 100 def process_basic_value(value) value.is_a?(BaseModel) ? value.to_hash : value end |
#process_hash(value) ⇒ Object
Processes a hash of values, recursively calling ‘to_hash` on BaseModel objects.
93 94 95 96 97 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 93 def process_hash(value) value.transform_values do |v| v.is_a?(BaseModel) ? v.to_hash : v end end |
#to_hash ⇒ Object
Returns a Hash representation of the current object.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 12 def to_hash # validating the model being serialized self.class.validate(self) if self.class.respond_to?(:validate) hash = {} instance_variables.each do |name| value = instance_variable_get(name) name = name[1..] if name == 'additional_properties' additional_properties = process_additional_properties(value, self.class.names) hash.merge!(additional_properties) else key = self.class.names.key?(name) ? self.class.names[name] : name optional_fields = self.class.optionals nullable_fields = self.class.nullables if value.nil? next unless nullable_fields.include?(name) if !optional_fields.include?(name) && !nullable_fields.include?(name) raise ArgumentError, "`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value." end end hash[key] = nil unless value.nil? if respond_to?("to_custom_#{name}") if (value.instance_of? Array) || (value.instance_of? Hash) params = [hash, key] hash[key] = send("to_custom_#{name}", *params) else hash[key] = send("to_custom_#{name}") end elsif respond_to?("to_union_type_#{name}") hash[key] = send("to_union_type_#{name}") elsif value.instance_of? Array hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v } elsif value.instance_of? Hash hash[key] = {} value.each do |k, v| hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v end else hash[key] = value.is_a?(BaseModel) ? value.to_hash : value end end end end hash end |
#to_json(options = {}) ⇒ Object
Returns a JSON representation of the curent object.
105 106 107 108 |
# File 'lib/inventory_management_and_item_management_and_order_management_and_price_management/models/base_model.rb', line 105 def to_json( = {}) hash = to_hash hash.to_json() end |