lib/you_track/client/real.rb in you_track-0.3.0 vs lib/you_track/client/real.rb in you_track-0.4.0
- old
+ new
@@ -46,11 +46,11 @@
required_param if options[required_param].nil?
end.compact
raise RuntimeError, "Missing required options: #{missing.inspect}" unless missing.empty?
end
- def request(options={})
+ def authenticate!
# @note first request gets the cookie
if !@authenticated && !@authenticating
@authenticate_mutex.synchronize {
next if @authenticated
@@ -63,9 +63,13 @@
end
@authenticated = true
}
end
+ end
+
+ def request(options={})
+ authenticate!
method = options[:method] || :get
query = options[:query]
url = URI.parse(options[:url] || File.join(self.url.to_s, "/rest", options.fetch(:path)))
url.query = query.map { |k,v| "#{URI.escape(k)}=#{URI.escape(v.to_s)}" }.join('&') if query