Class: UserService
- Inherits:
-
Object
- Object
- UserService
- Defined in:
- lib/services/user_service.rb
Constant Summary collapse
- @@create_user_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users'
- @@create_update_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me'
- @@check_email_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/email'
- @@reset_password_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/reset_password'
- @@change_password_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me/password'
- @@show_logged_in_user_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me'
- @@show_user_id_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/'
Class Method Summary collapse
- .change_password(user, bearer_token) ⇒ Object
- .check_email(user) ⇒ Object
- .create_user(user) ⇒ Object
- .get_user(user) ⇒ Object
- .get_user_with_client_info(user) ⇒ Object
- .reset_password(user) ⇒ Object
- .show_logged_in_user(bearer_token) ⇒ Object
- .show_user_id(user_id, bearer_token) ⇒ Object
- .update_user(user, bearer_token) ⇒ Object
Class Method Details
.change_password(user, bearer_token) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/services/user_service.rb', line 46 def self.change_password(user, bearer_token) user_data = get_user(user) change_password_payload = User.get_payload(user_data) return RestClient::Request.execute(method: :post, url: @@change_password_url, payload: change_password_payload, headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |
.check_email(user) ⇒ Object
33 34 35 36 |
# File 'lib/services/user_service.rb', line 33 def self.check_email(user) return RestClient::Request.execute(method: :get, url: @@check_email_url, headers: {'Content-Type': 'application/json', params: {:email => user.email , :client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret}}) end |
.create_user(user) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/services/user_service.rb', line 18 def self.create_user(user) user_with_client_info = get_user_with_client_info(user) create_user_payload = User.get_payload(user_with_client_info) return RestClient::Request.execute(method: :post, url: @@create_user_url, payload: create_user_payload, headers: {'Content-Type': 'application/json'}) end |
.get_user(user) ⇒ Object
73 74 75 76 77 |
# File 'lib/services/user_service.rb', line 73 def self.get_user(user) user_data = UserBase.new user_data.user = user return user_data end |
.get_user_with_client_info(user) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/services/user_service.rb', line 65 def self.get_user_with_client_info(user) user_with_client_info = ClientInfoBase.new user_with_client_info.client_id = ApplicationConfig.get_client_id user_with_client_info.client_secret = ApplicationConfig.get_client_secret user_with_client_info.user = user return user_with_client_info end |
.reset_password(user) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/services/user_service.rb', line 38 def self.reset_password(user) user_with_client_info = get_user_with_client_info(user) reset_password_payload = User.get_payload(user_with_client_info) return RestClient::Request.execute(method: :post, url: @@reset_password_url, payload: reset_password_payload, headers: {'Content-Type': 'application/json'}) end |
.show_logged_in_user(bearer_token) ⇒ Object
54 55 56 57 |
# File 'lib/services/user_service.rb', line 54 def self.show_logged_in_user(bearer_token) return RestClient::Request.execute(method: :get, url: @@show_logged_in_user_url, headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |
.show_user_id(user_id, bearer_token) ⇒ Object
59 60 61 62 63 |
# File 'lib/services/user_service.rb', line 59 def self.show_user_id(user_id, bearer_token) url_with_id = @@show_user_id_url + "#{user_id}" return RestClient::Request.execute(method: :get, url: url_with_id, headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |
.update_user(user, bearer_token) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/services/user_service.rb', line 25 def self.update_user(user, bearer_token) user_data = get_user(user) update_user_payload = User.get_payload(user_data) return RestClient::Request.execute(method: :put, url: @@create_update_url, payload: update_user_payload, headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |