Class: NotionRubyMapping::Search
- Inherits:
-
Object
- Object
- NotionRubyMapping::Search
- Defined in:
- lib/notion_ruby_mapping/controllers/search.rb
Instance Method Summary collapse
- #exec(dry_run: false) ⇒ Object
-
#initialize(ascending: false, database_only: false, page_only: false, query: nil) ⇒ Search
constructor
A new instance of Search.
- #payload ⇒ Object
Constructor Details
#initialize(ascending: false, database_only: false, page_only: false, query: nil) ⇒ Search
Returns a new instance of Search.
4 5 6 7 8 9 |
# File 'lib/notion_ruby_mapping/controllers/search.rb', line 4 def initialize(ascending: false, database_only: false, page_only: false, query: nil) @ascending = ascending @database_only = database_only @page_only = page_only @query = query end |
Instance Method Details
#exec(dry_run: false) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/notion_ruby_mapping/controllers/search.rb', line 11 def exec(dry_run: false) if dry_run Base.dry_run_script :post, NotionCache.instance.search_path, payload else response = NotionCache.instance.search payload List.new json: response, type: :search, value: self, query: Query.new end end |
#payload ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/notion_ruby_mapping/controllers/search.rb', line 20 def payload ans = {} ans["sort"] = {"direction" => "ascending", "timestamp" => "last_edited_time"} if @ascending ans["filter"] = {"value" => "database", "property" => "object" } if @database_only ans["filter"] = {"value" => "page", "property" => "object" } if @page_only ans["query"] = @query if @query ans end |