dailymotion-api-client 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDAzNGY2MTMzN2FiNmU3YjNjODU2ZWE0MDQ1MGY0ZTMyMTNiNDFiNA==
4
+ ZDRlNTI2ZjI0NmJmNGQxOWYxMDk5MTk2OWMyNjNlOWQ0NTM2OTBkMQ==
5
5
  data.tar.gz: !binary |-
6
- MjBkOWEwYzdkZTcxOTEzMGQ0MTU4NDQwYjFhZTYyNDAxZmMyYzQ3ZA==
7
- !binary "U0hBNTEy":
6
+ ZTJjN2JhOGQ4ODNmNmQ2ZTc3NGZjYjc2Y2IyZWM2ZWQwNzEyMjBlMA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- NzU4MmQyN2E5YzVjMWNkZjJhM2RiMjU5NzQzNjFlNzRlYWY2YTQ2ZDdiZjE5
10
- MjQ1YjhhMDcyZDY2NjhhNmUxZDE5ZDM2ZTM0MTVlZDcwODc3NWUyODJjY2I1
11
- YWNhNTFkNzM4ZGI0ZTI3NjM4OTljZWJjNjlkNjk0MDc4NjIzNjA=
9
+ OGIyZTBmZmYxYjAwZGYwODY3YjNkNWY4NWIwYTdlOTlmNzVhOGQ4NzFlYzEy
10
+ OWRkODU0ODliOTU2NzNhOTFkZmFjMWRjMjMzMzZkNDRkYjg1OGE1MDdmY2U3
11
+ OTg0MmZmMTZlNTA4MDhjZGYyYzQ5OWJjMDMzYWQwMzI5ZjE4NGI=
12
12
  data.tar.gz: !binary |-
13
- ZDk3ZGEzMjczMDUwYjRiZmMyOWVjNzdjMjQ0YzQ0MjAyZTMyNDllNDZmNTFh
14
- MmMyMWFkOGU5ZjQwZjkwNWZjM2QzMzI3MDRmZmRiOGFjYzIyMTMwODhhNGM0
15
- Nzc3MTJhMjJjM2RmMWI0MjI4NTkxMzc4YzdkOWFjMTNmNWFlOTg=
13
+ YjUyYzA1NmJhNDliYTEwZmJmODVlMmUyZWM2MzZjZTMzNzU3MmQwZDVhZDU1
14
+ Yjc5MzJiZWJmYzVmN2MyNjk5MjU4NzY2YWYzM2ZkYjEzZGVlYTVlMzg2OWVl
15
+ OTNiMDFjNTkwN2RhNzViZTA5YWQxZDZlN2EzN2ZjY2NmN2RmZjM=
@@ -0,0 +1,11 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ RunRailsCops: false
5
+ DisplayCopNames: true
6
+
7
+ Style/StringLiterals:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/Documentation:
11
+ Enabled: false
@@ -0,0 +1,34 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-08-13 14:01:08 -0300 using RuboCop version 0.33.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 38
10
+ # Configuration parameters: AllowURI, URISchemes.
11
+ Metrics/LineLength:
12
+ Max: 250
13
+
14
+ # Offense count: 1
15
+ Style/AccessorMethodName:
16
+ Exclude:
17
+ - 'lib/dailymotion-api/client.rb'
18
+
19
+ # Offense count: 1
20
+ # Configuration parameters: Exclude.
21
+ Style/FileName:
22
+ Exclude:
23
+ - 'lib/dailymotion-api-client.rb'
24
+
25
+ # Offense count: 1
26
+ Style/RescueModifier:
27
+ Exclude:
28
+ - 'lib/dailymotion-api/client.rb'
29
+
30
+ # Offense count: 1
31
+ # Cop supports --auto-correct.
32
+ # Configuration parameters: SupportedStyles.
33
+ Style/SpaceBeforeBlockBraces:
34
+ EnforcedStyle: no_space
@@ -0,0 +1 @@
1
+ dailymotion-api-client
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p194
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ sudo: false
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - Rename `get_upload_url` to `generate_upload_url`
6
+ - Add a `request_access_token_manage_videos_scope` to request an access token with "manage_videos" scope
7
+ - Add support to get a list of videos from the authenticated user
8
+ - Add support to get info from the authenticated user
9
+ - Add support to delete a video
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in esportes-client.gemspec
3
+ # Specify your gem's dependencies in dailymotion-api-client.gemspec
4
4
  gemspec
