Class: Wes::Data::API::Model::CreatorUser

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

Instance Attribute Summary

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods inherited from Base

#exist?, #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

#assign_collectives(collective_ids) ⇒ Object



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

def assign_collectives(collective_ids)
  validate_collectives(collective_ids)
  records = create_collectives(collective_ids)
  map_objects(records, Wes::Data::API::Model::Collective)
end

#submissions(state: nil, fetch: false) ⇒ Object



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

def submissions(state: nil, fetch: false)
  records = fetch || !state.nil? ? fetch_submissions(state)
                                 : @attributes.submissions
  map_objects(
    records, Wes::Data::API::Model::Submission
  )
end

#update(changes) ⇒ Object



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

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

  self
end

#videos(fetch: false) ⇒ Object



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

def videos(fetch: false)
  records = fetch ? fetch_videos : @attributes.videos
  map_objects(
    records, Wes::Data::API::Model::Video
  )
end