class Tickethub::User
Public Class Methods
[](attributes)
click to toggle source
# File lib/tickethub/user.rb, line 29 def self.[](attributes) token = if attributes[:email] Tickethub.endpoint['/user/token'].post(grant_type: 'password', username: attributes[:email], password: attributes[:password]) .decoded['access_token'] else attributes[:token].is_a?(String) ? attributes[:token] : attributes[:token][:access_token] end endpoint = Tickethub.endpoint(auth_type: :bearer, password: token)['/user'] self.new endpoint end
create(attributes)
click to toggle source
# File lib/tickethub/user.rb, line 11 def self.create(attributes) response = Tickethub.endpoint['/user'].post(attributes) self[attributes.slice 'email', 'password'] rescue Tickethub::ResourceInvalid => err new nil, Tickethub::Response.new(err.response).decoded end
reset(email)
click to toggle source
# File lib/tickethub/user.rb, line 18 def self.reset(email) Tickethub.endpoint['/user/reset'].post email: email end
verify(attributes)
click to toggle source
# File lib/tickethub/user.rb, line 22 def self.verify(attributes) response = Tickethub.endpoint['/user/verify'].post(attributes) self[email: response.decoded['email'], password: attributes['password']] rescue Tickethub::ResourceInvalid => err new nil, Tickethub::Response.new(err.response).decoded end
Public Instance Methods
full_name()
click to toggle source
# File lib/tickethub/user.rb, line 43 def full_name [first_name, last_name].reject(&:nil?).join ' ' end