social_authority 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/social_authority/api.rb +41 -0
- data/lib/social_authority/client.rb +21 -0
- data/lib/social_authority/error.rb +3 -0
- data/lib/social_authority/version.rb +14 -0
- data/lib/social_authority.rb +5 -2
- metadata +42 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff66d767a678ce5d2a90b69cfda86d262a497a9d
|
4
|
+
data.tar.gz: 7ad96a68d6e669c3a17f94ea01d304ed2907366b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e5e4cdfcbf71791d20d2d1eff21ec7ceb571ec6d1fe14bd9a9299527ea7f967e12615616f90349caf2ab18774f09534da7928693464e235702753e0fd62e036
|
7
|
+
data.tar.gz: a004c473b81114d12d8328d4962530d60f8863f5b9dd7b85720ee62a37e5d06f363175d4be2afdd3e1be4b138d473777a3b08fec6eef9437596c5d7fe824d2f5
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module SocialAuthority
|
2
|
+
class Api
|
3
|
+
attr_reader :access_id, :secret_key, :user_ids, :screen_names
|
4
|
+
|
5
|
+
def initialize(access_id, secret_key)
|
6
|
+
@access_id, @secret_key = access_id, secret_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch(user_ids = [], screen_names = [])
|
10
|
+
@user_ids, @screen_names = user_ids, screen_names
|
11
|
+
|
12
|
+
response = HTTParty.get(generate_request_url)
|
13
|
+
|
14
|
+
if response.response.code == '200'
|
15
|
+
response.parsed_response['_embedded']
|
16
|
+
else
|
17
|
+
raise ResponseError, response.parsed_response
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def generate_request_url
|
23
|
+
timestamp = Time.now.to_i + 500
|
24
|
+
|
25
|
+
url = 'https://api.followerwonk.com/social-authority'
|
26
|
+
url << '?'
|
27
|
+
url << "user_id=#{ user_ids.join(',') };"
|
28
|
+
url << "screen_name=#{ screen_names.join(',') };"
|
29
|
+
url << "AccessID=#{ access_id };"
|
30
|
+
url << "Timestamp=#{ timestamp };"
|
31
|
+
url << "Signature=#{ generate_signature(timestamp) }"
|
32
|
+
url
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_signature(timestamp)
|
36
|
+
digest = OpenSSL::Digest.new('sha1')
|
37
|
+
data = "#{ access_id }\n#{ timestamp }"
|
38
|
+
CGI::escape(Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret_key, data)))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SocialAuthority
|
2
|
+
class Client
|
3
|
+
attr_reader :api
|
4
|
+
|
5
|
+
def initialize(access_id, secret_key)
|
6
|
+
@api = Api.new(access_id, secret_key)
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch(user_ids, screen_names)
|
10
|
+
api.fetch(user_ids, screen_names)
|
11
|
+
end
|
12
|
+
|
13
|
+
def fetch_user_ids(user_ids)
|
14
|
+
api.fetch(user_ids, [])
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch_screen_names(screen_names)
|
18
|
+
api.fetch([], screen_names)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/social_authority.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_authority
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam A. Gasanov
|
@@ -9,14 +9,52 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-02-19 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.11.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.12.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.11.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.12.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.2'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.2'
|
47
|
+
description: A Ruby interface to the Social Authority API.
|
14
48
|
email: rustamagasanov@gmail.com
|
15
49
|
executables: []
|
16
50
|
extensions: []
|
17
51
|
extra_rdoc_files: []
|
18
52
|
files:
|
19
53
|
- lib/social_authority.rb
|
54
|
+
- lib/social_authority/api.rb
|
55
|
+
- lib/social_authority/client.rb
|
56
|
+
- lib/social_authority/error.rb
|
57
|
+
- lib/social_authority/version.rb
|
20
58
|
homepage: http://rubygems.org/gems/social_authority
|
21
59
|
licenses:
|
22
60
|
- MIT
|
@@ -40,5 +78,5 @@ rubyforge_project:
|
|
40
78
|
rubygems_version: 2.2.2
|
41
79
|
signing_key:
|
42
80
|
specification_version: 4
|
43
|
-
summary: Social Authority API
|
81
|
+
summary: Social Authority API wrapper
|
44
82
|
test_files: []
|