Class: Jekyll::Airtable::API

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-airtable/api.rb

Direct Known Subclasses

Client

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Creates a new API



9
10
11
12
13
14
15
# 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

Instance Method Details

#configObject



17
18
19
20
21
22
23
24
25
# 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) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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_urlObject



27
28
29
# File 'lib/jekyll-airtable/api.rb', line 27

def versioned_base_endpoint_url
  config[:endpoint] + config[:api_version] + '/' + config[:base_uid] + '/'
end