chili_player 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 3fd3065c55fbf4c4736c7b6d92ef96028bf11d6a
4
- data.tar.gz: 8503bfdefc8971446a81eed0cc30f89b6a8cc2af
3
+ metadata.gz: 3e25bc13323d11d4263d32f9acb851af4d5079d6
4
+ data.tar.gz: f74e8d89ed8f693873b8990e35b37ee1879ac4fb
5
5
  SHA512:
6
- metadata.gz: 7b76d234a1b4680ea4667d692dfc8f63ffb5fbe661bbe4308de31c125b60720cad0a7c6a98e2711a7ae654e22cf4b29c27019bd2113a7a39efe97001957498c3
7
- data.tar.gz: a80786d0bb33be551c4eefc8ba88dcfc4766cd0bdcf5005661587db9c27c63c27b2eb02330961d8f8755d156b0bc102096650226a39cec55cca810ca2f44a036
6
+ metadata.gz: 9e93b3e77a55362e90a7879a500d87f47f67dd07d6e445ef8840b743c2f7cafd49f2d4444d2bfb4edb6c8415f23f7233026b69571bf611bc387c6ece8dee2113
7
+ data.tar.gz: 0f528e79727f11ac6b685278b71de82588535c7023f60ac2162e27b41dc6746cd3a7314960f15b882343a188d0e9e12b29e27080ee98af7a281e989bc35ec619
data/.DS_Store ADDED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chili_player (0.1.3)
4
+ chili_player (0.1.4)
5
5
  json (~> 2.1)
6
6
  rest-client (~> 2.0)
7
7
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  First of all, you need to sign in [chili player](https://player.chiligumvideos.com/) and then you need to get your credential.
24
24
  After you get `token`, you can instantiate the class as in this example:
25
25
 
26
- client = ChiliPlayer::Init.new(token: 'your-token')
26
+ client = Player.new('your-token')
27
27
 
28
28
  ## Videos
29
29
 
@@ -31,31 +31,39 @@ After you had instantiate the class, to manipulate the API endpoints we provide
31
31
 
32
32
  ### List all videos
33
33
 
34
- response = client.all_videos
35
- response.body
34
+ response = client.videos
36
35
 
37
- This method returns the entire response to chili player call, the `.body` returns an array of hashes containing information for all links createad in your account
36
+ This method returns an array containing hashes of all information about the videos created, e.g:
37
+
38
+ [{"id"=>164, "data"=>"https://s3.amazonaws.com/chilihls/uploads/7d00f8054103d0a3824e59a3689743d69faf4d4b.mp4", "player_url"=>"https://player.chiligumvideos.com/d6d791b7a8", "postback_url"=>nil, "preserve_original_file"=>true, "activated"=>true, "watermark_image_url"=>nil, "watermark_link"=>nil, "watermark_position"=>nil, "wartermark_start"=>nil, "watermark_duration"=>nil, "created_at"=>"2018-06-27T16:43:28.026Z"}, {"id"=>162, "data"=>"https://s3.amazonaws.com/chilihls/uploads/d24ceab72878a4fcdb2c4b52b6d1ef0c67a2ed43.mp4", "player_url"=>"https://player.chiligumvideos.com/dff4f6b549", "postback_url"=>nil, "preserve_original_file"=>true, "activated"=>true, "watermark_image_url"=>nil, "watermark_link"=>nil, "watermark_position"=>nil, "wartermark_start"=>nil, "watermark_duration"=>nil, "created_at"=>"2018-06-19T17:56:50.498Z"}]
39
+
38
40
 
39
41
  ### Get a specific video
40
42
 
41
- response = client.get_video(video_id)
42
- response.body
43
+ response = client.video(video_id)
44
+
45
+ If video_id exists this call returns all information about the requested video, e.g:
43
46
 
44
- If video_id exists this call returns all information about the requested video.
47
+ {"id"=>5212, "data"=>"https://s3.amazonaws.com/chilihls/uploads/9f46c3365c3f20cb32d82dd795fdb664fa363d33.mp4", "player_url"=>"https://player.chiligumvideos.com/db4d980eef", "postback_url"=>nil, "preserve_original_file"=>true, "activated"=>true, "watermark_image_url"=>nil, "watermark_link"=>nil, "watermark_position"=>nil, "wartermark_start"=>nil, "watermark_duration"=>nil, "created_at"=>"2018-08-30T18:11:16.907Z"}
45
48
 
46
49
  ### Upload video
47
- In order to upload video, you must pass as parameters the video's title and the video file you want to upload.
50
+ In order to upload a video, you must pass as parameters the video's title, the video file you want to upload and also optional parameters such as: name, postback_url, preserve_original_file, activated, watermark_image_url, watermark_link, watermark_position, wartermark_start, watermark_duration.
51
+
52
+ response = client.upload(name_video, video_file, video_optional_params)
53
+
54
+ This method returns all information displayed at 'Get a specific video' topic.
55
+
56
+ ### Update video
57
+ In order to update a video, you must pass as parameters the video's id and also optional parameters such as: name, postback_url, preserve_original_file, activated, watermark_image_url, watermark_link, watermark_position, wartermark_start, watermark_duration. When you update the video, you cannot change the video's file.
48
58
 
49
- response = client.upload(name_video, video_file)
50
- response.body
59
+ response = client.upload(video_id, video_optional_params)
51
60
 
52
- This method returns all information about your uploaded video, such as id, name, duration, token and so forth.
61
+ This method returns all information displayed at 'Get a specific video' topic.
53
62
 
54
63
  ### Delete a video
55
64
  If you want to delete a previous uploaded video, you just need to pass the id of this video
56
65
 
57
66
  response = client.delete(video_id)
58
- response.body
59
67
 
60
68
  If the video_id is valid, this method returns the message `{"msg": "deleted"}`
61
69
 
@@ -75,4 +83,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
75
83
 
76
84
  ## Code of Conduct
77
85
 
78
- Everyone interacting in the ChiliPlayer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/urli_me/blob/master/CODE_OF_CONDUCT.md).
86
+ Everyone interacting in the ChiliPlayer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/chili_player/blob/master/CODE_OF_CONDUCT.md).
@@ -2,28 +2,24 @@ require 'chili_player'
2
2
  require 'chili_player/version'
