Sha256: b4751d29f0eed1e654b288371d02d8a620782fa408945b30ee852fdd1b66d6bc

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',
          'identifiers' => [{
            'identifier' => '/wikipedia_id',
            'scheme' => 'Wikipedia',
          }],
          'links' => [{
            'url' => '/opencorporates_url',
            'note' => 'OpenCorporates page',
          }],
          'created_at' => '/created_at',
          'updated_at' => '/updated_at',
        }

        # 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.3 lib/whos_got_dirt/responses/list/open_corporates.rb