widgets_api_client 0.1.0.9 → 0.2.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/user.rb +4 -4
- data/lib/domain/widget.rb +63 -27
- data/lib/domain/widget_base.rb +17 -12
- data/lib/services/user_service.rb +0 -1
- data/lib/services/widget_service.rb +4 -4
- data/lib/widgets_api_client.rb +4 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8c2eb9724a9049008068f6440156e22eb2196da
|
4
|
+
data.tar.gz: 873e11f319f44f636b832f6c7c0f1f64f5a0afa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea9bef88302bbd6a54566875df1d3d71f2b9b2fb2cbe474edb197043a261a98be0a5565704c4e29a8addac7fc343123b459acc881dda882781b1a1a700117e46
|
7
|
+
data.tar.gz: f73aa6c2a4ec2807340b307c418424471ca781365d46b5b209e8ae889d47fa070b98892d4907573b1a98fe43dd0a8b740393c9d262d090b5b603b8c46f86dfb0
|
data/lib/domain/user.rb
CHANGED
@@ -46,7 +46,7 @@ class User
|
|
46
46
|
# @return [Json] Json represenatation of user object
|
47
47
|
#
|
48
48
|
def to_json(*data)
|
49
|
-
{
|
49
|
+
hash = {
|
50
50
|
first_name: @first_name,
|
51
51
|
last_name: @last_name,
|
52
52
|
password: @password,
|
@@ -55,9 +55,9 @@ class User
|
|
55
55
|
date_of_birth: @date_of_birth,
|
56
56
|
email: @email,
|
57
57
|
image_url: @image_url
|
58
|
-
}
|
59
|
-
|
60
|
-
|
58
|
+
}
|
59
|
+
hash.delete_if { |k, v| v.nil? }
|
60
|
+
hash.to_json(*data)
|
61
61
|
end
|
62
62
|
|
63
63
|
#
|
data/lib/domain/widget.rb
CHANGED
@@ -1,34 +1,70 @@
|
|
1
1
|
require 'json'
|
2
|
+
|
3
|
+
#
|
4
|
+
# Widget model conatining widget craeate and update attributes
|
5
|
+
#
|
2
6
|
class Widget
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
hash.delete_if { |k, v| v.nil? || v.empty? }
|
19
|
-
hash.to_json(*a)
|
7
|
+
attr_accessor :name
|
8
|
+
attr_accessor :description
|
9
|
+
attr_accessor :kind
|
10
|
+
|
11
|
+
#
|
12
|
+
# Inialise the widget model
|
13
|
+
#
|
14
|
+
# @param [String] name Name of widget
|
15
|
+
# @param [String] description
|
16
|
+
# @param [String] kind Kind of widget - hidden/visible
|
17
|
+
#
|
18
|
+
def initialize(name: nil, description: nil, kind: nil)
|
19
|
+
self.name = name
|
20
|
+
self.description = description
|
21
|
+
self.kind = kind
|
20
22
|
end
|
21
23
|
|
22
|
-
def self.json_create(o)
|
23
|
-
b_from_json = new
|
24
|
-
b_from_json.name = o['name']
|
25
|
-
b_from_json.description = o['description']
|
26
|
-
b_from_json.kind = o['kind']
|
27
|
-
b_from_json
|
28
|
-
end
|
29
24
|
|
25
|
+
|
26
|
+
|
27
|
+
def as_json(options={})
|
28
|
+
hash1 = {
|
29
|
+
self.class.name.downcase => {
|
30
|
+
name: @name,
|
31
|
+
description: @description,
|
32
|
+
kind: @kind
|
33
|
+
}
|
34
|
+
}
|
35
|
+
#hash1.each {|k,v| v.delete(:two) if k == :clubs}
|
36
|
+
hash1.each {|k,v| v.delete_if { |k, v| v.nil? || v.empty? }}
|
37
|
+
|
38
|
+
hash1
|
39
|
+
#hash.delete_if { |k, v| v.nil? || v.empty? }
|
40
|
+
#hash
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
#hash.delete_if { |k, v| v.nil? }
|
45
|
+
#hash.to_json(*data)
|
46
|
+
|
47
|
+
|
48
|
+
#
|
49
|
+
# Converts Widget object to Json object
|
50
|
+
#
|
51
|
+
# @param [refrence] *data widget object refrence
|
52
|
+
#
|
53
|
+
# @return [<Type>] Json represenatation of widget object
|
54
|
+
#
|
55
|
+
|
56
|
+
|
57
|
+
#
|
58
|
+
# Gets Json represenatation of widget object
|
59
|
+
#
|
60
|
+
# @param [Object] widget Widget object
|
61
|
+
#
|
62
|
+
# @return [Json] Json represenatation of widget object
|
63
|
+
#
|
30
64
|
def self.get_payload(widget)
|
31
|
-
|
65
|
+
hash = widget.as_json.to_json
|
66
|
+
#hashto_json(:include => {:bs => :c})
|
67
|
+
#widget.to_hash
|
68
|
+
#JSON.parse(widget.to_json )
|
32
69
|
end
|
33
|
-
|
34
|
-
end
|
70
|
+
end
|
data/lib/domain/widget_base.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'json'
|
2
|
+
|
3
|
+
#
|
4
|
+
# Widget Base class containing widget object
|
5
|
+
#
|
2
6
|
class WidgetBase
|
3
|
-
|
7
|
+
attr_accessor :widget
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
#
|
10
|
+
# Converts Widget object to Json object
|
11
|
+
#
|
12
|
+
# @param [Refrence] *data widget object refrence
|
13
|
+
#
|
14
|
+
# @return [Json] Json represenatation of widget object
|
15
|
+
#
|
16
|
+
def to_json(*data)
|
17
|
+
{
|
18
|
+
widget: @widget
|
19
|
+
}.to_json(*data)
|
15
20
|
end
|
16
|
-
end
|
21
|
+
end
|
@@ -19,7 +19,6 @@ class UserService
|
|
19
19
|
def self.create_user(user)
|
20
20
|
user_with_client_info = get_user_with_client_info(user)
|
21
21
|
create_user_payload = User.get_payload(user_with_client_info)
|
22
|
-
puts create_user_payload
|
23
22
|
RestClient::Request.execute(method: :post,
|
24
23
|
url: ApplicationConfig.get_url('create_user_path'),
|
25
24
|
payload: create_user_payload,
|
@@ -19,6 +19,7 @@ class WidgetService
|
|
19
19
|
def self.create_widget(widget, bearer_token)
|
20
20
|
widget_data = get_widget(widget)
|
21
21
|
create_widget_payload = Widget.get_payload(widget_data)
|
22
|
+
puts create_widget_payload
|
22
23
|
RestClient::Request.execute(method: :post, url: ApplicationConfig.get_url('create_widget_path'),
|
23
24
|
payload: create_widget_payload,
|
24
25
|
headers: { 'Content-Type': 'application/json',
|
@@ -37,7 +38,6 @@ class WidgetService
|
|
37
38
|
def self.update_widget(widget, widget_id, bearer_token)
|
38
39
|
widget_data = get_widget(widget)
|
39
40
|
update_widget_payload = Widget.get_payload(widget_data)
|
40
|
-
puts update_widget_payload
|
41
41
|
update_url_with_widget_id = ApplicationConfig.get_url('update_widget_path') + '/' + widget_id.to_s
|
42
42
|
RestClient::Request.execute(method: :put, url: update_url_with_widget_id,
|
43
43
|
payload: update_widget_payload,
|
@@ -117,8 +117,8 @@ class WidgetService
|
|
117
117
|
# @return [Object] Widget as child object
|
118
118
|
#
|
119
119
|
def self.get_widget(widget)
|
120
|
-
|
121
|
-
widget_data.widget = widget
|
122
|
-
|
120
|
+
# widget_data = WidgetBase.new
|
121
|
+
#widget_data.widget = widget
|
122
|
+
widget
|
123
123
|
end
|
124
124
|
end
|
data/lib/widgets_api_client.rb
CHANGED
@@ -266,20 +266,9 @@ class WidgetsApiClient
|
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
|
-
#WidgetsApiClient.set_config("
|
270
|
-
#user = User.new
|
271
|
-
#user.first_name = 'fname1'
|
272
|
-
#user.last_name = 'lname1'
|
273
|
-
#user.password = 'password'
|
274
|
-
#user.email = 'fname1@gmail.com'
|
275
|
-
#user.image_url ='https://static'
|
276
|
-
#WidgetsApiClient.create_user(user)
|
277
|
-
|
278
|
-
|
279
|
-
#WidgetsApiClient.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352", "https://showoff-rails-react-production.herokuapp.com")
|
269
|
+
#WidgetsApiClient.set_config("a","b", "c")
|
280
270
|
#widget = Widget.new
|
281
|
-
#widget.name ='
|
282
|
-
#widget.description ='
|
271
|
+
#widget.name ='name'
|
272
|
+
#widget.description ='desc'
|
283
273
|
#widget.kind ='hidden'
|
284
|
-
#WidgetsApiClient.
|
285
|
-
|
274
|
+
#WidgetsApiClient.create_widget(widget, "Bearer xxxxxxxxxxxxxxxxxxx")
|