Class: Tickethub::User
Defined Under Namespace
Classes: Supplier
Instance Attribute Summary
Attributes inherited from Resource
#endpoint
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
#==, #[], #[]=, all, association, attribute, attributes, call, collection, collection_method, collection_methods, descendants, #destroy, dump_value, #eql?, #errors, #hash, inherited, #initialize, #inspect, #load, load_value, path, polymorphic, register_type, registered_types, #reload!, #respond_to?, scope, scopes, serialize, singleton?, #to_h, #to_param, #to_s, #update, #valid?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Tickethub::Resource
Class Method Details
.[](attributes) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# 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) ⇒ Object
.reset(email) ⇒ Object
18
19
20
|
# File 'lib/tickethub/user.rb', line 18
def self.reset(email)
Tickethub.endpoint['/user/reset'].post email: email
end
|
.verify(attributes) ⇒ Object
Instance Method Details
#full_name ⇒ Object
43
44
45
|
# File 'lib/tickethub/user.rb', line 43
def full_name
[first_name, last_name].reject(&:nil?).join ' '
end
|