Sha256: 0edf5f443a021a0fef8c6a6403184d1ada44180dcfc9e3ff73693f05f0e142e1

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module WhosGotDirt
  module Responses
    module List
      # Converts corporate groupings from the OpenCorporates API to Popolo format.
      #
      # @see https://api.opencorporates.com/documentation/API-Reference
      class OpenCorporates < Helpers::OpenCorporatesHelper
        @template = {
          '@type' => 'List',
          'name' => '/name',
          'created_at' => '/created_at',
          'updated_at' => '/updated_at',
          'identifiers' => [{
            'identifier' => '/wikipedia_id',
            'scheme' => 'Wikipedia',
          }],
          'links' => [{
            'url' => '/opencorporates_url',
            'note' => 'OpenCorporates page',
          }],
        }

        # Transforms the parsed response body into results.
        #
        # @return [Array<Hash>] the results
        def to_a
          parsed_body['corporate_groupings'].map do |data|
            Result.new('List', renderer.result(data['corporate_grouping']), self).finalize!
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whos_got_dirt-0.0.2 lib/whos_got_dirt/responses/list/open_corporates.rb