Class: Wes::Data::API::User
- Inherits:
-
Object
- Object
- Wes::Data::API::User
show all
- Defined in:
- lib/wes/data/api/user.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
10
11
12
|
# File 'lib/wes/data/api/user.rb', line 10
def initialize(attributes)
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym) ⇒ Object
43
44
45
|
# File 'lib/wes/data/api/user.rb', line 43
def method_missing(method_sym)
attributes.send method_sym
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
8
9
10
|
# File 'lib/wes/data/api/user.rb', line 8
def attributes
@attributes
end
|
Class Method Details
.client ⇒ Object
15
16
17
|
# File 'lib/wes/data/api/user.rb', line 15
def client
Client.new
end
|
.configuration ⇒ Object
19
20
21
|
# File 'lib/wes/data/api/user.rb', line 19
def configuration
Configuration
end
|
.create(id) ⇒ Object
23
24
25
26
|
# File 'lib/wes/data/api/user.rb', line 23
def create(id)
attributes = client.post("#{routes.user}/#{id}", {}).first
new(attributes)
end
|
.find(key, value) ⇒ Object
28
29
30
31
32
|
# File 'lib/wes/data/api/user.rb', line 28
def find(key, value)
attrs = key == :id ? client.get("#{routes.user}/#{value}")
: client.get("#{routes.user}?#{key}=#{value}")
new(attrs.first)
end
|
.routes ⇒ Object
34
35
36
|
# File 'lib/wes/data/api/user.rb', line 34
def routes
configuration.routes
end
|
Instance Method Details
#closed_submissions ⇒ Object
39
40
41
|
# File 'lib/wes/data/api/user.rb', line 39
def closed_submissions
client.get "#{routes.user}/#{id}#{routes.submissions}/closed"
end
|
#open_submissions ⇒ Object
47
48
49
|
# File 'lib/wes/data/api/user.rb', line 47
def open_submissions
client.get("#{routes.user}/#{id}#{routes.submissions}/open")
end
|
#submissions ⇒ Object
51
52
53
|
# File 'lib/wes/data/api/user.rb', line 51
def submissions
client.get("#{routes.user}/#{id}#{routes.submissions}")
end
|
#update(changes) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/wes/data/api/user.rb', line 59
def update(changes)
@attributes = client.put(
"#{routes.user}/#{id}",
@attributes.to_h.merge(changes)
).first
end
|
#videos ⇒ Object
55
56
57
|
# File 'lib/wes/data/api/user.rb', line 55
def videos
client.get("#{routes.user}/#{id}#{routes.videos}")
end
|