shilpa20 1.1.8 → 1.1.9
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 +4 -4
- data/lib/domain/client_info_base.rb +0 -4
- data/lib/domain/widget_base.rb +1 -0
- data/lib/shilpa20/user_service.rb +27 -15
- data/lib/shilpa20/user_widget_service.rb +11 -8
- data/lib/shilpa20/widget_service.rb +13 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b4bb38d8e5bb9efcfc4af44b86e3cfe62be372770ac89a6c02f280dae19e862
|
4
|
+
data.tar.gz: 86468e67737f4e981f036a4752df1d4ed60513b533bc78de3250d8f7749db242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d045085bbe04a3fe0f104d4db8eba24eec4565eec192d2f3fba04cd2c32e467862901d2a190a9cef733169d3a02c605021e02cbb0a39b3792b0ee13119322023
|
7
|
+
data.tar.gz: a4ad031ca7f8febf344da1fdd07cdd5533542ffc68c0630b4b45212f848c24f54447a8598f9e1f7c80e9296de9a8da484b5478a93f604b99d464be3c19de3b51
|
data/lib/domain/widget_base.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rest-client'
|
|
2
2
|
require 'json'
|
3
3
|
require_relative '../domain/client_info_base.rb'
|
4
4
|
require_relative '../domain/user.rb'
|
5
|
+
require_relative '../domain/application_config.rb'
|
5
6
|
require_relative 'authentication_service'
|
6
7
|
|
7
8
|
class UserService
|
@@ -13,33 +14,35 @@ class UserService
|
|
13
14
|
@@show_logged_in_user_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me'
|
14
15
|
@@show_user_id_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/'
|
15
16
|
|
16
|
-
def self.create_user(
|
17
|
+
def self.create_user(user)
|
18
|
+
user_with_client_info = get_user_with_client_info(user)
|
17
19
|
create_user_payload = User.get_payload(user_with_client_info)
|
18
20
|
return RestClient::Request.execute(method: :post, url: @@create_user_url,
|
19
21
|
payload: create_user_payload, headers: {'Content-Type': 'application/json'})
|
20
22
|
end
|
21
23
|
|
22
|
-
def self.update_user(
|
23
|
-
update_user_payload = User.get_payload(
|
24
|
+
def self.update_user(user, bearer_token)
|
25
|
+
update_user_payload = User.get_payload(user)
|
24
26
|
return RestClient::Request.execute(method: :put, url: @@create_update_url,
|
25
27
|
payload: update_user_payload,
|
26
28
|
headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
27
29
|
end
|
28
30
|
|
29
|
-
def self.check_email(
|
31
|
+
def self.check_email(user)
|
30
32
|
return RestClient::Request.execute(method: :get, url: @@check_email_url,
|
31
|
-
headers: {'Content-Type': 'application/json', params: {:email =>
|
33
|
+
headers: {'Content-Type': 'application/json', params: {:email => user.email , :client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret}})
|
32
34
|
end
|
33
35
|
|
34
|
-
def self.reset_password(
|
36
|
+
def self.reset_password(user)
|
37
|
+
user_with_client_info = get_user_with_client_info(user)
|
35
38
|
reset_password_payload = User.get_payload(user_with_client_info)
|
36
39
|
return RestClient::Request.execute(method: :post, url: @@reset_password_url,
|
37
40
|
payload: reset_password_payload,
|
38
41
|
headers: {'Content-Type': 'application/json'})
|
39
42
|
end
|
40
43
|
|
41
|
-
def self.change_password(
|
42
|
-
change_password_payload = User.get_payload(
|
44
|
+
def self.change_password(user, bearer_token)
|
45
|
+
change_password_payload = User.get_payload(user)
|
43
46
|
return RestClient::Request.execute(method: :post, url: @@change_password_url,
|
44
47
|
payload: change_password_payload,
|
45
48
|
headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
@@ -56,6 +59,14 @@ class UserService
|
|
56
59
|
headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
57
60
|
end
|
58
61
|
|
62
|
+
def self.get_user_with_client_info(user)
|
63
|
+
user_with_client_info = ClientInfoBase.new
|
64
|
+
user_with_client_info.client_id = ApplicationConfig.get_client_id
|
65
|
+
user_with_client_info.client_secret = ApplicationConfig.get_client_secret
|
66
|
+
user_with_client_info.user = user
|
67
|
+
return user_with_client_info
|
68
|
+
end
|
69
|
+
|
59
70
|
# to remove once tested
|
60
71
|
def self.create_user_with_client_info
|
61
72
|
user = User.new
|
@@ -65,18 +76,19 @@ class UserService
|
|
65
76
|
user.current_password = "password"
|
66
77
|
user.new_password = "password123"
|
67
78
|
user.date_of_birth = 1464083530
|
68
|
-
user.email = "
|
79
|
+
user.email = "sachinmurthy901@gmail.com"
|
69
80
|
user.image_url = "https://static.thenounproject.com/png/961-200.png"
|
70
81
|
|
71
|
-
user_with_client_info = ClientInfoBase.new
|
72
|
-
user_with_client_info.client_id = "277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe"
|
73
|
-
user_with_client_info.client_secret = "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352"
|
74
|
-
user_with_client_info.user = user
|
75
|
-
return
|
82
|
+
#user_with_client_info = ClientInfoBase.new
|
83
|
+
#user_with_client_info.client_id = "277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe"
|
84
|
+
#user_with_client_info.client_secret = "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352"
|
85
|
+
#user_with_client_info.user = user
|
86
|
+
return user
|
76
87
|
end
|
77
88
|
|
78
89
|
end
|
79
90
|
|
80
91
|
# to remove once tested
|
92
|
+
#ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
|
81
93
|
#userWithClientIfno = UserService.create_user_with_client_info
|
82
|
-
#puts UserService.
|
94
|
+
#puts UserService.create_user(userWithClientIfno)
|
@@ -2,34 +2,37 @@ require 'rest-client'
|
|
2
2
|
require 'json'
|
3
3
|
require_relative 'authentication_service'
|
4
4
|
require_relative 'user_service'
|
5
|
+
require_relative '../domain/application_config.rb'
|
5
6
|
|
6
7
|
class UserWidgetService
|
7
8
|
@@own_widgets_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me/widgets'
|
8
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
|
9
12
|
|
10
|
-
def self.get_private_widgets(
|
13
|
+
def self.get_private_widgets(bearer_token)
|
11
14
|
return RestClient::Request.execute(method: :get, url: @@own_widgets_url,
|
12
|
-
headers: {'Content-Type': 'application/json', params: {:client_id =>
|
15
|
+
headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret},
|
13
16
|
'Authorization':'Bearer '+ bearer_token})
|
14
17
|
end
|
15
18
|
|
16
|
-
def self.get_private_widgets_with_search_term(
|
19
|
+
def self.get_private_widgets_with_search_term(search_term, bearer_token)
|
17
20
|
return RestClient::Request.execute(method: :get, url: @@own_widgets_url,
|
18
|
-
headers: {'Content-Type': 'application/json', params: {:client_id =>
|
21
|
+
headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret, :term => search_term},
|
19
22
|
'Authorization':'Bearer '+ bearer_token})
|
20
23
|
end
|
21
24
|
|
22
|
-
def self.get_widgets_by_user_id(
|
25
|
+
def self.get_widgets_by_user_id(user_id, bearer_token)
|
23
26
|
url_with_id = @@widgets_by_user_id_url + "#{user_id}" + "/widgets"
|
24
27
|
return RestClient::Request.execute(method: :get, url: url_with_id,
|
25
|
-
headers: {'Content-Type': 'application/json', params: {:client_id =>
|
28
|
+
headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret},
|
26
29
|
'Authorization':'Bearer '+ bearer_token})
|
27
30
|
end
|
28
31
|
|
29
|
-
def self.get_widgets_by_user_id_with_search_term(
|
32
|
+
def self.get_widgets_by_user_id_with_search_term(user_id, search_term, bearer_token)
|
30
33
|
url_with_id = @@widgets_by_user_id_url + "#{user_id}" + "/widgets"
|
31
34
|
return RestClient::Request.execute(method: :get, url: url_with_id,
|
32
|
-
headers: {'Content-Type': 'application/json', params: {:client_id =>
|
35
|
+
headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret, :term => search_term},
|
33
36
|
'Authorization':'Bearer '+ bearer_token})
|
34
37
|
end
|
35
38
|
|
@@ -4,24 +4,25 @@ require_relative '../domain/widget_base.rb'
|
|
4
4
|
require_relative '../domain/widget.rb'
|
5
5
|
require_relative 'authentication_service'
|
6
6
|
require_relative 'user_service'
|
7
|
+
require_relative '../domain/application_config.rb'
|
7
8
|
|
8
9
|
class WidgetService
|
9
10
|
@@create_widget_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets'
|
10
11
|
@@update_destroy_widget_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/'
|
11
12
|
@@list_widget_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/visible'
|
13
|
+
@@client_id = ApplicationConfig.get_client_id
|
14
|
+
@@client_secret = ApplicationConfig.get_client_secret
|
12
15
|
|
13
|
-
def self.create_widget(
|
14
|
-
create_widget_payload = Widget.get_payload(
|
15
|
-
puts "widgets create payload : " + create_widget_payload
|
16
|
+
def self.create_widget(widget_data, bearer_token)
|
17
|
+
create_widget_payload = Widget.get_payload(widget_data)
|
16
18
|
return RestClient::Request.execute(method: :post, url: @@create_widget_url,
|
17
19
|
payload: create_widget_payload,
|
18
20
|
headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
19
21
|
end
|
20
22
|
|
21
|
-
def self.update_widget(
|
23
|
+
def self.update_widget(widget_data, widget_id, bearer_token)
|
22
24
|
update_url_with_widget_id = @@update_destroy_widget_url + "#{widget_id}"
|
23
|
-
update_widget_payload = Widget.get_payload(
|
24
|
-
puts "widgets update payload : " + update_widget_payload
|
25
|
+
update_widget_payload = Widget.get_payload(widget_data)
|
25
26
|
return RestClient::Request.execute(method: :put, url: update_url_with_widget_id,
|
26
27
|
payload: update_widget_payload,
|
27
28
|
headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
@@ -38,15 +39,15 @@ class WidgetService
|
|
38
39
|
headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
39
40
|
end
|
40
41
|
|
41
|
-
def self.get_public_widgets(
|
42
|
+
def self.get_public_widgets(bearer_token)
|
42
43
|
return RestClient::Request.execute(method: :get, url: @@list_widget_url,
|
43
|
-
headers: {'Content-Type': 'application/json', params: {:client_id =>
|
44
|
+
headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret},
|
44
45
|
'Authorization':'Bearer '+ bearer_token})
|
45
46
|
end
|
46
47
|
|
47
|
-
def self.get_public_widgets_with_search_term(
|
48
|
+
def self.get_public_widgets_with_search_term(search_term, bearer_token)
|
48
49
|
return RestClient::Request.execute(method: :get, url: @@list_widget_url,
|
49
|
-
headers: {'Content-Type': 'application/json', params: {:client_id =>
|
50
|
+
headers: {'Content-Type': 'application/json', params: {:client_id => @@client_id, :client_secret => @@client_secret, :term => search_term},
|
50
51
|
'Authorization':'Bearer '+ bearer_token})
|
51
52
|
end
|
52
53
|
|
@@ -66,5 +67,5 @@ end
|
|
66
67
|
|
67
68
|
# to remove once tested
|
68
69
|
#widget_json = WidgetService.create_widget_data
|
69
|
-
userWithClientIfno = UserService.create_user_with_client_info
|
70
|
-
puts WidgetService.search_list_widget(userWithClientIfno, "widget one")
|
70
|
+
#userWithClientIfno = UserService.create_user_with_client_info
|
71
|
+
#puts WidgetService.search_list_widget(userWithClientIfno, "widget one")
|