Sha256: 37534d18dec8f80264f405532a613a3a8c43aa06afd8038f3734c1ec8a806305

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

module Chronicle
  module Foursquare
    class CheckinExtractor < Chronicle::ETL::Extractor
      register_connector do |r|
        r.source = :foursquare
        r.type = :checkin
        r.strategy = :api
        r.description = 'foursquare checkin'
      end

      setting :access_token, required: true

      def prepare
        raise(Chronicle::ETL::ExtractionError, 'Access token is missing') if @config.access_token.empty?

        @proxy = Chronicle::Foursquare::Proxy.new(access_token: @config.access_token)
        @actor = load_actor
        @checkins = load_checkins
      end

      def results_count
        @checkins.count
      end

      def extract
        @checkins.each do |checkin|
          yield build_extraction(data: checkin, meta: { actor: @actor })
        end
      end

      private

      def load_checkins
        @proxy.load_checkins(limit: @config.limit, since: @config.since)
      end

      def load_actor
        @proxy.load_self
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronicle-foursquare-0.2.0 lib/chronicle/foursquare/checkin_extractor.rb