Class: Vidsy::Data::API::User

Inherits:
Object
  • Object
show all
Defined in:
lib/vidsy/data/api/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ User

Returns a new instance of User.



8
9
10
# File 'lib/vidsy/data/api/user.rb', line 8

def initialize(id = nil)
  @id = id
end

Class Method Details

.create(options) ⇒ Object



12
13
14
# File 'lib/vidsy/data/api/user.rb', line 12

def self.create(options)
  new.create options
end

.find(id) ⇒ Object



16
17
18
# File 'lib/vidsy/data/api/user.rb', line 16

def self.find(id)
  new.find id
end

.find_by_email(email) ⇒ Object



20
21
22
# File 'lib/vidsy/data/api/user.rb', line 20

def self.find_by_email(email)
  new.find_by_email email
end

Instance Method Details

#closed_submissionsObject

Raises:

  • (ArgumentError)


24
25
26
27
# File 'lib/vidsy/data/api/user.rb', line 24

def closed_submissions
  raise(ArgumentError, "ID not set for User") if id.nil?
  client.get "#{routes.user}/#{id}#{routes.submissions}/closed"
end

#create(options) ⇒ Object



29
30
31
# File 'lib/vidsy/data/api/user.rb', line 29

def create(options)
  client.post(routes.user, options).first
end

#find(id) ⇒ Object



33
34
35
# File 'lib/vidsy/data/api/user.rb', line 33

def find(id)
  client.get("#{routes.user}/#{id}").first
end

#find_by_email(email) ⇒ Object



37
38
39
# File 'lib/vidsy/data/api/user.rb', line 37

def find_by_email(email)
  client.get("#{routes.user}?email=#{email}").first
end

#open_submissionsObject

Raises:

  • (ArgumentError)


41
42
43
44
# File 'lib/vidsy/data/api/user.rb', line 41

def open_submissions
  raise(ArgumentError, "ID not set for User") if id.nil?
  client.get "#{routes.user}/#{id}#{routes.submissions}/open"
end

#submissionsObject

Raises:

  • (ArgumentError)


46
47
48
49
# File 'lib/vidsy/data/api/user.rb', line 46

def submissions
  raise(ArgumentError, "ID not set for User") if id.nil?
  client.get "#{routes.user}/#{id}#{routes.submissions}"
end

#videosObject

Raises:

  • (ArgumentError)


51
52
53
54
# File 'lib/vidsy/data/api/user.rb', line 51

def videos
  raise(ArgumentError, "ID not set for User") if id.nil?
  client.get "#{routes.user}/#{id}#{routes.videos}"
end