shilpa20 1.2.0 → 1.2.1

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: 1570a1cbb5fca548133cc359a8af604b9f093eb2ac2f926374630311cf5ae32e
4
- data.tar.gz: d7c1c62cc19e813b16911e609cf9c78ea56c2bd0657b2f179934abee83c138be
3
+ metadata.gz: 3f3dadf7fdb26c4c174030b626080b6d6d4864dfb3519a01fae8cb049b68655e
4
+ data.tar.gz: 7ad7b99f84f17109537bee66e7c0320b331348516ed8b5d37486701288f3098e
5
5
  SHA512:
6
- metadata.gz: c02b61acd9ddb9aba9a6b63a0e0abe87ded9f64314ff29c48384d3707bc7f4c6d083812645745dbefe63c8977275f9e145d5f2db3d632c2eb469b5266b52d869
7
- data.tar.gz: fe1777173ac5bab079b4cc2ead0d5e00686144868204f735b6433b7e46128f826fc2e1e929d78f6d7e6351f5ca679f2b03fda886acf7368785ecabab9b7d3412
6
+ metadata.gz: 52bd2e06400559133f4a040d80bae582f8cd220bdfac44f0a9b5b32cae27991b68d48ec0d63b5a4cf81217f823d4fbe8f0958f14ce0b1536952fb13d8f175e50
7
+ data.tar.gz: 91a71dddbe786f58e0d082f66696f56fc79f2c8d8416f3a3319474cf96757376c3a9e27e208656e72af4a28b570539f19ce2fd1f542ab847e3d2cced97bb7bc5
@@ -5,10 +5,11 @@ class Authentication
5
5
  attr_accessor :client_secret
6
6
  attr_accessor :username
7
7
  attr_accessor :password
8
+ attr_accessor :refresh_token
8
9
 
9
- def initialize grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil
10
- self.grant_type, self.client_id, self.client_secret, self.username, self.password =
11
- grant_type, client_id, client_secret, username, password
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
12
13
  end
13
14
 
14
15
 
@@ -18,7 +19,8 @@ class Authentication
18
19
  client_id: @client_id,
19
20
  client_secret: @client_secret,
20
21
  username: @username,
21
- password: @password
22
+ password: @password,
23
+ refresh_token: @refresh_token
22
24
  }.to_json(*a)
23
25
  end
24
26
 
@@ -29,6 +31,7 @@ class Authentication
29
31
  b_from_json.client_secret = o['client_secret']
30
32
  b_from_json.username = o['username']
31
33
  b_from_json.password = o['password']
34
+ b_from_json.refresh_token = o['refresh_token']
32
35
  b_from_json
33
36
  end
34
37
 
@@ -5,15 +5,23 @@ 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
10
 
9
11
  def self.create_authentication(auth_data)
10
- auth_data.client_id = ApplicationConfig.get_client_id
11
- auth_data.client_secret = ApplicationConfig.get_client_secret
12
+ auth_data = get_auth_with_client_info(auth_data)
12
13
  auth_payload = Authentication.get_payload(auth_data)
13
14
  return RestClient::Request.execute(method: :post, url: @@authentication_url,
14
15
  payload: auth_payload, headers: {'Content-Type': 'application/json'})
15
16
  end
16
17
 
18
+ def self.refresh_token(auth_data, bearer_token)
19
+ auth_data = get_auth_with_client_info(auth_data)
20
+ auth_payload = Authentication.get_payload(auth_data)
21
+ return RestClient::Request.execute(method: :post, url: @@authentication_url,
22
+ payload: auth_payload, headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
23
+ end
24
+
17
25
  # to remove once tested
18
26
  def self.create_auth_data
19
27
  auth = Authentication.new
@@ -25,12 +33,21 @@ class AuthenticationService
25
33
  return auth
26
34
  end
27
35
 
28
- def self.refresh_token(refresh_data)
29
- refresh_payload = Authentication.get_payload(refresh_data)
30
- return RestClient::Request.execute(method: :post, url: @@authentication_url,
31
- payload: refresh_payload, headers: {'Content-Type': 'application/json'})
32
- end
36
+
37
+ #def self.refresh_token(refresh_data)
38
+ # refresh_payload = Authentication.get_payload(refresh_data)
39
+ # return RestClient::Request.execute(method: :post, url: @@authentication_url,
40
+ # payload: refresh_payload, headers: {'Content-Type': 'application/json'})
41
+ #end
42
+
43
+
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
33
49
 
50
+ #remove once tested
34
51
  def self.get_access_token
35
52
  auth_data = AuthenticationService.create_auth_data
36
53
  authJson = AuthenticationService.create_authentication(auth_data)
data/lib/shilpa20.rb CHANGED
@@ -12,7 +12,7 @@ class Shilpa20
12
12
 
13
13
  def self.set_config(client_id, client_secret)
14
14
  #ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
15
- ApplicationConfig.set_config(client_id, client_secret)
15
+ ApplicationConfig.set_config(client_id, client_secret)
16
16
  end
17
17
 
18
18
 
@@ -21,6 +21,11 @@ class Shilpa20
21
21
  return AuthenticationService.create_authentication(auth_data)
22
22
  end
23
23
 
24
+ #Create authentication token
25
+ def self.refresh_token(auth_data, bearer_token)
26
+ return AuthenticationService.refresh_token(auth_data, bearer_token)
27
+ end
28
+
24
29
  #Create user
25
30
  def self.create_user(user_data)
26
31
  return UserService.create_user(user_data)
@@ -114,6 +119,7 @@ class Shilpa20
114
119
  end
115
120
 
116
121
  #puts " Inside shilpa 20"
122
+ #ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
117
123
  #puts Shilpa20.create_authentication_token(AuthenticationService.create_auth_data)
118
124
  #Shilpa20.set_config("cid1","csecret1")
119
125
  #Shilpa20.getConfig
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.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sachin Murthy