sproutvideo-rb 1.7.0 → 1.8.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
  SHA256:
3
- metadata.gz: 01c75acda409b9a3a9890c2bd9a4a050bd1d592686521a1390e1727b0572bb1c
4
- data.tar.gz: 2d003362ec7390b3f49a6c60850daa1dc0a4b8b60899624b4db1f658f1929cd4
3
+ metadata.gz: 8e13ddf68bf70448163cde8c0045b976926a0ed9927ce24b77fe33cd895f146f
4
+ data.tar.gz: 985a727c9bc400dbe0844496648d659d03c40d44816ee67aecd0c9d088e9b1f3
5
5
  SHA512:
6
- metadata.gz: c32f913ec550dfd97e2b5c6ecb2f3a1eb97369d3591450dbca5b241d35994291abe29f8b64fba751d8da40e1001bb1609859f5f9e57a6c1e4a0e59f3ab0cef0c
7
- data.tar.gz: 7b5964b53f2622c9a8754f4baedb7a83ea84807441cbe83cd5e0dc862ea0efa2807b5807b23b385b2a75fafebd4afb711758fd78728afe0b039e9a3877942486
6
+ metadata.gz: b31337a738156031080f321fb5642ee55cefea66b3f1db8248d905599d88bbd0e0206e3bfa57df67960f184729ee0fa5e1187aa34b2996e9fcba6e19bfbe98ae
7
+ data.tar.gz: '050186fd9d93ac3f392297e7ed3ad106126a1b99a713dddd4b135654b36324e7672383edc268ae35f56452742b2a824654ad3ae06d0382007e69f444cdab1b60'
data/Gemfile CHANGED
@@ -1,10 +1,9 @@
1
1
  source "http://rubygems.org"
2
-
3
- gem "rest-client", '~> 1.8.0'
4
- gem 'json', '~> 1.8.6'
2
+ gem "rest-client"
3
+ gem 'json', '~> 2.3.0'
5
4
  gem "multi_json"
6
5
 
7
6
  group :development do
8
7
  gem "rspec", "~> 2.8.0"
9
- gem "rdoc", "~> 3.12.1"
8
+ gem "rdoc", "~> 6.3.1"
10
9
  end
data/Gemfile.lock CHANGED
@@ -4,18 +4,21 @@ GEM
4
4
  diff-lcs (1.1.3)
5
5
  domain_name (0.5.20190701)
6
6
  unf (>= 0.0.5, < 1.0.0)
7
+ http-accept (1.7.0)
7
8
  http-cookie (1.0.3)
8
9
  domain_name (~> 0.5)
9
- json (1.8.6)
10
- mime-types (2.99.3)
10
+ json (2.3.0)
11
+ mime-types (3.3.1)
12
+ mime-types-data (~> 3.2015)
13
+ mime-types-data (3.2020.0512)
11
14
  multi_json (1.14.1)
12
15
  netrc (0.11.0)
13
- rdoc (3.12.2)
14
- json (~> 1.4)
15
- rest-client (1.8.0)
16
+ rdoc (6.3.1)
17
+ rest-client (2.1.0)
18
+ http-accept (>= 1.7.0, < 2.0)
16
19
  http-cookie (>= 1.0.2, < 2.0)
17
- mime-types (>= 1.16, < 3.0)
18
- netrc (~> 0.7)
20
+ mime-types (>= 1.16, < 4.0)
21
+ netrc (~> 0.8)
19
22
  rspec (2.8.0)
20
23
  rspec-core (~> 2.8.0)
21
24
  rspec-expectations (~> 2.8.0)
@@ -26,16 +29,16 @@ GEM
26
29
  rspec-mocks (2.8.0)
27
30
  unf (0.1.4)
28
31
  unf_ext
29
- unf_ext (0.0.7.6)
32
+ unf_ext (0.0.7.7)
30
33
 
31
34
  PLATFORMS
32
35
  ruby
33
36
 
