lib/popit.rb in popit-0.0.3 vs lib/popit.rb in popit-0.0.4
- old
+ new
@@ -1,5 +1,7 @@
+require 'json'
+
require 'httparty'
# A Ruby wrapper for the PopIt API.
#
# Instead of writing the path to an API endpoint, you can use method chaining.
@@ -104,10 +106,10 @@
when :get
self.class.send http_method, path, :query => opts
when :delete
self.class.send http_method, path, :basic_auth => {:username => username, :password => password}, :query => opts
when :post, :put
- self.class.send http_method, path, :basic_auth => {:username => username, :password => password}, :body => opts
+ self.class.send http_method, path, :basic_auth => {:username => username, :password => password}, :body => JSON.dump(opts), :headers => {'Content-Type' => 'application/json', 'Accept' => 'application/json'}
end
unless ['200', '201', '204'].include?(response.response.code)
if response.response.content_type == 'text/html'
message = response.response.code