Class: WidgetService
- Inherits:
-
Object
- Object
- WidgetService
- Defined in:
- lib/services/widget_service.rb
Constant Summary collapse
- @@create_widget_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets'
- @@update_destroy_widget_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/'
- @@list_widget_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/widgets/visible'
Class Method Summary collapse
- .create_widget(widget, bearer_token) ⇒ Object
- .destroy_widget(widget_id, bearer_token) ⇒ Object
- .get_private_widgets(bearer_token) ⇒ Object
- .get_public_widgets(bearer_token) ⇒ Object
- .get_public_widgets_with_search_term(search_term, bearer_token) ⇒ Object
- .get_widget(widget) ⇒ Object
- .update_widget(widget, widget_id, bearer_token) ⇒ Object
Class Method Details
.create_widget(widget, bearer_token) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/services/widget_service.rb', line 13 def self.(, bearer_token) = () = Widget.get_payload() return RestClient::Request.execute(method: :post, url: @@create_widget_url, payload: , headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |
.destroy_widget(widget_id, bearer_token) ⇒ Object
30 31 32 33 34 |
# File 'lib/services/widget_service.rb', line 30 def self.(, bearer_token) = @@update_destroy_widget_url + "#{}" return RestClient::Request.execute(method: :delete, url: , headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |
.get_private_widgets(bearer_token) ⇒ Object
36 37 38 39 |
# File 'lib/services/widget_service.rb', line 36 def self.(bearer_token) return RestClient::Request.execute(method: :get, url: @@create_widget_url, headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |
.get_public_widgets(bearer_token) ⇒ Object
41 42 43 44 45 |
# File 'lib/services/widget_service.rb', line 41 def self.(bearer_token) return RestClient::Request.execute(method: :get, url: @@list_widget_url, headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret}, 'Authorization': bearer_token}) end |
.get_public_widgets_with_search_term(search_term, bearer_token) ⇒ Object
47 48 49 50 51 |
# File 'lib/services/widget_service.rb', line 47 def self.(search_term, bearer_token) return RestClient::Request.execute(method: :get, url: @@list_widget_url, headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret, :term => search_term}, 'Authorization': bearer_token}) end |
.get_widget(widget) ⇒ Object
53 54 55 56 57 |
# File 'lib/services/widget_service.rb', line 53 def self.() = WidgetBase.new . = return end |
.update_widget(widget, widget_id, bearer_token) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/services/widget_service.rb', line 21 def self.(, , bearer_token) = @@update_destroy_widget_url + "#{}" = () = Widget.get_payload() return RestClient::Request.execute(method: :put, url: , payload: , headers: {'Content-Type': 'application/json', 'Authorization': bearer_token}) end |