vzaar 1.0.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzdkYjI2M2RlM2VhMjIxNGNmMDVhMzM2MjQ5NDI3ZDg2NTU0ZjU4Ng==
5
- data.tar.gz: !binary |-
6
- NmZjYjI4OWI4OTQ3NWFjYmQ4YzM0ODMzZDA3OWYyNWIyODBiNGJlMg==
2
+ SHA1:
3
+ metadata.gz: cd706c9dfeffddadb3e72aba97a5919ce112f1b5
4
+ data.tar.gz: 31b3f768cc98ce03cea3c5d2b9a45a74603a6479
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MmU1MmQ0ZTkyNzNmZTY3Nzc3YTkyODNiZTFmNjI2MzIwZWU3MGE5Mjg0YWU5
10
- MGVkZTE5Y2U0MmE0MDFiZWY1YmE5OTU5MzgxMTIzYTY4Y2U0OWEyMTM0MDFl
11
- N2YyNjM5YzgzZDBiZmVhZDM3OThiYzQ5MjhiMjAzMWQ4ODQ2NWY=
12
- data.tar.gz: !binary |-
13
- OTcxMmU2M2E5Mjk0NTQyOGVlNmNlNTAwZjUzMzcwZDNiZDQ0MjVhM2M4OWRk
14
- YTcwNjI5ZTQ4ZWI1YzcwZDc2ZTlmYmJiYzVlOTMxNjFlYjNlNzJkNzU1MDE4
15
- ZDViMzgxNDEyYWMxN2RhNGRmNDRiMmFmODc0MDBmYzdlOTU2Y2U=
6
+ metadata.gz: f5352345e8a8536de21eb1a8ed480c2dea5433431decb1f8abb82198ef165e02ffa27c6d92df224047a4ac39823e35ca4b233ce1db198efeb601d26bacfda9c3
7
+ data.tar.gz: 819a3b0655698054a67817815596df29b1a6e1229dd6b4ba5f5ef1d41035c8b35c3eb84b9b1f650835cda4342ed3bcfde8002bf9b53b4b95da7a238b0dd2408e
data/.gitignore CHANGED
@@ -22,3 +22,5 @@ load.rb
22
22
  *\#
23
23
  *.mp4
24
24
  test.rb
25
+ .tags
26
+ .gemtags
data/README.md CHANGED
@@ -79,7 +79,7 @@ api.upload_video(options)
79
79
  # options are: path, url, title, description, profile, transcoding, replace_id,
80
80
  # width and bitrate
81
81
  #
82
- # e.g api.upload(path: "./path/to/video.mp4", title: "my video")
82
+ # api.upload(path: "./path/to/video.mp4", title: "my video")
83
83
  #
84
84
  # For link upload use url param:
85
85
  # api.upload_video(url: "http://example.com/video.mp4", title: "my video")
@@ -87,9 +87,23 @@ api.upload_video(options)
87
87
 
88
88
  Uploading new thumbnail for video (authentication required):
89
89
  ```ruby
90
- api.upload_thumbnail(video_id, opts={})
90
+ api.upload_thumbnail(video_id, options)
91
91
 
92
- # e.g api.upload_thumbnail(123456, path: "/path/to/image.jpg")
92
+ # api.upload_thumbnail(123456, path: "/path/to/image.jpg")
93
+ ```
94
+
95
+ Generating new thumbnail based on given time value (authentication required):
96
+ ```ruby
97
+ api.generate_thumbnail(video_id, options)
98
+
99
+ # api.generate_thumbnail(123456, time: 3)
100
+ ```
101
+
102
+ Adding subtitle to the video (authentication required):
103
+ ```ruby
104
+ api.add_subtitle(video_id, options)
105
+
106
+ # api.add_subtitle(123456, body: "1\n00:00:17,440 --> 00:01:20,375\n ......", language: "en")
93
107
  ```
94
108
 
95
109
  Getting guid and aws signature (authentication required):
data/lib/vzaar/api.rb CHANGED
@@ -50,10 +50,18 @@ module Vzaar
50
50
  end
51
51
  end
52
52
 
53
+ def add_subtitle(video_id, opts={})
54
+ Request::AddSubtitle.new(conn, opts.merge(video_id: video_id)).execute
55
+ end
56
+
53
57
  def upload_thumbnail(video_id, opts={})
54
58
  Request::UploadThumbnail.new(conn, opts.merge(video_id: video_id)).execute
