Class: Airtable::Client

Inherits:
Resource show all
Defined in:
lib/airtable/client.rb

Overview

Client carrying authorization token

Instance Attribute Summary

Attributes inherited from Resource

#id, #token

Instance Method Summary collapse

Methods inherited from Resource

#check_and_raise_error

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

Returns:



30
31
32
# File 'lib/airtable/client.rb', line 30

def base(base_id)
  Airtable::Base.new(@token, base_id)
end

#basesArray

Returns <Airtable::Base>.

Returns:

  • (Array)

    <Airtable::Base>

See Also:



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

#whoamiHash



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