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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f91e85b87dad2aaf8a6b7a9e505f0c37b0d57da0320925e712f7b851927e6ffc
4
- data.tar.gz: 0fd98b2c8db6fb01607d596f0d012d603f6b84c11472e16a3100f30e224b3606
3
+ metadata.gz: 3eaba402a6d0d78f613732d830365688b85c4fc797356dd5e4593800c60b01e8
4
+ data.tar.gz: cc59e86f156510264ec6e8ac474b25b08440472f4b97d5faf24ccb89c54c9ef4
5
5
  SHA512:
6
- metadata.gz: d8afd55db524361be8bc119ce9ec4fa25f95a48eced91bc830ac4cf1e0aa54e0ad6c9497d73b55d3640b43c8d0bdd512b788d119f20e6317259d7e70cf446d41
7
- data.tar.gz: bc3d50eae682d0826f9bcda49d28e4dd381ea96e85cdb84ace75db5d5f91ec8316e452a7028dd51c6bdab93eca5fc40859b143d630aa4d89a9684501d3a84df0
6
+ metadata.gz: 5df52de38e01b72bafbb15b04772dd5e5bdf0f59cb266fa4f55eaf595ab847b63abaf6dc3162d666e510ee820dfc6dd1ddc5b56ee4b7c374ecc335a578ea2eb8
7
+ data.tar.gz: 027e28e2e1f78a19a35467230787c385e7f0e16239ab993c1433611d4e420526deeb1af85e6c5aecff1ca11aacdc53048afaa7eff72cbcd0fc4829ee2eeff4a1
@@ -10,22 +10,11 @@ module Line
10
10
  end
11
11
 
12
12
  def oauth
13
- Request::Oauth.new(self)
13
+ Request::Oauth.new(@access_token)
14
14
  end
15
15
 
16
16
  def profile
17
- Request::Profile.new(self)
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
@@ -5,8 +5,8 @@ module Line
5
5
 
6
6
  attribute :userId, String
7
7
  attribute :displayName, String
8
- attribute :pictureUrl, String
9
- attribute :statusMessage, String
8
+ attribute :pictureUrl
9
+ attribute :statusMessage
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,14 @@
1
+ module Line
2
+ module Social
3
+ module Request
4
+ class Base
5
+ def request
6
+ Faraday.new(url: url) do |connection|
7
+ connection.response :json, content_type: /\bjson$/
8
+ connection.adapter Faraday.default_adapter
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,14 +1,20 @@
1
1
  module Line
2
2
  module Social
3
3
  module Request
4
- class Friendship
5
- def initialize(client)
6
- @client = client
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
- def initialize(client)
6
- @client = client
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 = @client.request.get("#{@client.request_path}/verify", access_token: @client.access_token)
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
- def initialize(client)
6
- @client = client
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 = @client.request.get do |request|
11
- request.url "#{@client.request_path}/profile"
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
@@ -1,5 +1,5 @@
1
1
  module Line
2
2
  module Social
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/lib/line/social.rb CHANGED
@@ -4,6 +4,7 @@ require "virtus"
4
4
 
5
5
  require "line/social/version"
6
6
  require "line/social/client"
7
+ require "line/social/request/base"
7
8
  require "line/social/request/oauth"
8
9
  require "line/social/request/profile"
9
10
  require "line/social/request/friendship"
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.0
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