widgets_api_client 0.0.9.2 → 0.0.9.3
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/application_config.rb +7 -0
- data/lib/widgets_api_client.rb +91 -10
- 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: abfa8dc11102c5118e2bcfc08d6a25b3c889b26483d01683070545f5d783619c
|
4
|
+
data.tar.gz: 7b94eaf58703e06d638f0168fc03f57e5d90359ec12a0ad140999bec4775eacd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36fdd7a781c578e29090dd2ff623b5a12d21b8ce76120bbf191a081228325e0f6ac7ab263610f3c3e8dac6010474632353735b8f14d94904ee82ed98c40fb86c
|
7
|
+
data.tar.gz: 3bac93832b82b94581c5858889e693b89a0d43729b30a125bc310c5eb31e02cf82363fe9325d066f51273e4e573e16b21fee00c20ea5d12fc1f740b645da0c43
|
@@ -9,6 +9,13 @@ class ApplicationConfig
|
|
9
9
|
@@base_url = ''
|
10
10
|
@@config = {}
|
11
11
|
|
12
|
+
#
|
13
|
+
# Sets Application Configuration
|
14
|
+
#
|
15
|
+
# @param [String] client_id
|
16
|
+
# @param [String] client_secret
|
17
|
+
# @param [String] base_url
|
18
|
+
#
|
12
19
|
def self.set_config(client_id, client_secret, base_url)
|
13
20
|
@@client_id = client_id
|
14
21
|
@@client_secret = client_secret
|
data/lib/widgets_api_client.rb
CHANGED
@@ -6,61 +6,142 @@ require File.dirname(__FILE__) + '/services/widget_service'
|
|
6
6
|
require File.dirname(__FILE__) + '/services/user_widget_service'
|
7
7
|
require File.dirname(__FILE__) + '/domain/application_config'
|
8
8
|
|
9
|
+
#
|
10
|
+
# Interface for gem methods
|
11
|
+
#
|
9
12
|
class WidgetsApiClient
|
13
|
+
|
14
|
+
#
|
15
|
+
# Sets Application Configuration
|
16
|
+
#
|
17
|
+
# @param [String] client_id
|
18
|
+
# @param [String] client_secret
|
19
|
+
# @param [String] base_url
|
20
|
+
#
|
10
21
|
def self.set_config(client_id, client_secret, base_url)
|
11
22
|
ApplicationConfig.set_config(client_id, client_secret, base_url)
|
12
23
|
end
|
13
24
|
|
25
|
+
#
|
26
|
+
# Return Client Id
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
#
|
14
30
|
def self.client_id
|
15
31
|
ApplicationConfig.client_id
|
16
32
|
end
|
17
33
|
|
18
|
-
#
|
34
|
+
#
|
35
|
+
# Creates authentication token
|
36
|
+
#
|
37
|
+
# @param [object] auth_data Authentication object
|
38
|
+
#
|
39
|
+
# @return [Json] Response with brearer and refresh token
|
40
|
+
#
|
19
41
|
def self.create_authentication_token(auth_data)
|
20
42
|
AuthenticationService.create_authentication(auth_data)
|
21
43
|
end
|
22
44
|
|
45
|
+
#
|
23
46
|
# Refresh authentication token
|
47
|
+
#
|
48
|
+
# @param [Object] auth_data Authentication object
|
49
|
+
# @param [String] bearer_token
|
50
|
+
#
|
51
|
+
# @return [Json] Response with brearer and refresh token
|
52
|
+
#
|
24
53
|
def self.refresh_authentication_token(auth_data, bearer_token)
|
25
54
|
AuthenticationService.refresh_authentication_token(auth_data, bearer_token)
|
26
55
|
end
|
27
56
|
|
28
|
-
#
|
57
|
+
#
|
58
|
+
# Revokes authentication token
|
59
|
+
#
|
60
|
+
# @param [Object] auth_data Authentication object
|
61
|
+
# @param [String] bearer_token
|
62
|
+
#
|
63
|
+
# @return [Json] Response with revoke message
|
64
|
+
#
|
29
65
|
def self.revoke_authentication_token(auth_data, bearer_token)
|
30
66
|
AuthenticationService.revoke_authentication_token(auth_data, bearer_token)
|
31
67
|
end
|
32
68
|
|
33
|
-
#
|
69
|
+
#
|
70
|
+
# Creates User
|
71
|
+
#
|
72
|
+
# @param [Object] user User Object for create
|
73
|
+
#
|
74
|
+
# @return [Json] Response of create user
|
75
|
+
#
|
34
76
|
def self.create_user(user_data)
|
35
77
|
UserService.create_user(user_data)
|
36
78
|
end
|
37
79
|
|
38
|
-
#
|
80
|
+
#
|
81
|
+
# Updates existing user
|
82
|
+
#
|
83
|
+
# @param [Object] user User Object for update
|
84
|
+
# @param [String] bearer_token
|
85
|
+
#
|
86
|
+
# @return [Json] Response of update user
|
87
|
+
#
|
39
88
|
def self.update_user(user_data, bearer_token)
|
40
89
|
UserService.update_user(user_data, bearer_token)
|
41
90
|
end
|
42
91
|
|
43
|
-
#
|
92
|
+
#
|
93
|
+
# Verifies if email is already registered
|
94
|
+
#
|
95
|
+
# @param [Object] user user object conatining email
|
96
|
+
#
|
97
|
+
# @return [Json] Response of verify email
|
98
|
+
#
|
44
99
|
def self.check_email(user_data)
|
45
100
|
UserService.check_email(user_data)
|
46
101
|
end
|
47
102
|
|
48
|
-
#
|
103
|
+
#
|
104
|
+
# Sends email with reset password link
|
105
|
+
#
|
106
|
+
# @param [Object] user User object
|
107
|
+
#
|
108
|
+
# @return [Json] Response of reset password
|
109
|
+
#
|
49
110
|
def self.reset_password(user_data)
|
50
111
|
UserService.reset_password(user_data)
|
51
112
|
end
|
52
113
|
|
53
|
-
#
|
114
|
+
#
|
115
|
+
# Updates old password to new password
|
116
|
+
#
|
117
|
+
# @param [Object] user User object with old and new password details
|
118
|
+
# @param [String] bearer_token
|
119
|
+
#
|
120
|
+
# @return [Json] Response of change password
|
121
|
+
#
|
54
122
|
def self.change_password(user_data, bearer_token)
|
55
123
|
UserService.change_password(user_data, bearer_token)
|
56
124
|
end
|
57
125
|
|
58
|
-
#
|
126
|
+
#
|
127
|
+
# Displays logged in user details
|
128
|
+
#
|
129
|
+
# @param [String] bearer_token
|
130
|
+
#
|
131
|
+
# @return [Json] Response containing logged in user details
|
132
|
+
#
|
59
133
|
def self.show_logged_in_user(bearer_token)
|
60
134
|
UserService.show_logged_in_user(bearer_token)
|
61
135
|
end
|
62
136
|
|
63
|
-
#
|
137
|
+
#
|
138
|
+
# Displays details of user id
|
139
|
+
#
|
140
|
+
# @param [String] user_id
|
141
|
+
# @param [String] bearer_token
|
142
|
+
#
|
143
|
+
# @return [Json] Response containing details of given user id
|
144
|
+
#
|
64
145
|
def self.show_user_id(user_id, bearer_token)
|
65
146
|
UserService.show_user_id(user_id, bearer_token)
|
66
147
|
end
|
@@ -120,7 +201,7 @@ b = User.new
|
|
120
201
|
b.first_name = "sam"
|
121
202
|
b.last_name = "test"
|
122
203
|
b.password = "password"
|
123
|
-
b.email = "
|
204
|
+
b.email = "sam1@gmail.com"
|
124
205
|
b.image_url = "https://static.thenounproject.com/png/961-200.png"
|
125
206
|
WidgetsApiClient.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352",
|
126
207
|
"https://showoff-rails-react-production.herokuapp.com")
|