GrafoscopioUtils/repository/Grafoscopio-Utils/Airtable.class.st

51 lines
904 B
Smalltalk

Class {
#name : #Airtable,
#superclass : #Object,
#instVars : [
'id',
'apiKey'
],
#category : #'Grafoscopio-Utils-Grafoscopio-Utils'
}
{ #category : #accessing }
Airtable >> apiKey [
^ apiKey
]
{ #category : #accessing }
Airtable >> apiKey: anString [
apiKey := anString
]
{ #category : #accessing }
Airtable >> id [
^ id
]
{ #category : #accessing }
Airtable >> id: idString [
id := idString
]
{ #category : #accessing }
Airtable >> rawRecords [
^ ZnClient new
url: (self id);
headerAt: 'Authorization' put: 'Bearer ', (self apiKey);
get.
]
{ #category : #accessing }
Airtable >> records [
| recordsTemp |
recordsTemp := (NeoJSONReader fromString: self rawRecords contents) at: 'records'.
^ recordsTemp collect: [ :recordsDict |
AirtableRecord new
id: (recordsDict at: 'id');
createdTime: (recordsDict at: 'createdTime');
fields: (recordsDict at: 'fields')
]
]