Class: Parser::DealWithCreateSendInvalidJson

Inherits:
HTTParty::Parser
  • Object
show all
Defined in:
lib/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.



64
65
66
67
68
69
70
# File 'lib/createsend.rb', line 64

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