=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 OrderPaymentECheck # Bank routing code attr_accessor :bank_aba_code # Bank account name attr_accessor :bank_account_name # Bank account number (masked to last 4) attr_accessor :bank_account_number # Bank account type attr_accessor :bank_account_type # Bank name attr_accessor :bank_name # Bank owner type attr_accessor :bank_owner_type # Customer tax id (masked to last 4) attr_accessor :customer_tax_id # Driver license date of birth attr_accessor :drivers_license_dob # Driver license number (masked to last 4) attr_accessor :drivers_license_number # Driver license state attr_accessor :drivers_license_state 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 { :'bank_aba_code' => :'bank_aba_code', :'bank_account_name' => :'bank_account_name', :'bank_account_number' => :'bank_account_number', :'bank_account_type' => :'bank_account_type', :'bank_name' => :'bank_name', :'bank_owner_type' => :'bank_owner_type', :'customer_tax_id' => :'customer_tax_id', :'drivers_license_dob' => :'drivers_license_dob', :'drivers_license_number' => :'drivers_license_number', :'drivers_license_state' => :'drivers_license_state' } end # Attribute type mapping. def self.swagger_types { :'bank_aba_code' => :'String', :'bank_account_name' => :'String', :'bank_account_number' => :'String', :'bank_account_type' => :'String', :'bank_name' => :'String', :'bank_owner_type' => :'String', :'customer_tax_id' => :'String', :'drivers_license_dob' => :'String', :'drivers_license_number' => :'String', :'drivers_license_state' => :'String' } 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?(:'bank_aba_code') self.bank_aba_code = attributes[:'bank_aba_code'] end if attributes.has_key?(:'bank_account_name') self.bank_account_name = attributes[:'bank_account_name'] end if attributes.has_key?(:'bank_account_number') self.bank_account_number = attributes[:'bank_account_number'] end if attributes.has_key?(:'bank_account_type') self.bank_account_type = attributes[:'bank_account_type'] end if attributes.has_key?(:'bank_name') self.bank_name = attributes[:'bank_name'] end if attributes.has_key?(:'bank_owner_type') self.bank_owner_type = attributes[:'bank_owner_type'] end if attributes.has_key?(:'customer_tax_id') self.customer_tax_id = attributes[:'customer_tax_id'] end if attributes.has_key?(:'drivers_license_dob') self.drivers_license_dob = attributes[:'drivers_license_dob'] end if attributes.has_key?(:'drivers_license_number') self.drivers_license_number = attributes[:'drivers_license_number'] end if attributes.has_key?(:'drivers_license_state') self.drivers_license_state = attributes[:'drivers_license_state'] 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 !@bank_aba_code.nil? && @bank_aba_code.to_s.length > 9 invalid_properties.push('invalid value for "bank_aba_code", the character length must be smaller than or equal to 9.') end if !@bank_account_name.nil? && @bank_account_name.to_s.length > 50 invalid_properties.push('invalid value for "bank_account_name", the character length must be smaller than or equal to 50.') end if !@bank_account_number.nil? && @bank_account_number.to_s.length > 50 invalid_properties.push('invalid value for "bank_account_number", the character length must be smaller than or equal to 50.') end if !@bank_name.nil? && @bank_name.to_s.length > 50 invalid_properties.push('invalid value for "bank_name", the character length must be smaller than or equal to 50.') end if !@customer_tax_id.nil? && @customer_tax_id.to_s.length > 9 invalid_properties.push('invalid value for "customer_tax_id", the character length must be smaller than or equal to 9.') end if !@drivers_license_dob.nil? && @drivers_license_dob.to_s.length > 10 invalid_properties.push('invalid value for "drivers_license_dob", the character length must be smaller than or equal to 10.') end if !@drivers_license_number.nil? && @drivers_license_number.to_s.length > 50 invalid_properties.push('invalid value for "drivers_license_number", the character length must be smaller than or equal to 50.') end if !@drivers_license_state.nil? && @drivers_license_state.to_s.length > 2 invalid_properties.push('invalid value for "drivers_license_state", the character length must be smaller than or equal to 2.') 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 !@bank_aba_code.nil? && @bank_aba_code.to_s.length > 9 return false if !@bank_account_name.nil? && @bank_account_name.to_s.length > 50 return false if !@bank_account_number.nil? && @bank_account_number.to_s.length > 50 bank_account_type_validator = EnumAttributeValidator.new('String', ['Checking', 'Savings']) return false unless bank_account_type_validator.valid?(@bank_account_type) return false if !@bank_name.nil? && @bank_name.to_s.length > 50 bank_owner_type_validator = EnumAttributeValidator.new('String', ['Personal', 'Business']) return false unless bank_owner_type_validator.valid?(@bank_owner_type) return false if !@customer_tax_id.nil? && @customer_tax_id.to_s.length > 9 return false if !@drivers_license_dob.nil? && @drivers_license_dob.to_s.length > 10 return false if !@drivers_license_number.nil? && @drivers_license_number.to_s.length > 50 return false if !@drivers_license_state.nil? && @drivers_license_state.to_s.length > 2 true end # Custom attribute writer method with validation # @param [Object] bank_aba_code Value to be assigned def bank_aba_code=(bank_aba_code) if !bank_aba_code.nil? && bank_aba_code.to_s.length > 9 fail ArgumentError, 'invalid value for "bank_aba_code", the character length must be smaller than or equal to 9.' end @bank_aba_code = bank_aba_code end # Custom attribute writer method with validation # @param [Object] bank_account_name Value to be assigned def bank_account_name=(bank_account_name) if !bank_account_name.nil? && bank_account_name.to_s.length > 50 fail ArgumentError, 'invalid value for "bank_account_name", the character length must be smaller than or equal to 50.' end @bank_account_name = bank_account_name end # Custom attribute writer method with validation # @param [Object] bank_account_number Value to be assigned def bank_account_number=(bank_account_number) if !bank_account_number.nil? && bank_account_number.to_s.length > 50 fail ArgumentError, 'invalid value for "bank_account_number", the character length must be smaller than or equal to 50.' end @bank_account_number = bank_account_number end # Custom attribute writer method checking allowed values (enum). # @param [Object] bank_account_type Object to be assigned def bank_account_type=(bank_account_type) validator = EnumAttributeValidator.new('String', ['Checking', 'Savings']) unless validator.valid?(bank_account_type) fail ArgumentError, 'invalid value for "bank_account_type", must be one of #{validator.allowable_values}.' end @bank_account_type = bank_account_type end # Custom attribute writer method with validation # @param [Object] bank_name Value to be assigned def bank_name=(bank_name) if !bank_name.nil? && bank_name.to_s.length > 50 fail ArgumentError, 'invalid value for "bank_name", the character length must be smaller than or equal to 50.' end @bank_name = bank_name end # Custom attribute writer method checking allowed values (enum). # @param [Object] bank_owner_type Object to be assigned def bank_owner_type=(bank_owner_type) validator = EnumAttributeValidator.new('String', ['Personal', 'Business']) unless validator.valid?(bank_owner_type) fail ArgumentError, 'invalid value for "bank_owner_type", must be one of #{validator.allowable_values}.' end @bank_owner_type = bank_owner_type end # Custom attribute writer method with validation # @param [Object] customer_tax_id Value to be assigned def customer_tax_id=(customer_tax_id) if !customer_tax_id.nil? && customer_tax_id.to_s.length > 9 fail ArgumentError, 'invalid value for "customer_tax_id", the character length must be smaller than or equal to 9.' end @customer_tax_id = customer_tax_id end # Custom attribute writer method with validation # @param [Object] drivers_license_dob Value to be assigned def drivers_license_dob=(drivers_license_dob) if !drivers_license_dob.nil? && drivers_license_dob.to_s.length > 10 fail ArgumentError, 'invalid value for "drivers_license_dob", the character length must be smaller than or equal to 10.' end @drivers_license_dob = drivers_license_dob end # Custom attribute writer method with validation # @param [Object] drivers_license_number Value to be assigned def drivers_license_number=(drivers_license_number) if !drivers_license_number.nil? && drivers_license_number.to_s.length > 50 fail ArgumentError, 'invalid value for "drivers_license_number", the character length must be smaller than or equal to 50.' end @drivers_license_number = drivers_license_number end # Custom attribute writer method with validation # @param [Object] drivers_license_state Value to be assigned def drivers_license_state=(drivers_license_state) if !drivers_license_state.nil? && drivers_license_state.to_s.length > 2 fail ArgumentError, 'invalid value for "drivers_license_state", the character length must be smaller than or equal to 2.' end @drivers_license_state = drivers_license_state 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 && bank_aba_code == o.bank_aba_code && bank_account_name == o.bank_account_name && bank_account_number == o.bank_account_number && bank_account_type == o.bank_account_type && bank_name == o.bank_name && bank_owner_type == o.bank_owner_type && customer_tax_id == o.customer_tax_id && drivers_license_dob == o.drivers_license_dob && drivers_license_number == o.drivers_license_number && drivers_license_state == o.drivers_license_state 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 [bank_aba_code, bank_account_name, bank_account_number, bank_account_type, bank_name, bank_owner_type, customer_tax_id, drivers_license_dob, drivers_license_number, drivers_license_state].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