55
59
  end
56
60
 
61
+ def generate_thumbnail(video_id, opts={})
62
+ Request::GenerateThumbnail.new(conn, opts.merge(video_id: video_id)).execute
63
+ end
64
+
57
65
  def link_upload(url, opts={})
58
66
  sig = signature
59
67
  _opts = opts.merge({ guid: sig.guid, key: sig.key, url: url })
@@ -2,7 +2,7 @@ module Vzaar
2
2
  class Connection
3
3
  include Vzaar::Helper
4
4
 
5
- SERVER = "vzaar.com".freeze
5
+ SERVER = "vzaar.com"
6
6
  attr_reader :application_token, :force_http, :login, :options
7
7
 
8
8
  def initialize(options)
@@ -0,0 +1,27 @@
1
+ module Vzaar
2
+ module Request
3
+ class AddSubtitle < Base
4
+ endpoint "/api/subtitle/upload"
5
+ resource "Status"
6
+ http_verb :post
7
+ authenticated true
8
+
9
+ def xml_body
10
+ <<-XML
11
+ <?xml version="1.0" encoding="UTF-8"?>#{hash_to_xml(json_body)}
12
+ XML
13
+ end
14
+
15
+ def json_body
16
+ { "vzaar-api" => {
17
+ "subtitle" => {
18
+ "language" => options[:language],
19
+ "video_id" => options[:video_id],
20
+ "body" => options[:body]
21
+ }
22
+ }
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -4,7 +4,7 @@ module Vzaar
4
4
  include Vzaar::Helper
5
5
 
6
6
  class << self
7
- [:authenticated, :http_verb, :format].each do |method_name|
7
+ [:authenticated, :http_verb].each do |method_name|
8
8
  define_method(method_name) do |val|
9
9
  define_method(method_name) do
10
10
  val.nil? ? self.options[method_name] : val
@@ -19,6 +19,13 @@ module Vzaar
19
19
  def resource(name)
20
20
  define_method(:resource) { name }
21
21
  end
22
+
23
+ def format(f)
24
+ define_method(:format) do
25
+ # JC: options should always overwrite format param
26
+ self.options[:format] ? self.options[:format] : f
27
+ end
28
+ end
22
29
  end
23
30
 
24
31
  authenticated nil
@@ -27,7 +34,12 @@ module Vzaar
27
34
 
28
35
  def execute
29
36
  conn.using_connection(url, user_options) do |res|
30
- return resource_klass.new(Response::Base.new(res).body, res.code)
37
+ _res = Response::Base.new(res)
38
+ if _res.json?
39
+ return _res.body
40
+ else
41
+ return resource_klass.new(_res.body, res.code)
42
+ end
31
43
  end
32
44
  end
33
45
 
@@ -0,0 +1,20 @@
1
+ module Vzaar
2
+ module Request
3
+ class GenerateThumbnail < Video
4
+ endpoint { |o| "/api/videos/#{o.video_id}/generate_thumb" }
5
+ authenticated true
6
+ http_verb :post
7
+ resource "Status"
8
+
9
+ def xml_body
10
+ <<-XML
11
+ <?xml version="1.0" encoding="UTF-8"?>#{hash_to_xml(json_body)}
12
+ XML
13
+ end
14
+
15
+ def json_body
16
+ { "vzaar-api" => { "video" => { "thumb_time" => options[:time] }}}
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,4 @@
1
+ require "pry"
1
2
  module Vzaar
2
3
  module Request
3
4
  class LinkUpload < Base
@@ -8,26 +9,29 @@ module Vzaar
8
9
 
9
10
  def xml_body
10
11
  <<-XML
11
- <?xml version="1.0" encoding="UTF-8"?>
12
- <vzaar-api>
13
- <link_upload>
14
- <key>#{options[:key]}</key>
15
- <guid>#{options[:guid]}</guid>
16
- <url>#{options[:url]}</url>
17
- <encoding_params>
18
- <title>#{options[:title]}</title>
19
- <description>#{options[:description]}</description>
20
- <profile>#{options[:profile]}</profile>
21
- <bitrate>#{options[:bitrate]}</bitrate>
22
- <width>#{options[:width]}</width>
23
- <replace_id>#{options[:replace_id]}</replace_id>
24
- <transcoding>#{options[:transcoding]}</transcoding>
25
- </encoding_params>
26
- </link_upload>
27
- </vzaar-api>
12
+ <?xml version="1.0" encoding="UTF-8"?>#{hash_to_xml(json_body)}
28
13
  XML
29
14
  end
30
15
 
16
+ def json_body
17
+ { "vzaar-api" => {
18
+ link_upload: {
19
+ key: options[:key],
20
+ guid: options[:guid],
21
+ url: options[:url],
22
+ encoding_params: {
23
+ title: options[:title],
24
+ description: options[:description],
25
+ size_id: options[:profile],
26
+ bitrate: options[:bitrate],
27
+ width: options[:width],
28
+ replace_id: options[:replace_id],
29
+ transcoding: options[:transcoding]
30
+ }
31
+ }
32
+ }
33
+ }
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -1,7 +1,7 @@
1
1
  module Vzaar
2
2
  module Request
3
3
  class Multipart < Struct.new(:path, :file)
4
- CRLF = "\r\n".freeze
4
+ CRLF = "\r\n"
5
5
 
6
6
  def request
7
7
  req = Net::HTTP::Post.new(path)
@@ -1,10 +1,7 @@
1
1
  module Vzaar
2
2
  module Request
3
- class UploadThumbnail < Video
3
+ class UploadThumbnail < GenerateThumbnail
4
4
  endpoint { |o| "/api/videos/#{o.video_id}/upload_thumb" }
5
- authenticated true
6
- http_verb :post
7
- resource "UploadThumbnail"
8
5
 
9
6
  def data
10
7
  { file: File.open(options[:path]) }
@@ -3,6 +3,7 @@ module Vzaar
3
3
  class LinkUpload < Base
4
4
  root_node "//vzaar-api"
5
5
  attribute :id, type: Integer
6
+ attribute :error
6
7
  end
7
8
  end
8
9
  end
@@ -0,0 +1,8 @@
1
+ module Vzaar
2
+ module Resource
3
+ class Status < Base
4
+ root_node "//vzaar-api"
5
+ attribute :status
6
+ end
7
+ end
8
+ end
data/lib/vzaar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vzaar
2
- VERSION = "1.0.0"
2
+ VERSION = "1.2.2"
3
3
  end
data/lib/vzaar.rb CHANGED
@@ -13,6 +13,13 @@ module Vzaar
13
13
  end
14
14
  h
15
15
  end
16
+
17
+ def hash_to_xml(h)
18
+ h.map do |k, v|
19
+ text = Hash === v ? hash_to_xml(v) : v
20
+ "<%s>%s</%s>" % [k, text, k]
21
+ end.join
22
+ end
16
23
  end
17
24
 
18
25
  class Error < StandardError; end
@@ -46,6 +53,7 @@ require 'vzaar/resources/processed_video'
46
53
  require 'vzaar/resources/who_am_i'
47
54
  require 'vzaar/resources/link_upload'
48
55
  require 'vzaar/resources/upload_thumbnail'
56
+ require 'vzaar/resources/status'
49
57
 
50
58
  # request
51
59
 
@@ -58,7 +66,10 @@ require 'vzaar/request/video_list'
58
66
  require 'vzaar/request/delete_video'
59
67
  require 'vzaar/request/upload_status'
60
68
  require 'vzaar/request/link_upload'
69
+ require 'vzaar/request/generate_thumbnail'
61
70
  require 'vzaar/request/upload_thumbnail'
71
+ require 'vzaar/request/add_subtitle'
72
+
62
73
 
63
74
  require 'vzaar/uploader'
64
75
 
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://vzaar.com/api/subtitle/upload.xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: |2
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <vzaar-api>
11
+ <subtitle>
12
+ <language>en</language>
13
+ <video_id>1519682</video_id>
14
+ <body>SRT api</body>
15
+ </subtitle>
16
+ </vzaar-api>
17
+ headers:
18
+ Content-Type:
19
+ - application/xml
20
+ Accept-Encoding:
21
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
22
+ Accept:
23
+ - "*/*"
24
+ User-Agent:
25
+ - OAuth gem v0.4.7
26
+ Content-Length:
27
+ - '257'
28
+ Authorization:
29
+ - OAuth oauth_body_hash="PvzgbGOols7jqFA83XETMFVwCl8%3D", oauth_nonce="DaCXigQHPZ8IMZzdCM2MsAKKtH3jjJIpdIKcu5jELU",
30
+ oauth_signature="JPtmK%2BkCwaNLOfiMG5ZCOtZNZHA%3D", oauth_signature_method="HMAC-SHA1",
31
+ oauth_timestamp="1401110294", oauth_token="vz-test1", oauth_version="1.0"
32
+ response:
33
+ status:
34
+ code: 422
35
+ message: ''
36
+ headers:
37
+ Cache-Control:
38
+ - no-cache
39
+ Content-Type:
40
+ - application/xml; charset=utf-8
41
+ Date:
42
+ - Mon, 26 May 2014 13:18:15 GMT
43
+ P3p:
44
+ - CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
45
+ Server:
46
+ - nginx
47
+ Set-Cookie:
48
+ - _vzaar_session_id=BAh7BzoPc2Vzc2lvbl9pZCIlZGY3NGI1ZTAwMjk0ZjY0MjM0MDAxOWExYTFiMjkwNDM6Em9hdXRoX3VzZXJfaWRpAzuhAQ%3D%3D--14d927ccb22d33d4a277f392dd368265680c9f84;
49
+ path=/; expires=Wed, 25-Jun-2014 13:18:14 GMT; HttpOnly
50
+ X-Runtime:
51
+ - '107'
52
+ Content-Length:
53
+ - '147'
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: UTF-8
58
+ string: '<?xml version="1.0" encoding="utf-8"?><vzaar-api><status>Failure</status><errors><user>Permission
59
+ Denied: 106811/101210</user></errors></vzaar-api>'
60
+ http_version:
61
+ recorded_at: Mon, 26 May 2014 13:18:15 GMT
62
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,61 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://vzaar.com/api/subtitle/upload.xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: |2
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <vzaar-api>
11
+ <subtitle>
12
+ <language>en</language>
13
+ <video_id>1627985</video_id>
14
+ <body>SRT api</body>
15
+ </subtitle>
16
+ </vzaar-api>
17
+ headers:
18
+ Content-Type:
19
+ - application/xml
20
+ Accept-Encoding:
21
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
22
+ Accept:
23
+ - "*/*"
24
+ User-Agent:
25
+ - OAuth gem v0.4.7
26
+ Content-Length:
27
+ - '257'
28
+ Authorization:
29
+ - OAuth oauth_body_hash="xibTQvtRg%2B8j%2BF2FAJY%2FwqIZJEI%3D", oauth_nonce="G5JHy8yyYnAOY7PBA7iBAFhdAIjX7v1uQqVwDQt2R4",
30
+ oauth_signature="pH2Gy%2B3o8ofpL46s30YbEsHuz7s%3D", oauth_signature_method="HMAC-SHA1",
31
+ oauth_timestamp="1401110291", oauth_token="vz-test1", oauth_version="1.0"
32
+ response:
33
+ status:
34
+ code: 202
35
+ message: Accepted
36
+ headers:
37
+ Cache-Control:
38
+ - no-cache
39
+ Content-Type:
40
+ - application/xml; charset=utf-8
41
+ Date:
42
+ - Mon, 26 May 2014 13:18:14 GMT
43
+ P3p:
44
+ - CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
45
+ Server:
46
+ - nginx
47
+ Set-Cookie:
48
+ - _vzaar_session_id=BAh7BzoPc2Vzc2lvbl9pZCIlYmE1MjhiNTgzN2NlMjM3ZTliNjkyYzI3M2M1NGE1Y2U6Em9hdXRoX3VzZXJfaWRpAzuhAQ%3D%3D--fe3ceef10677aef3fb8fcae522472b26f4c4e5f4;
49
+ path=/; expires=Wed, 25-Jun-2014 13:18:13 GMT; HttpOnly
50
+ X-Runtime:
51
+ - '1980'
52
+ Content-Length:
53
+ - '86'
54
+ Connection:
55
+ - keep-alive
56
+ body:
57
+ encoding: UTF-8
58
+ string: <?xml version="1.0" encoding="utf-8"?><vzaar-api><status>Accepted</status></vzaar-api>
59
+ http_version:
60
+ recorded_at: Mon, 26 May 2014 13:18:14 GMT
61
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://vzaar.com/api/videos/1519682/generate_thumb.xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: |2
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <vzaar-api>
11
+ <video>
12
+ <thumb_time>3</thumb_time>
13
+ </video>
14
+ </vzaar-api>
15
+ headers:
16
+ Content-Type:
17
+ - application/xml
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ User-Agent:
23
+ - OAuth gem v0.4.7
24
+ Content-Length:
25
+ - '176'
26
+ Authorization:
27
+ - OAuth oauth_body_hash="G%2FOl0Dp0PLu5u9b9YdmYz4d2ZBs%3D", oauth_nonce="9RN0RM791Q5yvSuqbT1I1sAG2N3jVTQUtzUJ6pBKY",
28
+ oauth_signature="A4M0VOyZt6EtUD0nWjbzsA%2FNYCI%3D", oauth_signature_method="HMAC-SHA1",
29
+ oauth_timestamp="1401110620", oauth_token="vz-test1", oauth_version="1.0"
30
+ response:
31
+ status:
32
+ code: 422
33
+ message: ''
34
+ headers:
35
+ Cache-Control:
36
+ - no-cache
37
+ Content-Type:
38
+ - application/xml; charset=utf-8
39
+ Date:
40
+ - Mon, 26 May 2014 13:23:41 GMT
41
+ P3p:
42
+ - CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
43
+ Server:
44
+ - nginx
45
+ Set-Cookie:
46
+ - _vzaar_session_id=BAh7BzoPc2Vzc2lvbl9pZCIlYzNkMjg1N2U5N2ZmY2QwODVhYTk4YzQ1OTAxZWM1OWY6Em9hdXRoX3VzZXJfaWRpAzuhAQ%3D%3D--aa4776928dc582b1d45f454fc7d3a68f7ba88f0a;
47
+ path=/; expires=Wed, 25-Jun-2014 13:23:41 GMT; HttpOnly
48
+ X-Runtime:
49
+ - '187'
50
+ Content-Length:
51
+ - '147'
52
+ Connection:
53
+ - keep-alive
54
+ body:
55
+ encoding: UTF-8
56
+ string: '<?xml version="1.0" encoding="utf-8"?><vzaar-api><status>Failure</status><errors><user>Permission
57
+ Denied: 106811/101210</user></errors></vzaar-api>'
58
+ http_version:
59
+ recorded_at: Mon, 26 May 2014 13:23:42 GMT
60
+ recorded_with: VCR 2.9.0
@@ -0,0 +1,59 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://vzaar.com/api/videos/1627985/generate_thumb.xml
6
+ body:
7
+ encoding: UTF-8
8
+ string: |2
9
+ <?xml version="1.0" encoding="UTF-8"?>
10
+ <vzaar-api>
11
+ <video>
12
+ <thumb_time>3</thumb_time>
13
+ </video>
14
+ </vzaar-api>
15
+ headers:
16
+ Content-Type:
17
+ - application/xml
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - "*/*"
22
+ User-Agent:
23
+ - OAuth gem v0.4.7
24
+ Content-Length:
25
+ - '176'
26
+ Authorization:
27
+ - OAuth oauth_body_hash="G%2FOl0Dp0PLu5u9b9YdmYz4d2ZBs%3D", oauth_nonce="75j3IWVpsmNRDYBRk47nuWh6xs1rWH1dEPOxoSWtzbY",
28
+ oauth_signature="S90WxRByGMNc6qnVzB5Ql93ZcOw%3D", oauth_signature_method="HMAC-SHA1",
29
+ oauth_timestamp="1401110622", oauth_token="vz-test1", oauth_version="1.0"
30
+ response:
31
+ status:
32
+ code: 202
33
+ message: Accepted
34
+ headers:
35
+ Cache-Control:
36
+ - no-cache
37
+ Content-Type:
38
+ - application/xml; charset=utf-8
39
+ Date:
40
+ - Mon, 26 May 2014 13:23:42 GMT
41
+ P3p:
42
+ - CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
43
+ Server:
44
+ - nginx
45
+ Set-Cookie:
46
+ - _vzaar_session_id=BAh7BzoPc2Vzc2lvbl9pZCIlNTg1ZDBkMzFhMzhhNGE1NjQ0MzdjMTg2NjU3MzRiMTE6Em9hdXRoX3VzZXJfaWRpAzuhAQ%3D%3D--719eb2427a45a0fa7fdf87c0880663b8d0595643;
47
+ path=/; expires=Wed, 25-Jun-2014 13:23:42 GMT; HttpOnly
48
+ X-Runtime:
49
+ - '103'
50
+ Content-Length:
51
+ - '86'
52
+ Connection:
53
+ - keep-alive
54
+ body:
55
+ encoding: UTF-8
56
+ string: <?xml version="1.0" encoding="utf-8"?><vzaar-api><status>Accepted</status></vzaar-api>
57
+ http_version:
58
+ recorded_at: Mon, 26 May 2014 13:23:43 GMT
59
+ recorded_with: VCR 2.9.0
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  require 'vzaar'
9
9
  require 'vcr'
10
+ require 'pry'
10
11
 
11
12
  Dir["./spec/support/**/*.rb"].each { |f| require f }
12
13
 
@@ -349,5 +349,52 @@ module Vzaar
349
349
  end
350
350
  end
351
351
 
352
+ describe "#add_subtitle" do
353
+ context "when there are errors" do
354
+ specify do
355
+ VCR.use_cassette('add_subtitle-failure') do
356
+ res = subject.add_subtitle(1519682, body: "SRT api", language: "en")
357
+ expect(res.errors).to_not be_empty
358
+ expect(res.http_status_code).to eq(422)
359
+ end
360
+ end
361
+ end
362
+
363
+ context "when there are no errors" do
364
+ specify do
365
+ VCR.use_cassette('add_subtitle-success') do
366
+ res = subject.add_subtitle(1627985, body: "SRT api", language: "en")
367
+ expect(res.http_status_code).to eq(202)
368
+ expect(res.status).to eq("Accepted")
369
+ end
370
+ end
371
+ end
372
+ end
373
+
374
+ describe "#generate_thumbnail" do
375
+ let(:application_token) { 'km9h3rdM8CjPgASZrSdNmRuzUdxq1UsCHSgi8WJWk' }
376
+ let(:login) { 'vz-test1' }
377
+
378
+ context "when there are errors" do
379
+ specify do
380
+ VCR.use_cassette('generate_thumbnail-failure') do
381
+ res = subject.generate_thumbnail(1519682, time: 3)
382
+ expect(res.errors).to_not be_empty
383
+ expect(res.http_status_code).to eq(422)
384
+ end
385
+ end
386
+ end
387
+
388
+ context "when there are no errors" do
389
+ specify do
390
+ VCR.use_cassette('generate_thumbnail-success') do
391
+ res = subject.generate_thumbnail(1627985, time: 3)
392
+ expect(res.http_status_code).to eq(202)
393
+ expect(res.status).to eq("Accepted")
394
+ end
395
+ end
396
+ end
397
+ end
398
+
352
399
  end
353
400
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vzaar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed James
@@ -9,160 +9,160 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-20 00:00:00.000000000 Z
12
+ date: 2014-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.6'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.6'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: httpclient
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2.3'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.3'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: oauth
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0.4'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0.4'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.3'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.3'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: fuubar
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ~>
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '1.2'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ~>
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.2'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ~>
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ~>
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: growl
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ~>
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
104
  version: '1.0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ~>
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: '1.0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: guard-rspec
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ~>
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '4.0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ~>
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '4.0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rspec
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ~>
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '2.14'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ~>
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
139
  version: '2.14'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: vcr
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ~>
144
+ - - "~>"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '2.7'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ~>
151
+ - - "~>"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '2.7'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: webmock
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ~>
158
+ - - "~>"
159
159
  - !ruby/object:Gem::Version
160
160
  version: '1.16'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ~>
165
+ - - "~>"
166
166
  - !ruby/object:Gem::Version
167
167
  version: '1.16'
168
168
  description: A Ruby gem for the vzaar API
@@ -173,11 +173,11 @@ executables: []
173
173
  extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
- - .gitignore
177
- - .rspec
178
- - .ruby-version
179
- - .rvmrc
180
- - .travis.yml
176
+ - ".gitignore"
177
+ - ".rspec"
178
+ - ".ruby-version"
179
+ - ".rvmrc"
180
+ - ".travis.yml"
181
181
  - Gemfile
182
182
  - Guardfile
183
183
  - LICENSE
@@ -189,9 +189,11 @@ files:
189
189
  - lib/vzaar/connection.rb
190
190
  - lib/vzaar/ext/oauth.rb
191
191
  - lib/vzaar/request/account_type.rb
192
+ - lib/vzaar/request/add_subtitle.rb
192
193
  - lib/vzaar/request/base.rb
193
194
  - lib/vzaar/request/delete_video.rb
194
195
  - lib/vzaar/request/edit_video.rb
196
+ - lib/vzaar/request/generate_thumbnail.rb
195
197
  - lib/vzaar/request/link_upload.rb
196
198
  - lib/vzaar/request/multipart.rb
197
199
  - lib/vzaar/request/process_video.rb
@@ -209,6 +211,7 @@ files:
209
211
  - lib/vzaar/resources/link_upload.rb
210
212
  - lib/vzaar/resources/processed_video.rb
211
213
  - lib/vzaar/resources/signature.rb
214
+ - lib/vzaar/resources/status.rb
212
215
  - lib/vzaar/resources/upload_thumbnail.rb
213
216
  - lib/vzaar/resources/user.rb
214
217
  - lib/vzaar/resources/video.rb
@@ -224,6 +227,8 @@ files:
224
227
  - lib/vzaar/version.rb
225
228
  - spec/fixtures/vcr_cassettes/account_type-fail.yml
226
229
  - spec/fixtures/vcr_cassettes/account_type-success.yml
230
+ - spec/fixtures/vcr_cassettes/add_subtitle-failure.yml
231
+ - spec/fixtures/vcr_cassettes/add_subtitle-success.yml
227
232
  - spec/fixtures/vcr_cassettes/delete_video-fail.yml
228
233
  - spec/fixtures/vcr_cassettes/delete_video-not-found.yml
229
234
  - spec/fixtures/vcr_cassettes/delete_video-retry-success.yml
@@ -231,6 +236,8 @@ files:
231
236
  - spec/fixtures/vcr_cassettes/edit_video-fail.yml
232
237
  - spec/fixtures/vcr_cassettes/edit_video-not-found.yml
233
238
  - spec/fixtures/vcr_cassettes/edit_video-success.yml
239
+ - spec/fixtures/vcr_cassettes/generate_thumbnail-failure.yml
240
+ - spec/fixtures/vcr_cassettes/generate_thumbnail-success.yml
234
241
  - spec/fixtures/vcr_cassettes/process_video-default.yml
235
242
  - spec/fixtures/vcr_cassettes/signature-default.yml
236
243
  - spec/fixtures/vcr_cassettes/signature-with-options.yml
@@ -276,12 +283,12 @@ require_paths:
276
283
  - lib
277
284
  required_ruby_version: !ruby/object:Gem::Requirement
278
285
  requirements:
279
- - - ! '>='
286
+ - - ">="
280
287
  - !ruby/object:Gem::Version
281
288
  version: '1.9'
282
289
  required_rubygems_version: !ruby/object:Gem::Requirement
283
290
  requirements:
284
- - - ! '>='
291
+ - - ">="
285
292
  - !ruby/object:Gem::Version
286
293
  version: '0'
287
294
  requirements: []
@@ -289,10 +296,12 @@ rubyforge_project:
289
296
  rubygems_version: 2.2.2
290
297
  signing_key:
291
298
  specification_version: 4
292
- summary: vzaar-1.0.0
299
+ summary: vzaar-1.2.2
293
300
  test_files:
294
301
  - spec/fixtures/vcr_cassettes/account_type-fail.yml
295
302
  - spec/fixtures/vcr_cassettes/account_type-success.yml
303
+ - spec/fixtures/vcr_cassettes/add_subtitle-failure.yml
304
+ - spec/fixtures/vcr_cassettes/add_subtitle-success.yml
296
305
  - spec/fixtures/vcr_cassettes/delete_video-fail.yml
297
306
  - spec/fixtures/vcr_cassettes/delete_video-not-found.yml
298
307
  - spec/fixtures/vcr_cassettes/delete_video-retry-success.yml
@@ -300,6 +309,8 @@ test_files:
300
309
  - spec/fixtures/vcr_cassettes/edit_video-fail.yml
301
310
  - spec/fixtures/vcr_cassettes/edit_video-not-found.yml
302
311
  - spec/fixtures/vcr_cassettes/edit_video-success.yml
312
+ - spec/fixtures/vcr_cassettes/generate_thumbnail-failure.yml
313
+ - spec/fixtures/vcr_cassettes/generate_thumbnail-success.yml
303
314
  - spec/fixtures/vcr_cassettes/process_video-default.yml
304
315
  - spec/fixtures/vcr_cassettes/signature-default.yml
305
316
  - spec/fixtures/vcr_cassettes/signature-with-options.yml