Sha256: 7840ec772bc3e359f804173d574ff4074b0859854b6319ee4fb90b98826d6ac4

Contents?: true

Size: 987 Bytes

Versions: 6

Compression:

Stored size: 987 Bytes

Contents

# typed: strict
#
module Researchable
  module FreedcampApi
    # TODO: Does this work?
    class Endpoint < ActiveInteraction::Base
      # class Endpoint < T::Types::Base
      extend T::Sig
      object :session,
             default: -> { FreedcampApi.signed_session },
             class: Researchable::FreedcampApi::Sessions::Session

      private

      # Fetch all browses paginated responses
      # @param keyword [[TODO:type]] [TODO:description]
      sig { params(keyword: String).returns(T::Array[T.untyped]) }
      def fetch_all(keyword)
        result = T.let([], T::Array[T.untyped])
        has_more = T.let(true, T::Boolean)
        offset = T.let(0, Integer)
        limit = T.let(200, Integer)

        while has_more
          temp = yield limit, offset
          has_more = T.let(temp.dig('data', 'meta', 'has_more') == 'true', T::Boolean)
          result += temp['data'][keyword]
          offset += limit
        end
        result
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
researchable-freedcamp-api-0.1.5 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.4 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.3 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.2 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.1 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.0 lib/researchable/freedcamp_api/endpoint.rb