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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f6395196c2b2e74cc6bb7aa6f4557b286c7bd95
4
- data.tar.gz: a3df4113899f7d1e8679cad877d61a377d52895a
3
+ metadata.gz: e8c2eb9724a9049008068f6440156e22eb2196da
4
+ data.tar.gz: 873e11f319f44f636b832f6c7c0f1f64f5a0afa4
5
5
  SHA512:
6
- metadata.gz: 7f2b42a73ca1f7acbe201f987ada7ca9ad9a9ddbdd6b73cf90723e8f2edb7d25a0e6fb63315a846d854cf00266d60c97e71f615ad076a522fde1aff710903896
7
- data.tar.gz: 540b8708fd3c9b9f15f668db4645a55d19fcf7e866a9e21ca62a12b461a26cd1e7880b3d8f7438caf31016d5665722efd9d269589bbe4e123a5fd4f49f84e663
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
- }.to_json(*data)
59
- # hash.delete_if { |k, v| v.nil? }
60
- #hash.to_json(*data)
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
- attr_accessor :name
4
- attr_accessor :description
5
- attr_accessor :kind
6
-
7
- def initialize name: nil, description: nil, kind: nil
8
- self.name, self.description, self.kind =
9
- name, description, kind
10
- end
11
-
12
- def to_json(*a)
13
- hash = {
14
- name: @name,
15
- description: @description,
16
- kind: @kind
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
- return widget.to_json
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
@@ -1,16 +1,21 @@
1
1
  require 'json'
2
+
3
+ #
4
+ # Widget Base class containing widget object
5
+ #
2
6
  class WidgetBase
3
- attr_accessor :widget
7
+ attr_accessor :widget
4
8
 
5
- def to_json(*a)
6
- {
7
- widget: @widget
8
- }.to_json(*a)
9
- end
10
-
11
- def self.json_create(o)
12
- a_from_json = new
13
- a_from_json.widget = o['widget']
14
- a_from_json
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
- widget_data = WidgetBase.new
121
- widget_data.widget = widget
122
- widget_data
120
+ # widget_data = WidgetBase.new
121
+ #widget_data.widget = widget
122
+ widget
123
123
  end
124
124
  end
@@ -266,20 +266,9 @@ class WidgetsApiClient
266
266
  end
267
267
  end
268
268
 
269
- #WidgetsApiClient.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352", "https://showoff-rails-react-production.herokuapp.com")
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 ='updated 1'
282
- #widget.description ='new update'
271
+ #widget.name ='name'
272
+ #widget.description ='desc'
283
273
  #widget.kind ='hidden'
284
- #WidgetsApiClient.update_widget(widget, 206,'Bearer 6825d9b46bf447563c062504814eb0e0fcda105dbdea55e32680d6f054f252e8')
285
-
274
+ #WidgetsApiClient.create_widget(widget, "Bearer xxxxxxxxxxxxxxxxxxx")
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.1.0.9
4
+ version: 0.2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sachin Murthy