Module: CASClient::UserAPI

Included in:
User
Defined in:
lib/cas_client/user_api.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/cas_client/user_api.rb', line 8

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#cas_createObject



92
93
94
95
96
# File 'lib/cas_client/user_api.rb', line 92

def cas_create
  url = URI.parse("#{::CAS_SERVER["internal_cas_domain"]}/api/users")
  res = handle_response(make_request(url, Net::HTTP::Post.new(url.path)))
  Yajl::Parser.new(:symbolize_keys => true).parse(res.body)
end

#cas_passwordObject



80
81
82
# File 'lib/cas_client/user_api.rb', line 80

def cas_password
  @cas_password
end

#cas_password=(_password) ⇒ Object



76
77
78
# File 'lib/cas_client/user_api.rb', line 76

def cas_password=(_password)
  @cas_password = _password
end

#cas_password_confirmationObject



88
89
90
# File 'lib/cas_client/user_api.rb', line 88

def cas_password_confirmation
  @cas_password_confirmation
end

#cas_password_confirmation=(_password_confirmation) ⇒ Object



84
85
86
# File 'lib/cas_client/user_api.rb', line 84

def cas_password_confirmation=(_password_confirmation)
  @cas_password_confirmation = _password_confirmation
end

#cas_reset_passwordObject



115
116
117
118
# File 'lib/cas_client/user_api.rb', line 115

def cas_reset_password
  res = fetch("#{::CAS_SERVER["internal_cas_domain"]}/api/users/#{CGI.escape(self.send(self.class.cas_map[:uuid]))}/reset_password")
  res.body
end

#cas_retrieve_attributesObject



110
111
112
113
# File 'lib/cas_client/user_api.rb', line 110

def cas_retrieve_attributes
  res = fetch("#{::CAS_SERVER["internal_cas_domain"]}/api/users/#{CGI.escape(self.send(self.class.cas_map[:uuid]))}")
  Yajl::Parser.new(:symbolize_keys => true).parse(res.body)
end

#cas_update_attributesObject



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/cas_client/user_api.rb', line 98

def cas_update_attributes
  if self.changes.keys.include?(self.class.cas_map[:uuid].to_s)
    _user_identifier = self.changes[self.class.cas_map[:uuid].to_s].first
  else
    _user_identifier = self.send(self.class.cas_map[:uuid])
  end
  uri_string = "#{::CAS_SERVER["internal_cas_domain"]}/api/users/#{CGI.escape(_user_identifier)}"
  url = URI.parse(uri_string)
  res = handle_response(make_request(url, Net::HTTP::Put.new(url.path)))
  Yajl::Parser.new(:symbolize_keys => true).parse(res.body)
end