Class: UserWidgetService

Inherits:
Object
  • Object
show all
Defined in:
lib/services/user_widget_service.rb

Constant Summary collapse

@@own_widgets_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/me/widgets'
@@widgets_by_user_id_url =
'https://showoff-rails-react-production.herokuapp.com/api/v1/users/'

Class Method Summary collapse

Class Method Details

.get_private_widgets(bearer_token) ⇒ Object



9
10
11
12
13
# File 'lib/services/user_widget_service.rb', line 9

def self.get_private_widgets(bearer_token)
 return RestClient::Request.execute(method: :get, url: @@own_widgets_url, 
    headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret}, 
    'Authorization': bearer_token})
end

.get_private_widgets_with_search_term(search_term, bearer_token) ⇒ Object



15
16
17
18
19
# File 'lib/services/user_widget_service.rb', line 15

def self.get_private_widgets_with_search_term(search_term, bearer_token)
    return RestClient::Request.execute(method: :get, url: @@own_widgets_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_widgets_by_user_id(user_id, bearer_token) ⇒ Object



21
22
23
24
25
26
# File 'lib/services/user_widget_service.rb', line 21

def self.get_widgets_by_user_id(user_id, bearer_token)
    url_with_id = @@widgets_by_user_id_url + "#{user_id}" + "/widgets"
    return RestClient::Request.execute(method: :get, url: url_with_id, 
       headers: {'Content-Type': 'application/json', params: {:client_id => ApplicationConfig.get_client_id, :client_secret => ApplicationConfig.get_client_secret}, 
       'Authorization': bearer_token})
end

.get_widgets_by_user_id_with_search_term(user_id, search_term, bearer_token) ⇒ Object



28
29
30
31
32
33
# File 'lib/services/user_widget_service.rb', line 28

def self.get_widgets_by_user_id_with_search_term(user_id, search_term, bearer_token)
    url_with_id = @@widgets_by_user_id_url + "#{user_id}" + "/widgets"
    return RestClient::Request.execute(method: :get, url: url_with_id, 
       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