lib/flexirest/request.rb in flexirest-1.2.1 vs lib/flexirest/request.rb in flexirest-1.2.2

- old
+ new

@@ -223,10 +223,24 @@ @post_params = nil else @post_params = default_params.merge(params || {}) @get_params = {} end + + if @method[:options][:requires] + requires = @method[:options][:requires].dup + merged_params = @get_params.merge(@post_params || {}) + missing = [] + requires.each do |key| + if merged_params[key.to_sym].blank? && ![true, false].include?(merged_params[key.to_sym]) + missing << key + end + end + if missing.any? + raise Flexirest::MissingParametersException.new("The following parameters weren't specifed: #{missing.join(", ")}") + end + end end def prepare_url if @forced_url && @forced_url.present? @url = @forced_url @@ -545,9 +559,10 @@ end class RequestException < StandardError ; end class InvalidRequestException < RequestException ; end + class MissingParametersException < RequestException ; end class ResponseParseException < RequestException attr_accessor :status, :body def initialize(options) @status = options[:status] @body = options[:body]