require 'date' module PureCloud class User # The globally unique identifier for the object. attr_accessor :id attr_accessor :name attr_accessor :username attr_accessor :email attr_accessor :display_name attr_accessor :phone_number attr_accessor :user_images attr_accessor :chat attr_accessor :roles attr_accessor :voicemail_enabled attr_accessor :department attr_accessor :title attr_accessor :routing_status attr_accessor :password attr_accessor :primary_presence attr_accessor :conversations attr_accessor :conversation_summary attr_accessor :out_of_office attr_accessor :geolocation attr_accessor :permissions # The URI for this object attr_accessor :self_uri attr_accessor :requested_status attr_accessor :default_station_uri attr_accessor :station_uri attr_accessor :last_station_uri # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'id' => :'id', :'name' => :'name', :'username' => :'username', :'email' => :'email', :'display_name' => :'displayName', :'phone_number' => :'phoneNumber', :'user_images' => :'userImages', :'chat' => :'chat', :'roles' => :'roles', :'voicemail_enabled' => :'voicemailEnabled', :'department' => :'department', :'title' => :'title', :'routing_status' => :'routingStatus', :'password' => :'password', :'primary_presence' => :'primaryPresence', :'conversations' => :'conversations', :'conversation_summary' => :'conversationSummary', :'out_of_office' => :'outOfOffice', :'geolocation' => :'geolocation', :'permissions' => :'permissions', :'self_uri' => :'selfUri', :'requested_status' => :'requestedStatus', :'default_station_uri' => :'defaultStationUri', :'station_uri' => :'stationUri', :'last_station_uri' => :'lastStationUri' } end # Attribute type mapping. def self.swagger_types { :'id' => :'String', :'name' => :'String', :'username' => :'String', :'email' => :'String', :'display_name' => :'String', :'phone_number' => :'String', :'user_images' => :'Array', :'chat' => :'Chat', :'roles' => :'Array', :'voicemail_enabled' => :'BOOLEAN', :'department' => :'String', :'title' => :'String', :'routing_status' => :'RoutingStatus', :'password' => :'String', :'primary_presence' => :'UserPresence', :'conversations' => :'UserConversationSummary', :'conversation_summary' => :'UserConversationSummary', :'out_of_office' => :'OutOfOffice', :'geolocation' => :'Geolocation', :'permissions' => :'Array', :'self_uri' => :'String', :'requested_status' => :'UserStatus', :'default_station_uri' => :'String', :'station_uri' => :'String', :'last_station_uri' => :'String' } end def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} if attributes[:'id'] self.id = attributes[:'id'] end if attributes[:'name'] self.name = attributes[:'name'] end if attributes[:'username'] self.username = attributes[:'username'] end if attributes[:'email'] self.email = attributes[:'email'] end if attributes[:'displayName'] self.display_name = attributes[:'displayName'] end if attributes[:'phoneNumber'] self.phone_number = attributes[:'phoneNumber'] end if attributes[:'userImages'] if (value = attributes[:'userImages']).is_a?(Array) self.user_images = value end end if attributes[:'chat'] self.chat = attributes[:'chat'] end if attributes[:'roles'] if (value = attributes[:'roles']).is_a?(Array) self.roles = value end end if attributes[:'voicemailEnabled'] self.voicemail_enabled = attributes[:'voicemailEnabled'] else self.voicemail_enabled = false end if attributes[:'department'] self.department = attributes[:'department'] end if attributes[:'title'] self.title = attributes[:'title'] end if attributes[:'routingStatus'] self.routing_status = attributes[:'routingStatus'] end if attributes[:'password'] self.password = attributes[:'password'] end if attributes[:'primaryPresence'] self.primary_presence = attributes[:'primaryPresence'] end if attributes[:'conversations'] self.conversations = attributes[:'conversations'] end if attributes[:'conversationSummary'] self.conversation_summary = attributes[:'conversationSummary'] end if attributes[:'outOfOffice'] self.out_of_office = attributes[:'outOfOffice'] end if attributes[:'geolocation'] self.geolocation = attributes[:'geolocation'] end if attributes[:'permissions'] if (value = attributes[:'permissions']).is_a?(Array) self.permissions = value end end if attributes[:'selfUri'] self.self_uri = attributes[:'selfUri'] end if attributes[:'requestedStatus'] self.requested_status = attributes[:'requestedStatus'] end if attributes[:'defaultStationUri'] self.default_station_uri = attributes[:'defaultStationUri'] end if attributes[:'stationUri'] self.station_uri = attributes[:'stationUri'] end if attributes[:'lastStationUri'] self.last_station_uri = attributes[:'lastStationUri'] end end # Check equality by comparing each attribute. def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && name == o.name && username == o.username && email == o.email && display_name == o.display_name && phone_number == o.phone_number && user_images == o.user_images && chat == o.chat && roles == o.roles && voicemail_enabled == o.voicemail_enabled && department == o.department && title == o.title && routing_status == o.routing_status && password == o.password && primary_presence == o.primary_presence && conversations == o.conversations && conversation_summary == o.conversation_summary && out_of_office == o.out_of_office && geolocation == o.geolocation && permissions == o.permissions && self_uri == o.self_uri && requested_status == o.requested_status && default_station_uri == o.default_station_uri && station_uri == o.station_uri && last_station_uri == o.last_station_uri end # @see the `==` method def eql?(o) self == o end # Calculate hash code according to all attributes. def hash [id, name, username, email, display_name, phone_number, user_images, chat, roles, voicemail_enabled, department, title, routing_status, password, primary_presence, conversations, conversation_summary, out_of_office, geolocation, permissions, self_uri, requested_status, default_station_uri, station_uri, last_station_uri].hash end # build the object from hash 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 if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) else #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) else # data not found in attributes(hash), not an issue as the data can be optional end end self end 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 =~ /^(true|t|yes|y|1)$/i true else false end 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 _model = Object.const_get("PureCloud").const_get(type).new _model.build_from_hash(value) end end def to_s to_hash.to_s end # to_body is an alias to to_body (backward compatibility)) def to_body to_hash end # return 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 # Method to output non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value 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