Class: Wes::Data::API::Model::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/wes/data/api/model/video.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

#add_partner_asset(options) ⇒ Object



16
17
18
19
20
# File 'lib/wes/data/api/model/video.rb', line 16

def add_partner_asset(options)
  route = [routes.video, id, routes.partner_asset].join('/')
  attributes = client.post(route, options).first
  attributes.nil? ? nil : Wes::Data::API::Model::VideoPartnerAsset.new(attributes)
end

#creator_userObject



22
23
24
25
26
27
# File 'lib/wes/data/api/model/video.rb', line 22

def creator_user
  route = [routes.video, id, routes.creator_user].join('/')
  attributes = client.get(route).first
  attributes.nil? ? nil
                  : Wes::Data::API::Model::CreatorUser.new(attributes)
end

#current_version(fetch: false) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/wes/data/api/model/video.rb', line 29

def current_version(fetch: false)
  if fetch
    fetch_current_version
  else
    Wes::Data::API::Model::VideoVersion.new(
      @attributes.current_version.first
    )
  end
end

#partner_assets(fetch: false) ⇒ Object



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

def partner_assets(fetch: false)
  return fetch_partner_assets if fetch

  map_objects(
    @attributes.partner_assets,
    Wes::Data::API::Model::VideoPartnerAsset
  )
end

#set_caption(edit) ⇒ Object



48
49
50
# File 'lib/wes/data/api/model/video.rb', line 48

def set_caption(edit)
  update(caption: edit)
end

#set_state(state) ⇒ Object



52
53
54
# File 'lib/wes/data/api/model/video.rb', line 52

def set_state(state)
  update(state: state)
end

#submission(fetch: false) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/wes/data/api/model/video.rb', line 56

def submission(fetch: false)
  if fetch
    fetch_submission
  else
    Wes::Data::API::Model::Submission.new(
      @attributes.submission.first
    )
  end
end

#tagsObject



66
67
68
69
70
71
# File 'lib/wes/data/api/model/video.rb', line 66

def tags
  map_objects(
    fetch_tags,
    Wes::Data::API::Model::TagVideoVersion
  )
end

#transcoding_state(type, fetch = false) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/wes/data/api/model/video.rb', line 73

def transcoding_state(type, fetch = false)
  if fetch
    fetch_transcoding_state(type)
  else
    Wes::Data::API::Model::VideoTranscodingState.new(
      find_transcoding_state(type)
    )
  end
end

#update(changes) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/wes/data/api/model/video.rb', line 83

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

  self
end