Class: Airtable::Resource

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/airtable/resource.rb

Overview

Base class for authorized resources sending network requests

Direct Known Subclasses

Base, Client, Field, Record, Table, Workspace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Resource

Returns a new instance of Resource.



11
12
13
14
# File 'lib/airtable/resource.rb', line 11

def initialize(token)
  @token = token
  self.class.headers({ 'Authorization': "Bearer #{@token}", 'Content-Type': 'application/json' })
end

Instance Attribute Details

#idObject (readonly)

debug_output $stdout



9
10
11
# File 'lib/airtable/resource.rb', line 9

def id
  @id
end

#tokenObject (readonly)

debug_output $stdout



9
10
11
# File 'lib/airtable/resource.rb', line 9

def token
  @token
end

Instance Method Details

#check_and_raise_error(response) ⇒ Object

If API response is an error, raises an Airtable::Error with the error message



17
18
19
# File 'lib/airtable/resource.rb', line 17

def check_and_raise_error(response)
  response['error'] ? raise(Error, response['error']) : false
end