kewego_party 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +47 -0
- data/Rakefile +10 -0
- data/TODO.md +4 -0
- data/kewego_party.gemspec +35 -0
- data/lib/kewego_party.rb +29 -0
- data/lib/kewego_party/cache.rb +42 -0
- data/lib/kewego_party/client.rb +52 -0
- data/lib/kewego_party/client/app.rb +16 -0
- data/lib/kewego_party/client/auth.rb +35 -0
- data/lib/kewego_party/client/channel.rb +57 -0
- data/lib/kewego_party/client/channel_list.rb +18 -0
- data/lib/kewego_party/client/upload.rb +31 -0
- data/lib/kewego_party/client/video.rb +36 -0
- data/lib/kewego_party/configuration.rb +49 -0
- data/lib/kewego_party/connection.rb +20 -0
- data/lib/kewego_party/exceptions.rb +5 -0
- data/lib/kewego_party/parse_xml.rb +19 -0
- data/lib/kewego_party/request.rb +55 -0
- data/lib/kewego_party/version.rb +3 -0
- data/spec/fixtures/app_get_auth_token.xml +6 -0
- data/spec/fixtures/app_get_token.xml +5 -0
- data/spec/fixtures/cassette_library/app_check_token.yml +68 -0
- data/spec/fixtures/cassette_library/app_get_token.yml +30 -0
- data/spec/fixtures/cassette_library/channel_get_details.yml +68 -0
- data/spec/fixtures/cassette_library/channel_get_player_code.yml +69 -0
- data/spec/fixtures/cassette_library/channel_get_thumbnail.yml +68 -0
- data/spec/fixtures/cassette_library/channel_get_videos.yml +68 -0
- data/spec/fixtures/cassette_library/channel_list_get_channels.yml +68 -0
- data/spec/fixtures/cassette_library/channel_list_get_details.yml +68 -0
- data/spec/fixtures/cassette_library/upload_get_available_categories.yml +115 -0
- data/spec/fixtures/cassette_library/video_get_details.yml +69 -0
- data/spec/fixtures/cassette_library/video_get_stats.yml +60 -0
- data/spec/fixtures/kewego_response_error.xml +5 -0
- data/spec/fixtures/not_kewego_response.xml +4 -0
- data/spec/fixtures/upload_get_upload_progress.xml +8 -0
- data/spec/kewego_party/client/app_spec.rb +28 -0
- data/spec/kewego_party/client/auth_spec.rb +45 -0
- data/spec/kewego_party/client/cache_spec.rb +34 -0
- data/spec/kewego_party/client/channel_list_spec.rb +36 -0
- data/spec/kewego_party/client/channel_spec.rb +59 -0
- data/spec/kewego_party/client/request_spec.rb +31 -0
- data/spec/kewego_party/client/upload_spec.rb +39 -0
- data/spec/kewego_party/client/video_spec.rb +33 -0
- data/spec/kewego_party/client_spec.rb +20 -0
- data/spec/kewego_party_spec.rb +22 -0
- data/spec/spec_helper.rb +32 -0
- metadata +257 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :get
|
5
|
+
uri: http://api.kewego.com:80/app/getToken/?appKey=d4c804fd0f42533351aca404313d26eb
|
6
|
+
body:
|
7
|
+
headers:
|
8
|
+
response: !ruby/struct:VCR::Response
|
9
|
+
status: !ruby/struct:VCR::ResponseStatus
|
10
|
+
code: 200
|
11
|
+
message: OK
|
12
|
+
headers:
|
13
|
+
expires:
|
14
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
15
|
+
content-type:
|
16
|
+
- text/html; charset=utf-8
|
17
|
+
server:
|
18
|
+
- lighttpd
|
19
|
+
date:
|
20
|
+
- Tue, 09 Aug 2011 14:19:51 GMT
|
21
|
+
transfer-encoding:
|
22
|
+
- chunked
|
23
|
+
body: |
|
24
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
25
|
+
<kewego_response>
|
26
|
+
<message><appToken>34b54efcb338fb42a12f479ae493780f3c2b234a4b0188fb8f2a3ba2af3806d038f2471459ae851bab977f09a466ac55ef6dc2b9eff6ab184f6f0356822113a8</appToken></message>
|
27
|
+
<KqId>4e414207da593</KqId>
|
28
|
+
</kewego_response>
|
29
|
+
|
30
|
+
http_version: "1.1"
|
31
|
+
- !ruby/struct:VCR::HTTPInteraction
|
32
|
+
request: !ruby/struct:VCR::Request
|
33
|
+
method: :get
|
34
|
+
uri: http://api.kewego.com:80/video/getStats/?appToken=34b54efcb338fb42a12f479ae493780f3c2b234a4b0188fb8f2a3ba2af3806d038f2471459ae851bab977f09a466ac55ef6dc2b9eff6ab184f6f0356822113a8&sig=iLyROoaf22Mr&type=day&value=15
|
35
|
+
body:
|
36
|
+
headers:
|
37
|
+
response: !ruby/struct:VCR::Response
|
38
|
+
status: !ruby/struct:VCR::ResponseStatus
|
39
|
+
code: 200
|
40
|
+
message: OK
|
41
|
+
headers:
|
42
|
+
expires:
|
43
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
44
|
+
content-type:
|
45
|
+
- text/html; charset=utf-8
|
46
|
+
server:
|
47
|
+
- lighttpd
|
48
|
+
date:
|
49
|
+
- Tue, 09 Aug 2011 14:19:52 GMT
|
50
|
+
transfer-encoding:
|
51
|
+
- chunked
|
52
|
+
body: |
|
53
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
54
|
+
<kewego_response>
|
55
|
+
<message><stats sig="iLyROoaf22Mr"><points><point day="2011-07-25" value="0"/><point day="2011-07-26" value="0"/><point day="2011-07-27" value="6"/><point day="2011-07-28" value="0"/><point day="2011-07-29" value="1"/><point day="2011-07-30" value="0"/><point day="2011-07-31" value="0"/><point day="2011-08-01" value="1"/><point day="2011-08-02" value="0"/><point day="2011-08-03" value="0"/><point day="2011-08-04" value="0"/><point day="2011-08-05" value="1"/><point day="2011-08-06" value="0"/><point day="2011-08-07" value="0"/><point day="2011-08-08" value="4"/></points></stats>
|
56
|
+
</message>
|
57
|
+
<KqId>4e4142086d9c1</KqId>
|
58
|
+
</kewego_response>
|
59
|
+
|
60
|
+
http_version: "1.1"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::App do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".app_get_token" do
|
11
|
+
use_vcr_cassette "app_get_token"
|
12
|
+
|
13
|
+
it "should return an app_token" do
|
14
|
+
app_token = @client.app_get_token()
|
15
|
+
app_token.should_not be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".app_check_token" do
|
20
|
+
use_vcr_cassette "app_check_token"
|
21
|
+
|
22
|
+
it "should return true" do
|
23
|
+
@client.app_get_token # Get and save the app_token
|
24
|
+
result = @client.app_check_token()
|
25
|
+
result.should be_true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::Auth do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe ".auth_get_auth_token" do
|
11
|
+
it "should return a token" do
|
12
|
+
VCR.turned_off do
|
13
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
14
|
+
to_return(:body => fixture("app_get_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
15
|
+
|
16
|
+
stub_request(:get, "http://login.kewego.com/api/getAuthToken/?password=demo&username=test@kewego.com&appToken=#{@client.app_token}").
|
17
|
+
to_return(:body => fixture("app_get_auth_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
18
|
+
|
19
|
+
# @client.app_get_token # Get and save the app_token
|
20
|
+
@client.app_token = "d24267bee58313337341f46771f3eeaa64b9254856b0ff3dc6eab18718db0a5e"
|
21
|
+
token = @client.auth_get_auth_token(:password => "demo", :username => "test@kewego.com")
|
22
|
+
|
23
|
+
token.should_not be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".auth_get_login_token" do
|
29
|
+
it "should return a token" do
|
30
|
+
VCR.turned_off do
|
31
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
32
|
+
to_return(:body => fixture("app_get_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
33
|
+
|
34
|
+
stub_request(:get, "http://login.kewego.com/api/getLoginToken/?password=demo&username=test@kewego.com&appToken=#{@client.app_token}").
|
35
|
+
to_return(:body => fixture("app_get_auth_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
36
|
+
|
37
|
+
# @client.app_get_token # Get and save the app_token
|
38
|
+
@client.app_token = "d24267bee58313337341f46771f3eeaa64b9254856b0ff3dc6eab18718db0a5e"
|
39
|
+
token = @client.auth_get_login_token(:password => "demo", :username => "test@kewego.com")
|
40
|
+
|
41
|
+
token.should_not be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::App do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should use the default APICache.store as caching_store" do
|
11
|
+
@client.caching_store.should be_kind_of(APICache.store.class)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should cache the app_token when access" do
|
15
|
+
VCR.turned_off do
|
16
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
17
|
+
to_return(:body => fixture("app_get_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
18
|
+
|
19
|
+
2.times { @client.app_token }
|
20
|
+
a_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").should have_been_made.once
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should execute the request if reset the app_token" do
|
25
|
+
VCR.turned_off do
|
26
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
27
|
+
to_return(:body => fixture("app_get_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
28
|
+
|
29
|
+
@client.app_token
|
30
|
+
@client.app_reset_app_token
|
31
|
+
a_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").should have_been_made.twice
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::ChannelList do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
|
9
|
+
@lsig = "327982b09c3l"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".get_channels" do
|
13
|
+
use_vcr_cassette "channel_list_get_channels"
|
14
|
+
|
15
|
+
it "should return the cannels" do
|
16
|
+
@client.app_get_token # Get and save the app_token
|
17
|
+
channels = @client.channel_list_get_channels(@lsig)
|
18
|
+
|
19
|
+
channels.total_result.should == "7"
|
20
|
+
channels.channel.should have(7).items
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".get_details" do
|
25
|
+
use_vcr_cassette "channel_list_get_details"
|
26
|
+
|
27
|
+
it "should return a token" do
|
28
|
+
@client.app_get_token # Get and save the app_token
|
29
|
+
details = @client.channel_list_get_details(@lsig)
|
30
|
+
|
31
|
+
details.title.should == "Todos los canales"
|
32
|
+
details.description.should == "Todos los canales de CharHadasTv"
|
33
|
+
details.lsig.should == @lsig
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::Channel do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
|
9
|
+
@csig = "iLyROoafYVn8"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".channel_get_videos" do
|
13
|
+
use_vcr_cassette "channel_get_videos"
|
14
|
+
|
15
|
+
pending "should return the videos of the channel" do
|
16
|
+
@client.app_get_token # Get and save the app_token
|
17
|
+
videos = @client.channel_get_videos(@csig)
|
18
|
+
|
19
|
+
videos.total_results.should == "2"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".channel_get_player_code" do
|
24
|
+
use_vcr_cassette "channel_get_player_code"
|
25
|
+
|
26
|
+
it "should return the player code" do
|
27
|
+
@client.app_get_token # Get and save the app_token
|
28
|
+
player_code = @client.channel_get_player_code(@csig)
|
29
|
+
|
30
|
+
player_code.should =~ /<object.*<\/object>/
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".channel_get_details" do
|
35
|
+
use_vcr_cassette "channel_get_details"
|
36
|
+
|
37
|
+
it "should return the channel details" do
|
38
|
+
@client.app_get_token # Get and save the app_token
|
39
|
+
details = @client.channel_get_details(@csig)
|
40
|
+
|
41
|
+
details.csig.should == @csig
|
42
|
+
details.name.should == "Recetas"
|
43
|
+
details.thumbnail.should == "http://tll.kewego.com/t/img/thumb_default.jpg"
|
44
|
+
details.nbvideos.should == "2"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ".channel_get_thumbnail" do
|
49
|
+
use_vcr_cassette "channel_get_thumbnail"
|
50
|
+
|
51
|
+
pending "should return the thumbnail" do
|
52
|
+
@client.app_get_token # Get and save the app_token
|
53
|
+
puts @client.app_token
|
54
|
+
details = @client.channel_get_thumbnail(@csig)
|
55
|
+
|
56
|
+
details.should == @csig
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Request do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "raise an exception if the response not a kewego response" do
|
11
|
+
VCR.turned_off do
|
12
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
13
|
+
to_return(:body => fixture("not_kewego_response.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
14
|
+
|
15
|
+
expect {
|
16
|
+
@client.app_get_token
|
17
|
+
}.to raise_error(KewegoParty::InvalidResponseException)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raise an exception if the response has a kewego error" do
|
22
|
+
VCR.turned_off do
|
23
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
24
|
+
to_return(:body => fixture("kewego_response_error.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
25
|
+
|
26
|
+
expect {
|
27
|
+
@client.app_get_token
|
28
|
+
}.to raise_error(KewegoParty::ErrorResponseException, 'appToken can not delivered')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::Video do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
|
9
|
+
@upload_key = "9c4f35567be7fda1e143d95696fadb1a" # Digest::MD5.hexdigest(SecureRandom.hex(15))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".upload_get_available_categories" do
|
13
|
+
use_vcr_cassette "upload_get_available_categories"
|
14
|
+
|
15
|
+
it "should return the upload categories" do
|
16
|
+
@client.app_get_token # Get and save the app_token
|
17
|
+
categories = @client.upload_get_available_categories
|
18
|
+
|
19
|
+
categories.should have_at_least(2).items
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".upload_get_upload_progress" do
|
24
|
+
it "should return the progress of an upload" do
|
25
|
+
VCR.turned_off do
|
26
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
27
|
+
to_return(:body => fixture("app_get_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
28
|
+
|
29
|
+
stub_request(:get, "http://api.kewego.com/upload/getUploadProgress/?appToken=#{@client.app_token}&upload_key=#{@upload_key}").
|
30
|
+
to_return(:body => fixture("upload_get_upload_progress.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
31
|
+
|
32
|
+
@client.app_get_token # Get and save the app_token
|
33
|
+
stats = @client.upload_get_upload_progress(@upload_key)
|
34
|
+
|
35
|
+
stats.state.should == 'uploading'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client::Video do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
|
9
|
+
@sig = "iLyROoaf22Mr"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".video_get_details" do
|
13
|
+
use_vcr_cassette "video_get_details"
|
14
|
+
|
15
|
+
it "should return the video details" do
|
16
|
+
@client.app_get_token # Get and save the app_token
|
17
|
+
video = @client.video_get_details(@sig)
|
18
|
+
|
19
|
+
video.thumbnails.keys.should have(3).items
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".video_get_stats" do
|
24
|
+
use_vcr_cassette "video_get_stats"
|
25
|
+
|
26
|
+
it "should return the stats from 15 days" do
|
27
|
+
@client.app_get_token # Get and save the app_token
|
28
|
+
stats = @client.video_get_stats(@sig)
|
29
|
+
|
30
|
+
stats.points.point.should have(15).items
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty::Client do
|
5
|
+
|
6
|
+
before do
|
7
|
+
@client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise an exception if the response not corresponds" do
|
11
|
+
VCR.turned_off do
|
12
|
+
stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
|
13
|
+
to_return(:body => fixture("app_get_auth_token.xml"), :headers => {:content_type => "text/html; charset=utf-8"})
|
14
|
+
|
15
|
+
expect {
|
16
|
+
@client.app_get_token
|
17
|
+
}.to raise_error(KewegoParty::InvalidResponseException)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe KewegoParty do
|
5
|
+
describe ".respond_to?" do
|
6
|
+
it "should be true if method exists" do
|
7
|
+
KewegoParty.respond_to?(:new, true).should be_true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".new" do
|
12
|
+
it "should be a KewegoParty::Client" do
|
13
|
+
KewegoParty.new.should be_a KewegoParty::Client
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".delegate" do
|
18
|
+
pending "should delegate missing methods to Kewego::Client" do
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|