Class: Nocion::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/nocion.rb

Defined Under Namespace

Classes: Page

Instance Method Summary collapse

Constructor Details

#initialize(key: Config.key, id: nil) ⇒ Database

Returns a new instance of Database.



12
13
14
15
# File 'lib/nocion.rb', line 12

def initialize(key: Config.key, id: nil)
  @id = id
  @header = {content_type: :json, accept: :json, authorization: key, notion_version: '2021-08-16'}
end

Instance Method Details

#queryObject



21
22
23
24
25
26
27
28
# File 'lib/nocion.rb', line 21

def query
  return @pages if @pages
  @pages = []
  @start_cursor = nil
  @has_more = true
  _query while @has_more
  @pages
end

#retrieveObject



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

def retrieve
  resp = RestClient.get("https://api.notion.com/v1/databases/#{@id}", @header)
end