zype 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95995e7141312c55086a5877d529c7256d810afc1fa9243d2cfbd878f3abee48
4
- data.tar.gz: a0ccc891332c5d5e4e7cd5841eceef356164f0e4b7034f411666a8f87f167659
3
+ metadata.gz: 7199fcef0cba518a656b3556b0351b7390e5816b685ea5b4af8dfd2b4386911d
4
+ data.tar.gz: ec53fee1915a8e77dff8b022a5b7a1957c7dffa8081808b764bfbff80320825b
5
5
  SHA512:
6
- metadata.gz: 44106d36a3cb56b4ae07203a5ba66e0e72c920c4916dcd1d428cf025660fc4b89642f631dfb69230cd5b6cb48d4f5aafbcc2a4a9f5b168e8f3bf0939486ca7a9
7
- data.tar.gz: cf8598bdf9a15dc3472ff43774730f2eb8761e93454842aeaaac9ef51988e53c85abbc4885939fef2aa41f2528c87a713331f4c57c5ca2c342a8d4246ca4ab91
6
+ metadata.gz: b322e552e741a5967eef6135bd63420b46614af1a7eda5b18ba1f6c322f1cd99f7293c7221b65b781ee73aeca02aa40ef80634dd0197c4a707676f652be22cb8
7
+ data.tar.gz: ad10fd3649ae7a42d046aca34faa5b6f2678ca0e3b9537fcc26a837db56d70a7d0a9f4e5cf011024f60dd20f845a19b55e9aa1d5e9ad5467ff89675e2c7c110b
data/lib/zype/client.rb CHANGED
@@ -20,7 +20,7 @@ module Zype
20
20
 
21
21
  # Automatically converts all files in lib/zype/models to be used as methods
22
22
  class << self
23
- Dir["lib/zype/models/*"].each do |file|
23
+ Dir["lib/zype/models/*.rb"].each do |file|
24
24
  model = file[/.*\/(.*?).rb$/, 1]
25
25
  define_method model do
26
26
  constant = model.split("_").map { |s| s.capitalize }.join("")
@@ -0,0 +1,50 @@
1
+ module Zype
2
+ module Base
3
+ # Any videos nested routes will inherit from this class
4
+ class Videos < Zype::BaseModel
5
+ # Returns all objects for given class
6
+ #
7
+ # @param video_id [String] the ID of the video
8
+ # @return [Array<Hash>] the objects returned from the API
9
+ def all(video_id:)
10
+ client.execute(method: :get, path: "/videos/#{video_id}/#{path}")
11
+ end
12
+
13
+ # Returns object matching ID
14
+ #
15
+ # @param video_id [String] the ID of the video
16
+ # @param id [String] the ID of the object
17
+ # @return [Hash] the object returned from the API
18
+ def find(video_id:, id:)
19
+ client.execute(method: :get, path: "/videos/#{video_id}/#{path}/#{id}")
20
+ end
21
+
22
+ # Creates a new object via the API.
23
+ #
24
+ # @param video_id [String] ID of the video to assign to the object
25
+ # @param params [Hash] the properties of the object
26
+ # @return [Hash] the newly created object
27
+ def create(video_id:, params:)
28
+ client.execute(method: :post, path: "/videos/#{video_id}/#{path}", params: params)
29
+ end
30
+
31
+ # Updates an existing object via the API
32
+ #
33
+ # @param id [String] the ID of the object
34
+ # @param params [Hash] the properties to be updated
35
+ # @return [Hash] the updated object
36
+ def update(video_id:, id:, params:)
37
+ client.execute(method: :put, path: "/videos/#{video_id}/#{path}/#{id}", params: params)
38
+ end
39
+
40
+ # Deletes an existing object via the API
41
+ #
42
+ # @param video_id [String] the ID of the video
43
+ # @param id [String] the ID of the object
44
+ # @return [Hash] the deleted object
45
+ def delete(video_id:, id:)
46
+ client.execute(method: :delete, path: "/videos/#{video_id}/#{path}/#{id}")
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,7 @@
1
+ module Zype
2
+ # Read more at https://docs.zype.com/v1.0/reference#segments
3
+ #
4
+ # @since 0.11.0
5
+ class Segments < Zype::Base::Videos
6
+ end
7
+ end
@@ -5,23 +5,13 @@ module Zype
5
5
  # Read more at https://docs.zype.com/v1.0/reference#subtitle-playlists
6
6
  #
7
7
  # @since 0.7.0
8
- class SubtitlePlaylists < Zype::BaseModel
8
+ class SubtitlePlaylists < Zype::Base::Videos
9
9
  %i[all find update].each do |mtd|
10
10
  send(:define_method, mtd) do
11
11
  raise NoMethodError
12
12
  end
13
13
  end
14
14
 
15
- # Creates a new subtitle via the API.
16
- # Files must be hosted and be accessible with a URL
17
- #
18
- # @param video_id [String] ID of the video to assign to the subtitle
19
- # @param params [Hash] the properties of the subtitle
20
- # @return [Hash] the newly created subtitle
21
- def create(video_id:, params:)
22
- client.execute(method: :post, path: "/videos/#{video_id}/subtitle_playlists", params: params)
23
- end
24
-
25
15
  # Deletes an existing subtitle via the API
26
16
  #
27
17
  # @param language [String] language of the playlist - must be full name - not code
data/lib/zype.rb CHANGED
@@ -4,6 +4,7 @@ require './lib/zype/client.rb'
4
4
  require './lib/zype/client/player_client.rb'
5
5
  require './lib/zype/client/api_client.rb'
6
6
  require './lib/zype/base_model.rb'
7
+ Dir[File.join(__dir__, '../lib/zype/models/base', '*.rb')].each { |file| require file }
7
8
  Dir[File.join(__dir__, '../lib/zype/models', '*.rb')].each { |file| require file }
8
9
 
9
10
  module Zype
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zype
@@ -65,6 +65,7 @@ files:
65
65
  - lib/zype/client/player_client.rb
66
66
  - lib/zype/configuration.rb
67
67
  - lib/zype/models/apps.rb
68
+ - lib/zype/models/base/videos.rb
68
69
  - lib/zype/models/categories.rb
69
70
  - lib/zype/models/device_categories.rb
70
71
  - lib/zype/models/devices.rb
@@ -76,6 +77,7 @@ files:
76
77
  - lib/zype/models/players.rb
77
78
  - lib/zype/models/playlists.rb
78
79
  - lib/zype/models/program_guides.rb
80
+ - lib/zype/models/segments.rb
79
81
  - lib/zype/models/subtitle_playlists.rb
80
82
  - lib/zype/models/subtitles.rb
81
83
  - lib/zype/models/videos.rb