lib/nds_api.rb in nds_api-0.1.18 vs lib/nds_api.rb in nds_api-0.1.19
- old
+ new
@@ -1,9 +1,10 @@
require 'nds_api/http'
require 'nds_api/method'
require 'nds_api/url'
require 'nds_api/utils'
+require 'nds_api/validator'
require 'nds_api/version'
module NdsApi
class Client
# Create a new client instance
@@ -23,10 +24,13 @@
end
def method_missing(method, *args, &block)
@method = NdsApi::Method.new(method)
@args = *args
+
+ validate_search_providers_params!
+
console_debug(step: 1)
@response = http_action(method, *args, &block)
console_debug(step: 2)
NdsApi::Utils.hash_keys_str_to_sym(@response)
end
@@ -58,10 +62,16 @@
def query_params
@args.count > 1 ? @args[1] : nil
end
+ def validate_search_providers_params!
+ return unless @method.is_search_providers?
+ console_debug(action: 'search_providers - validating params')
+ NdsApi::Validator.validate_search_providers_params!(data)
+ end
+
def console_debug(params)
return unless @options[:debug]
if params[:step] == 1
params_to_display = @options.dup
params_to_display[:password] = 'XXXXXXXXXXXXXXX'
@@ -73,8 +83,9 @@
puts 'NDS API DEBUG: METHOD GET'
end
end
puts "NDS API DEBUG: RESPONSE: #{@response.inspect}" if params[:step] == 2
puts "NDS API DEBUG: URL: #{params[:url]}" if params[:url]
+ puts "NDS API DEBUG: ACTION: #{params[:action]}" if params[:action]
end
end
end