Class: Rallio::User
Overview
Represents a user object as it comes from Rallio.
Instance Attribute Summary collapse
-
#access_token ⇒ Rallio::AccessToken
Creates or returns the API access token for user.
-
#accounts ⇒ Array<Rallio::Account>
Accounts user has access to.
-
#email ⇒ String
User email.
-
#first_name ⇒ String
User first name.
-
#franchisors ⇒ Array<Rallio::Franchisor>
Franchisors user has access to.
-
#id ⇒ Integer
Unique id for user.
-
#last_name ⇒ String
User last name.
-
#name ⇒ String
Full name if available.
Class Method Summary collapse
-
.accessible_users ⇒ Array<Rallio::User>
Lists accessible users on Rallio’s platform for application.
-
.create(user:) ⇒ Rallio::User
Create a user on the Rallio platform.
Instance Method Summary collapse
-
#account_ownerships ⇒ Array<Rallio::AccountOwnership>
Retreives account ownerships for user.
-
#dashboard ⇒ Rallio::User
Retreives current data for user.
-
#franchisor_ownerships ⇒ Array<Rallio::FranchisorOwnership>
Retreives franchisor ownerships for user.
-
#sign_on_token(params: {}) ⇒ Rallio::SignOnToken
Creates new single signon for user to be redirected to.
Methods inherited from Base
Instance Attribute Details
#access_token ⇒ Rallio::AccessToken
Creates or returns the API access token for user. NOTE: These tokens do not expire so it is suggested (recommended) that the token be cached and reused whenever possible.
67 68 69 |
# File 'lib/rallio/user.rb', line 67 def access_token @access_token ||= AccessToken.create(user_id: id) end |
#accounts ⇒ Array<Rallio::Account>
Returns accounts user has access to.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
#email ⇒ String
Returns user email.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
#first_name ⇒ String
Returns user first name.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
#franchisors ⇒ Array<Rallio::Franchisor>
Returns franchisors user has access to.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
#id ⇒ Integer
Returns unique id for user.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
#last_name ⇒ String
Returns user last name.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
#name ⇒ String
Returns full name if available.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rallio/user.rb', line 18 class User < Base attribute :id, Integer attribute :email, String attribute :first_name, String attribute :last_name, String attribute :name, String attribute :accounts, Array[Account] attribute :franchisors, Array[Franchisor] attr_writer :access_token # Lists accessible users on Rallio's platform for application. # # @return [Array<Rallio::User>] array of users accessible to application def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end # Create a user on the Rallio platform. # # @param user [Hash] user info used to create new user # @option user [String] :email unique email address # @option user [String] :first_name # @option user [String] :last_name # @return [Rallio::User] user object that was just created def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end # Creates new single signon for user to be redirected to. # @see Rallio::SignOnToken # # @param params [Hash] optional uri params sent with request # @option params [String] :connect_account_id account id to display social # connections for # @return [Rallio::SignOnToken] def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end # Creates or returns the API access token for user. # @see Rallio::AccessToken # # NOTE: These tokens do not expire so it is suggested (recommended) that the # token be cached and reused whenever possible. # # @return [Rallio::AccessToken] def access_token @access_token ||= AccessToken.create(user_id: id) end # Retreives account ownerships for user. # @see Rallio::AccountOwnership # # @return [Array<Rallio::AccountOwnership>] array of user's account ownerships def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end # Retreives franchisor ownerships for user. # @see Rallio::FranchisorOwnership # # @return [Array<Rallio::FranchisorOwnership>] array of user's franchisor ownerships def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end # Retreives current data for user. # # @return [Rallio::User] def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end private def user_credentials { 'Authorization' => "Bearer #{access_token.access_token}" } end end |
Class Method Details
.accessible_users ⇒ Array<Rallio::User>
Lists accessible users on Rallio’s platform for application.
32 33 34 35 |
# File 'lib/rallio/user.rb', line 32 def self.accessible_users response = self.get('/accessible_users', headers: app_credentials) response.parsed_response['users'].map { |u| new u } end |
.create(user:) ⇒ Rallio::User
Create a user on the Rallio platform.
44 45 46 47 |
# File 'lib/rallio/user.rb', line 44 def self.create(user:) response = self.post('/users', headers: app_credentials, body: { user: user }) new response.parsed_response['user'] end |
Instance Method Details
#account_ownerships ⇒ Array<Rallio::AccountOwnership>
Retreives account ownerships for user.
75 76 77 |
# File 'lib/rallio/user.rb', line 75 def account_ownerships AccountOwnership.for(access_token: access_token.access_token) end |
#dashboard ⇒ Rallio::User
Retreives current data for user.
90 91 92 93 94 95 96 |
# File 'lib/rallio/user.rb', line 90 def dashboard response = self.class.get('/dashboard', headers: user_credentials) self.attributes = response.parsed_response['me'] self.accounts = response.parsed_response['accounts'] self.franchisors = response.parsed_response['franchisors'] self end |
#franchisor_ownerships ⇒ Array<Rallio::FranchisorOwnership>
Retreives franchisor ownerships for user.
83 84 85 |
# File 'lib/rallio/user.rb', line 83 def franchisor_ownerships FranchisorOwnership.for(access_token: access_token.access_token) end |
#sign_on_token(params: {}) ⇒ Rallio::SignOnToken
Creates new single signon for user to be redirected to.
56 57 58 |
# File 'lib/rallio/user.rb', line 56 def sign_on_token(params: {}) SignOnToken.create(user_id: id, params: params) end |