widgets_api_client 0.0.7 → 0.0.8

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: 89008eec1366ab100f65284591ddc10556c3c02e749f707216f685c4d158b684
4
- data.tar.gz: c63b702e0ec63aaaea1ecbfba0246c8e6fa4596215aaa0688de04739fde56bbe
3
+ metadata.gz: 714e0e9eca02de4b6b8be32b72e4eedfc97baf05e8d905b3b0a076f69d8656a9
4
+ data.tar.gz: 25affba49c32bbff89c52e619fdf127bb2eb76f6083cc70d7191d2f6c4228b24
5
5
  SHA512:
6
- metadata.gz: 8e56ce66a4ce67530241013ffaa3bf113993a0ca00e22dcbaec51ea2f41b4a0b332d75529e396ac492f4576856fd25fcd0046d24b2bf1266e65f269847b6ac0d
7
- data.tar.gz: 58ae7f1cf56a66893ee2a48633a20229971ed76759e14468b86b2b9e0307295802501b7075d717aded517da6ee883cc38d62edf628fb511c1bbcac290475bdd1
6
+ metadata.gz: 03bfe5e12e8a99f5f505002ef3fd769c14a1d12b3e06a61a5dc92e4818c5d31116409c6bad3f6708f436b6a6bde7e131b607f91bda8d9aeb2a538960bda33354
7
+ data.tar.gz: c42f695579298af5008af414b2492e08e4a515c9477ea23a04e8f4ef3132af21eab1cf8b061a61a0edd8fe181c3594fc27478b981a355f58f5d71a4adb82933a
@@ -0,0 +1,16 @@
1
+ create_authentication_path: /oauth/token
2
+ revoke_authentication_path: /oauth/revoke
3
+ create_user_path: /api/v1/users
4
+ update_user_path: /api/v1/users/me
5
+ show_logged_in_user_path: /api/v1/users/me
6
+ show_user_id_path: /api/v1/users
7
+ change_password_path: /api/v1/users/me/password
8
+ check_email_path: /api/v1/users/email
9
+ reset_password_path: /api/v1/users/reset_password
10
+ own_widgets_path: /api/v1/users/me/widgets
11
+ widgets_by_user_id_path: /api/v1/users
12
+ create_widget_path: /api/v1/widgets
13
+ update_widget_path: /api/v1/widgets
14
+ destroy_widget_path: /api/v1/widgets
15
+ list_own_widget_path: /api/v1/widgets
16
+ list_public_widget_path: /api/v1/widgets/visible
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  #
2
4
  # Sets Application Configurations
3
5
  #
@@ -5,10 +7,13 @@ class ApplicationConfig
5
7
  @@client_id = ''
6
8
  @@client_secret = ''
7
9
  @@base_url = ''
10
+ @@config = {}
8
11
 
9
- def self.set_config(client_id, client_secret)
12
+ def self.set_config(client_id, client_secret, base_url)
10
13
  @@client_id = client_id
11
14
  @@client_secret = client_secret
15
+ @@base_url = base_url
16
+ @@config = YAML.load_file('../../config/application_config.yml')
12
17
  end
13
18
 
14
19
  #
@@ -28,4 +33,14 @@ class ApplicationConfig
28
33
  def self.client_secret
29
34
  @@client_secret
30
35
  end
36
+
37
+ #
38
+ # Creates complete url by key
39
+ #
40
+ # @return [String]
41
+ #
42
+ def self.get_url(key)
43
+ url = @@base_url + @@config[key]
44
+ url
45
+ end
31
46
  end
@@ -7,9 +7,6 @@ require_relative '../domain/application_config.rb'
7
7
  # Authentication Service for token activies
8
8
  #
9
9
  class AuthenticationService
10
- @@authentication_url = 'https://showoff-rails-react-production.herokuapp.com/oauth/token'
11
- @@revoke_url = 'https://showoff-rails-react-production.herokuapp.com/oauth/revoke'
12
-
13
10
  #
14
11
  # Creates authentication token
