lib/createsend.rb in createsend-0.3.2 vs lib/createsend.rb in createsend-1.0.0

- old
+ new

@@ -55,9 +55,22 @@ # Provides high level CreateSend functionality/data you'll probably need. class CreateSend include HTTParty + class Parser::DealWithCreateSendInvalidJson < HTTParty::Parser + # The createsend API returns an ID as a string when a 201 Created + # response is returned. Unfortunately this is invalid json. + def parse + begin + super + rescue MultiJson::DecodeError => e + body[1..-2] # Strip surrounding quotes and return as is. + end + end + end + parser Parser::DealWithCreateSendInvalidJson + headers({ 'User-Agent' => "createsend-ruby-#{CreateSend::VERSION}", 'Content-Type' => 'application/json; charset=utf-8', 'Accept-Encoding' => 'gzip, deflate' }) base_uri CreateSendOptions['base_uri'] \ No newline at end of file