class QwilAPI::ContractorSerializer
Attributes
URL of the endpoint describing the User's Accounts.
Business name. Only use this field if this user is a business entity.
Calculate what fees would be charged for a specific Cashout amount.
URL of the endpoint describing the User's Cashouts.
Default account to use for payment of unpaid income.
First name, if the user is an individual. Leave blank if this user is a company.
Flag specifying if the User has set their password.
URL of the endpoint describing the User's Income.
Last name, if the user is an individual. Leave blank if this user is a company.
DEPRECATED: The full name of the contractor. Use first_name/last_name instead.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/qwil_api/models/contractor_serializer.rb, line 86 def self.attribute_map { :'url' => :'url', :'email' => :'email', :'income' => :'income', :'name' => :'name', :'first_name' => :'first_name', :'last_name' => :'last_name', :'business_name' => :'business_name', :'contractor_type' => :'contractor_type', :'accounts' => :'accounts', :'default_account' => :'default_account', :'cashouts' => :'cashouts', :'calculate_cashout_available' => :'calculate_cashout_available', :'has_password' => :'has_password' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/qwil_api/models/contractor_serializer.rb, line 125 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?(:'url') self.url = attributes[:'url'] end if attributes.has_key?(:'email') self.email = attributes[:'email'] end if attributes.has_key?(:'income') self.income = attributes[:'income'] end if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'first_name') self.first_name = attributes[:'first_name'] end if attributes.has_key?(:'last_name') self.last_name = attributes[:'last_name'] end if attributes.has_key?(:'business_name') self.business_name = attributes[:'business_name'] end if attributes.has_key?(:'contractor_type') self.contractor_type = attributes[:'contractor_type'] end if attributes.has_key?(:'accounts') self.accounts = attributes[:'accounts'] end if attributes.has_key?(:'default_account') self.default_account = attributes[:'default_account'] end if attributes.has_key?(:'cashouts') self.cashouts = attributes[:'cashouts'] end if attributes.has_key?(:'calculate_cashout_available') self.calculate_cashout_available = attributes[:'calculate_cashout_available'] end if attributes.has_key?(:'has_password') self.has_password = attributes[:'has_password'] end end
Attribute type mapping.
# File lib/qwil_api/models/contractor_serializer.rb, line 105 def self.swagger_types { :'url' => :'String', :'email' => :'String', :'income' => :'String', :'name' => :'String', :'first_name' => :'String', :'last_name' => :'String', :'business_name' => :'String', :'contractor_type' => :'String', :'accounts' => :'String', :'default_account' => :'String', :'cashouts' => :'String', :'calculate_cashout_available' => :'String', :'has_password' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/qwil_api/models/contractor_serializer.rb, line 225 def ==(o) return true if self.equal?(o) self.class == o.class && url == o.url && email == o.email && income == o.income && name == o.name && first_name == o.first_name && last_name == o.last_name && business_name == o.business_name && contractor_type == o.contractor_type && accounts == o.accounts && default_account == o.default_account && cashouts == o.cashouts && calculate_cashout_available == o.calculate_cashout_available && has_password == o.has_password 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/qwil_api/models/contractor_serializer.rb, line 279 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 =~ /^(true|t|yes|y|1)$/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 = QwilAPI.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/qwil_api/models/contractor_serializer.rb, line 345 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/qwil_api/models/contractor_serializer.rb, line 258 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i # check to ensure the input is an array given that the 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
Custom attribute writer method checking allowed values (enum). @param [Object] contractor_type
Object to be assigned
# File lib/qwil_api/models/contractor_serializer.rb, line 215 def contractor_type=(contractor_type) validator = EnumAttributeValidator.new('String', ["INDIVIDUAL", "BUSINESS"]) unless validator.valid?(contractor_type) fail ArgumentError, "invalid value for 'contractor_type', must be one of #{validator.allowable_values}." end @contractor_type = contractor_type end
@see the `==` method @param [Object] Object to be compared
# File lib/qwil_api/models/contractor_serializer.rb, line 245 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/qwil_api/models/contractor_serializer.rb, line 251 def hash [url, email, income, name, first_name, last_name, business_name, contractor_type, accounts, default_account, cashouts, calculate_cashout_available, has_password].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properies with the reasons
# File lib/qwil_api/models/contractor_serializer.rb, line 187 def list_invalid_properties invalid_properties = Array.new return invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/qwil_api/models/contractor_serializer.rb, line 331 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/qwil_api/models/contractor_serializer.rb, line 319 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/qwil_api/models/contractor_serializer.rb, line 194 def valid? return false if @url.nil? return false if @email.nil? return false if @income.nil? return false if @name.nil? return false if @first_name.nil? return false if @last_name.nil? return false if @business_name.nil? return false if @contractor_type.nil? contractor_type_validator = EnumAttributeValidator.new('String', ["INDIVIDUAL", "BUSINESS"]) return false unless contractor_type_validator.valid?(@contractor_type) return false if @accounts.nil? return false if @default_account.nil? return false if @cashouts.nil? return false if @calculate_cashout_available.nil? return false if @has_password.nil? return true end