Class: Wes::Data::API::User

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

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, configuration, #exist?, #initialize, mapped_objects, #method_missing, routes

Constructor Details

This class inherits a constructor from Wes::Data::API::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wes::Data::API::Base

Class Method Details

.allObject



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

def all
  mapped_objects(routes.users)
end

.create(id) ⇒ Object



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

def create(id)
  super("#{routes.user}/#{id}")
end

.find(key, value) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/wes/data/api/user.rb', line 16

def find(key, value)
  case key
  when :id
    super("#{routes.user}/#{value}")
  else
    super("#{routes.user}?#{key}=#{value}")
  end
end

Instance Method Details

#assign_collectives(collective_ids) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wes/data/api/user.rb', line 46

def assign_collectives(collective_ids)
  unless collective_ids.kind_of?(Array)
    raise ArgumentError, "List of collective ids must be an array"
  end

  if collective_ids.empty?
    raise StandardError, "At least one collective_id must be specified"
  end

  client.post(
    [routes.user, id, "collectives"].join("/"),
    collective_ids
  )
end

#closed_submissionsObject



26
27
28
# File 'lib/wes/data/api/user.rb', line 26

def closed_submissions
  mapped_objects("#{routes.user}/#{id}#{routes.submissions}/closed")
end

#open_submissionsObject



30
31
32
# File 'lib/wes/data/api/user.rb', line 30

def open_submissions
  mapped_objects("#{routes.user}/#{id}#{routes.submissions}/open")
end

#submissionsObject



34
35
36
# File 'lib/wes/data/api/user.rb', line 34

def submissions
  mapped_objects("#{routes.user}/#{id}#{routes.submissions}")
end

#update(changes) ⇒ Object



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

def update(changes)
  super("#{routes.user}/#{id}", changes)
end

#videosObject



38
39
40
# File 'lib/wes/data/api/user.rb', line 38

def videos
  mapped_objects("#{routes.user}/#{id}#{routes.videos}")
end