Class: Redvine

Inherits:
Object
  • Object
show all
Defined in:
lib/redvine.rb,
lib/redvine/version.rb

Constant Summary collapse

VERSION =
"0.0.3"
@@baseUrl =
'https://api.vineapp.com/'
@@deviceToken =
'Redvine'
@@userAgent =
'com.vine.iphone/1.01 (unknown, iPhone OS 6.0, iPad, Scale/2.000000) (Redvine)'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#user_idObject (readonly)

Returns the value of attribute user_id.



7
8
9
# File 'lib/redvine.rb', line 7

def user_id
  @user_id
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/redvine.rb', line 7

def username
  @username
end

#vine_keyObject (readonly)

Returns the value of attribute vine_key.



7
8
9
# File 'lib/redvine.rb', line 7

def vine_key
  @vine_key
end

Instance Method Details

#connect(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/redvine.rb', line 13

def connect(opts={})
  validate_connect_args(opts)
  query = {username: opts[:email], password: opts[:password], deviceToken: @@deviceToken}
  headers = {'User-Agent' => @@userAgent}
  response = HTTParty.post(@@baseUrl + 'users/authenticate', {body: query, headers: headers})
  @vine_key = response.parsed_response['data']['key']
  @username = response.parsed_response['data']['username']
  @user_id = response.parsed_response['data']['userId']
end


28
29
30
# File 'lib/redvine.rb', line 28

def popular
  get_request_data('timelines/popular')
end


32
33
34
# File 'lib/redvine.rb', line 32

def promoted
  get_request_data('timelines/promoted')
end

#search(tag) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
# File 'lib/redvine.rb', line 23

def search(tag)
  raise(ArgumentError, 'You must specify a tag') if !tag
  get_request_data('timelines/tags/' + tag)
end

#timelineObject



36
37
38
# File 'lib/redvine.rb', line 36

def timeline
  get_request_data('timelines/graph')
end

#user_profile(uid) ⇒ Object

Raises:

  • (ArgumentError)


40
41
42
43
# File 'lib/redvine.rb', line 40

def (uid)
  raise(ArgumentError, 'You must specify a user id') if !uid
  get_request_data('users/profiles/' + uid, false)
end

#user_timeline(uid) ⇒ Object

Raises:

  • (ArgumentError)


45
46
47
48
# File 'lib/redvine.rb', line 45

def user_timeline(uid)
  raise(ArgumentError, 'You must specify a user id') if !uid
  get_request_data('timelines/users/' + uid)
end