Class: Jekyll::Airtable::Client
- Defined in:
- lib/jekyll-airtable/client.rb
Instance Method Summary collapse
Methods inherited from API
#config, #initialize, #processing_query_params, #versioned_base_endpoint_url
Constructor Details
This class inherits a constructor from Jekyll::Airtable::API
Instance Method Details
#list_records(table_name:, params: {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jekyll-airtable/client.rb', line 9 def list_records(table_name:, params: {}) @connection = Faraday.new(url: versioned_base_endpoint_url) do |faraday| faraday.response :logger # log requests to STDOUT faraday.request :url_encoded faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end @connection.(:Bearer, Airtable.api_key) records = [] offset = nil counter = 1 begin looper = "request no. #{counter}" puts 'Sending ' + looper params[:offset] = offset if !offset.nil? data = send_get_request(table_name, params) puts "Response received for the " + looper records << data['records'] offset = data['offset'] # Pause for 1 second, just to be safe sleep 1 counter += 1 end while !offset.nil? records.flatten end |