line-social 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/line/social/client.rb +2 -13
- data/lib/line/social/profile.rb +2 -2
- data/lib/line/social/request/base.rb +14 -0
- data/lib/line/social/request/friendship.rb +9 -3
- data/lib/line/social/request/oauth.rb +12 -4
- data/lib/line/social/request/profile.rb +13 -5
- data/lib/line/social/version.rb +1 -1
- data/lib/line/social.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eaba402a6d0d78f613732d830365688b85c4fc797356dd5e4593800c60b01e8
|
4
|
+
data.tar.gz: cc59e86f156510264ec6e8ac474b25b08440472f4b97d5faf24ccb89c54c9ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5df52de38e01b72bafbb15b04772dd5e5bdf0f59cb266fa4f55eaf595ab847b63abaf6dc3162d666e510ee820dfc6dd1ddc5b56ee4b7c374ecc335a578ea2eb8
|
7
|
+
data.tar.gz: 027e28e2e1f78a19a35467230787c385e7f0e16239ab993c1433611d4e420526deeb1af85e6c5aecff1ca11aacdc53048afaa7eff72cbcd0fc4829ee2eeff4a1
|
data/lib/line/social/client.rb
CHANGED
@@ -10,22 +10,11 @@ module Line
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def oauth
|
13
|
-
Request::Oauth.new(
|
13
|
+
Request::Oauth.new(@access_token)
|
14
14
|
end
|
15
15
|
|
16
16
|
def profile
|
17
|
-
Request::Profile.new(
|
18
|
-
end
|
19
|
-
|
20
|
-
def request_path
|
21
|
-
Client::API_URI.path
|
22
|
-
end
|
23
|
-
|
24
|
-
def request
|
25
|
-
@request ||= Faraday.new(url: "#{API_URI.scheme}://#{API_URI.host}") do |connection|
|
26
|
-
connection.response :json, content_type: /\bjson$/
|
27
|
-
connection.adapter Faraday.default_adapter
|
28
|
-
end
|
17
|
+
Request::Profile.new(@access_token)
|
29
18
|
end
|
30
19
|
end
|
31
20
|
end
|
data/lib/line/social/profile.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
module Line
|
2
2
|
module Social
|
3
3
|
module Request
|
4
|
-
class Friendship
|
5
|
-
def initialize(
|
6
|
-
@
|
4
|
+
class Friendship < Base
|
5
|
+
def initialize(access_token)
|
6
|
+
@access_token = access_token
|
7
7
|
end
|
8
8
|
|
9
9
|
def get
|
10
10
|
raise Line::Social::NotImplementedError
|
11
11
|
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def url
|
16
|
+
"#{API_URI.scheme}://#{API_URI.host}"
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Line
|
2
2
|
module Social
|
3
3
|
module Request
|
4
|
-
class Oauth
|
5
|
-
|
6
|
-
|
4
|
+
class Oauth < Base
|
5
|
+
API_URI = URI.parse("https://api.line.me/oauth2/v2.1")
|
6
|
+
|
7
|
+
def initialize(access_token)
|
8
|
+
@access_token = access_token
|
7
9
|
end
|
8
10
|
|
9
11
|
def issue
|
@@ -11,7 +13,7 @@ module Line
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def verify
|
14
|
-
response =
|
16
|
+
response = request.get("#{API_URI.path}/verify", access_token: @access_token)
|
15
17
|
|
16
18
|
if response.body["error"]
|
17
19
|
raise Line::Social::Error.new(response.body["error_description"])
|
@@ -27,6 +29,12 @@ module Line
|
|
27
29
|
def revoke
|
28
30
|
raise Line::Social::NotImplementedError
|
29
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def url
|
36
|
+
"#{API_URI.scheme}://#{API_URI.host}"
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module Line
|
2
2
|
module Social
|
3
3
|
module Request
|
4
|
-
class Profile
|
5
|
-
|
6
|
-
|
4
|
+
class Profile < Base
|
5
|
+
API_URI = URI.parse("https://api.line.me/v2")
|
6
|
+
|
7
|
+
def initialize(access_token)
|
8
|
+
@access_token = access_token
|
7
9
|
end
|
8
10
|
|
9
11
|
def get
|
10
|
-
response =
|
11
|
-
request.url "#{
|
12
|
+
response = request.get do |request|
|
13
|
+
request.url "#{API_URI.path}/profile"
|
12
14
|
request.headers["Authorization"] = "Bearer #{@access_token}"
|
13
15
|
end
|
14
16
|
|
@@ -18,6 +20,12 @@ module Line
|
|
18
20
|
Line::Social::Profile.new(response.body)
|
19
21
|
end
|
20
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def url
|
27
|
+
"#{API_URI.scheme}://#{API_URI.host}"
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/line/social/version.rb
CHANGED
data/lib/line/social.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: line-social
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- camelmasa
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/line/social/error.rb
|
117
117
|
- lib/line/social/oauth.rb
|
118
118
|
- lib/line/social/profile.rb
|
119
|
+
- lib/line/social/request/base.rb
|
119
120
|
- lib/line/social/request/friendship.rb
|
120
121
|
- lib/line/social/request/oauth.rb
|
121
122
|
- lib/line/social/request/profile.rb
|