Class: WidgetService
- Inherits:
-
Object
- Object
- WidgetService
- Defined in:
- lib/services/widget_service.rb
Overview
Widget Service for CRUD operation related to widget
Class Method Summary collapse
-
.create_widget(widget, bearer_token) ⇒ Json
Creates Widget.
-
.delete_widget(widget_id, bearer_token) ⇒ Json
Deletes own widget for given widget id.
-
.get_own_widgets(bearer_token) ⇒ String
Lists own widgets.
-
.get_public_widgets(bearer_token) ⇒ Json
Lists public widgets.
-
.get_public_widgets_with_search_term(search_term, bearer_token) ⇒ Json
Lists public widgets with search term.
-
.get_widget(widget) ⇒ Object
Sets Parent to Widget object.
-
.update_widget(widget, widget_id, bearer_token) ⇒ Json
Updates existing widget.
Class Method Details
.create_widget(widget, bearer_token) ⇒ Json
Creates Widget
19 20 21 22 23 24 25 26 |
# File 'lib/services/widget_service.rb', line 19 def self.(, bearer_token) = () = Widget.get_payload() RestClient::Request.execute(method: :post, url: ApplicationConfig.get_url('create_widget_path'), payload: , headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end |
.delete_widget(widget_id, bearer_token) ⇒ Json
Deletes own widget for given widget id
58 59 60 61 62 63 64 |
# File 'lib/services/widget_service.rb', line 58 def self.(, bearer_token) = ApplicationConfig.get_url('create_widget_path') + '/' + .to_s RestClient::Request.execute(method: :delete, url: , headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end |
.get_own_widgets(bearer_token) ⇒ String
Lists own widgets
73 74 75 76 77 78 |
# File 'lib/services/widget_service.rb', line 73 def self.(bearer_token) RestClient::Request.execute(method: :get, url: ApplicationConfig.get_url('list_own_widget_path'), headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end |
.get_public_widgets(bearer_token) ⇒ Json
Lists public widgets
87 88 89 90 91 92 93 94 |
# File 'lib/services/widget_service.rb', line 87 def self.(bearer_token) RestClient::Request.execute(method: :get, url: ApplicationConfig.get_url('list_public_widget_path'), headers: { 'Content-Type': 'application/json', params: { client_id: ApplicationConfig.client_id, client_secret: ApplicationConfig.client_secret }, 'Authorization': bearer_token }) end |
.get_public_widgets_with_search_term(search_term, bearer_token) ⇒ Json
Lists public widgets with search term
104 105 106 107 108 109 110 111 112 |
# File 'lib/services/widget_service.rb', line 104 def self.(search_term, bearer_token) RestClient::Request.execute(method: :get, url: ApplicationConfig.get_url('list_public_widget_path'), headers: { 'Content-Type': 'application/json', params: { client_id: ApplicationConfig.client_id, client_secret: ApplicationConfig.client_secret, term: search_term }, 'Authorization': bearer_token }) end |
.get_widget(widget) ⇒ Object
Sets Parent to Widget object
121 122 123 124 125 |
# File 'lib/services/widget_service.rb', line 121 def self.() = WidgetBase.new . = end |
.update_widget(widget, widget_id, bearer_token) ⇒ Json
Updates existing widget
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/services/widget_service.rb', line 37 def self.(, , bearer_token) # puts widget.kind #widget.attributes.except("name") = () = Widget.get_payload() puts = ApplicationConfig.get_url('update_widget_path') + '/' + .to_s RestClient::Request.execute(method: :put, url: , payload: , headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end |