@@ -1,22 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dailymotion-api-client (0.1.0)
4
+ dailymotion-api-client (0.2.0)
5
5
  httmultiparty
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.1.0)
11
+ astrolabe (1.3.1)
12
+ parser (~> 2.2)
10
13
  diff-lcs (1.2.1)
11
- httmultiparty (0.3.8)
14
+ httmultiparty (0.3.16)
12
15
  httparty (>= 0.7.3)
16
+ mimemagic
13
17
  multipart-post
14
- httparty (0.10.2)
15
- multi_json (~> 1.0)
18
+ httparty (0.13.5)
19
+ json (~> 1.8)
16
20
  multi_xml (>= 0.5.2)
17
- multi_json (1.6.1)
18
- multi_xml (0.5.3)
19
- multipart-post (1.2.0)
21
+ json (1.8.3)
22
+ mimemagic (0.3.0)
23
+ multi_xml (0.5.5)
24
+ multipart-post (2.0.0)
25
+ parser (2.2.2.6)
26
+ ast (>= 1.1, < 3.0)
27
+ powerpack (0.1.1)
28
+ rainbow (2.0.0)
29
+ rake (0.9.2.2)
20
30
  rspec (2.13.0)
21
31
  rspec-core (~> 2.13.0)
22
32
  rspec-expectations (~> 2.13.0)
@@ -25,10 +35,22 @@ GEM
25
35
  rspec-expectations (2.13.0)
26
36
  diff-lcs (>= 1.1.3, < 2.0)
27
37
  rspec-mocks (2.13.0)
38
+ rubocop (0.33.0)
39
+ astrolabe (~> 1.3)
40
+ parser (>= 2.2.2.5, < 3.0)
41
+ powerpack (~> 0.1)
42
+ rainbow (>= 1.99.1, < 3.0)
43
+ ruby-progressbar (~> 1.4)
44
+ ruby-progressbar (1.7.5)
28
45
 
29
46
  PLATFORMS
30
47
  ruby
31
48
 
32
49
  DEPENDENCIES
33
50
  dailymotion-api-client!
51
+ rake
34
52
  rspec
53
+ rubocop
54
+
55
+ BUNDLED WITH
56
+ 1.10.6
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # DailyMotion API Ruby Client
2
2
 
