Sha256: ce05f0150f5ae87fbe2e21efe667e743ed580d9c5428fc629fbd42d9bb4a2714

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

module Strava
  module Api
    class Client < Strava::Web::Client
      include Endpoints::Activities
      include Endpoints::Athletes
      include Endpoints::Clubs
      include Endpoints::Gears
      include Endpoints::Routes
      include Endpoints::RunningRaces
      include Endpoints::SegmentEfforts
      include Endpoints::Segments
      include Endpoints::Streams
      include Endpoints::Uploads
      include Endpoints::OAuth

      attr_accessor(*Config::ATTRIBUTES)

      def initialize(options = {})
        Config::ATTRIBUTES.each do |key|
          send("#{key}=", options[key] || Strava::Api.config.send(key))
        end
        super
      end

      def headers
        { 'Authorization' => "Bearer #{access_token}" }
      end

      class << self
        def configure
          block_given? ? yield(Config) : Config
        end

        def config
          Config
        end
      end

      private

      def paginate(path, options, model)
        if block_given?
          Cursor.new(self, path, options).each do |page|
            page.each do |row|
              yield model.new(row)
            end
          end
        else
          get(path, options).map do |row|
            model.new(row)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
strava-ruby-client-0.4.2 lib/strava/api/client.rb
strava-ruby-client-0.4.1 lib/strava/api/client.rb
strava-ruby-client-0.4.0 lib/strava/api/client.rb
strava-ruby-client-0.3.2 lib/strava/api/client.rb
strava-ruby-client-0.3.1 lib/strava/api/client.rb