15
12
  #
@@ -21,7 +18,7 @@ class AuthenticationService
21
18
  auth_data = get_auth_with_client_info(auth_data)
22
19
  auth_payload = Authentication.get_payload(auth_data)
23
20
  RestClient::Request.execute(method: :post,
24
- url: @@authentication_url,
21
+ url: ApplicationConfig.get_url('create_authentication_path'),
25
22
  payload: auth_payload,
26
23
  headers: { 'Content-Type': 'application/json' })
27
24
  end
@@ -38,7 +35,7 @@ class AuthenticationService
38
35
  auth_data = get_auth_with_client_info(auth_data)
39
36
  auth_payload = Authentication.get_payload(auth_data)
40
37
  RestClient::Request.execute(method: :post,
41
- url: @@authentication_url,
38
+ url: ApplicationConfig.get_url('create_authentication_path'),
42
39
  payload: auth_payload,
43
40
  headers: { 'Content-Type': 'application/json',
44
41
  'Authorization': bearer_token })
@@ -55,7 +52,7 @@ class AuthenticationService
55
52
  def self.revoke_authentication_token(auth_data, bearer_token)
56
53
  auth_payload = Authentication.get_payload(auth_data)
57
54
  RestClient::Request.execute(method: :post,
58
- url: @@revoke_url,
55
+ url: ApplicationConfig.get_url('revoke_authentication_path'),
59
56
  payload: auth_payload,
60
57
  headers: { 'Content-Type': 'application/json',
61
58
  'Authorization': bearer_token })
@@ -9,14 +9,6 @@ require_relative '../domain/application_config.rb'
9
9
  # User Service for CRUD operation related to user
10
10
  #
11
11
  class UserService
12
- @@create_user_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users'
13
- @@create_update_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me'
14
- @@check_email_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/email'
15
- @@reset_password_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/reset_password'
16
- @@change_password_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me/password'
17
- @@show_logged_in_user_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me'
18
- @@show_user_id_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/'
19
-
20
12
  #
21
13
  # Creates User
22
14
  #
@@ -28,7 +20,7 @@ class UserService
28
20
  user_with_client_info = get_user_with_client_info(user)
29
21
  create_user_payload = User.get_payload(user_with_client_info)
30
22
  RestClient::Request.execute(method: :post,
31
- url: @@create_user_url,
23
+ url: ApplicationConfig.get_url('create_user_path'),
32
24
  payload: create_user_payload,
33
25
  headers: { 'Content-Type': 'application/json' })
34
26
  end
@@ -45,7 +37,7 @@ class UserService
45
37
  user_data = get_user(user)
46
38
  update_user_payload = User.get_payload(user_data)
47
39
  RestClient::Request.execute(method: :put,
48
- url: @@create_update_url,
40
+ url: ApplicationConfig.get_url('update_user_path'),
49
41
  payload: update_user_payload,
50
42
  headers: { 'Content-Type': 'application/json',
51
43
  'Authorization': bearer_token })
@@ -60,7 +52,7 @@ class UserService
60
52
  #
61
53
  def self.check_email(user)
