Sha256: 5c269be2d27d51c7cd6314085555a2518c781b19856a18a5eb3247c5133868ea

Contents?: true

Size: 632 Bytes

Versions: 8

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true

require "json"

module ActiveCampaign
  class ResponseParser < Faraday::Response::Middleware # :nodoc:
    def on_complete(env)
      parsed_data   = JSON.parse(env[:body], symbolize_names: true)
      metadata      = parsed_data.delete(:meta) || []
      errors        = parsed_data.delete(:errors) || {}
      score_values  = parsed_data.delete(:scoreValues) || {}
      status_code   = env[:status]

      env[:parsed_data] = {
        status_code: status_code,
        data: parsed_data,
        errors: errors,
        meta: metadata,
        score_values: score_values
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ractive_campaign-0.1.6 lib/active_campaign/parser.rb
ractive_campaign-0.1.5 lib/active_campaign/parser.rb
ractive_campaign-0.1.4 lib/active_campaign/parser.rb
ractive_campaign-0.1.3 lib/active_campaign/parser.rb
ractive_campaign-0.1.2 lib/active_campaign/parser.rb
ractive_campaign-0.1.1 lib/active_campaign/parser.rb
ractive_campaign-0.1.0 lib/active_campaign/parser.rb
ractive_campaign-0.0.1 lib/active_campaign/parser.rb