class Jekyll::Airtable::API

Public Class Methods

new(options={}) click to toggle source

Creates a new API

# File lib/jekyll-airtable/api.rb, line 9
def initialize(options={})
  options = Airtable.options.merge(options)

  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end

Public Instance Methods

config() click to toggle source
# File lib/jekyll-airtable/api.rb, line 17
def config
  conf = {}

  Configuration::VALID_OPTIONS_KEYS.each do |key|
    conf[key] = send key
  end

  conf
end
processing_query_params(request_obj, params, params_key) click to toggle source
# File lib/jekyll-airtable/api.rb, line 31
def processing_query_params(request_obj, params, params_key)
  keys = [
    :fields,
    :filter_by_formula,
    :max_records,
    :page_size,
    :sort,
    :view,
    :cell_format,
    :time_zone,
    :user_locale,
    :offset
  ]

  return nil unless keys.include?(params_key) || 
                    params[params_key].nil? || 
                    params[params_key] == ''

  key_string = params_key.to_s.split('_').each_with_index.map do |a, i| 
    if i == 0 then a else a.capitalize end 
  end.join

  request_obj.params[key_string] = params[params_key]
end
versioned_base_endpoint_url() click to toggle source
# File lib/jekyll-airtable/api.rb, line 27
def versioned_base_endpoint_url
  config[:endpoint] + config[:api_version] + '/' + config[:base_uid] + '/'
end