Module: Users
Instance Method Summary collapse
-
#get_accomplishments(id) ⇒ HTTParty::Response
Get user accomplishments.
-
#get_availability(id) ⇒ HTTParty::Response
Get user availability.
-
#get_available_mentors ⇒ User
Get available mentors for a user.
-
#get_enrollments(id) ⇒ HTTParty::Response
Get user enrollments.
-
#get_me ⇒ User
Get your own user.
-
#get_user(id) ⇒ User
Get all user.
-
#get_users ⇒ HTTParty::Response
Get all users.
-
#onboard(id) ⇒ HTTParty::Response
Mark user’s current enrollment as onboarded.
-
#update_password(id, password) ⇒ User
Update the user’s password.
-
#update_user(id, options = {}) ⇒ User
Update a user.
Methods included from BaseClient
#auth_header, #convert_keys, #convert_response, #handle_timeouts, #success?, #whitelist_params
Instance Method Details
#get_accomplishments(id) ⇒ HTTParty::Response
Get user accomplishments
93 94 95 96 97 98 |
# File 'lib/client/users.rb', line 93 def get_accomplishments(id) url = "#{@api_base_path}/users/#{id}/accomplishments" handle_timeouts do self.class.get(url, headers: auth_header) end end |
#get_availability(id) ⇒ HTTParty::Response
Get user availability
66 67 68 69 70 71 72 |
# File 'lib/client/users.rb', line 66 def get_availability(id) url = "#{@api_base_path}/users/#{id}/availability" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "availability") end end |
#get_available_mentors ⇒ User
Get available mentors for a user
52 53 54 55 56 57 58 |
# File 'lib/client/users.rb', line 52 def get_available_mentors url = "#{@api_base_path}/users/available_mentors" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "user") end end |
#get_enrollments(id) ⇒ HTTParty::Response
Get user enrollments
80 81 82 83 84 85 |
# File 'lib/client/users.rb', line 80 def get_enrollments(id) url = "#{@api_base_path}/users/#{id}/enrollments" handle_timeouts do self.class.get(url, headers: auth_header) end end |
#get_me ⇒ User
Get your own user
24 25 26 27 28 29 30 |
# File 'lib/client/users.rb', line 24 def get_me url = "#{@api_base_path}/users/me" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "user") end end |
#get_user(id) ⇒ User
Get all user
38 39 40 41 42 43 44 |
# File 'lib/client/users.rb', line 38 def get_user(id) url = "#{@api_base_path}/users/#{id}" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "user") end end |
#get_users ⇒ HTTParty::Response
Get all users
11 12 13 14 15 16 17 |
# File 'lib/client/users.rb', line 11 def get_users url = "#{@api_base_path}/users" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "user") end end |
#onboard(id) ⇒ HTTParty::Response
Mark user’s current enrollment as onboarded
106 107 108 109 110 111 |
# File 'lib/client/users.rb', line 106 def onboard(id) url = "#{@api_base_path}/users/#{id}/onboard" handle_timeouts do self.class.post(url, headers: auth_header) end end |
#update_password(id, password) ⇒ User
Update the user’s password
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/client/users.rb', line 120 def update_password(id, password) url = "#{@api_base_path}/users/#{id}/update_password" handle_timeouts do response = self.class.put(url, headers: auth_header, body: { user: { password: password, confirmation: password } }) convert_response(response, "user") end end |
#update_user(id, options = {}) ⇒ User
Update a user
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/client/users.rb', line 175 def update_user(id, ={}) whitelist = ['email','first_name','last_name','twitter_handle', 'dribbble_handle','github_handle','codecademy_handle', 'linkedin','time_zone','bio','name','photo','os', 'dismissed_holiday_freeze','title','lead_mentor_account', 'password','password_confirmation','remember_me','facebook_id', 'stripe_customer_id','stripe_token','skype_handle', 'referral_token','send_new_message_emails','referred_by_id', 'google_plus_id','private_profile','quota','quota_limit', 'first_visit_id','crm_lead_id','phone_num','role', 'student_profile','tos'] = convert_keys() user_params = whitelist_params(, whitelist) url = "#{@api_base_path}/users/#{id}" handle_timeouts do response = self.class.put(url, headers: auth_header, body: { user: user_params }) convert_response(response, "User") end end |