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

#create(options) ⇒ Object



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

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

#find(id) ⇒ Object



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

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

#find_by_email(email) ⇒ Object



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

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

#videosObject

Raises:

  • (ArgumentError)


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

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