lib/lelylan/connection.rb in lelylan-rb-0.0.2 vs lib/lelylan/connection.rb in lelylan-rb-0.0.3
- old
+ new
@@ -4,11 +4,11 @@
module Lelylan
module Connection
private
- def connection(authenticate=true, raw=false, version=0, force_urlencoded=false, path='')
+ def connection(authenticate=true, raw=false, version=0, force_urlencoded=false, path='', method)
options = {
:headers => {'Accept' => 'application/json', 'User-Agent' => user_agent, 'Content-Type' => 'application/json'},
:proxy => proxy,
:ssl => { :verify => false },
@@ -23,9 +23,11 @@
if path =~ /subscriptions/
raise Lelylan::Error, 'To make a request to the realtime services you need both client id and client secret' if (!client_id or !client_secret) and path =~ /subscriptions/
basic = Base64.encode64("#{self.client_id}:#{self.client_secret}")
options[:headers].merge!('Authorization' => "Bearer #{basic}")
end
+
+ options[:headers].merge!('Content-Length' => '0') if method == :delete
connection = Faraday.new(options) do |builder|
builder.request :json
builder.use Faraday::Response::RaiseHttpError
builder.use FaradayMiddleware::Mashify