lib/rdstation/error/formatter.rb in rdstation-ruby-client-2.3.1 vs lib/rdstation/error/formatter.rb in rdstation-ruby-client-2.4.0

- old
+ new

@@ -11,10 +11,12 @@ def to_array return @error_response unless @error_response.is_a?(Hash) case error_format.format + when RDStation::Error::Format::SINGLE_HASH + return from_single_hash when RDStation::Error::Format::FLAT_HASH return from_flat_hash when RDStation::Error::Format::HASH_OF_ARRAYS return from_hash_of_arrays when RDStation::Error::Format::HASH_OF_HASHES @@ -24,10 +26,23 @@ end errors end + def from_single_hash + error_hash = @error_response.dup + error_message = error_hash.delete('error') + + [ + { + 'error_type' => 'TOO_MANY_REQUESTS', + 'error_message' => error_message, + 'details' => error_hash + } + ] + end + def from_flat_hash [errors] end def from_hash_of_multiple_types @@ -58,10 +73,10 @@ def error_format @error_format ||= RDStation::Error::Format.new(errors) end def errors - @errors ||= @error_response['errors'] + @errors ||= @error_response.fetch('errors', @error_response) end private def build_error_from_array(attribute_name, attribute_errors)