redvine 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -25,16 +25,20 @@ It pretty much goes without saying that this wasn't authorized by Vine or anyone
25
25
 
26
26
  # Find videos by tag
27
27
  client.search('cats')
28
+ client.search('cats', :page => 2)
28
29
 
29
30
  # Find user profiles by user ID
30
31
  client.user_profile('908082141764657152')
31
32
 
32
33
  # Get a user's timeline by their user ID
33
34
  client.user_timeline('908082141764657152')
35
+ client.user_timeline('908082141764657152', :page => 2)
34
36
 
35
37
  # Get popular and promoted videos
36
38
  client.popular
39
+ client.popular(:page => 2)
37
40
  client.promoted
41
+ client.promoted(:page => 2)
38
42
 
39
43
  ## Things To Do
40
44
 
@@ -8,7 +8,7 @@ class Redvine
8
8
 
9
9
  @@baseUrl = 'https://api.vineapp.com/'
10
10
  @@deviceToken = 'Redvine'
11
- @@userAgent = 'com.vine.iphone/1.01 (unknown, iPhone OS 6.0, iPad, Scale/2.000000) (Redvine)'
11
+ @@userAgent = 'iphone/1.3.1 (iPhone; iOS 6.1.3; Scale/2.00) (Redvine)'
12
12
 
13
13
  def connect(opts={})
14
14
  validate_connect_args(opts)
@@ -20,31 +20,31 @@ class Redvine
20
20
  @user_id = response.parsed_response['data']['userId']
21
21
  end
22
22
 
23
- def search(tag)
23
+ def search(tag, opts={})
24
24
  raise(ArgumentError, 'You must specify a tag') if !tag
25
- get_request_data('timelines/tags/' + tag)
25
+ get_request_data('timelines/tags/' + tag, opts)
26
26
  end
27
27
 
28
- def popular
29
- get_request_data('timelines/popular')
28
+ def popular(opts={})
29
+ get_request_data('timelines/popular', opts)
30
30
  end
31
31
 
32
- def promoted
33
- get_request_data('timelines/promoted')
32
+ def promoted(opts={})
33
+ get_request_data('timelines/promoted', opts)
34
34
  end
35
35
 
36
- def timeline
37
- get_request_data('timelines/graph')
36
+ def timeline(opts={})
37
+ get_request_data('timelines/graph', opts)
38
38
  end
39
39
 
40
40
  def user_profile(uid)
41
41
  raise(ArgumentError, 'You must specify a user id') if !uid
42
- get_request_data('users/profiles/' + uid, false)
42
+ get_request_data('users/profiles/' + uid, {}, false)
43
43
  end
44
44
 
45
- def user_timeline(uid)
45
+ def user_timeline(uid, opts={})
46
46
  raise(ArgumentError, 'You must specify a user id') if !uid
47
- get_request_data('timelines/users/' + uid)
47
+ get_request_data('timelines/users/' + uid, opts)
48
48
  end
49
49
 
50
50
 
@@ -56,11 +56,19 @@ class Redvine
56
56
  end
57
57
 
58
58
  def session_headers
59
- {'User-Agent' => @@userAgent, 'vine-session-id' => @vine_key}
59
+ {
60
+ 'User-Agent' => @@userAgent,
61
+ 'vine-session-id' => @vine_key,
62
+ 'Accept' => '*/*',
63
+ 'Accept-Language' => 'en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5'
64
+ }
60
65
  end
61
66
 
62
- def get_request_data(endpoint, records=true)
63
- response = HTTParty.get(@@baseUrl + endpoint, {headers: session_headers})
67
+ def get_request_data(endpoint, query={}, records=true)
68
+ query.merge!(:size => 20) if query.has_key?(:page) && !query.has_key?(:size)
69
+ args = {:headers => session_headers}
70
+ args.merge!(:query => query) if query != {}
71
+ response = HTTParty.get(@@baseUrl + endpoint, args)
64
72
  if response.parsed_response['success'] == false
65
73
  response.parsed_response['error'] = true
66
74
  return Hashie::Mash.new(response.parsed_response)
@@ -1,3 +1,3 @@
1
1
  class Redvine
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -54,6 +54,16 @@ describe Redvine do
54
54
  end
55
55
  end
56
56
 
57
+ it 'should return a second page of results' do
58
+ VCR.use_cassette('redvine', :record => :new_episodes) do
59
+ client = setup_client()
60
+ vines = client.search('cat')
61
+ vinesp2 = client.search('cat', :page => 2)
62
+ expect(vines).to_not equal(vinesp2)
63
+ expect(vines.first.videoUrl).to_not equal(vinesp2.first.videoUrl)
64
+ end
65
+ end
66
+
57
67
  end
58
68
 
59
69
  describe '.popular' do
@@ -71,6 +81,16 @@ describe Redvine do
71
81
  end
72
82
  end
73
83
 
84
+ it 'should return a second page of results' do
85
+ VCR.use_cassette('redvine', :record => :new_episodes) do
86
+ client = setup_client()
87
+ vines = client.popular
88
+ vinesp2 = client.popular(:page => 2)
89
+ expect(vines).to_not equal(vinesp2)
90
+ expect(vines.first.videoUrl).to_not equal(vinesp2.first.videoUrl)
91
+ end
92
+ end
93
+
74
94
  end
75
95
 
76
96
 
@@ -89,6 +109,16 @@ describe Redvine do
89
109
  end
90
110
  end
91
111
 
112
+ it 'should return a second page of results' do
113
+ VCR.use_cassette('redvine', :record => :new_episodes) do
114
+ client = setup_client()
115
+ vines = client.promoted
116
+ vinesp2 = client.promoted(:page => 2)
117
+ expect(vines).to_not equal(vinesp2)
118
+ expect(vines.first.videoUrl).to_not equal(vinesp2.first.videoUrl)
119
+ end
120
+ end
121
+
92
122
  end
93
123
 
94
124
  describe '.timeline' do
@@ -106,6 +136,16 @@ describe Redvine do
106
136
  end
107
137
  end
108
138
 
139
+ it 'should return a second page of results' do
140
+ VCR.use_cassette('redvine', :record => :new_episodes) do
141
+ client = setup_client()
142
+ vines = client.timeline()
143
+ vinesp2 = client.timeline(:page => 2)
144
+ expect(vines).to_not equal(vinesp2)
145
+ expect(vines.first.videoUrl).to_not equal(vinesp2.first.videoUrl)
146
+ end
147
+ end
148
+
109
149
  end
110
150
 
111
151
  describe '.user_profile' do
@@ -161,6 +201,16 @@ describe Redvine do
161
201
  end
162
202
  end
163
203
 
204
+ it 'should return a second page of results' do
205
+ VCR.use_cassette('redvine', :record => :new_episodes) do
206
+ client = setup_client()
207
+ vines = client.user_timeline('914021455983943680')
208
+ vinesp2 = client.user_timeline('914021455983943680', :page => 2)
209
+ expect(vines).to_not equal(vinesp2)
210
+ expect(vines.first.videoUrl).to_not equal(vinesp2.first.videoUrl)
211
+ end
212
+ end
213
+
164
214
  it 'should not break if an error is returned from Vine' do
165
215
  VCR.use_cassette('redvine', :record => :new_episodes) do
166
216
  client = setup_client()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redvine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-21 00:00:00.000000000 Z
12
+ date: 2013-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty