widgets_api_client 0.2.0.4 → 1.0.0
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/authentication.rb +23 -9
- data/lib/domain/user.rb +30 -17
- data/lib/domain/widget.rb +12 -5
- data/lib/services/authentication_service.rb +1 -0
- data/lib/services/user_service.rb +3 -3
- data/lib/services/widget_service.rb +1 -1
- data/lib/widgets_api_client.rb +8 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81fb7ee129dfb3c49a93195c25b02360d8c7cbce
|
4
|
+
data.tar.gz: 4fbe7b40c3a518168d0cd45dfd8cb901b5ead842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de3e873a28ca1cd1ebe8c525d5f52b8d0f5928f8455337553044a95f82a1cab2aa6eee437aa8293c8c75d2609553f64e823fae28ac31318fd9fde60c97732e28
|
7
|
+
data.tar.gz: cd70580d48619263902e2e07970c4b8c4f26939ac454cdca0d4fc0ca6761dad2f285a9e15d3615d3f71dccf5cafe4dd97f343593895c2c6caa3098d718a63bad
|
@@ -27,19 +27,26 @@ class Authentication
|
|
27
27
|
self.refresh_token = refresh_token
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
#
|
31
|
+
# Converts Authentication object to Hash and deletes null value fields
|
32
|
+
#
|
33
|
+
# @param [Refrence] options
|
34
|
+
#
|
35
|
+
# @return [Hash] Hash of authentication object
|
36
|
+
#
|
37
|
+
def as_json(options = {})
|
31
38
|
hash_data = {
|
32
39
|
grant_type: @grant_type,
|
33
40
|
username: @username,
|
34
41
|
password: @password,
|
35
42
|
token: @token,
|
36
43
|
refresh_token: @refresh_token
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
}
|
45
|
+
|
46
|
+
hash_data.delete_if { |k, v| v.nil? || v.empty? }
|
47
|
+
hash_data
|
48
|
+
end
|
49
|
+
|
43
50
|
#
|
44
51
|
# Gets Json represenatation of authentication object
|
45
52
|
#
|
@@ -48,10 +55,17 @@ class Authentication
|
|
48
55
|
# @return [Json] Json represenatation of authentication object
|
49
56
|
#
|
50
57
|
def self.get_payload(auth_data)
|
51
|
-
|
58
|
+
auth_data.as_json.to_json
|
52
59
|
end
|
53
60
|
|
61
|
+
#
|
62
|
+
# Gets Json represenatation of authentication object with client details
|
63
|
+
#
|
64
|
+
# @param [Object] auth_data Authentication object
|
65
|
+
#
|
66
|
+
# @return [Json] Json represenatation of authentication object
|
67
|
+
#
|
54
68
|
def self.get_payload_with_client_info(auth_data)
|
55
|
-
auth_data.as_json.merge!({'client_id' => ApplicationConfig.client_id, 'client_secret' => ApplicationConfig.client_secret}).to_json
|
69
|
+
auth_data.as_json.merge!({ 'client_id' => ApplicationConfig.client_id, 'client_secret' => ApplicationConfig.client_secret }).to_json
|
56
70
|
end
|
57
71
|
end
|
data/lib/domain/user.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
#
|
4
4
|
# User model conatining user create and update attributes
|
5
5
|
#
|
6
|
-
class User
|
6
|
+
class User
|
7
7
|
attr_accessor :first_name
|
8
8
|
attr_accessor :last_name
|
9
9
|
attr_accessor :password
|
@@ -28,7 +28,6 @@ class User
|
|
28
28
|
def initialize(first_name: nil, last_name: nil, password: nil,
|
29
29
|
current_password: nil, new_password: nil,
|
30
30
|
date_of_birth: nil, email: nil, image_url: nil)
|
31
|
-
|
32
31
|
self.first_name = first_name
|
33
32
|
self.last_name = last_name
|
34
33
|
self.password = password
|
@@ -39,23 +38,30 @@ class User
|
|
39
38
|
self.image_url = image_url
|
40
39
|
end
|
41
40
|
|
42
|
-
|
41
|
+
#
|
42
|
+
# Converts User object to Hash and deletes null value fields
|
43
|
+
#
|
44
|
+
# @param [Refrence] options
|
45
|
+
#
|
46
|
+
# @return [Hash] Hash of user object
|
47
|
+
#
|
48
|
+
def as_json(options = {})
|
43
49
|
hash_data = {
|
44
50
|
self.class.name.downcase => {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
first_name: @first_name,
|
52
|
+
last_name: @last_name,
|
53
|
+
password: @password,
|
54
|
+
current_password: @current_password,
|
55
|
+
new_password: @new_password,
|
56
|
+
date_of_birth: @date_of_birth,
|
57
|
+
email: @email,
|
58
|
+
image_url: @image_url
|
53
59
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
}
|
61
|
+
|
62
|
+
hash_data.each { |k, v| v.delete_if { |k, v| v.nil? } }
|
63
|
+
hash_data
|
64
|
+
end
|
59
65
|
|
60
66
|
#
|
61
67
|
# Gets Json represenatation of user object
|
@@ -68,7 +74,14 @@ class User
|
|
68
74
|
user.as_json.to_json
|
69
75
|
end
|
70
76
|
|
77
|
+
#
|
78
|
+
# Gets Json represenatation of user object with client details
|
79
|
+
#
|
80
|
+
# @param [Object] user User object
|
81
|
+
#
|
82
|
+
# @return [Json] Json represenatation of user object
|
83
|
+
#
|
71
84
|
def self.get_payload_with_client_info(user)
|
72
|
-
|
85
|
+
user.as_json.merge!({ 'client_id' => ApplicationConfig.client_id, 'client_secret' => ApplicationConfig.client_secret }).to_json
|
73
86
|
end
|
74
87
|
end
|
data/lib/domain/widget.rb
CHANGED
@@ -21,16 +21,23 @@ class Widget
|
|
21
21
|
self.kind = kind
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
#
|
25
|
+
# Converts Widget object to Hash and deletes null value fields
|
26
|
+
#
|
27
|
+
# @param [Refrence] options
|
28
|
+
#
|
29
|
+
# @return [Hash] Hash of widget object
|
30
|
+
#
|
31
|
+
def as_json(options = {})
|
32
|
+
hash_data = {
|
33
|
+
self.class.name.downcase => {
|
27
34
|
name: @name,
|
28
35
|
description: @description,
|
29
36
|
kind: @kind
|
30
37
|
}
|
31
38
|
}
|
32
|
-
|
33
|
-
hash_data.each {|k,v| v.delete_if { |k, v| v.nil? || v.empty? }}
|
39
|
+
|
40
|
+
hash_data.each { |k, v| v.delete_if { |k, v| v.nil? || v.empty? } }
|
34
41
|
hash_data
|
35
42
|
end
|
36
43
|
|
@@ -49,6 +49,7 @@ class AuthenticationService
|
|
49
49
|
#
|
50
50
|
def self.revoke_authentication_token(auth_data, bearer_token)
|
51
51
|
auth_payload = Authentication.get_payload(auth_data)
|
52
|
+
puts auth_payload
|
52
53
|
RestClient::Request.execute(method: :post,
|
53
54
|
url: ApplicationConfig.get_url('revoke_authentication_path'),
|
54
55
|
payload: auth_payload,
|
@@ -50,9 +50,9 @@ class UserService
|
|
50
50
|
RestClient::Request.execute(method: :get,
|
51
51
|
url: ApplicationConfig.get_url('check_email_path'),
|
52
52
|
headers: { 'Content-Type': 'application/json',
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
params: { email: user.email,
|
54
|
+
client_id: ApplicationConfig.client_id,
|
55
|
+
client_secret: ApplicationConfig.client_secret } })
|
56
56
|
end
|
57
57
|
|
58
58
|
#
|
@@ -83,7 +83,7 @@ class WidgetService
|
|
83
83
|
url: ApplicationConfig.get_url('list_public_widget_path'),
|
84
84
|
headers: { 'Content-Type': 'application/json',
|
85
85
|
params: { client_id: ApplicationConfig.client_id,
|
86
|
-
|
86
|
+
client_secret: ApplicationConfig.client_secret },
|
87
87
|
'Authorization': bearer_token })
|
88
88
|
end
|
89
89
|
|
data/lib/widgets_api_client.rb
CHANGED
@@ -10,7 +10,7 @@ require File.dirname(__FILE__) + '/domain/application_config'
|
|
10
10
|
# Interface for gem methods
|
11
11
|
#
|
12
12
|
class WidgetsApiClient
|
13
|
-
|
13
|
+
|
14
14
|
#
|
15
15
|
# Sets Application Configuration
|
16
16
|
#
|
@@ -69,7 +69,7 @@ class WidgetsApiClient
|
|
69
69
|
#
|
70
70
|
# Creates User
|
71
71
|
#
|
72
|
-
# @param [Object]
|
72
|
+
# @param [Object] user_data User Object for create
|
73
73
|
#
|
74
74
|
# @return [Json] Response of create user
|
75
75
|
#
|
@@ -80,7 +80,7 @@ class WidgetsApiClient
|
|
80
80
|
#
|
81
81
|
# Updates existing user
|
82
82
|
#
|
83
|
-
# @param [Object]
|
83
|
+
# @param [Object] user_data User Object for update
|
84
84
|
# @param [String] bearer_token
|
85
85
|
#
|
86
86
|
# @return [Json] Response of update user
|
@@ -92,7 +92,7 @@ class WidgetsApiClient
|
|
92
92
|
#
|
93
93
|
# Verifies if email is already registered
|
94
94
|
#
|
95
|
-
# @param [Object]
|
95
|
+
# @param [Object] user_data user object conatining email
|
96
96
|
#
|
97
97
|
# @return [Json] Response of verify email
|
98
98
|
#
|
@@ -103,7 +103,7 @@ class WidgetsApiClient
|
|
103
103
|
#
|
104
104
|
# Sends email with reset password link
|
105
105
|
#
|
106
|
-
# @param [Object]
|
106
|
+
# @param [Object] user_data User object
|
107
107
|
#
|
108
108
|
# @return [Json] Response of reset password
|
109
109
|
#
|
@@ -114,7 +114,7 @@ class WidgetsApiClient
|
|
114
114
|
#
|
115
115
|
# Updates old password to new password
|
116
116
|
#
|
117
|
-
# @param [Object]
|
117
|
+
# @param [Object] user_data User object with old and new password details
|
118
118
|
# @param [String] bearer_token
|
119
119
|
#
|
120
120
|
# @return [Json] Response of change password
|
@@ -197,7 +197,7 @@ class WidgetsApiClient
|
|
197
197
|
#
|
198
198
|
# Creates Widget
|
199
199
|
#
|
200
|
-
# @param [Object]
|
200
|
+
# @param [Object] widget_data Widget object for create
|
201
201
|
# @param [String] bearer_token
|
202
202
|
#
|
203
203
|
# @return [Json] Response of create widget
|
@@ -209,7 +209,7 @@ class WidgetsApiClient
|
|
209
209
|
#
|
210
210
|
# Updates existing widget
|
211
211
|
#
|
212
|
-
# @param [Object]
|
212
|
+
# @param [Object] widget_data Widget object for update
|
213
213
|
# @param [String] widget_id widget to update
|
214
214
|
# @param [String] bearer_token
|
215
215
|
#
|
@@ -265,4 +265,3 @@ class WidgetsApiClient
|
|
265
265
|
WidgetService.get_public_widgets_with_search_term(search_term, bearer_token)
|
266
266
|
end
|
267
267
|
end
|
268
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: widgets_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sachin Murthy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|