3
3
  require 'chili_player/videos'
4
4
  require 'rest-client'
5
+ require 'json'
5
6
 
6
- # lib/chili_player/init.rb
7
- module ChiliPlayer
8
- # init access class
9
- class Init
10
- include RestClient
11
- include ChiliPlayer::Videos
7
+ # init access class
8
+ class Player
9
+ include RestClient
10
+ include Videos
12
11
 
13
- def initialize(options = {})
14
- options.each do |key, value|
15
- instance_variable_set("@#{key}", value)
16
- end
17
- end
12
+ def initialize(options = {})
13
+ instance_variable_set('@token', options)
14
+ end
18
15
 
19
- private
16
+ private
20
17
 
21
- def header_request
22
- { token: @token }
23
- end
18
+ def header_request
19
+ { token: @token }
20
+ end
24
21
 
25
- def links_url
26
- ChiliPlayer::LINKS_URL
27
- end
22
+ def endpoint_url
23
+ ChiliPlayer::ENDPOINT_URL
28
24
  end
29
25
  end
@@ -1,4 +1,4 @@
1
1
  module ChiliPlayer
2
- VERSION = '0.1.3'.freeze
3
- LINKS_URL = 'https://player.chiligumvideos.com/api/videos/'.freeze
2
+ VERSION = '0.1.4'.freeze
3
+ ENDPOINT_URL = 'https://player.chiligumvideos.com/api/videos/'.freeze
4
4
  end
@@ -1,36 +1,40 @@
1
1
  require 'chili_player'
2
2
  require 'chili_player/init'
3
3
  require 'rest-client'
4
+ require 'json'
4
5
 
5
6
  # lib/chili_player/videos.rb
6
- module ChiliPlayer
7
- # videos module
8
- module Videos
9
- def all_videos
10
- RestClient.get(links_url, header_request)
11
- end
7
+ module Videos
8
+ def videos
9
+ JSON.parse RestClient.get(endpoint_url, header_request)
10
+ end
11
+
12
+ def video(video_id)
13
+ JSON.parse RestClient.get(endpoint_url + video_id.to_s, header_request)
14
+ end
12
15
 
13
- def get_video(video_id)
14
- RestClient.get(links_url + video_id.to_s, header_request)
15
- end
16
+ def upload(name, video, options = {})
17
+ JSON.parse RestClient.post(endpoint_url, params(options, name, video),
18
+ header_request)
19
+ end
16
20
 
17
- def upload(name, video)
18
- RestClient.post(links_url, params(name, video), header_request)
19
- end
21
+ def update(video_id, options)
22
+ JSON.parse RestClient.patch(endpoint_url + video_id.to_s, params(options),
23
+ header_request)
24
+ end
20
25
 
21
- def delete(video_id)
22
- RestClient.delete(links_url + video_id.to_s, header_request)
23
- end
26
+ def delete(video_id)
27
+ JSON.parse RestClient.delete(endpoint_url + video_id.to_s, header_request)
28
+ end
24
29
 
25
- private
30
+ private
26
31
 
27
- def params(name, video)
28
- {
29
- video: {
30
- name: name,
31
- data: File.new(video, 'rb')
32
- }
33
- }
34
- end
32
+ def params(options, name = nil, video = nil)
33
+ data = { video: {} }
34
+ options.delete(:data)
35
+ data[:video].merge!(options)
36
+ data[:video][:name] = name unless name.nil?
37
+ data[:video][:data] = File.new(video, 'rb') unless video.nil?
38
+ data
35
39
  end
36
40
  end
data/test.mp4 CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chili_player
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Casimiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-29 00:00:00.000000000 Z
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".DS_Store"
90
91
  - ".gitignore"
91
92
  - ".travis.yml"
92
93
  - CODE_OF_CONDUCT.md