class WidgetService
Widget
Service for CRUD operation related to widget
Public Class Methods
Creates Widget
@param [Object] widget Widget
object for create @param [String] bearer_token
@return [Json] Response of create widget
# File lib/services/widget_service.rb, line 18 def self.create_widget(widget, bearer_token) create_widget_payload = Widget.get_payload(widget) RestClient::Request.execute(method: :post, url: ApplicationConfig.get_url('create_widget_path'), payload: create_widget_payload, headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end
Deletes own widget for given widget id
@param [String] widget_id widgets to delete @param [String] bearer_token
@return [Json] Response of delete widget
# File lib/services/widget_service.rb, line 52 def self.delete_widget(widget_id, bearer_token) destroy_url_with_widget_id = ApplicationConfig.get_url('create_widget_path') + '/' + widget_id.to_s RestClient::Request.execute(method: :delete, url: destroy_url_with_widget_id, headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end
Lists own widgets
@param [String] bearer_token
@return [String] Response with list of own widgets
# File lib/services/widget_service.rb, line 67 def self.get_own_widgets(bearer_token) RestClient::Request.execute(method: :get, url: ApplicationConfig.get_url('list_own_widget_path'), headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end
Lists public widgets
@param [String] bearer_token
@return [Json] Response with list of public visible widgets
# File lib/services/widget_service.rb, line 81 def self.get_public_widgets(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
Lists public widgets with search term
@param [String] search_term @param [String] bearer_token
@return [Json] Response with searched public widgets by given search term
# File lib/services/widget_service.rb, line 98 def self.get_public_widgets_with_search_term(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
Updates existing widget
@param [Object] widget Widget
object for update @param [String] widget_id widget to update @param [String] bearer_token
@return [Json] Response of update widget
# File lib/services/widget_service.rb, line 35 def self.update_widget(widget, widget_id, bearer_token) update_widget_payload = Widget.get_payload(widget) update_url_with_widget_id = ApplicationConfig.get_url('update_widget_path') + '/' + widget_id.to_s RestClient::Request.execute(method: :put, url: update_url_with_widget_id, payload: update_widget_payload, headers: { 'Content-Type': 'application/json', 'Authorization': bearer_token }) end