62
54
  RestClient::Request.execute(method: :get,
63
- url: @@check_email_url,
55
+ url: ApplicationConfig.get_url('check_email_path'),
64
56
  headers: { 'Content-Type': 'application/json',
65
57
  params: { email: user.email,
66
58
  client_id: ApplicationConfig.client_id,
@@ -78,7 +70,7 @@ class UserService
78
70
  user_with_client_info = get_user_with_client_info(user)
79
71
  reset_password_payload = User.get_payload(user_with_client_info)
80
72
  RestClient::Request.execute(method: :post,
81
- url: @@reset_password_url,
73
+ url: ApplicationConfig.get_url('reset_password_path'),
82
74
  payload: reset_password_payload,
83
75
  headers: { 'Content-Type': 'application/json' })
84
76
  end
@@ -95,7 +87,7 @@ class UserService
95
87
  user_data = get_user(user)
96
88
  change_password_payload = User.get_payload(user_data)
97
89
  RestClient::Request.execute(method: :post,
98
- url: @@change_password_url,
90
+ url: ApplicationConfig.get_url('change_password_path'),
99
91
  payload: change_password_payload,
100
92
  headers: { 'Content-Type': 'application/json',
101
93
  'Authorization': bearer_token })
@@ -110,7 +102,7 @@ class UserService
110
102
  #
111
103
  def self.show_logged_in_user(bearer_token)
112
104
  RestClient::Request.execute(method: :get,
113
- url: @@show_logged_in_user_url,
105
+ url: ApplicationConfig.get_url('show_logged_in_user_path'),
114
106
  headers: { 'Content-Type': 'application/json',
115
107
  'Authorization': bearer_token })
116
108
  end
@@ -124,7 +116,7 @@ class UserService
124
116
  # @return [Json] Response containing details of given user id
125
117
  #
126
118
  def self.show_user_id(user_id, bearer_token)
127
- url_with_id = @@show_user_id_url + user_id.to_s
119
+ url_with_id = ApplicationConfig.get_url('show_user_id_path') + '/' + user_id.to_s
128
120
  RestClient::Request.execute(method: :get,
129
121
  url: url_with_id,
130
122
  headers: { 'Content-Type': 'application/json',
@@ -6,9 +6,6 @@ require_relative '../domain/application_config.rb'
6
6
  # User Widget Service for widget display based on user details
7
7
  #
8
8
  class UserWidgetService
9
- @@own_widgets_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me/widgets'
10
- @@widgets_by_user_id_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/users/'
11
-
12
9
  #
13
10
  # Displays own widgets
14
11
  #
@@ -18,7 +15,7 @@ class UserWidgetService
18
15
  #
19
16
  def self.get_private_widgets(bearer_token)
20
17
  RestClient::Request.execute(method: :get,
21
- url: @@own_widgets_url,
18
+ url: ApplicationConfig.get_url('own_widgets_path'),
22
19
  headers: { 'Content-Type': 'application/json',
23
20
  params: { client_id: ApplicationConfig.client_id,
24
21
  client_secret: ApplicationConfig.client_secret },
@@ -35,7 +32,7 @@ class UserWidgetService
35
32
  #
36
33
  def self.get_private_widgets_with_search_term(search_term, bearer_token)
37
34
  RestClient::Request.execute(method: :get,
38
- url: @@own_widgets_url,
35
+ url: ApplicationConfig.get_url('own_widgets_path'),
39
36
  headers: { 'Content-Type': 'application/json',
40
37
  params: { client_id: ApplicationConfig.client_id,
41
38
  client_secret: ApplicationConfig.client_secret,
@@ -52,7 +49,7 @@ class UserWidgetService
52
49
  # @return [Json] Resopnse containing widgets list for given user id
53
50
  #
54
51
  def self.get_widgets_by_user_id(user_id, bearer_token)
55
- url_with_id = @@widgets_by_user_id_url + user_id.to_s + '/widgets'
52
+ url_with_id = ApplicationConfig.get_url('widgets_by_user_id_path') + '/' + user_id.to_s + '/widgets'
56
53
  RestClient::Request.execute(method: :get,
57
54
  url: url_with_id,
58
55
  headers: { 'Content-Type': 'application/json',
@@ -71,7 +68,7 @@ class UserWidgetService
71
68
  # @return [Json] Response contating widget details for user id and serach term
72
69
  #
73
70
  def self.get_widgets_by_user_id_with_search_term(user_id, search_term, bearer_token)
74
- url_with_id = @@widgets_by_user_id_url + user_id.to_s + '/widgets'
71
+ url_with_id = ApplicationConfig.get_url('widgets_by_user_id_path') + '/' + user_id.to_s + '/widgets'
75
72
  RestClient::Request.execute(method: :get,
76
73
  url: url_with_id,
77
74
  headers: { 'Content-Type': 'application/json',
@@ -8,10 +8,6 @@ require_relative '../domain/application_config.rb'
8
8
  # Widget Service for CRUD operation related to widget
9
9
  #
10
10
  class WidgetService
11
- @@create_widget_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets'
12
- @@update_destroy_widget_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/'
13
- @@list_widget_url = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/visible'
14
-
15
11
  #
16
12
  # Creates Widget
17
13
  #
@@ -23,7 +19,7 @@ class WidgetService
23
19
  def self.create_widget(widget, bearer_token)
24
20
  widget_data = get_widget(widget)
25
21
  create_widget_payload = Widget.get_payload(widget_data)
26
- RestClient::Request.execute(method: :post, url: @@create_widget_url,
22
+ RestClient::Request.execute(method: :post, url: ApplicationConfig.get_url('create_widget_path'),
27
23
  payload: create_widget_payload,
28
24
  headers: { 'Content-Type': 'application/json',
29
25
  'Authorization': bearer_token })
@@ -39,7 +35,7 @@ class WidgetService
39
35
  # @return [Json] Response of update widget
40
36
  #
41
37
  def self.update_widget(widget, widget_id, bearer_token)
42
- update_url_with_widget_id = @@update_destroy_widget_url + widget_id.to_s
38
+ update_url_with_widget_id = ApplicationConfig.get_url('create_widget_path') + '/' + widget_id.to_s
43
39
  widget_data = get_widget(widget)
44
40
  update_widget_payload = Widget.get_payload(widget_data)
45
41
  RestClient::Request.execute(method: :put, url: update_url_with_widget_id,
@@ -57,7 +53,7 @@ class WidgetService
57
53
  # @return [Json] Response of delete widget
58
54
  #
59
55
  def self.delete_widget(widget_id, bearer_token)
60
- destroy_url_with_widget_id = @@update_destroy_widget_url + widget_id.to_s
56
+ destroy_url_with_widget_id = ApplicationConfig.get_url('create_widget_path') + '/' + widget_id.to_s
61
57
  RestClient::Request.execute(method: :delete,
62
58
  url: destroy_url_with_widget_id,
63
59
  headers: { 'Content-Type': 'application/json',
@@ -73,7 +69,7 @@ class WidgetService
73
69
  #
74
70
  def self.get_own_widgets(bearer_token)
75
71
  RestClient::Request.execute(method: :get,
76
- url: @@create_widget_url,
72
+ url: ApplicationConfig.get_url('list_own_widget_path'),
77
73
  headers: { 'Content-Type': 'application/json',
78
74
  'Authorization': bearer_token })
79
75
  end
@@ -87,7 +83,7 @@ class WidgetService
87
83
  #
88
84
  def self.get_public_widgets(bearer_token)
89
85
  RestClient::Request.execute(method: :get,
90
- url: @@list_widget_url,
86
+ url: ApplicationConfig.get_url('list_public_widget_path'),
91
87
  headers: { 'Content-Type': 'application/json',
92
88
  params: { client_id: ApplicationConfig.client_id,
93
89
  client_secret: ApplicationConfig.client_secret },
@@ -104,7 +100,7 @@ class WidgetService
104
100
  #
105
101
  def self.get_public_widgets_with_search_term(search_term, bearer_token)
106
102
  RestClient::Request.execute(method: :get,
107
- url: @@list_widget_url,
103
+ url: ApplicationConfig.get_url('list_public_widget_path'),
108
104
  headers: { 'Content-Type': 'application/json',
109
105
  params: { client_id: ApplicationConfig.client_id,
110
106
  client_secret: ApplicationConfig.client_secret,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: widgets_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sachin Murthy
@@ -32,6 +32,7 @@ extra_rdoc_files: []
32
32
  files:
33
33
  - Gemfile
34
34
  - Rakefile
35
+ - config/application_config.yml
35
36
  - lib/domain/application_config.rb
36
37
  - lib/domain/authentication.rb
37
38
  - lib/domain/client_info_base.rb