lib/nds_api.rb in nds_api-0.1.5 vs lib/nds_api.rb in nds_api-0.1.6

- old
+ new

@@ -9,10 +9,11 @@ # Create a new client instance # # @param [Hash] options # @option options [String] :user NDS User # @option options [String] :password NDS Password + # @option options [String] :agency_key NDS Agency Key # # @return [NdsApi::Client] new client instance def initialize(options = {}) @options = options.dup @@ -29,18 +30,30 @@ private def http_action(method, *args, &block) if @method.is_create? or @method.is_search? - @http.post(@url.send(@method.action), data) + @http.post(url, data) elsif @method.is_update? - @http.put(@url.send(@method.action), data) + @http.put(url, data) else @http.get(@url.send(method, *args)) end end def data @args.include?(:data) ? @args[:data] : @args.first + end + + def url + if @method.is_search? and query_params + @url.send(@method.action, query_params) + else + @url.send(@method.action) + end + end + + def query_params + @args.count > 1 ? @args[1] : nil end end end