Class: Airtable::Base
Overview
Object corresponding to an Airtable Base
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#base_url ⇒ Object
protected
Instantiate table in base.
-
#create_table(table_data) ⇒ Airtable::Table
Expects name:,description:,fields:[].
-
#initialize(token, id) ⇒ Base
constructor
A new instance of Base.
-
#table(table_id) ⇒ Airtable::Table
Instantiate table in base.
-
#tables ⇒ Array
<Airtable::Table>.
Methods inherited from Resource
Constructor Details
#initialize(token, id) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 |
# File 'lib/airtable/base.rb', line 5 def initialize(token, id) @token = token @id = id self.class.headers({ 'Authorization': "Bearer #{@token}", 'Content-Type': 'application/json' }) end |
Instance Method Details
#base_url ⇒ Object (protected)
Instantiate table in base
42 |
# File 'lib/airtable/base.rb', line 42 def base_url = "/v0/meta/bases/#{@id}" |
#create_table(table_data) ⇒ Airtable::Table
Expects name:,description:,fields:[]
14 15 16 17 18 19 20 21 |
# File 'lib/airtable/base.rb', line 14 def create_table(table_data) response = self.class.post("#{base_url}/tables", body: table_data.to_json).parsed_response check_and_raise_error(response) Airtable::Table.new @token, @id, response end |
#table(table_id) ⇒ Airtable::Table
Instantiate table in base
35 36 37 |
# File 'lib/airtable/base.rb', line 35 def table(table_id) Airtable::Table.new(@token, @id, table_id) end |