wes-data-api 8.1.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f3c87c91ba5ba37afe1d9888b06a6eb627054f3
4
- data.tar.gz: 8a1917e11316cf96427e761fdf83f517bf6aae80
3
+ metadata.gz: de5ad3766b808f03e5c9b09412fb919db6b4e8aa
4
+ data.tar.gz: 2d8de2f18b25de0994efc30934939770b7cb49c3
5
5
  SHA512:
6
- metadata.gz: 3fedf8df17d4e19a1bfdd22fbec21b0f24f3064afd1fe81a1fa6c97674f9980b58ced2b344f19309e142c26274f10f5be994dad9e0523999fb67b0c4bec644e9
7
- data.tar.gz: 3a3e8f57102211c4a46fe18d0b5da01c558220277991f7964a9138bb83003b9cc3b63d7393250c683ad626212e80c2524f745ef0033fec2ffae77e13da5109b9
6
+ metadata.gz: 79c77cbe0becf15e2ffb232e1ccacf82af2c64ea56c711403b93f1e06cc44f2171ebdc1188355ed18b3ff1aa81ea2a17f401fc47ca3c0d0eb2f578b2345e8019
7
+ data.tar.gz: 050640bb1d5b1b6f7a703a36c90cc968b34a703f0056261aafd4c984e9c185a6710b423257481678af2ae3cc6591253c9efec7988abbc3019a6b6cdd7633e824
@@ -5,7 +5,7 @@ require "wes/data/api/configuration"
5
5
  module Wes
6
6
  module Data
7
7
  module API
8
- VERSION = "8.1.0".freeze
8
+ VERSION = "9.0.0".freeze
9
9
  end
10
10
  end
11
11
  end
@@ -2,6 +2,8 @@ require "wes/data/api/model/base"
2
2
  require "wes/data/api/model/creator_user"
3
3
  require "wes/data/api/video_transcoding_state"
4
4
  require "wes/data/api/model/submission"
5
+ require "wes/data/api/model/video_version"
6
+ require "wes/data/api/submission"
5
7
 
6
8
  module Wes
7
9
  module Data
@@ -33,22 +35,61 @@ module Wes
33
35
  end
34
36
 
35
37
  def submission(fetch: false)
36
- record = fetch ? fetch_submission : @attributes.submission
37
- Wes::Data::API::Model::Submission.new(record)
38
+ if fetch
39
+ fetch_submission
40
+ else
41
+ es::Data::API::Model::Submission.new(
42
+ @attributes.submission.first
43
+ )
44
+ end
38
45
  end
39
46
 
40
- def transcoding_state(type)
47
+ def current_version(fetch: false)
48
+ if fetch
49
+ fetch_current_version
50
+ else
51
+ Wes::Data::API::Model::VideoVersion.new(
52
+ @attributes.current_version.first
53
+ )
54
+ end
55
+ end
56
+
57
+ def transcoding_state(type, fetch = false)
58
+ if fetch
59
+ fetch_transcoding_state(type)
60
+ else
61
+ Wes::Data::API::Model::VideoTranscodingState.new(
62
+ find_transcoding_state(type)
63
+ )
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def fetch_current_version
70
+ Wes::Data::API::VideoVersion.current(id)
71
+ end
72
+
73
+ def fetch_submission
74
+ Wes::Data::API::Submission.find(
75
+ :id,
76
+ @attributes.submission_id
77
+ )
78
+ end
79
+
80
+ def fetch_transcoding_state(type)
81
+ return nil unless current_version
41
82
  Wes::Data::API::VideoTranscodingState.find(
42
83
  id,
84
+ current_version.id,
43
85
  type
44
86
  )
45
87
  end
46
88
 
47
- private
48
-
49
- def fetch_submission
50
- route = [routes.submission, id].join("/")
51
- client.get(route).first
89
+ def find_transcoding_state(type)
90
+ @attributes.transcoding_states.find do |state|
91
+ state["type"] == type
92
+ end
52
93
  end
53
94
  end
54
95
  end
@@ -0,0 +1,20 @@
1
+ require "wes/data/api/model/base"
2
+
3
+ module Wes
4
+ module Data
5
+ module API
6
+ module Model
7
+ class VideoVersion < Base
8
+ def update(changes)
9
+ route = [routes.video, @attributes.video_id, routes.version, id].join("/")
10
+ @attributes = client.put(
11
+ route, @attributes.to_h.merge(changes)
12
+ ).first
13
+
14
+ self
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -20,6 +20,7 @@ module Wes
20
20
  :video => "video",
21
21
  :videos => "videos",
22
22
  :transcoding_state => "transcoding-state",
23
+ :version => "version",
23
24
  :questions => "questions",
24
25
  :answers => "answers"
25
26
  )
@@ -8,19 +8,21 @@ module Wes
8
8
  class << self
9
9
  include Base
10
10
 
11
- def find(video_id, type)
12
- attributes = data(video_id, type).first
11
+ def find(video_id, video_version_id, type)
12
+ attributes = data(video_id, video_version_id, type).first
13
13
  attributes.nil? ? nil : model_klass.new(attributes)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def data(video_id, type)
19
- client.get(route(video_id, type))
18
+ def data(video_id, video_version_id, type)
19
+ client.get(
20
+ format("%s?type=%s", route(video_id, video_version_id), type)
21
+ )
20
22
  end
21
23
 
22
- def route(video_id, type)
23
- [routes.video, video_id, routes.transcoding_state, type].join("/")
24
+ def route(video_id, video_version_id)
25
+ [routes.video, video_id, routes.version, video_version_id, routes.transcoding_state].join("/")
24
26
  end
25
27
 
26
28
  def model_klass
@@ -0,0 +1,39 @@
1
+ require "wes/data/api/base"
2
+ require "wes/data/api/model/video"
3
+
4
+ module Wes
5
+ module Data
6
+ module API
7
+ class VideoVersion
8
+ class << self
9
+ include Base
10
+
11
+ def create(video_id, options)
12
+ attributes = client.post(route(video_id), options).first
13
+ attributes.nil? ? nil : model_klass.new(attributes)
14
+ end
15
+
16
+ def find(video_id, key)
17
+ route = format("%s/%s", route(video_id), key)
18
+ attributes = client.get(route).first
19
+ attributes.nil? ? nil : model_klass.new(attributes)
20
+ end
21
+
22
+ def current(video_id)
23
+ find(video_id, "latest")
24
+ end
25
+
26
+ private
27
+
28
+ def route(video_id)
29
+ [routes.video, video_id, routes.version].join("/")
30
+ end
31
+
32
+ def model_klass
33
+ Wes::Data::API::Model::VideoVersion
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wes-data-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,6 +139,7 @@ files:
139
139
  - lib/wes/data/api/model/submission.rb
140
140
  - lib/wes/data/api/model/video.rb
141
141
  - lib/wes/data/api/model/video_transcoding_state.rb
142
+ - lib/wes/data/api/model/video_version.rb
142
143
  - lib/wes/data/api/request.rb
143
144
  - lib/wes/data/api/response.rb
144
145
  - lib/wes/data/api/reward.rb
@@ -146,6 +147,7 @@ files:
146
147
  - lib/wes/data/api/submission.rb
147
148
  - lib/wes/data/api/video.rb
148
149
  - lib/wes/data/api/video_transcoding_state.rb
150
+ - lib/wes/data/api/video_version.rb
149
151
  - wes-data-api.gemspec
150
152
  homepage: ''
151
153
  licenses: []