=begin #UltraCart Rest API V2 #UltraCart REST API Version 2 OpenAPI spec version: 2.0.0 Contact: support@ultracart.com Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.15-SNAPSHOT =end require 'date' module UltracartClient class AutoOrderItem # Arbitrary item id that should be rebilled instead of the normal schedule attr_accessor :arbitrary_item_id # An arbitrary percentage discount to provide on future rebills attr_accessor :arbitrary_percentage_discount # Arbitrary quantity to rebill attr_accessor :arbitrary_quantity # The number of days to rebill if the frequency is set to an arbitrary number of days attr_accessor :arbitrary_schedule_days # Arbitrary unit cost that rebills of this item should occur at attr_accessor :arbitrary_unit_cost # The number of rebills to give the arbitrary unit cost on before reverting to normal pricing. attr_accessor :arbitrary_unit_cost_remaining_orders # Primary key of AutoOrderItem attr_accessor :auto_order_item_oid # Calculated Date/time that this item is scheduled to rebill. Will be null if no more shipments are going to occur on this item attr_accessor :calculated_next_shipment_dts # Date/time of the first order of this item. Null if item added to auto order and has not been rebilled yet. attr_accessor :first_order_dts # Frequency of the rebill if not a fixed schedule attr_accessor :frequency # The future rebill schedule for this item up to the next ten rebills attr_accessor :future_schedules # Date/time of the last order of this item attr_accessor :last_order_dts # The life time value of this item including the original purchase attr_accessor :life_time_value # Calculated next item id attr_accessor :next_item_id # The date/time of when the next pre-shipment notice should be sent attr_accessor :next_preshipment_notice_dts # Date/time that this item is scheduled to rebill attr_accessor :next_shipment_dts # Date/time after which no additional rebills of this item should occur attr_accessor :no_order_after_dts # The number of times this item has rebilled attr_accessor :number_of_rebills # Options associated with this item attr_accessor :options # The original item id purchased. This item controls scheduling. If you wish to modify a schedule, for example, from monthly to yearly, change this item from your monthly item to your yearly item, and then change the next_shipment_dts to your desired date. attr_accessor :original_item_id # The original quantity purchased attr_accessor :original_quantity # True if paused. This field is an object instead of a primitive for backwards compatibility. attr_accessor :paused # The PayPal Payer ID tied to this item attr_accessor :paypal_payer_id # The PayPal Profile ID tied to this item attr_accessor :paypal_recurring_payment_profile_id # True if the preshipment notice associated with the next rebill has been sent attr_accessor :preshipment_notice_sent # The value of the rebills of this item attr_accessor :rebill_value # The number of rebills remaining before this item is complete attr_accessor :remaining_repeat_count attr_accessor :simple_schedule class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @allowable_values = allowable_values.map do |value| case datatype.to_s when /Integer/i value.to_i when /Float/i value.to_f else value end end end def valid?(value) !value || allowable_values.include?(value) end end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'arbitrary_item_id' => :'arbitrary_item_id', :'arbitrary_percentage_discount' => :'arbitrary_percentage_discount', :'arbitrary_quantity' => :'arbitrary_quantity', :'arbitrary_schedule_days' => :'arbitrary_schedule_days', :'arbitrary_unit_cost' => :'arbitrary_unit_cost', :'arbitrary_unit_cost_remaining_orders' => :'arbitrary_unit_cost_remaining_orders', :'auto_order_item_oid' => :'auto_order_item_oid', :'calculated_next_shipment_dts' => :'calculated_next_shipment_dts', :'first_order_dts' => :'first_order_dts', :'frequency' => :'frequency', :'future_schedules' => :'future_schedules', :'last_order_dts' => :'last_order_dts', :'life_time_value' => :'life_time_value', :'next_item_id' => :'next_item_id', :'next_preshipment_notice_dts' => :'next_preshipment_notice_dts', :'next_shipment_dts' => :'next_shipment_dts', :'no_order_after_dts' => :'no_order_after_dts', :'number_of_rebills' => :'number_of_rebills', :'options' => :'options', :'original_item_id' => :'original_item_id', :'original_quantity' => :'original_quantity', :'paused' => :'paused', :'paypal_payer_id' => :'paypal_payer_id', :'paypal_recurring_payment_profile_id' => :'paypal_recurring_payment_profile_id', :'preshipment_notice_sent' => :'preshipment_notice_sent', :'rebill_value' => :'rebill_value', :'remaining_repeat_count' => :'remaining_repeat_count', :'simple_schedule' => :'simple_schedule' } end # Attribute type mapping. def self.swagger_types { :'arbitrary_item_id' => :'String', :'arbitrary_percentage_discount' => :'Float', :'arbitrary_quantity' => :'Float', :'arbitrary_schedule_days' => :'Integer', :'arbitrary_unit_cost' => :'Float', :'arbitrary_unit_cost_remaining_orders' => :'Integer', :'auto_order_item_oid' => :'Integer', :'calculated_next_shipment_dts' => :'String', :'first_order_dts' => :'String', :'frequency' => :'String', :'future_schedules' => :'Array', :'last_order_dts' => :'String', :'life_time_value' => :'Float', :'next_item_id' => :'String', :'next_preshipment_notice_dts' => :'String', :'next_shipment_dts' => :'String', :'no_order_after_dts' => :'String', :'number_of_rebills' => :'Integer', :'options' => :'Array', :'original_item_id' => :'String', :'original_quantity' => :'Float', :'paused' => :'BOOLEAN', :'paypal_payer_id' => :'String', :'paypal_recurring_payment_profile_id' => :'String', :'preshipment_notice_sent' => :'BOOLEAN', :'rebill_value' => :'Float', :'remaining_repeat_count' => :'Integer', :'simple_schedule' => :'AutoOrderItemSimpleSchedule' } end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'arbitrary_item_id') self.arbitrary_item_id = attributes[:'arbitrary_item_id'] end if attributes.has_key?(:'arbitrary_percentage_discount') self.arbitrary_percentage_discount = attributes[:'arbitrary_percentage_discount'] end if attributes.has_key?(:'arbitrary_quantity') self.arbitrary_quantity = attributes[:'arbitrary_quantity'] end if attributes.has_key?(:'arbitrary_schedule_days') self.arbitrary_schedule_days = attributes[:'arbitrary_schedule_days'] end if attributes.has_key?(:'arbitrary_unit_cost') self.arbitrary_unit_cost = attributes[:'arbitrary_unit_cost'] end if attributes.has_key?(:'arbitrary_unit_cost_remaining_orders') self.arbitrary_unit_cost_remaining_orders = attributes[:'arbitrary_unit_cost_remaining_orders'] end if attributes.has_key?(:'auto_order_item_oid') self.auto_order_item_oid = attributes[:'auto_order_item_oid'] end if attributes.has_key?(:'calculated_next_shipment_dts') self.calculated_next_shipment_dts = attributes[:'calculated_next_shipment_dts'] end if attributes.has_key?(:'first_order_dts') self.first_order_dts = attributes[:'first_order_dts'] end if attributes.has_key?(:'frequency') self.frequency = attributes[:'frequency'] end if attributes.has_key?(:'future_schedules') if (value = attributes[:'future_schedules']).is_a?(Array) self.future_schedules = value end end if attributes.has_key?(:'last_order_dts') self.last_order_dts = attributes[:'last_order_dts'] end if attributes.has_key?(:'life_time_value') self.life_time_value = attributes[:'life_time_value'] end if attributes.has_key?(:'next_item_id') self.next_item_id = attributes[:'next_item_id'] end if attributes.has_key?(:'next_preshipment_notice_dts') self.next_preshipment_notice_dts = attributes[:'next_preshipment_notice_dts'] end if attributes.has_key?(:'next_shipment_dts') self.next_shipment_dts = attributes[:'next_shipment_dts'] end if attributes.has_key?(:'no_order_after_dts') self.no_order_after_dts = attributes[:'no_order_after_dts'] end if attributes.has_key?(:'number_of_rebills') self.number_of_rebills = attributes[:'number_of_rebills'] end if attributes.has_key?(:'options') if (value = attributes[:'options']).is_a?(Array) self.options = value end end if attributes.has_key?(:'original_item_id') self.original_item_id = attributes[:'original_item_id'] end if attributes.has_key?(:'original_quantity') self.original_quantity = attributes[:'original_quantity'] end if attributes.has_key?(:'paused') self.paused = attributes[:'paused'] end if attributes.has_key?(:'paypal_payer_id') self.paypal_payer_id = attributes[:'paypal_payer_id'] end if attributes.has_key?(:'paypal_recurring_payment_profile_id') self.paypal_recurring_payment_profile_id = attributes[:'paypal_recurring_payment_profile_id'] end if attributes.has_key?(:'preshipment_notice_sent') self.preshipment_notice_sent = attributes[:'preshipment_notice_sent'] end if attributes.has_key?(:'rebill_value') self.rebill_value = attributes[:'rebill_value'] end if attributes.has_key?(:'remaining_repeat_count') self.remaining_repeat_count = attributes[:'remaining_repeat_count'] end if attributes.has_key?(:'simple_schedule') self.simple_schedule = attributes[:'simple_schedule'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? frequency_validator = EnumAttributeValidator.new('String', ['Weekly', 'Biweekly', 'Every...', 'Every 10 Days', 'Every 24 Days', 'Every 28 Days', 'Monthly', 'Every 45 Days', 'Every 2 Months', 'Every 3 Months', 'Every 4 Months', 'Every 5 Months', 'Every 6 Months', 'Yearly', 'Every 4 Weeks', 'Every 6 Weeks', 'Every 8 Weeks']) return false unless frequency_validator.valid?(@frequency) true end # Custom attribute writer method checking allowed values (enum). # @param [Object] frequency Object to be assigned def frequency=(frequency) validator = EnumAttributeValidator.new('String', ['Weekly', 'Biweekly', 'Every...', 'Every 10 Days', 'Every 24 Days', 'Every 28 Days', 'Monthly', 'Every 45 Days', 'Every 2 Months', 'Every 3 Months', 'Every 4 Months', 'Every 5 Months', 'Every 6 Months', 'Yearly', 'Every 4 Weeks', 'Every 6 Weeks', 'Every 8 Weeks']) unless validator.valid?(frequency) fail ArgumentError, 'invalid value for "frequency", must be one of #{validator.allowable_values}.' end @frequency = frequency end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && arbitrary_item_id == o.arbitrary_item_id && arbitrary_percentage_discount == o.arbitrary_percentage_discount && arbitrary_quantity == o.arbitrary_quantity && arbitrary_schedule_days == o.arbitrary_schedule_days && arbitrary_unit_cost == o.arbitrary_unit_cost && arbitrary_unit_cost_remaining_orders == o.arbitrary_unit_cost_remaining_orders && auto_order_item_oid == o.auto_order_item_oid && calculated_next_shipment_dts == o.calculated_next_shipment_dts && first_order_dts == o.first_order_dts && frequency == o.frequency && future_schedules == o.future_schedules && last_order_dts == o.last_order_dts && life_time_value == o.life_time_value && next_item_id == o.next_item_id && next_preshipment_notice_dts == o.next_preshipment_notice_dts && next_shipment_dts == o.next_shipment_dts && no_order_after_dts == o.no_order_after_dts && number_of_rebills == o.number_of_rebills && options == o.options && original_item_id == o.original_item_id && original_quantity == o.original_quantity && paused == o.paused && paypal_payer_id == o.paypal_payer_id && paypal_recurring_payment_profile_id == o.paypal_recurring_payment_profile_id && preshipment_notice_sent == o.preshipment_notice_sent && rebill_value == o.rebill_value && remaining_repeat_count == o.remaining_repeat_count && simple_schedule == o.simple_schedule end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash [arbitrary_item_id, arbitrary_percentage_discount, arbitrary_quantity, arbitrary_schedule_days, arbitrary_unit_cost, arbitrary_unit_cost_remaining_orders, auto_order_item_oid, calculated_next_shipment_dts, first_order_dts, frequency, future_schedules, last_order_dts, life_time_value, next_item_id, next_preshipment_notice_dts, next_shipment_dts, no_order_after_dts, number_of_rebills, options, original_item_id, original_quantity, paused, paypal_payer_id, paypal_recurring_payment_profile_id, preshipment_notice_sent, rebill_value, remaining_repeat_count, simple_schedule].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = UltracartClient.const_get(type).new temp_model.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end end end