class ServiceNow::User
Public Class Methods
find(netid)
click to toggle source
# File lib/classes/user.rb, line 12 def self.find(netid) User.check_configuration query_hash = {} query_hash[:user_name] = netid response = Configuration.get_resource(query_hash = query_hash, table = "sys_user").get() hash = JSON.parse(response, { :symbolize_names => true }) # there should be only one user = User.new(hash[:records][0]) if user.attributes.nil? puts "SN::Alert: No user with netID: #{netid} found" return User.new else user end end
find_by_name(name)
click to toggle source
# File lib/classes/user.rb, line 43 def self.find_by_name(name) User.check_configuration query_hash = {} query_hash[:name] = name response = Configuration.get_resource(query_hash = query_hash, table = "sys_user").get() hash = JSON.parse(response, { :symbolize_names => true }) user = User.new(hash[:records][0]) if user.attributes.nil? puts "SN::Alert: No user with user_name: #{name} found" return User.new else user end end
find_by_sys_id(sys_id)
click to toggle source
# File lib/classes/user.rb, line 28 def self.find_by_sys_id(sys_id) User.check_configuration query_hash = {} query_hash[:sys_id] = sys_id response = Configuration.get_resource(query_hash = query_hash, table = "sys_user").get() hash = JSON.parse(response, { :symbolize_names => true }) user = User.new(hash[:records][0]) if user.attributes.nil? puts "SN::Alert: No user with sys_id: #{sys_id} found" return User.new else user end end
new(attributes = {})
click to toggle source
# File lib/classes/user.rb, line 4 def initialize(attributes = {}) @attributes = attributes end
Private Class Methods
check_configuration()
click to toggle source
# File lib/classes/user.rb, line 64 def self.check_configuration if $root_url.nil? || $username.nil? || $password.nil? raise "SN::Error: You have not configured yet, please run ServiceNow::Configuration.configure() first" end end
Public Instance Methods
attributes()
click to toggle source
# File lib/classes/user.rb, line 8 def attributes @attributes end
method_missing(method, args = nil)
click to toggle source
# File lib/classes/user.rb, line 58 def method_missing(method, args = nil) method_name = method.to_s @attributes[method_name.to_sym] end