class ProtonApi::SpendingAnalysisRequest
Attributes
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/proton_api/models/spending_analysis_request.rb, line 88 def self.attribute_map { :'merchant_scope' => :'merchant_scope', :'account_ids' => :'account_ids', :'business_ids' => :'business_ids', :'card_ids' => :'card_ids', :'show_by_merchant' => :'show_by_merchant', :'show_by_period' => :'show_by_period', :'only_cleansed' => :'only_cleansed', :'frequency' => :'frequency', :'end_date' => :'end_date', :'as_of_date' => :'as_of_date', :'transaction_category_scope' => :'transaction_category_scope', :'start_date' => :'start_date', :'card_status_scope' => :'card_status_scope', :'only_active_clients' => :'only_active_clients', :'lookback_periods' => :'lookback_periods', :'frequency_unit' => :'frequency_unit', :'household_ids' => :'household_ids', :'aggregation_account_ids' => :'aggregation_account_ids', :'currency_code' => :'currency_code', :'client_ids' => :'client_ids', :'scope' => :'scope', :'currency_conversion' => :'currency_conversion', :'transaction_status_scope' => :'transaction_status_scope', :'show_by_category' => :'show_by_category' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/proton_api/models/spending_analysis_request.rb, line 149 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?(:'merchant_scope') if (value = attributes[:'merchant_scope']).is_a?(Array) self.merchant_scope = value end end if attributes.has_key?(:'account_ids') if (value = attributes[:'account_ids']).is_a?(Array) self.account_ids = value end end if attributes.has_key?(:'business_ids') if (value = attributes[:'business_ids']).is_a?(Array) self.business_ids = value end end if attributes.has_key?(:'card_ids') if (value = attributes[:'card_ids']).is_a?(Array) self.card_ids = value end end if attributes.has_key?(:'show_by_merchant') self.show_by_merchant = attributes[:'show_by_merchant'] else self.show_by_merchant = false end if attributes.has_key?(:'show_by_period') self.show_by_period = attributes[:'show_by_period'] else self.show_by_period = false end if attributes.has_key?(:'only_cleansed') self.only_cleansed = attributes[:'only_cleansed'] else self.only_cleansed = false end if attributes.has_key?(:'frequency') self.frequency = attributes[:'frequency'] else self.frequency = 1 end if attributes.has_key?(:'end_date') self.end_date = attributes[:'end_date'] end if attributes.has_key?(:'as_of_date') self.as_of_date = attributes[:'as_of_date'] end if attributes.has_key?(:'transaction_category_scope') if (value = attributes[:'transaction_category_scope']).is_a?(Array) self.transaction_category_scope = value end end if attributes.has_key?(:'start_date') self.start_date = attributes[:'start_date'] end if attributes.has_key?(:'card_status_scope') if (value = attributes[:'card_status_scope']).is_a?(Array) self.card_status_scope = value end end if attributes.has_key?(:'only_active_clients') self.only_active_clients = attributes[:'only_active_clients'] else self.only_active_clients = false end if attributes.has_key?(:'lookback_periods') self.lookback_periods = attributes[:'lookback_periods'] else self.lookback_periods = 0 end if attributes.has_key?(:'frequency_unit') self.frequency_unit = attributes[:'frequency_unit'] end if attributes.has_key?(:'household_ids') if (value = attributes[:'household_ids']).is_a?(Array) self.household_ids = value end end if attributes.has_key?(:'aggregation_account_ids') if (value = attributes[:'aggregation_account_ids']).is_a?(Array) self.aggregation_account_ids = value end end if attributes.has_key?(:'currency_code') self.currency_code = attributes[:'currency_code'] end if attributes.has_key?(:'client_ids') if (value = attributes[:'client_ids']).is_a?(Array) self.client_ids = value end end if attributes.has_key?(:'scope') self.scope = attributes[:'scope'] else self.scope = 'all' end if attributes.has_key?(:'currency_conversion') self.currency_conversion = attributes[:'currency_conversion'] end if attributes.has_key?(:'transaction_status_scope') if (value = attributes[:'transaction_status_scope']).is_a?(Array) self.transaction_status_scope = value end end if attributes.has_key?(:'show_by_category') self.show_by_category = attributes[:'show_by_category'] else self.show_by_category = false end end
Attribute type mapping.
# File lib/proton_api/models/spending_analysis_request.rb, line 118 def self.swagger_types { :'merchant_scope' => :'Array<String>', :'account_ids' => :'Array<String>', :'business_ids' => :'Array<String>', :'card_ids' => :'Array<String>', :'show_by_merchant' => :'BOOLEAN', :'show_by_period' => :'BOOLEAN', :'only_cleansed' => :'BOOLEAN', :'frequency' => :'Integer', :'end_date' => :'Date', :'as_of_date' => :'Date', :'transaction_category_scope' => :'Array<String>', :'start_date' => :'Date', :'card_status_scope' => :'Array<String>', :'only_active_clients' => :'BOOLEAN', :'lookback_periods' => :'Integer', :'frequency_unit' => :'String', :'household_ids' => :'Array<String>', :'aggregation_account_ids' => :'Array<String>', :'currency_code' => :'String', :'client_ids' => :'Array<String>', :'scope' => :'String', :'currency_conversion' => :'String', :'transaction_status_scope' => :'Array<String>', :'show_by_category' => :'BOOLEAN' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/proton_api/models/spending_analysis_request.rb, line 362 def ==(o) return true if self.equal?(o) self.class == o.class && merchant_scope == o.merchant_scope && account_ids == o.account_ids && business_ids == o.business_ids && card_ids == o.card_ids && show_by_merchant == o.show_by_merchant && show_by_period == o.show_by_period && only_cleansed == o.only_cleansed && frequency == o.frequency && end_date == o.end_date && as_of_date == o.as_of_date && transaction_category_scope == o.transaction_category_scope && start_date == o.start_date && card_status_scope == o.card_status_scope && only_active_clients == o.only_active_clients && lookback_periods == o.lookback_periods && frequency_unit == o.frequency_unit && household_ids == o.household_ids && aggregation_account_ids == o.aggregation_account_ids && currency_code == o.currency_code && client_ids == o.client_ids && scope == o.scope && currency_conversion == o.currency_conversion && transaction_status_scope == o.transaction_status_scope && show_by_category == o.show_by_category end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/proton_api/models/spending_analysis_request.rb, line 426 def _deserialize(type, value) case type.to_sym when :DateTime value when :Date 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<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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 = ProtonApi.const_get(type).new temp_model.build_from_hash(value) end 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
# File lib/proton_api/models/spending_analysis_request.rb, line 490 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/proton_api/models/spending_analysis_request.rb, line 406 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
@see the `==` method @param [Object] Object to be compared
# File lib/proton_api/models/spending_analysis_request.rb, line 393 def eql?(o) self == o end
Custom attribute writer method with validation @param [Object] frequency Value to be assigned
# File lib/proton_api/models/spending_analysis_request.rb, line 322 def frequency=(frequency) if !frequency.nil? && frequency < 1 fail ArgumentError, 'invalid value for "frequency", must be greater than or equal to 1.' end @frequency = frequency end
Custom attribute writer method checking allowed values (enum). @param [Object] frequency_unit
Object to be assigned
# File lib/proton_api/models/spending_analysis_request.rb, line 342 def frequency_unit=(frequency_unit) validator = EnumAttributeValidator.new('String', ['daily', 'weekly', 'bi-weekly', 'monthly', 'quarterly', 'annually']) unless validator.valid?(frequency_unit) fail ArgumentError, 'invalid value for "frequency_unit", must be one of #{validator.allowable_values}.' end @frequency_unit = frequency_unit end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/proton_api/models/spending_analysis_request.rb, line 399 def hash [merchant_scope, account_ids, business_ids, card_ids, show_by_merchant, show_by_period, only_cleansed, frequency, end_date, as_of_date, transaction_category_scope, start_date, card_status_scope, only_active_clients, lookback_periods, frequency_unit, household_ids, aggregation_account_ids, currency_code, client_ids, scope, currency_conversion, transaction_status_scope, show_by_category].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/proton_api/models/spending_analysis_request.rb, line 290 def list_invalid_properties invalid_properties = Array.new if !@frequency.nil? && @frequency < 1 invalid_properties.push('invalid value for "frequency", must be greater than or equal to 1.') end if !@lookback_periods.nil? && @lookback_periods < 0 invalid_properties.push('invalid value for "lookback_periods", must be greater than or equal to 0.') end if @frequency_unit.nil? invalid_properties.push('invalid value for "frequency_unit", frequency_unit cannot be nil.') end invalid_properties end
Custom attribute writer method with validation @param [Object] lookback_periods
Value to be assigned
# File lib/proton_api/models/spending_analysis_request.rb, line 332 def lookback_periods=(lookback_periods) if !lookback_periods.nil? && lookback_periods < 0 fail ArgumentError, 'invalid value for "lookback_periods", must be greater than or equal to 0.' end @lookback_periods = lookback_periods end
Custom attribute writer method checking allowed values (enum). @param [Object] scope Object to be assigned
# File lib/proton_api/models/spending_analysis_request.rb, line 352 def scope=(scope) validator = EnumAttributeValidator.new('String', ['all', 'external', 'internal', 'cards']) unless validator.valid?(scope) fail ArgumentError, 'invalid value for "scope", must be one of #{validator.allowable_values}.' end @scope = scope end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/proton_api/models/spending_analysis_request.rb, line 477 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
Returns the string representation of the object @return [String] String presentation of the object
# File lib/proton_api/models/spending_analysis_request.rb, line 465 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/proton_api/models/spending_analysis_request.rb, line 309 def valid? return false if !@frequency.nil? && @frequency < 1 return false if !@lookback_periods.nil? && @lookback_periods < 0 return false if @frequency_unit.nil? frequency_unit_validator = EnumAttributeValidator.new('String', ['daily', 'weekly', 'bi-weekly', 'monthly', 'quarterly', 'annually']) return false unless frequency_unit_validator.valid?(@frequency_unit) scope_validator = EnumAttributeValidator.new('String', ['all', 'external', 'internal', 'cards']) return false unless scope_validator.valid?(@scope) true end