34
37
  DEPENDENCIES
35
- json (~> 1.8.6)
38
+ json (~> 2.3.0)
36
39
  multi_json
37
- rdoc (~> 3.12.1)
38
- rest-client (~> 1.8.0)
40
+ rdoc (~> 6.3.1)
41
+ rest-client
39
42
  rspec (~> 2.8.0)
40
43
 
41
44
  BUNDLED WITH
data/README.markdown CHANGED
@@ -135,7 +135,7 @@ Sproutvideo::Video.update('abc123', :tags => [])
135
135
  You can upload a custom poster frame for a video by calling the upload_poster_frame method. The first parameter is the id of the video for wish you'd like the poster frame to be associated and the second parameter is the path to the image file.
136
136
 
137
137
  ```ruby
138
- SproutVideo::Video.upload_poster_frame('abc123', '/path/to/image.jpg')
138
+ Sproutvideo::Video.upload_poster_frame('abc123', '/path/to/image.jpg')
139
139
  ```
140
140
 
141
141
  ## destroy
@@ -248,10 +248,10 @@ By default, when deleting a folder, all of the contents of that folder (videos a
248
248
 
249
249
  ```ruby
250
250
  # delete the folder and move it's contents to the root folder
251
- Sproutvideo::Folder.delete('def456')
251
+ Sproutvideo::Folder.destroy('def456')
252
252
 
253
253
  # delete the folder and everything in it.
254
- Sproutvideo::Folder.delete('def456', :delete_all => true)
254
+ Sproutvideo::Folder.destroy('def456', :delete_all => true)
255
255
  ```
256
256
 
257
257
  # Playlists
@@ -351,6 +351,7 @@ Pass in the id of the login you wish to delete.
351
351
  ```ruby
352
352
  Sproutvideo::Login.destroy('asdf1234')
353
353
  ```
354
+
354
355
  # Access Grants
355
356
  The following methods are available: `list`, `create`, `details`, `update`, `destroy`
356
357
 
@@ -425,7 +426,7 @@ Each method can be called on it's own for overall account data for all time like
425
426
  ```ruby
426
427
  Sproutvideo::Analytics.play_counts
427
428
  Sproutvideo::Analytics.domains
428
- SproutVideo::Analytics.geo
429
+ Sproutvideo::Analytics.geo
429
430
  Sproutvideo::Analytics.video_types
430
431
  Sproutvideo::Analytics.playback_types
431
432
  Sproutvideo::Analytics.device_types
@@ -434,43 +435,86 @@ Each method can also take an options hash containing a :video_id for retrieving
434
435
  ```ruby
435
436
  Sproutvideo::Analytics.play_counts(:video_id => 'abc123')
436
437
  Sproutvideo::Analytics.domains(:video_id => 'abc123')
437
- SproutVideo::Analytics.geo(:video_id => 'abc123')
438
+ Sproutvideo::Analytics.geo(:video_id => 'abc123')
438
439
  Sproutvideo::Analytics.video_types(:video_id => 'abc123')
439
440
  Sproutvideo::Analytics.playback_types(:video_id => 'abc123')
440
441
  Sproutvideo::Analytics.device_types(:video_id => 'abc123')
441
442
  ```
443
+ The following methods can also take an options hash containing a :live_stream_id for retrieving overall data for a specific live_stream:
444
+ ```ruby
445
+ Sproutvideo::Analytics.play_counts(:live_stream_id => 'abc123')
446
+ Sproutvideo::Analytics.domains(:live_stream_id => 'abc123')
447
+ Sproutvideo::Analytics.geo(:live_stream_id => 'abc123')
448
+ Sproutvideo::Analytics.device_types(:live_stream_id => 'abc123')
449
+ ```
442
450
  Each method can also take an optional :start_date and :end_date to specify a date range for the returned data:
443
451
  ```ruby
444
452
  Sproutvideo::Analytics.play_counts(:start_date => '2013-01-01')
445
453
  Sproutvideo::Analytics.device_types(:video_id => 'abc123', :end_date => '2012-12-31')
446
454
  ```
447
455
 
448
- Lastly, the geo method can take an optional :country to retrieve playback data by city within that country
456
+ The geo method can take an optional :country to retrieve playback data by city within that country
449
457
  ```ruby
450
458
  Sproutvideo::Analytics.geo(:video_id => 'abc123', :country => 'US')
451
459
  ```
452
460
 
461
+ ## Misc endpoints
462
+ see api docs for more info
463
+
464
+ ```ruby
465
+ Sproutvideo::Analytics.popular_videos
466
+ ```
467
+
468
+ ```ruby
469
+ Sproutvideo::Analytics.live_stream_overview('abc123')
470
+ ```
471
+
453
472
  # Engagement
454
473
  You can grab the total number of seconds of your videos that have been watched like this:
455
474
  ```ruby
456
475
  Sproutvideo::Analytics.engagement
457
476
  ```
458
477
 
478
+ and for all livestreams:
479
+ ```ruby
480
+ Sproutvideo::Analytics.live_stream_engagement
481
+ ```
482
+
459
483
  You can grab engagement for a specific video like so:
460
484
  ```ruby
461
485
  Sproutvideo::Analytics.engagement(:video_id => 'abc123')
462
486
  ```
463
487
 
488
+ or for a specific live stream:
489
+ ```ruby
490
+ Sproutvideo::Analytics.live_stream_engagement(:live_stream_id => 'abc123')
491
+ ```
492
+
493
+ You can grab playback sessions data for your videos with:
494
+ ```ruby
495
+ Sproutvideo::Analytics.engagement_sessions
496
+ ```
497
+
498
+ and for live streams with
499
+ ```ruby
500
+ Sproutvideo::Analytics.live_stream_engagement_sessions
501
+ ```
502
+
464
503
  Lastly, you can grab every single playback session for a video like this:
465
504
  ```ruby
466
505
  Sproutvideo::Analytics.engagement_sessions('abc123')
467
- Sproutvideo::Analytics.engagement_sessions('abc123', :page => 3)
468
- Sproutvideo::Analytics.engagement_sessions('abc123', :page => 3, :per_page => 40)
506
+ Sproutvideo::Analytics.engagement_sessions('abc123', page: 3)
507
+ Sproutvideo::Analytics.engagement_sessions('abc123', page: 3, :per_page => 40)
508
+ ```
509
+
510
+ and for a live stream:
511
+ ```ruby
512
+ Sproutvideo::Analytics.live_stream_engagement_sessions('abc123')
469
513
  ```
470
514
 
471
515
  You can also grab engagement sessions for a video for a specific email address like so:
472
516
  ```ruby
473
- Sproutvideo::Analytics.engagement_sessions('abc123', :vemail => 'test@example.com')
517
+ Sproutvideo::Analytics.engagement_sessions(video_id: 'abc123', vemail: 'test@example.com')
474
518
  ```
475
519
 
476
520
  # Account
@@ -490,6 +534,148 @@ To update account settings:
490
534
  Sproutvideo::Account.update({download_sd: true})
491
535
  ```
492
536
 
537
+ # Subtitles
538
+ The following methods are available: `list`, `create`, `details`, `update`, `destroy`. All requests for a subtitle must be given a `video_id` option indicating the video that you want to access or update the subtitles of.
539
+
540
+ ## list
541
+ By default the subtitle listing is paginated with 25 tags per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
542
+
543
+ ```ruby
544
+ Sproutvideo::Subtitle.list(:video_id => 'abc123')
545
+ Sproutvideo::Subtitle.list(:video_id => 'abc123', :per_page => 10)
546
+ Sproutvideo::Subtitle.list(:video_id => 'abc123', :per_page => 10, :page => 2)
547
+ ```
548
+
549
+ ## create
550
+ Create takes three required parameters, `video_id`, `language`, and `content`, which will be to add the newly created subtitle file and associate it with the provided video id.
551
+
552
+ ```ruby
553
+ Sproutvideo::Subtitle.create(
554
+ :video_id => 'abc123',
555
+ :language => 'en',
556
+ :content => 'WEBVTT FILE...')
557
+ ```
558
+
559
+ ## details
560
+ pass both the video and the subtitle id.
561
+
562
+ ```ruby
563
+ Sproutvideo::Subtitle.details(:video_id => 'abc123', id: 'fdc432')
564
+ ```
565
+
566
+ ## update
567
+
568
+ You can change the optional parameters for a subtitle.
569
+
570
+ ```ruby
571
+ Sproutvideo::Subtitle.create(
572
+ :video_id => 'abc123',
573
+ :language => 'de',
574
+ :id => 'fdc432')
575
+ ```
576
+
577
+ ## destroy
578
+ Pass in the id of the subtitle you wish to delete.
579
+
580
+ ```ruby
581
+ Sproutvideo::Subtitle.destroy(:video_id => 'abc123', id: 'fdc432')
582
+ ```
583
+
584
+ # Calls to Action
585
+ The following methods are available: `list`, `create`, `details`, `update`, `destroy`. All requests for a call to action must be given a `video_id` option indicating the video that you want to access or update the calls to action of.
586
+
587
+ ## list
588
+ By default the call to action listing is paginated with 25 tags per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
589
+
590
+ ```ruby
591
+ Sproutvideo::CallToAction.list(:video_id => 'abc123')
592
+ Sproutvideo::CallToAction.list(:video_id => 'abc123', :per_page => 10)
593
+ Sproutvideo::CallToAction.list(:video_id => 'abc123', :per_page => 10, :page => 2)
594
+ ```
595
+
596
+ ## create
597
+ Create takes five required parameters, `video_id`, `text`, `url`, `start_time`, and `end_time`, which will be to add the newly created subtitle file and associate it with the provided video id.
598
+
599
+ ```ruby
600
+ Sproutvideo::CallToAction.create(
601
+ :video_id => 'abc123',
602
+ :text => 'join now',
603
+ :start_time => 1,
604
+ :end_time => 2,
605
+ :content => 'https://sproutvideo.com')
606
+ ```
607
+
608
+ ## details
609
+ pass both the video and the call to action id.
610
+
611
+ ```ruby
612
+ Sproutvideo::CallToAction.details(:video_id => 'abc123', id: 'fdc432')
613
+ ```
614
+
615
+ ## update
616
+
617
+ You can change the optional parameters for a call to action.
618
+
619
+ ```ruby
620
+ Sproutvideo::CallToAction.create(
621
+ :video_id => 'abc123',
622
+ :text => 'get it done!',
623
+ :id => 'fdc432')
624
+ ```
625
+
626
+ ## destroy
627
+ Pass in the id of the call to action you wish to delete.
628
+
629
+ ```ruby
630
+ Sproutvideo::CallToAction.destroy(:video_id => 'abc123', id: 'fdc432')
631
+ ```
632
+
633
+ # Live Streams
634
+ The following methods are available: `list`, `create`, `details`, `update`, `destroy`, and `end_stream`.
635
+
636
+ ## list
637
+ By default the call to action listing is paginated with 25 tags per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
638
+
639
+ ```ruby
640
+ Sproutvideo::LiveStream.list
641
+ Sproutvideo::LiveStream.list(:per_page => 10, :page => 2)
642
+ ```
643
+
644
+ ## create
645
+
646
+ ```ruby
647
+ Sproutvideo::LiveStream.create(title: 'hello')
648
+ # with a poster frame
649
+ Sproutvideo::LiveStream.create(title: 'hello', custom_poster_frame: '/path/to/posterframe.jpg')
650
+ ```
651
+
652
+ ## details
653
+
654
+ ```ruby
655
+ Sproutvideo::LiveStream.details('abc123')
656
+ ```
657
+
658
+ ## update
659
+ You can change the optional parameters
660
+
661
+ ```ruby
662
+ Sproutvideo::LiveStream.update(title: 'get it done!')
663
+ # with a poster frame
664
+ Sproutvideo::LiveStream.update(title: 'hello', custom_poster_frame: '/path/to/posterframe.jpg')
665
+ ```
666
+
667
+ ## destroy
668
+
669
+ ```ruby
670
+ Sproutvideo::LiveStream.destroy('abc123')
671
+ ```
672
+
673
+ ## end_stream
674
+
675
+ ```ruby
676
+ Sproutvideo::LiveStream.end_stream('abc123')
677
+ ```
678
+
493
679
  # Contributing to sproutvideo-rb
494
680
 
495
681
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
@@ -502,5 +688,5 @@ Sproutvideo::Account.update({download_sd: true})
502
688
 
503
689
  # Copyright
504
690
 
505
- Copyright (c) 2016 SproutVideo. See LICENSE.txt for
691
+ Copyright (c) 2021 SproutVideo. See LICENSE.txt for
506
692
  further details.
@@ -26,8 +26,8 @@ module Sproutvideo
26
26
  delete("/access_grants/#{access_grant_id}", options)
27
27
  end
28
28
 
29
- def self.bulk_create(access_grants, options={})
30
- post("/access_grants/bulk", options)
29
+ def self.bulk_create(access_grants)
30
+ post("/access_grants/bulk", access_grants)
31
31
  end
32
32
 
33
33
  end
@@ -1,73 +1,88 @@
1
1
  module Sproutvideo
2
2
  class Analytics < Resource
3
-
4
3
  def self.play_counts(options={})
5
- url = "/stats/counts"
6
- if options.include?(:video_id)
7
- video_id = options.delete(:video_id)
8
- url += "/#{video_id}"
9
- end
4
+ url = build_path("/stats/counts", options)
10
5
  get(url, options)
11
6
  end
12
7
 
13
8
  def self.domains(options={})
14
- url = "/stats/domains"
15
- if options.include?(:video_id)
16
- video_id = options.delete(:video_id)
17
- url += "/#{video_id}"
18
- end
9
+ url = build_path("/stats/domains", options)
19
10
  get(url, options)
20
11
  end
21
12
 
22
13
  def self.geo(options={})
23
- url = "/stats/geo"
24
- if options.include?(:video_id)
25
- video_id = options.delete(:video_id)
26
- url += "/#{video_id}"
27
- end
14
+ url = build_path("/stats/geo", options)
28
15
  get(url, options)
29
16
  end
30
17
 
31
18
  def self.video_types(options={})
32
- url = "/stats/video_types"
33
- if options.include?(:video_id)
34
- video_id = options.delete(:video_id)
35
- url += "/#{video_id}"
36
- end
19
+ url = build_path("/stats/video_types", options)
37
20
  get(url, options)
38
21
  end
39
22
 
40
23
  def self.playback_types(options={})
41
- url = "/stats/playback_types"
42
- if options.include?(:video_id)
43
- video_id = options.delete(:video_id)
44
- url += "/#{video_id}"
45
- end
24
+ url = build_path("/stats/playback_types", options)
46
25
  get(url, options)
47
26
  end
48
27
 
49
28
  def self.device_types(options={})
50
- url = "/stats/device_types"
51
- if options.include?(:video_id)
52
- video_id = options.delete(:video_id)
53
- url += "/#{video_id}"
54
- end
29
+ url = build_path("/stats/device_types", options)
55
30
  get(url, options)
56
31
  end
57
32
 
58
33
  def self.engagement(options={})
59
- url = "/stats/engagement"
60
- if options.include?(:video_id)
61
- video_id = options.delete(:video_id)
62
- url += "/#{video_id}"
34
+ url = build_path("/stats/engagement", options)
35
+ get(url, options)
36
+ end
37
+
38
+ def self.engagement_sessions(video_id=nil, options={})
39
+ if video_id.nil?
40
+ url = "/stats/engagement/sessions"
41
+ else
42
+ url = "/stats/engagement/#{video_id}/sessions"
43
+ end
44
+ get(url, options)
45
+ end
46
+
47
+ def self.live_stream_engagement(options={})
48
+ if options.include?(:live_stream_id)
49
+ url = build_path("/stats/engagement", options)
50
+ else
51
+ url = "/stats/live_streams/engagement"
63
52
  end
64
53
  get(url, options)
65
54
  end
66
55
 
67
- def self.engagement_sessions(video_id, options={})
68
- url = "/stats/engagement/#{video_id}/sessions"
56
+ def self.live_stream_engagement_sessions(live_stream_id=nil, options={})
57
+ if live_stream_id.nil?
58
+ url = "/stats/live_streams/engagement/sessions"
59
+ else
60
+ url = "/stats/live_streams/#{live_stream_id}/engagement/sessions"
61
+ end
69
62
  get(url, options)
70
63
  end
71
64
 
65
+ def self.popular_videos(options={})
66
+ get("/stats/popular_videos", options)
67
+ end
68
+
69
+ def self.live_stream_overview(live_stream_id, options={})
70
+ get("/stats/live_streams/#{live_stream_id}/overview", options)
71
+ end
72
+
73
+ private
74
+
75
+ def self.build_path(path, options)
76
+ if options.include?(:video_id)
77
+ video_id = options.delete(:video_id)
78
+ path += "/#{video_id}"
79
+ end
80
+ if options.include?(:live_stream_id)
81
+ video_id = options.delete(:live_stream_id)
82
+ resource = path.split('/').last
83
+ path = "/stats/live_streams/#{video_id}/#{resource}"
84
+ end
85
+ path
86
+ end
72
87
  end
73
- end
88
+ end
@@ -0,0 +1,39 @@
1
+ module Sproutvideo
2
+ class CallToAction < Resource
3
+ def self.create(options = {})
4
+ post(build_url(options), options)
5
+ end
6
+
7
+ def self.list(options = {})
8
+ url = build_url(options)
9
+ params = {
10
+ :page => options.delete(:page) || 1,
11
+ :per_page => options.delete(:per_page) || 25
12
+ }
13
+ params = params.merge(options)
14
+ get(url, params)
15
+ end
16
+
17
+ def self.details(options = {})
18
+ get("#{build_url(options)}/#{options[:id]}", options)
19
+ end
20
+
21
+ def self.update(options = {})
22
+ put("#{build_url(options)}/#{options[:id]}", options)
23
+ end
24
+
25
+ def self.destroy(options = {})
26
+ delete("#{build_url(options)}/#{options[:id]}", options)
27
+ end
28
+
29
+ private
30
+
31
+ def self.build_url(options)
32
+ if !options.include?(:video_id)
33
+ STDERR.puts "The video_id option is required for this endpoint."
34
+ end
35
+ video_id = options.delete(:video_id)
36
+ "/videos/#{video_id}/calls_to_action"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ module Sproutvideo
2
+ class Folder < Resource
3
+ def self.create(options = {})
4
+ post('/folders', options)
5
+ end
6
+
7
+ def self.list(options={})
8
+ params = {
9
+ :page => options.delete(:page) || 1,
10
+ :per_page => options.delete(:per_page) || 25
11
+ }
12
+ params = params.merge(options)
13
+ get('/folders', params)
14
+ end
15
+
16
+ def self.details(folder_id, options = {})
17
+ get("/folders/#{folder_id}", options)
18
+ end
19
+
20
+ def self.update(folder_id, options = {})
21
+ put("/folders/#{folder_id}", options)
22
+ end
23
+
24
+ def self.destroy(folder_id, options = {})
25
+ delete("/folders/#{folder_id}", options)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,43 @@
1
+ module Sproutvideo
2
+ class LiveStream < Resource
3
+
4
+ def self.create(options={})
5
+ if options.include?(:custom_poster_frame)
6
+ poster_frame = options.delete(:custom_poster_frame)
7
+ upload("/live_streams", poster_frame, options, :custom_poster_frame)
8
+ else
9
+ post("/live_streams", options)
10
+ end
11
+ end
12
+
13
+ def self.list(options={})
14
+ params = {
15
+ :page => options.delete(:page) || 1,
16
+ :per_page => options.delete(:per_page) || 25
17
+ }
18
+ params = params.merge(options)
19
+ get("/live_streams", params)
20
+ end
21
+
22
+ def self.details(live_stream_id, options={})
23
+ get("/live_streams/#{live_stream_id}", options)
24
+ end
25
+
26
+ def self.update(live_stream_id, options={})
27
+ if options.include?(:custom_poster_frame)
28
+ poster_frame = options.delete(:custom_poster_frame)
29
+ upload("/live_streams/#{live_stream_id}", poster_frame, options.merge({method: :PUT}), :custom_poster_frame)
30
+ else
31
+ put("/live_streams/#{live_stream_id}", options)
32
+ end
33
+ end
34
+
35
+ def self.destroy(live_stream_id, options={})
36
+ delete("/live_streams/#{live_stream_id}", options)
37
+ end
38
+
39
+ def self.end_stream(live_stream_id, options={})
40
+ put("/live_streams/#{live_stream_id}/end_stream", options)
41
+ end
42
+ end
43
+ end
@@ -20,18 +20,14 @@ module Sproutvideo
20
20
  Response.new(resp)
21
21
  end
22
22
 
23
- def self.upload(path, file_path, options = {})
23
+ def self.upload(path, file_path, options = {}, field_name)
24
24
  resp = nil
25
-
25
+
26
26
  method = options.delete(:method) == :PUT ? :PUT : :POST
27
27
 
28
28
  File.open(file_path) do |file|
29
-
30
- if method == :POST
31
- body = {:source_video => file}.merge(options.dup)
32
- else
33
- body = {:custom_poster_frame => file}
34
- end
29
+
30
+ body = { field_name => file }.merge(options.dup)
35
31
 
36
32
  begin
37
33
  resp = RestClient.send(
@@ -44,7 +40,7 @@ module Sproutvideo
44
40
  resp = e.response
45
41
  end
46
42
  end
47
-
43
+
48
44
  Response.new(resp)
49
45
  end
50
46
 
@@ -83,4 +79,4 @@ module Sproutvideo
83
79
  Response.new(resp)
84
80
  end
85
81
  end
86
- end
82
+ end
@@ -0,0 +1,39 @@
1
+ module Sproutvideo
2
+ class Subtitle < Resource
3
+ def self.create(options = {})
4
+ post(build_url(options), options)
5
+ end
6
+
7
+ def self.list(options = {})
8
+ url = build_url(options)
9
+ params = {
10
+ :page => options.delete(:page) || 1,
11
+ :per_page => options.delete(:per_page) || 25
12
+ }
13
+ params = params.merge(options)
14
+ get(url, params)
15
+ end
16
+
17
+ def self.details(options = {})
18
+ get("#{build_url(options)}/#{options[:id]}", options)
19
+ end
20
+
21
+ def self.update(options = {})
22
+ put("#{build_url(options)}/#{options[:id]}", options)
23
+ end
24
+
25
+ def self.destroy(options = {})
26
+ delete("#{build_url(options)}/#{options[:id]}", options)
27
+ end
28
+
29
+ private
30
+
31
+ def self.build_url(options)
32
+ if !options.include?(:video_id)
33
+ STDERR.puts "The video_id option is required for this endpoint."
34
+ end
35
+ video_id = options.delete(:video_id)
36
+ "/videos/#{video_id}/subtitles"
37
+ end
38
+ end
39
+ end