Sha256: a3be382fb6aef0b4345058797e02a60d7907867fee03d2dc05bf5b9e2697e791

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 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

3 entries across 3 versions & 1 rubygems

Version Path
researchable-freedcamp-api-0.1.8 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.7 lib/researchable/freedcamp_api/endpoint.rb
researchable-freedcamp-api-0.1.6 lib/researchable/freedcamp_api/endpoint.rb