vine_client 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/README.md +4 -0
- data/lib/vine_client/client.rb +38 -0
- data/lib/vine_client/request.rb +36 -0
- data/lib/vine_client.rb +9 -0
- data/vine_client.gemspec +15 -0
- metadata +82 -0
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Vine
|
2
|
+
class Client
|
3
|
+
include Request
|
4
|
+
def initialize(name, pass)
|
5
|
+
result=login(name,pass)
|
6
|
+
@key=result['key']
|
7
|
+
@userId=result['userId']
|
8
|
+
end
|
9
|
+
|
10
|
+
def login(name, pass)
|
11
|
+
post('/users/authenticate',{:username =>name, :password=>pass})
|
12
|
+
end
|
13
|
+
|
14
|
+
def logout
|
15
|
+
delete('/users/authenticate')
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_popular
|
19
|
+
get('/timelines/popular')
|
20
|
+
end
|
21
|
+
|
22
|
+
def user_info(user_id=@userId)
|
23
|
+
get("/users/profiles/#{user_id}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def timelines(user_id=@userId)
|
27
|
+
get("/timelines/users/#{user_id}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def tag(tag=nil)
|
31
|
+
get('/timelines/tags/#{tag}') if tag
|
32
|
+
end
|
33
|
+
|
34
|
+
def notifications(user_id=@userId)
|
35
|
+
get("/users/#{user_id}/pendingNotificationsCount")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Vine
|
2
|
+
module Request
|
3
|
+
|
4
|
+
[:get,:put,:post,:delete].each{|verb|define_method(verb){|*arg| call(verb, arg[0],arg[1])}}
|
5
|
+
|
6
|
+
def call(http_verb, path, params)
|
7
|
+
result = connection.send(http_verb, path, params){|req| req[:vine_session_id]=@key if @key}
|
8
|
+
result.body['data']
|
9
|
+
end
|
10
|
+
|
11
|
+
def connection
|
12
|
+
options = {
|
13
|
+
:url => 'https://api.vineapp.com/',
|
14
|
+
:headers => {
|
15
|
+
:accept => 'application/json',
|
16
|
+
:user_agent => "com.vine.iphone/1.0.3 (unknown, iPhone OS 6.1.0, iPhone, Scale/2.000000)",
|
17
|
+
},
|
18
|
+
:request => {
|
19
|
+
:open_timeout => 5,
|
20
|
+
:timeout => 10,
|
21
|
+
},
|
22
|
+
:ssl => {
|
23
|
+
:verify => true
|
24
|
+
},
|
25
|
+
}
|
26
|
+
|
27
|
+
Faraday.new(options) do |builder|
|
28
|
+
builder.response :raise_error
|
29
|
+
builder.response :mashify
|
30
|
+
builder.response :json
|
31
|
+
builder.request :url_encoded
|
32
|
+
builder.adapter :net_http
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/vine_client.rb
ADDED
data/vine_client.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'vine_client'
|
3
|
+
s.version = '0.0.0'
|
4
|
+
s.date = '2013-07-14'
|
5
|
+
s.summary = "vine_client"
|
6
|
+
s.description = "ruby wraper for vine.co api"
|
7
|
+
s.author = "Roman Lozhkin"
|
8
|
+
s.email = "obrigan228@gmail.com"
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.required_ruby_version = '>= 1.9.2'
|
11
|
+
s.add_runtime_dependency 'faraday', '~> 0.8'
|
12
|
+
s.add_runtime_dependency 'faraday_middleware', '~> 0.8'
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
s.homepage = 'https://github.com/obrigan228/vine_client'
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vine_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Roman Lozhkin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.8'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.8'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: faraday_middleware
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0.8'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.8'
|
46
|
+
description: ruby wraper for vine.co api
|
47
|
+
email: obrigan228@gmail.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- .gitignore
|
53
|
+
- README.md
|
54
|
+
- lib/vine_client.rb
|
55
|
+
- lib/vine_client/client.rb
|
56
|
+
- lib/vine_client/request.rb
|
57
|
+
- vine_client.gemspec
|
58
|
+
homepage: https://github.com/obrigan228/vine_client
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.9.2
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.25
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: vine_client
|
82
|
+
test_files: []
|