Class: Airtable::Resource
- Inherits:
-
Object
- Object
- Airtable::Resource
- Includes:
- HTTParty
- Defined in:
- lib/airtable/resource.rb
Overview
Base class for authorized resources sending network requests
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
debug_output $stdout.
-
#token ⇒ Object
readonly
debug_output $stdout.
Instance Method Summary collapse
-
#check_and_raise_error(response) ⇒ Object
If API response is an error, raises an Airtable::Error with the error message.
-
#initialize(token) ⇒ Resource
constructor
A new instance of Resource.
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
#id ⇒ Object (readonly)
debug_output $stdout
9 10 11 |
# File 'lib/airtable/resource.rb', line 9 def id @id end |
#token ⇒ Object (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 |