shilpa20 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f3dadf7fdb26c4c174030b626080b6d6d4864dfb3519a01fae8cb049b68655e
4
- data.tar.gz: 7ad7b99f84f17109537bee66e7c0320b331348516ed8b5d37486701288f3098e
3
+ metadata.gz: e51f4c2b9eedfeb74b5dd4478035004463fa2fbe735208945e76ae97ef0dec70
4
+ data.tar.gz: 3fc932e5ee469ca0610f692564af3c805d9388d03c7d0f4728da41dc9e6ff368
5
5
  SHA512:
6
- metadata.gz: 52bd2e06400559133f4a040d80bae582f8cd220bdfac44f0a9b5b32cae27991b68d48ec0d63b5a4cf81217f823d4fbe8f0958f14ce0b1536952fb13d8f175e50
7
- data.tar.gz: 91a71dddbe786f58e0d082f66696f56fc79f2c8d8416f3a3319474cf96757376c3a9e27e208656e72af4a28b570539f19ce2fd1f542ab847e3d2cced97bb7bc5
6
+ metadata.gz: 6d06006dc5651a897b6ffe0bae204c4a3602dc60600d29db77b44fa8039e89c08aa17bd01dc30eba9e60a9d867e987dda84224a21dbe243abd05c16e39cd5785
7
+ data.tar.gz: e85ba746f27e326c7df15b0cc426582b80324cb5c141ea5a70818d0cf752598acef93b4464ece458599b6a8893a018d27a4743e4efd1f2d558dbd4c158fb9bbe
@@ -1,6 +1,6 @@
1
1
  class ApplicationConfig
2
- @@client_id
3
- @@client_secret
2
+ @@client_id =""
3
+ @@client_secret =""
4
4
 
5
5
  def self.set_config(client_id, client_secret)
6
6
  @@client_id = client_id
@@ -5,11 +5,12 @@ class Authentication
5
5
  attr_accessor :client_secret
6
6
  attr_accessor :username
7
7
  attr_accessor :password
8
+ attr_accessor :token
8
9
  attr_accessor :refresh_token
9
10
 
10
- def initialize grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, refresh_token:nil
11
- self.grant_type, self.client_id, self.client_secret, self.username, self.password, self.refresh_token =
12
- grant_type, client_id, client_secret, username, password, refresh_token
11
+ def initialize grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, token:nil, refresh_token:nil
12
+ self.grant_type, self.client_id, self.client_secret, self.username, self.password, self.token, self.refresh_token =
13
+ grant_type, client_id, client_secret, username, password, token, refresh_token
13
14
  end
14
15
 
15
16
 
@@ -20,6 +21,7 @@ class Authentication
20
21
  client_secret: @client_secret,
21
22
  username: @username,
22
23
  password: @password,
24
+ token: @token,
23
25
  refresh_token: @refresh_token
24
26
  }.to_json(*a)
25
27
  end
@@ -31,6 +33,7 @@ class Authentication
31
33
  b_from_json.client_secret = o['client_secret']
32
34
  b_from_json.username = o['username']
33
35
  b_from_json.password = o['password']
36
+ b_from_json.token = o['token']
34
37
  b_from_json.refresh_token = o['refresh_token']
35
38
  b_from_json
36
39
  end
@@ -5,8 +5,9 @@ require_relative '../domain/application_config.rb'
5
5
 
6
6
  class AuthenticationService
7
7
  @@authentication_url = 'https://showoff-rails-react-production.herokuapp.com/oauth/token'
8
- @@client_id = ApplicationConfig.get_client_id
9
- @@client_secret = ApplicationConfig.get_client_secret
8
+ @@revoke_url = 'https://showoff-rails-react-production.herokuapp.com/oauth/revoke'
9
+ # @@client_id = ApplicationConfig.get_client_id
10
+ # @@client_secret = ApplicationConfig.get_client_secret
10
11
 
11
12
  def self.create_authentication(auth_data)
12
13
  auth_data = get_auth_with_client_info(auth_data)
@@ -15,13 +16,25 @@ class AuthenticationService
15
16
  payload: auth_payload, headers: {'Content-Type': 'application/json'})
16
17
  end
17
18
 
18
- def self.refresh_token(auth_data, bearer_token)
19
+ def self.refresh_authentication_token(auth_data, bearer_token)
19
20
  auth_data = get_auth_with_client_info(auth_data)
20
21
  auth_payload = Authentication.get_payload(auth_data)
