Class: Parser::DealWithCreateSendInvalidJson

Inherits:
HTTParty::Parser
  • Object
show all
Defined in:
lib/createsend/createsend.rb

Overview

Deals with an unfortunate situation where responses aren’t valid json.

Instance Method Summary collapse

Instance Method Details

#parseObject

The createsend API returns an ID as a string when a 201 Created response is returned. Unfortunately this is invalid json.



80
81
82
83
84
85
86
# File 'lib/createsend/createsend.rb', line 80

def parse
  begin
    super
  rescue MultiJson::DecodeError => e
    body[1..-2] # Strip surrounding quotes and return as is.
  end
end