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
56 57 58 59 60 61 62 |
# File 'lib/services/widget_service.rb', line 56 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
71 72 73 74 75 76 |
# File 'lib/services/widget_service.rb', line 71 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
85 86 87 88 89 90 91 92 |
# File 'lib/services/widget_service.rb', line 85 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
102 103 104 105 106 107 108 109 110 |
# File 'lib/services/widget_service.rb', line 102 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
119 120 121 122 123 |
# File 'lib/services/widget_service.rb', line 119 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 |
# File 'lib/services/widget_service.rb', line 37 def self.(, , bearer_token) = () = Widget.get_payload() #update_url_with_widget_id = ApplicationConfig.get_url('update_widget_path') + '/' + widget_id.to_s = 'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/205' RestClient::Request.execute(method: :put, url: , payload: , headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end |