21
22
  return RestClient::Request.execute(method: :post, url: @@authentication_url,
22
23
  payload: auth_payload, headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
23
24
  end
24
25
 
26
+ def self.revoke_authentication_token(auth_data, bearer_token)
27
+ auth_payload = Authentication.get_payload(auth_data)
28
+ return RestClient::Request.execute(method: :post, url: @@revoke_url,
29
+ payload: auth_payload, headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
30
+ end
31
+
32
+ def self.get_auth_with_client_info(auth_data)
33
+ auth_data.client_id = ApplicationConfig.get_client_id
34
+ auth_data.client_secret = ApplicationConfig.get_client_secret
35
+ return auth_data
36
+ end
37
+
25
38
  # to remove once tested
26
39
  def self.create_auth_data
27
40
  auth = Authentication.new
@@ -41,11 +54,7 @@ class AuthenticationService
41
54
  #end
42
55
 
43
56
 
44
- def self.get_auth_with_client_info(auth_data)
45
- auth_data.client_id = @@client_id
46
- auth_data.client_secret = @@client_secret
47
- return auth_data
48
- end
57
+
49
58
 
50
59
  #remove once tested
51
60
  def self.get_access_token
@@ -7,32 +7,32 @@ require_relative '../domain/application_config.rb'
7
7
  class UserWidgetService
8
8
  @@own_widgets_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me/widgets'
9
9
  @@widgets_by_user_id_url ='https://showoff-rails-react-production.herokuapp.com/api/v1/users/'
10
- @@client_id = ApplicationConfig.get_client_id
11
- @@client_secret = ApplicationConfig.get_client_secret
10
+ # @@client_id = ApplicationConfig.get_client_id
11
+ #@@client_secret = ApplicationConfig.get_client_secret
12
12
 
13
13
  def self.get_private_widgets(bearer_token)
14
14
  return RestClient::Request.execute(method: :get, url: @@own_widgets_url,
15
- headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret},
15
+ headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret},
16
16
  'Authorization':'Bearer '+ bearer_token})
17
17
  end
18
18
 
19
19
  def self.get_private_widgets_with_search_term(search_term, bearer_token)
20
20
  return RestClient::Request.execute(method: :get, url: @@own_widgets_url,
21
- headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret, :term => search_term},
21
+ headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret, :term => search_term},
22
22
  'Authorization':'Bearer '+ bearer_token})
23
23
  end
24
24
 
25
25
  def self.get_widgets_by_user_id(user_id, bearer_token)
26
26
  url_with_id = @@widgets_by_user_id_url + "#{user_id}" + "/widgets"
27
27
  return RestClient::Request.execute(method: :get, url: url_with_id,
28
- headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret},
28
+ headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret},
29
29
  'Authorization':'Bearer '+ bearer_token})
30
30
  end
31
31
 
32
32
  def self.get_widgets_by_user_id_with_search_term(user_id, search_term, bearer_token)
33
33
  url_with_id = @@widgets_by_user_id_url + "#{user_id}" + "/widgets"
34
34
  return RestClient::Request.execute(method: :get, url: url_with_id,
35
- headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret, :term => search_term},
35
+ headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret, :term => search_term},
36
36
  'Authorization':'Bearer '+ bearer_token})
37
37
  end
38
38
 
data/lib/shilpa20.rb CHANGED
@@ -1,7 +1,4 @@
1
1
  require 'rest-client'
2
- #require './authentication_service'
3
- #require './user_service'
4
- #require './user_widget_service'
5
2
 
6
3
  require File.dirname(__FILE__) + '/shilpa20/authentication_service'
7
4
  require File.dirname(__FILE__) + '/shilpa20/user_service'
@@ -11,8 +8,8 @@ require File.dirname(__FILE__) + '/domain/application_config'
11
8
  class Shilpa20
12
9
 
13
10
  def self.set_config(client_id, client_secret)
14
- #ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
15
- ApplicationConfig.set_config(client_id, client_secret)
11
+ #ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
12
+ ApplicationConfig.set_config(client_id, client_secret)
16
13
  end
17
14
 
18
15
 
@@ -21,11 +18,17 @@ class Shilpa20
21
18
  return AuthenticationService.create_authentication(auth_data)
22
19
  end
23
20
 
24
- #Create authentication token
25
- def self.refresh_token(auth_data, bearer_token)
26
- return AuthenticationService.refresh_token(auth_data, bearer_token)
21
+ #Refresh authentication token
22
+ def self.refresh_authentication_token(auth_data, bearer_token)
23
+ return AuthenticationService.refresh_authentication_token(auth_data, bearer_token)
27
24
  end
28
25
 
26
+ #Revoke authentication token
27
+ def self.revoke_authentication_token(auth_data, bearer_token)
28
+ return AuthenticationService.revoke_authentication_token(auth_data, bearer_token)
29
+ end
30
+
31
+
29
32
  #Create user
30
33
  def self.create_user(user_data)
31
34
  return UserService.create_user(user_data)
@@ -118,9 +121,10 @@ class Shilpa20
118
121
 
119
122
  end
120
123
 
124
+
121
125
  #puts " Inside shilpa 20"
122
- #ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
123
- #puts Shilpa20.create_authentication_token(AuthenticationService.create_auth_data)
126
+ #Shilpa20.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
127
+ #puts Shilpa20.refresh_authentication_token(AuthenticationService.create_auth_data)
124
128
  #Shilpa20.set_config("cid1","csecret1")
125
129
  #Shilpa20.getConfig
126
130
  #puts "Hi"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shilpa20
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sachin Murthy