Sha256: a428c9cb4d033710a79249480d3b0413585a2c44bc86984d21dcee96088495e8

Contents?: true

Size: 471 Bytes

Versions: 1

Compression:

Stored size: 471 Bytes

Contents

require 'json'
module Cogitate
  module Client
    module ResponseParsers
      # Responsible for parsing a Cogitate response with a focus on getting emails
      module EmailExtractor
        def self.call(response:)
          data = JSON.parse(response).fetch('data')
          data.each_with_object({}) do |datum, mem|
            mem[datum.fetch('id')] = datum.fetch('attributes').fetch('emails')
            mem
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cogitate-0.0.2 lib/cogitate/client/response_parsers/email_extractor.rb