Class: Airtable::Client
Overview
Client carrying authorization token
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#base(base_id) ⇒ Airtable::Base
Instantiate base.
-
#bases ⇒ Array
<Airtable::Base>.
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #whoami ⇒ Hash
Methods inherited from Resource
Constructor Details
#initialize(token) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/airtable/client.rb', line 5 def initialize(token) @token = token self.class.headers({ 'Authorization': "Bearer #{@token}", 'Content-Type': 'application/json' }) end |
Instance Method Details
#base(base_id) ⇒ Airtable::Base
Instantiate base
30 31 32 |
# File 'lib/airtable/client.rb', line 30 def base(base_id) Airtable::Base.new(@token, base_id) end |
#bases ⇒ Array
Returns <Airtable::Base>.
12 13 14 15 16 17 18 |
# File 'lib/airtable/client.rb', line 12 def bases response = self.class.get('/v0/meta/bases').parsed_response check_and_raise_error(response) response['bases'].map { Airtable::Base.new(@token, _1['id']) } end |
#whoami ⇒ Hash
36 37 38 39 40 41 42 |
# File 'lib/airtable/client.rb', line 36 def whoami response = self.class.get('/v0/meta/whoami').parsed_response check_and_raise_error(response) response end |