=begin #Subskribe API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.41 =end require 'date' module SubskribeDevClient class ChargeJson attr_accessor :id attr_accessor :name attr_accessor :display_name attr_accessor :description attr_accessor :tax_rate_id attr_accessor :unit_of_measure_id attr_accessor :is_renewable attr_accessor :min_quantity attr_accessor :default_quantity attr_accessor :max_quantity attr_accessor :external_id attr_accessor :min_amount attr_accessor :max_amount attr_accessor :recognition_rule_id attr_accessor :erp_id attr_accessor :plan_id attr_accessor :amount attr_accessor :type attr_accessor :charge_model attr_accessor :recurrence attr_accessor :price_tiers attr_accessor :is_drawdown attr_accessor :minimum_commit_base_charge_id attr_accessor :overage_base_charge_id attr_accessor :is_custom attr_accessor :is_list_price_editable attr_accessor :percent attr_accessor :percent_derived_from attr_accessor :target_plan_ids attr_accessor :ledger_account_mapping attr_accessor :duration_in_months attr_accessor :is_event_based attr_accessor :rate_card_id attr_accessor :billing_term attr_accessor :billing_cycle attr_accessor :should_track_arr attr_accessor :custom attr_accessor :drawdown attr_accessor :event_based attr_accessor :list_price_editable 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 { :'id' => :'id', :'name' => :'name', :'display_name' => :'displayName', :'description' => :'description', :'tax_rate_id' => :'taxRateId', :'unit_of_measure_id' => :'unitOfMeasureId', :'is_renewable' => :'isRenewable', :'min_quantity' => :'minQuantity', :'default_quantity' => :'defaultQuantity', :'max_quantity' => :'maxQuantity', :'external_id' => :'externalId', :'min_amount' => :'minAmount', :'max_amount' => :'maxAmount', :'recognition_rule_id' => :'recognitionRuleId', :'erp_id' => :'erpId', :'plan_id' => :'planId', :'amount' => :'amount', :'type' => :'type', :'charge_model' => :'chargeModel', :'recurrence' => :'recurrence', :'price_tiers' => :'priceTiers', :'is_drawdown' => :'isDrawdown', :'minimum_commit_base_charge_id' => :'minimumCommitBaseChargeId', :'overage_base_charge_id' => :'overageBaseChargeId', :'is_custom' => :'isCustom', :'is_list_price_editable' => :'isListPriceEditable', :'percent' => :'percent', :'percent_derived_from' => :'percentDerivedFrom', :'target_plan_ids' => :'targetPlanIds', :'ledger_account_mapping' => :'ledgerAccountMapping', :'duration_in_months' => :'durationInMonths', :'is_event_based' => :'isEventBased', :'rate_card_id' => :'rateCardId', :'billing_term' => :'billingTerm', :'billing_cycle' => :'billingCycle', :'should_track_arr' => :'shouldTrackArr', :'custom' => :'custom', :'drawdown' => :'drawdown', :'event_based' => :'eventBased', :'list_price_editable' => :'listPriceEditable' } end # Attribute type mapping. def self.swagger_types { :'id' => :'String', :'name' => :'String', :'display_name' => :'String', :'description' => :'String', :'tax_rate_id' => :'String', :'unit_of_measure_id' => :'String', :'is_renewable' => :'BOOLEAN', :'min_quantity' => :'Integer', :'default_quantity' => :'Integer', :'max_quantity' => :'Integer', :'external_id' => :'String', :'min_amount' => :'Float', :'max_amount' => :'Float', :'recognition_rule_id' => :'String', :'erp_id' => :'String', :'plan_id' => :'String', :'amount' => :'Float', :'type' => :'String', :'charge_model' => :'String', :'recurrence' => :'RecurrenceJson', :'price_tiers' => :'Array', :'is_drawdown' => :'BOOLEAN', :'minimum_commit_base_charge_id' => :'String', :'overage_base_charge_id' => :'String', :'is_custom' => :'BOOLEAN', :'is_list_price_editable' => :'BOOLEAN', :'percent' => :'Float', :'percent_derived_from' => :'String', :'target_plan_ids' => :'Array', :'ledger_account_mapping' => :'LedgerAccountMapping', :'duration_in_months' => :'Integer', :'is_event_based' => :'BOOLEAN', :'rate_card_id' => :'String', :'billing_term' => :'String', :'billing_cycle' => :'String', :'should_track_arr' => :'BOOLEAN', :'custom' => :'BOOLEAN', :'drawdown' => :'BOOLEAN', :'event_based' => :'BOOLEAN', :'list_price_editable' => :'BOOLEAN' } 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?(:'id') self.id = attributes[:'id'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'displayName') self.display_name = attributes[:'displayName'] end if attributes.has_key?(:'description') self.description = attributes[:'description'] end if attributes.has_key?(:'taxRateId') self.tax_rate_id = attributes[:'taxRateId'] end if attributes.has_key?(:'unitOfMeasureId') self.unit_of_measure_id = attributes[:'unitOfMeasureId'] end if attributes.has_key?(:'isRenewable') self.is_renewable = attributes[:'isRenewable'] end if attributes.has_key?(:'minQuantity') self.min_quantity = attributes[:'minQuantity'] end if attributes.has_key?(:'defaultQuantity') self.default_quantity = attributes[:'defaultQuantity'] end if attributes.has_key?(:'maxQuantity') self.max_quantity = attributes[:'maxQuantity'] end if attributes.has_key?(:'externalId') self.external_id = attributes[:'externalId'] end if attributes.has_key?(:'minAmount') self.min_amount = attributes[:'minAmount'] end if attributes.has_key?(:'maxAmount') self.max_amount = attributes[:'maxAmount'] end if attributes.has_key?(:'recognitionRuleId') self.recognition_rule_id = attributes[:'recognitionRuleId'] end if attributes.has_key?(:'erpId') self.erp_id = attributes[:'erpId'] end if attributes.has_key?(:'planId') self.plan_id = attributes[:'planId'] end if attributes.has_key?(:'amount') self.amount = attributes[:'amount'] end if attributes.has_key?(:'type') self.type = attributes[:'type'] end if attributes.has_key?(:'chargeModel') self.charge_model = attributes[:'chargeModel'] end if attributes.has_key?(:'recurrence') self.recurrence = attributes[:'recurrence'] end if attributes.has_key?(:'priceTiers') if (value = attributes[:'priceTiers']).is_a?(Array) self.price_tiers = value end end if attributes.has_key?(:'isDrawdown') self.is_drawdown = attributes[:'isDrawdown'] end if attributes.has_key?(:'minimumCommitBaseChargeId') self.minimum_commit_base_charge_id = attributes[:'minimumCommitBaseChargeId'] end if attributes.has_key?(:'overageBaseChargeId') self.overage_base_charge_id = attributes[:'overageBaseChargeId'] end if attributes.has_key?(:'isCustom') self.is_custom = attributes[:'isCustom'] end if attributes.has_key?(:'isListPriceEditable') self.is_list_price_editable = attributes[:'isListPriceEditable'] end if attributes.has_key?(:'percent') self.percent = attributes[:'percent'] end if attributes.has_key?(:'percentDerivedFrom') self.percent_derived_from = attributes[:'percentDerivedFrom'] end if attributes.has_key?(:'targetPlanIds') if (value = attributes[:'targetPlanIds']).is_a?(Array) self.target_plan_ids = value end end if attributes.has_key?(:'ledgerAccountMapping') self.ledger_account_mapping = attributes[:'ledgerAccountMapping'] end if attributes.has_key?(:'durationInMonths') self.duration_in_months = attributes[:'durationInMonths'] end if attributes.has_key?(:'isEventBased') self.is_event_based = attributes[:'isEventBased'] end if attributes.has_key?(:'rateCardId') self.rate_card_id = attributes[:'rateCardId'] end if attributes.has_key?(:'billingTerm') self.billing_term = attributes[:'billingTerm'] end if attributes.has_key?(:'billingCycle') self.billing_cycle = attributes[:'billingCycle'] end if attributes.has_key?(:'shouldTrackArr') self.should_track_arr = attributes[:'shouldTrackArr'] end if attributes.has_key?(:'custom') self.custom = attributes[:'custom'] end if attributes.has_key?(:'drawdown') self.drawdown = attributes[:'drawdown'] end if attributes.has_key?(:'eventBased') self.event_based = attributes[:'eventBased'] end if attributes.has_key?(:'listPriceEditable') self.list_price_editable = attributes[:'listPriceEditable'] 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 if @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end if @charge_model.nil? invalid_properties.push('invalid value for "charge_model", charge_model cannot be nil.') end 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? return false if @type.nil? type_validator = EnumAttributeValidator.new('String', ['ONE_TIME', 'RECURRING', 'USAGE', 'PREPAID', 'PERCENTAGE_OF']) return false unless type_validator.valid?(@type) return false if @charge_model.nil? charge_model_validator = EnumAttributeValidator.new('String', ['PER_UNIT', 'VOLUME', 'TIERED', 'FLAT_FEE', 'BLOCK', 'RATE_CARD_LOOKUP']) return false unless charge_model_validator.valid?(@charge_model) percent_derived_from_validator = EnumAttributeValidator.new('String', ['LIST_AMOUNT', 'SELL_AMOUNT']) return false unless percent_derived_from_validator.valid?(@percent_derived_from) billing_term_validator = EnumAttributeValidator.new('String', ['UP_FRONT', 'IN_ARREARS']) return false unless billing_term_validator.valid?(@billing_term) billing_cycle_validator = EnumAttributeValidator.new('String', ['DEFAULT', 'PAID_IN_FULL', 'MONTH', 'QUARTER', 'SEMI_ANNUAL', 'YEAR']) return false unless billing_cycle_validator.valid?(@billing_cycle) true end # Custom attribute writer method checking allowed values (enum). # @param [Object] type Object to be assigned def type=(type) validator = EnumAttributeValidator.new('String', ['ONE_TIME', 'RECURRING', 'USAGE', 'PREPAID', 'PERCENTAGE_OF']) unless validator.valid?(type) fail ArgumentError, 'invalid value for "type", must be one of #{validator.allowable_values}.' end @type = type end # Custom attribute writer method checking allowed values (enum). # @param [Object] charge_model Object to be assigned def charge_model=(charge_model) validator = EnumAttributeValidator.new('String', ['PER_UNIT', 'VOLUME', 'TIERED', 'FLAT_FEE', 'BLOCK', 'RATE_CARD_LOOKUP']) unless validator.valid?(charge_model) fail ArgumentError, 'invalid value for "charge_model", must be one of #{validator.allowable_values}.' end @charge_model = charge_model end # Custom attribute writer method checking allowed values (enum). # @param [Object] percent_derived_from Object to be assigned def percent_derived_from=(percent_derived_from) validator = EnumAttributeValidator.new('String', ['LIST_AMOUNT', 'SELL_AMOUNT']) unless validator.valid?(percent_derived_from) fail ArgumentError, 'invalid value for "percent_derived_from", must be one of #{validator.allowable_values}.' end @percent_derived_from = percent_derived_from end # Custom attribute writer method checking allowed values (enum). # @param [Object] billing_term Object to be assigned def billing_term=(billing_term) validator = EnumAttributeValidator.new('String', ['UP_FRONT', 'IN_ARREARS']) unless validator.valid?(billing_term) fail ArgumentError, 'invalid value for "billing_term", must be one of #{validator.allowable_values}.' end @billing_term = billing_term end # Custom attribute writer method checking allowed values (enum). # @param [Object] billing_cycle Object to be assigned def billing_cycle=(billing_cycle) validator = EnumAttributeValidator.new('String', ['DEFAULT', 'PAID_IN_FULL', 'MONTH', 'QUARTER', 'SEMI_ANNUAL', 'YEAR']) unless validator.valid?(billing_cycle) fail ArgumentError, 'invalid value for "billing_cycle", must be one of #{validator.allowable_values}.' end @billing_cycle = billing_cycle 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 && id == o.id && name == o.name && display_name == o.display_name && description == o.description && tax_rate_id == o.tax_rate_id && unit_of_measure_id == o.unit_of_measure_id && is_renewable == o.is_renewable && min_quantity == o.min_quantity && default_quantity == o.default_quantity && max_quantity == o.max_quantity && external_id == o.external_id && min_amount == o.min_amount && max_amount == o.max_amount && recognition_rule_id == o.recognition_rule_id && erp_id == o.erp_id && plan_id == o.plan_id && amount == o.amount && type == o.type && charge_model == o.charge_model && recurrence == o.recurrence && price_tiers == o.price_tiers && is_drawdown == o.is_drawdown && minimum_commit_base_charge_id == o.minimum_commit_base_charge_id && overage_base_charge_id == o.overage_base_charge_id && is_custom == o.is_custom && is_list_price_editable == o.is_list_price_editable && percent == o.percent && percent_derived_from == o.percent_derived_from && target_plan_ids == o.target_plan_ids && ledger_account_mapping == o.ledger_account_mapping && duration_in_months == o.duration_in_months && is_event_based == o.is_event_based && rate_card_id == o.rate_card_id && billing_term == o.billing_term && billing_cycle == o.billing_cycle && should_track_arr == o.should_track_arr && custom == o.custom && drawdown == o.drawdown && event_based == o.event_based && list_price_editable == o.list_price_editable 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 [id, name, display_name, description, tax_rate_id, unit_of_measure_id, is_renewable, min_quantity, default_quantity, max_quantity, external_id, min_amount, max_amount, recognition_rule_id, erp_id, plan_id, amount, type, charge_model, recurrence, price_tiers, is_drawdown, minimum_commit_base_charge_id, overage_base_charge_id, is_custom, is_list_price_editable, percent, percent_derived_from, target_plan_ids, ledger_account_mapping, duration_in_months, is_event_based, rate_card_id, billing_term, billing_cycle, should_track_arr, custom, drawdown, event_based, list_price_editable].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 = SubskribeDevClient.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