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
55 56 57 58 59 60 61 |
# File 'lib/services/widget_service.rb', line 55 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
70 71 72 73 74 75 |
# File 'lib/services/widget_service.rb', line 70 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
84 85 86 87 88 89 90 91 |
# File 'lib/services/widget_service.rb', line 84 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
101 102 103 104 105 106 107 108 109 |
# File 'lib/services/widget_service.rb', line 101 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
118 119 120 121 122 |
# File 'lib/services/widget_service.rb', line 118 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 |
# File 'lib/services/widget_service.rb', line 37 def self.(, , bearer_token) = () = Widget.get_payload() = ApplicationConfig.get_url('update_widget_path') + '/' + .to_s RestClient::Request.execute(method: :put, url: , payload: , headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end |