Class: Wes::Data::API::Model::Challenge

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

Instance Attribute Summary

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

#exist?, #id, #initialize

Constructor Details

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

Dynamic Method Handling

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

Instance Method Details

#rewardsObject



11
12
13
14
15
16
# File 'lib/wes/data/api/model/challenge.rb', line 11

def rewards
  route = [routes.challenge, id, routes.rewards].join("/")
  map_objects(
    client.get(route), Wes::Data::API::Model::Reward
  )
end

#update(changes) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/wes/data/api/model/challenge.rb', line 27

def update(changes)
  route = [routes.challenge, id].join("/")
  @attributes = client.put(
    route, @attributes.to_h.merge(changes)
  ).first

  self
end

#update_status(s) ⇒ Object



36
37
38
# File 'lib/wes/data/api/model/challenge.rb', line 36

def update_status(s)
  update(:status => s)
end

#users(state = nil) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/wes/data/api/model/challenge.rb', line 18

def users(state = nil)
  route = add_state(
    [routes.challenge, id, routes.creator_users].join("/"), state
  )
  map_objects(
    client.get(route), Wes::Data::API::Model::CreatorUser
  )
end

#videos(state = nil) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/wes/data/api/model/challenge.rb', line 40

def videos(state = nil)
  route = add_state(
    [routes.challenge, id, routes.videos].join("/"), state
  )
  map_objects(
    client.get(route), Wes::Data::API::Model::Video
  )
end