k2-connect-ruby 0.0.2 → 0.0.3

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: 6242c55fca28baeb083bf2e8aeb42f3789a181c119fe0806114d5022d1873005
4
- data.tar.gz: b34bee05232913b29b3494453b5bc97c4980f39b4950b7e802ac11ae3d195c68
3
+ metadata.gz: 813e08db1df91bfd2bc8129661251a50547dd412be8e3adf73e30601c96cfd96
4
+ data.tar.gz: e0152936b0c41216020713f4a9adc0b36f272f03dff49c2b5a334f7aa0bcff78
5
5
  SHA512:
6
- metadata.gz: ce85249348dbae888ae345a4a50b598ed2eb9f136f679f357f71c53cc35cbd42d8dca569846e8169727365e04251ba7ef21fde5cf2f58c12cb751c8a9dff2a43
7
- data.tar.gz: 8662b4c4056971b002e70db9133278522cbaf6db94961fbe89031a073c2971b5fc43754f1c9da5f3f4f07a1c80fdaa525b1ff0bebf03c7698c13df560e524c1e
6
+ metadata.gz: dd9f054d341616ae35e76f056e719576f5b90f323022564cb74d3a50de13e1f416dca358fe4029bbc393149e49f29802a84260a0f7e5cba72e2b3131a202754a
7
+ data.tar.gz: e4de423af14eb8af838f9bbe40ecc93b7fd770fc241ea492e104585d30eda2d451a7b8342df0f3b394a413fdf59b64b1e5034b51ea2b145b9cd0f8efcdf36287
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- k2-connect-ruby (0.0.1)
4
+ k2-connect-ruby (0.0.2)
5
5
  activemodel (~> 6.1.3.1)
6
6
  activesupport (~> 6.1.3.1)
7
7
  rest-client (~> 2.1.0)
@@ -1,6 +1,6 @@
1
1
  # Class for Gaining Access Token
2
2
  class K2AccessToken
3
- attr_reader :access_token
3
+ attr_reader :access_token, :token_response
4
4
 
5
5
  def initialize(client_id, client_secret)
6
6
  validate_client_credentials(client_id, client_secret)
@@ -8,7 +8,6 @@ class K2AccessToken
8
8
  @client_secret = client_secret
9
9
  end
10
10
 
11
- # Method for sending the request to K2 sandbox or Mock Server (Receives the access_token)
12
11
  def request_token
13
12
  token_params = {
14
13
  client_id: @client_id,
@@ -19,6 +18,33 @@ class K2AccessToken
19
18
  @access_token = K2Connect.make_request(token_hash)
20
19
  end
21
20
 
21
+ def revoke_token(access_token)
22
+ token_params = {
23
+ client_id: @client_id,
24
+ client_secret: @client_secret,
25
+ token: access_token
26
+ }
27
+ token_hash = K2AccessToken.make_hash(K2Config.path_url('revoke_token'), 'post', 'Access Token', token_params)
28
+ @token_response = K2Connect.make_request(token_hash)
29
+ end
30
+
31
+ def introspect_token(access_token)
32
+ token_params = {
33
+ client_id: @client_id,
34
+ client_secret: @client_secret,
35
+ token: access_token
36
+ }
37
+ token_hash = K2AccessToken.make_hash(K2Config.path_url('introspect_token'), 'post', 'Access Token', token_params)
38
+ @token_response = K2Connect.make_request(token_hash)
39
+ end
40
+
41
+ def token_info(access_token)
42
+ token_hash = K2AccessToken.make_hash(K2Config.path_url('token_info'), 'get', 'Access Token', nil)
43
+
44
+ token_hash[:access_token] = access_token
45
+ @token_response = K2Connect.make_request(token_hash)
46
+ end
47
+
22
48
  def validate_client_credentials(client_id, client_secret)
23
49
  raise ArgumentError, 'Nil or Empty Client Id or Secret!' if client_id.blank? || client_secret.blank?
24
50
  end
@@ -22,7 +22,7 @@ module K2Config
22
22
  end
23
23
 
24
24
  def path_endpoint(key)
25
- unless key.eql?('oauth_token')
25
+ unless key.include?('token')
26
26
  return "api/#{version}/#{@config[:endpoints][:"#{key}"]}"
27
27
  end
28
28
  @config[:endpoints][:"#{key}"]
@@ -3,6 +3,9 @@ version: v1
3
3
  base_url: http://127.0.0.1:3000/
4
4
  endpoints: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
5
5
  oauth_token: oauth/token
6
+ revoke_token: oauth/revoke
7
+ introspect_token: oauth/introspect
8
+ token_info: oauth/token/info
6
9
  webhook_subscriptions: webhook_subscriptions
7
10
  pay_recipient: pay_recipients
8
11
  payments: payments
@@ -12,7 +12,10 @@ module K2Connect
12
12
 
13
13
  # Set up Headers
14
14
  headers = { 'Content-Type': 'application/json', Accept: 'application/vnd.kopokopo.v1.hal+json', Authorization: "Bearer #{access_token}" }
15
- if path_url.include?('oauth/token')
15
+ # For access token request
16
+ if path_url.include?('oauth/token/info')
17
+ headers = { 'Content-Type': 'application/json', Accept: 'application/vnd.kopokopo.v1.hal+json', Authorization: "Bearer #{access_token}" }
18
+ elsif path_url.include?('oauth/')
16
19
  headers = { 'Content-Type': 'application/json' }
17
20
  end
18
21
 
@@ -1,3 +1,3 @@
1
1
  module K2ConnectRuby
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k2-connect-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DavidKar1uk1