Skip to content

[GoogleSearch Gem] Remove param validation from gem #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/search/apple_store_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class AppleStoreSearch < SerpApiSearch

def initialize(params = {})
super(params, APPLE_STORE_ENGINE)
check_params([:term, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/baidu_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class BaiduSearch < SerpApiSearch

def initialize(params = {})
super(params, BAIDU_ENGINE)
check_params([:q, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/bing_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class BingSearch < SerpApiSearch

def initialize(params = {})
super(params, BING_ENGINE)
check_params([:q, :engine])
end

end
1 change: 0 additions & 1 deletion lib/search/duckduckgo_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class DuckduckgoSearch < SerpApiSearch

def initialize(params = {})
super(params, DUCKDUCKGO_ENGINE)
check_params([:q, :engine])
end

end
1 change: 0 additions & 1 deletion lib/search/ebay_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class EbaySearch < SerpApiSearch

def initialize(params = {})
super(params, EBAY_ENGINE)
check_params([:_nkw, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/google_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class GoogleSearch < SerpApiSearch

def initialize(params = {})
super(params, GOOGLE_ENGINE)
check_params([:q, :engine])
end

end
1 change: 0 additions & 1 deletion lib/search/homedepot_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class HomedepotSearch < SerpApiSearch

def initialize(params = {})
super(params, HOMEDEPOT_ENGINE)
check_params([:q, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/naver_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class NaverSearch < SerpApiSearch

def initialize(params = {})
super(params, NAVER_ENGINE)
check_params([:query, :engine])
end

def get_location
Expand Down
29 changes: 0 additions & 29 deletions lib/search/serp_api_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,35 +146,6 @@ def get_results(path)
raise e
end
end

def check_params(keys = [])
return if @params.keys == [:engine]

raise SerpApiException.new('keys must be a list of String or Symbol') unless keys.class == Array
missing = []
keys.each do |key|
case key.class.to_s
when 'String'
if @params[key].nil?
if @params[key.to_sym].nil?
missing << key.to_s
end
end
when 'Symbol'
if @params[key].nil?
if @params[key.to_s].nil?
missing << key.to_s
end
end
else
raise SerpApiException.new('keys must contains Symbol or String')
end
end
if !missing.empty?
raise SerpApiException.new("missing required keys in params: \n - #{missing.join("\n -")}")
end
end

end

# Standard SerpApiException for anything related to the client
Expand Down
1 change: 0 additions & 1 deletion lib/search/walmart_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class WalmartSearch < SerpApiSearch

def initialize(params = {})
super(params, WALMART_ENGINE)
check_params([:query, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/yahoo_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class YahooSearch < SerpApiSearch

def initialize(params = {})
super(params, YAHOO_ENGINE)
check_params([:p, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/yandex_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class YandexSearch < SerpApiSearch

def initialize(params = {})
super(params, YANDEX_ENGINE)
check_params([:text, :engine])
end

def get_location
Expand Down
1 change: 0 additions & 1 deletion lib/search/youtube_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class YoutubeSearch < SerpApiSearch

def initialize(params = {})
super(params, YOUTUBE_ENGINE)
check_params([:search_query, :engine])
end

end
Loading