3
+ [![Build Status](https://travis-ci.org/ggarnier/dailymotion-api-client.svg)](https://travis-ci.org/ggarnier/dailymotion-api-client)
4
+
3
5
  Client for DailyMotion API (http://www.dailymotion.com/doc/api/graph-api.html) written in Ruby.
4
6
 
5
7
  ## Installation
@@ -18,22 +20,69 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
23
+ To use this client, you need to register an account at Dailymotion and [create an API key](http://www.dailymotion.com/settings/developer/new). You need an API key and API secret.
24
+
25
+ ```ruby
26
+ # Create an instance of DailymotionApi::Client
27
+ client = DailymotionApi::Client.new(username: "username", password: "password", api_key: "key", api_secret: "secret")
28
+ ```
29
+
21
30
  ### Publishing a video
22
31
 
23
- # Create an instance of DailymotionApi::Client
24
- client = DailymotionApi::Client.new(username: "username", password: "password", api_key: "key", api_secret: "secret")
25
- # Request an access token
26
- client.request_access_token
27
- # Request an upload url
28
- client.get_upload_url
29
- # Post your video
30
- client.post_video(File.new("my_video.mp4"))
31
- # Create a video
32
- client.create_video
33
- # Update video data an publish it
34
- client.publish_video(title: "my video", channel: "shortfilms", tags: "my_tag")
35
- # Get metadata for a video with a specified id
36
- client.get_video("video_id", "url,title")
32
+ ```ruby
33
+ # Request an access token
34
+ client.request_access_token
35
+
36
+ # Request an upload url
37
+ client.generate_upload_url
38
+
39
+ # Post your video
40
+ client.post_video(File.new("my_video.mp4"))
41
+
42
+ # Create a video
43
+ client.create_video
44
+
45
+ # Update video metadata an publish it
46
+ client.publish_video(title: "my video", channel: "shortfilms", tags: "my_tag")
47
+ ```
48
+
49
+ ### Getting info about a published video
50
+
51
+ ```ruby
52
+ # Get basic metadata for a video with id "video_id"
53
+ client.get_video("video_id")
54
+ => {"id"=>"video_id", "title"=>"my video", "channel"=>"shortfilms", "owner"=>"owner_id"}
55
+
56
+ # Get specific fields for a video with id "video_id"
57
+ client.get_video("video_id", "url,title")
58
+ => {"url"=>"http://www.dailymotion.com/video/video_id_my-video_shortfilms", "title"=>"my video"}
59
+ ```
60
+
61
+ ### Getting info about authenticated user
62
+
63
+ ```ruby
64
+ client.request_access_token
65
+
66
+ client.get_authenticated_user_info
67
+ => {"id"=>"owner_id", "screenname"=>"username"}
68
+
69
+ client.get_authenticated_user_info("screenname")
70
+ => {"screenname"=>"username"}
71
+ ```
72
+
73
+ ### Getting a list of videos published by authenticated user
74
+
75
+ ```ruby
76
+ client.request_access_token
77
+
78
+ client.get_authenticated_user_videos
79
+ => {"page"=>1, "limit"=>10, "explicit"=>false, "total"=>1, "has_more"=>false, "list"=>[{"id"=>"video_id", "title"=>"my video", "channel"=>"shortfilms", "owner"=>"owner_id"}]}
80
+
81
+ client.get_authenticated_user_videos("url")
82
+ => {"page"=>1, "limit"=>10, "explicit"=>false, "total"=>1, "has_more"=>false, "list"=>[{"url"=>"http://www.dailymotion.com/video/video_id_my-video_shortfilms"}]}
83
+ ```
84
+
85
+ ### Deleting a video
37
86
 
38
87
  ## Contributing
39
88
 
data/Rakefile CHANGED
@@ -4,3 +4,4 @@ require "rspec/core/rake_task"
4
4
  desc "Run all examples"
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
+ task default: :spec
@@ -1,18 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dailymotion-api/version'
5
+ require "dailymotion-api/version"
5
6
 
6
7
  Gem::Specification.new do |gem|
7
8
  gem.name = "dailymotion-api-client"
8
9
  gem.version = DailymotionApi::VERSION
9
10
  gem.authors = ["Guilherme Garnier"]
10
11
  gem.email = ["guilherme.garnier@gmail.com"]
11
- gem.description = %q{DailyMotion API Ruby client}
12
- gem.summary = %q{DailyMotion API Ruby client}
12
+ gem.description = "DailyMotion API Ruby client"
13
+ gem.summary = "DailyMotion API Ruby client"
13
14
  gem.homepage = "http://github.com/ggarnier/dailymotion-api-client"
14
15
 
15
- gem.files = `git ls-files`.split($/)
16
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
19
  gem.require_paths = ["lib"]
@@ -20,4 +21,6 @@ Gem::Specification.new do |gem|
20
21
  gem.add_runtime_dependency "httmultiparty"
21
22
 
22
23
  gem.add_development_dependency "rspec"
24
+ gem.add_development_dependency "rake"
25
+ gem.add_development_dependency "rubocop"
23
26
  end
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  require "httmultiparty"
3
4
 
4
5
  module DailymotionApi
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  module DailymotionApi
3
4
  class Client
4
5
  API_URL = "https://api.dailymotion.com"
@@ -13,38 +14,80 @@ module DailymotionApi
13
14
  end
14
15
 
15
16
  def request_access_token
16
- response = HTTMultiParty.post("#{API_URL}/oauth/token", body: {grant_type: "password", client_id: @api_key, client_secret: @api_secret, username: @username, password: @password})
17
+ response = HTTMultiParty.post("#{API_URL}/oauth/token", body: request_access_token_params)
18
+ @access_token = response.parsed_response["access_token"]
19
+ end
20
+
21
+ def request_access_token_manage_videos_scope
22
+ response = HTTMultiParty.post("#{API_URL}/oauth/token", body: request_access_token_params.merge(scope: "manage_videos"))
17
23
  @access_token = response.parsed_response["access_token"]
18
24
  end
19
25
 
20
- def get_upload_url
26
+ def generate_upload_url
21
27
  response = HTTMultiParty.get("#{API_URL}/file/upload?access_token=#{@access_token}")
22
28
  @upload_url = response.parsed_response["upload_url"]
23
29
  end
24
30
 
25
31
  def post_video(video)
26
- response = HTTMultiParty.post(@upload_url, body: {file: video})
32
+ response = HTTMultiParty.post(@upload_url, body: { file: video })
27
33
  @uploaded_video_url = response.parsed_response["url"]
28
34
  end
29
35
 
30
36
  def create_video
31
- response = HTTMultiParty.post("#{API_URL}/me/videos", body: {access_token: @access_token, url: @uploaded_video_url})
37
+ response = HTTMultiParty.post("#{API_URL}/me/videos", body: { access_token: @access_token, url: @uploaded_video_url })
32
38
  @video_id = response.parsed_response["id"]
33
39
  end
34
40
 
35
- def publish_video(data)
36
- HTTMultiParty.post("#{API_URL}/video/#{@video_id}", body: data.merge(access_token: @access_token, published: true))
41
+ def publish_video(metadata)
42
+ HTTMultiParty.post("#{API_URL}/video/#{@video_id}", body: metadata.merge(access_token: @access_token, published: true))
37
43
  end
38
44
 
39
45
  def get_video(video_id, fields = "")
40
46
  return nil unless video_id
41
47
 
42
- response = HTTMultiParty.get("#{API_URL}/video/#{video_id}?fields=#{fields}")
48
+ url = "#{API_URL}/video/#{video_id}"
49
+ url << "?fields=#{fields}" unless fields.empty?
50
+
51
+ response = HTTMultiParty.get(url)
43
52
  response.parsed_response
44
53
  end
45
54
 
46
55
  def video_url
47
56
  @video_url ||= get_video(@video_id, "url")["url"] rescue nil
48
57
  end
58
+
59
+ def get_authenticated_user_videos(fields = "")
60
+ if fields.empty?
61
+ response = HTTMultiParty.get("#{API_URL}/me/videos", headers: { "Authorization" => "Bearer #{@access_token}" })
62
+ else
63
+ response = HTTMultiParty.get("#{API_URL}/me/videos?fields=#{fields}", headers: { "Authorization" => "Bearer #{@access_token}" })
64
+ end
65
+
66
+ response.parsed_response
67
+ end
68
+
69
+ def get_authenticated_user_info(fields = "")
70
+ if fields.empty?
71
+ response = HTTMultiParty.get("#{API_URL}/me/", headers: { "Authorization" => "Bearer #{@access_token}" })
72
+ else
73
+ response = HTTMultiParty.get("#{API_URL}/me?fields=#{fields}", headers: { "Authorization" => "Bearer #{@access_token}" })
74
+ end
75
+
76
+ response.parsed_response
77
+ end
78
+
79
+ def delete_video(video_id)
80
+ # It's required to get an access token with manage_videos scope
81
+ return nil unless video_id
82
+
83
+ response = HTTMultiParty.delete("#{API_URL}/me/videos/#{video_id}", headers: { "Authorization" => "Bearer #{@access_token}" })
84
+ response.parsed_response
85
+ end
86
+
87
+ private
88
+
89
+ def request_access_token_params
90
+ { grant_type: "password", client_id: @api_key, client_secret: @api_secret, username: @username, password: @password }
91
+ end
49
92
  end
50
93
  end
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  module DailymotionApi
3
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
4
5
  end
@@ -1,10 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe DailymotionApi::Client do
5
6
  before do
6
7
  HTTMultiParty.stub(:get)
7
8
  HTTMultiParty.stub(:post)
9
+ HTTMultiParty.stub(:delete)
8
10
  end
9
11
 
10
12
  let! :client do
@@ -13,28 +15,28 @@ describe DailymotionApi::Client do
13
15
 
14
16
  describe "#request_access_token" do
15
17
  it "should do a request for an access token" do
16
- response = stub("response", parsed_response: {"access_token" => "token"})
17
- HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/oauth/token", body: {grant_type: "password", client_id: "key", client_secret: "secret", username: "test", password: "12345"}).and_return(response)
18
+ response = stub("response", parsed_response: { "access_token" => "token" })
19
+ HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/oauth/token", body: { grant_type: "password", client_id: "key", client_secret: "secret", username: "test", password: "12345" }).and_return(response)
18
20
 
19
21
  client.request_access_token.should == "token"
20
22
  end
21
23
  end
22
24
 
23
- describe "#get_upload_url" do
25
+ describe "#generate_upload_url" do
24
26
  it "should request an upload url" do
25
27
  client.instance_variable_set(:@access_token, "token")
26
- response = stub("response", parsed_response: {"upload_url" => "upload_url"})
28
+ response = stub("response", parsed_response: { "upload_url" => "upload_url" })
27
29
  HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/file/upload?access_token=token").and_return(response)
28
30
 
29
- client.get_upload_url.should == "upload_url"
31
+ client.generate_upload_url.should == "upload_url"
30
32
  end
31
33
  end
32
34
 
33
35
  describe "#post_video" do
34
36
  it "should post the video" do
35
37
  client.instance_variable_set(:@upload_url, "upload_url")
36
- response = stub("response", parsed_response: {"url" => "video_url"})
37
- HTTMultiParty.should_receive(:post).with("upload_url", body: {file: "video_data"}).and_return(response)
38
+ response = stub("response", parsed_response: { "url" => "video_url" })
39
+ HTTMultiParty.should_receive(:post).with("upload_url", body: { file: "video_data" }).and_return(response)
38
40
 
39
41
  client.post_video("video_data").should == "video_url"
40
42
  end
@@ -44,8 +46,8 @@ describe DailymotionApi::Client do
44
46
  it "should post the video" do
45
47
  client.instance_variable_set(:@access_token, "token")
46
48
  client.instance_variable_set(:@uploaded_video_url, "video_url")
47
- response = stub("response", parsed_response: {"id" => "video_id"})
48
- HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/me/videos", body: {access_token: "token", url: "video_url"}).and_return(response)
49
+ response = stub("response", parsed_response: { "id" => "video_id" })
50
+ HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/me/videos", body: { access_token: "token", url: "video_url" }).and_return(response)
49
51
 
50
52
  client.create_video.should == "video_id"
51
53
  end
@@ -55,19 +57,31 @@ describe DailymotionApi::Client do
55
57
  it "should publish the video" do
56
58
  client.instance_variable_set(:@access_token, "token")
57
59
  client.instance_variable_set(:@video_id, "video_id")
58
- HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/video/video_id", body: {access_token: "token", published: true, title: "video title", channel: "shortfilms", tags: "some_tag"})
60
+ HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/video/video_id", body: { access_token: "token", published: true, title: "video title", channel: "shortfilms", tags: "some_tag" })
59
61
 
60
62
  client.publish_video(title: "video title", channel: "shortfilms", tags: "some_tag")
61
63
  end
62
64
  end
63
65
 
64
66
  describe "#get_video" do
65
- it "should return video metadata" do
66
- parsed_response = {"url" => "video_url", "channel" => "video_channel"}
67
- response = stub("response", parsed_response: parsed_response)
68
- HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/video/123?fields=url,channel").and_return(response)
67
+ context "without parameters" do
68
+ it "should return requested video metadata" do
69
+ parsed_response = { "url" => "video_url", "channel" => "video_channel" }
70
+ response = stub("response", parsed_response: parsed_response)
71
+ HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/video/123?fields=url,channel").and_return(response)
72
+
73
+ client.get_video("123", "url,channel").should == parsed_response
74
+ end
75
+ end
69
76
 
70
- client.get_video("123", "url,channel").should == parsed_response
77
+ context "with parameters" do
78
+ it "should return basic video metadata" do
79
+ parsed_response = { "id" => "video_id", "title" => "my video" }
80
+ response = stub("response", parsed_response: parsed_response)
81
+ HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/video/123").and_return(response)
82
+
83
+ client.get_video("123").should == parsed_response
84
+ end
71
85
  end
72
86
  end
73
87
 
@@ -75,7 +89,7 @@ describe DailymotionApi::Client do
75
89
  context "when video_id is defined" do
76
90
  it "should return the video url" do
77
91
  client.instance_variable_set(:@video_id, "video_id")
78
- response = stub("response", parsed_response: {"url" => "url"})
92
+ response = stub("response", parsed_response: { "url" => "url" })
79
93
  HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/video/video_id?fields=url").and_return(response)
80
94
 
81
95
  client.video_url.should == "url"
@@ -87,5 +101,67 @@ describe DailymotionApi::Client do
87
101
  client.video_url.should be_nil
88
102
  end
89
103
  end
104
+
105
+ describe "#request_access_token_manage_videos_scope" do
106
+ it "should do a request for an access token with manage videos scrope" do
107
+ response = stub("response", parsed_response: { "access_token" => "token" })
108
+ HTTMultiParty.should_receive(:post).with("https://api.dailymotion.com/oauth/token", body: { grant_type: "password", client_id: "key", client_secret: "secret", username: "test", password: "12345", scope: "manage_videos" }).and_return(response)
109
+
110
+ client.request_access_token_manage_videos_scope.should == "token"
111
+ end
112
+ end
113
+
114
+ describe "#get_authenticated_user_info " do
115
+ it "should return the information of an user authenticated with filters" do
116
+ parsed_response = { "id" => "id", "screenname" => "screenname" }
117
+ response = stub("response", parsed_response: parsed_response)
118
+ HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/me?fields=id,screenname", headers: { "Authorization" => "Bearer #{@access_token}" }).and_return(response)
119
+
120
+ client.get_authenticated_user_info("id,screenname").should == parsed_response
121
+ end
122
+ end
123
+
124
+ describe "#get_authenticated_user_info" do
125
+ it "should return the information of an user authenticated without filters" do
126
+ parsed_response = { "id" => "id", "screenname" => "screenname" }
127
+ response = stub("response", parsed_response: parsed_response)
128
+ HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/me/", headers: { "Authorization" => "Bearer #{@access_token}" }).and_return(response)
129
+
130
+ client.get_authenticated_user_info.should == parsed_response
131
+ end
132
+ end
133
+
134
+ describe "#get_authenticated_user_videos" do
135
+ it "should return the information of an user authenticated with filters" do
136
+ parsed_response = { "page" => "1", "limit" => "10", "explicit" => "false", "total" => "1", "has_more" => "false", "list" => [{ "id" => "idvideo", "title" => "testvideo" }] }
137
+ response = stub("response", parsed_response: parsed_response)
138
+ HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/me/videos?fields=id,title", headers: { "Authorization" => "Bearer #{@access_token}" }).and_return(response)
139
+
140
+ client.get_authenticated_user_videos("id,title").should == parsed_response
141
+ end
142
+ end
143
+
144
+ describe "#get_authenticated_user_videos" do
145
+ it "should return the information of an user authenticated without filters" do
146
+ parsed_response = {
147
+ "page" => "1", "limit" => "10", "explicit" => "false", "total" => "1", "has_more" => "false",
148
+ "list" => [{ "id" => "idvideo", "title" => "testvideo", "channel" => "sportTest", "owner" => "test" }]
149
+ }
150
+ response = stub("response", parsed_response: parsed_response)
151
+ HTTMultiParty.should_receive(:get).with("https://api.dailymotion.com/me/videos", headers: { "Authorization" => "Bearer #{@access_token}" }).and_return(response)
152
+
153
+ client.get_authenticated_user_videos.should == parsed_response
154
+ end
155
+ end
156
+
157
+ describe "#delete_video" do
158
+ it "should delete a specific video" do
159
+ parsed_response = {}
160
+ response = stub("response", parsed_response: parsed_response)
161
+ HTTMultiParty.should_receive(:delete).with("https://api.dailymotion.com/me/videos/xxx", headers: { "Authorization" => "Bearer #{@access_token}" }).and_return(response)
162
+
163
+ client.delete_video("xxx").should == parsed_response
164
+ end
165
+ end
90
166
  end
91
167
  end
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
- ENV['RACK_ENV'] ||= 'test'
3
2
 
4
- $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ ENV["RACK_ENV"] ||= "test"
5
4
 
6
- require 'rspec'
7
- require 'dailymotion-api-client'
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
6
+
7
+ require "rspec"
8
+ require "dailymotion-api-client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dailymotion-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Garnier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-05 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httmultiparty
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  description: DailyMotion API Ruby client
42
70
  email:
43
71
  - guilherme.garnier@gmail.com
@@ -46,7 +74,12 @@ extensions: []
46
74
  extra_rdoc_files: []
47
75
  files:
48
76
  - .rspec
49
- - .rvmrc
77
+ - .rubocop.yml
78
+ - .rubocop_todo.yml
79
+ - .ruby-gemset
80
+ - .ruby-version
81
+ - .travis.yml
82
+ - CHANGELOG.md
50
83
  - Gemfile
51
84
  - Gemfile.lock
52
85
  - README.md
@@ -76,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
109
  version: '0'
77
110
  requirements: []
78
111
  rubyforge_project:
79
- rubygems_version: 2.0.0
112
+ rubygems_version: 2.4.8
80
113
  signing_key:
81
114
  specification_version: 4
82
115
  summary: DailyMotion API Ruby client
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 1.9.3-p194@dailymotion-api-client