Class: NotionRubyMapping::NotionCache
- Inherits:
-
Object
- Object
- NotionRubyMapping::NotionCache
- Includes:
- Singleton
- Defined in:
- lib/notion_ruby_mapping/controllers/notion_cache.rb
Overview
singleton class of caching Notion objects
Instance Attribute Summary collapse
-
#client ⇒ Object
writeonly
for test only.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#notion_token ⇒ Object
Returns the value of attribute notion_token.
-
#object_hash ⇒ Object
readonly
Returns the value of attribute object_hash.
-
#use_cache ⇒ Object
Returns the value of attribute use_cache.
-
#wait ⇒ Object
Returns the value of attribute wait.
Instance Method Summary collapse
-
#append_block_children_block_path(block_id) ⇒ String (frozen)
Block_path.
-
#append_block_children_page_path(page_id) ⇒ String (frozen)
Page_path.
- #append_block_children_request(id, payload) ⇒ Hash
- #append_comment_request(json) ⇒ Object
-
#block(id) ⇒ NotionRubyMapping::Base
Block object or nil.
-
#block_children_page_path(page_id, query_string = "") ⇒ String (frozen)
Page_path.
- #block_children_request(id, query_string) ⇒ Hash
-
#block_path(block_id) ⇒ String (frozen)
Page_path.
-
#block_request(block_id) ⇒ Hash
Response.
- #clear_object_hash ⇒ Hash
- #comment_path(comment_id) ⇒ Object
- #comment_request(comment_id) ⇒ Object
- #comments_path ⇒ String (frozen)
- #complete_a_file_upload_path(file_id) ⇒ Object
- #complete_a_file_upload_request(file_id) ⇒ Object
-
#create_client(notion_token, wait: 0.3333, debug: false) ⇒ NotionRubyMapping::NotionCache
Self (NotionCache.instance).
-
#create_data_source_request(payload) ⇒ Hash
Response.
-
#create_database_request(payload) ⇒ Hash
Response.
-
#create_file_upload_request(payload = {}) ⇒ Hash
Response.
-
#create_page_request(payload) ⇒ Hash
Response.
-
#data_source(id) ⇒ NotionRubyMapping::Base
DataSource object or nil.
-
#data_source_path(data_source_id) ⇒ String (frozen)
Data_source_path.
- #data_source_query_request(data_source_id, query) ⇒ Object
-
#data_source_request(data_source_id) ⇒ Hash
Response.
-
#data_sources_path ⇒ String (frozen)
Page_path.
-
#database(id) ⇒ NotionRubyMapping::Base
Database object or nil.
-
#database_path(database_id) ⇒ String (frozen)
Database_path.
-
#database_request(database_id) ⇒ Hash
Response.
-
#databases_path ⇒ String (frozen)
Page_path.
- #destroy_block(id) ⇒ NotionRubyMapping::Base
- #destroy_block_request(id) ⇒ Hash
- #destroy_comment_request(id) ⇒ Hash
- #file_upload_path(file_id) ⇒ Object
- #file_upload_request(file_id) ⇒ Object
- #file_uploads_path ⇒ String
-
#hex_id(id) ⇒ String
Id without “-”.
-
#initialize ⇒ NotionCache
constructor
A new instance of NotionCache.
- #inspect ⇒ Object
-
#list_data_source_templates_path(data_source_id, options = "") ⇒ String
Path.
-
#list_data_source_templates_request(data_source_id, page_size: nil, start_cursor: nil) ⇒ Hash
Response hash.
-
#markdown_page_path(page_id) ⇒ String
Path.
-
#markdown_page_request(page_id, payload) ⇒ Hash
Response hash.
-
#move_page_path(page_id) ⇒ String
Move_page_path.
-
#move_page_request(page_id, payload) ⇒ Hash
Response hash.
- #multipart_client ⇒ Object
-
#multipart_request(path, fname, options = {}) ⇒ Hash
Response hash.
- #object_for_key(id) ⇒ NotionRubyMapping::Base
-
#page(id) ⇒ NotionRubyMapping::Base
Page object or nil.
-
#page_path(page_id) ⇒ String (frozen)
Page_path.
-
#page_property_path(page_id, property_id) ⇒ String (frozen)
Page_property_path.
-
#page_property_request(page_id, property_id, query = {}) ⇒ Hash
Response.
-
#page_request(page_id) ⇒ Hash
Response.
-
#pages_path ⇒ String (frozen)
Page_path.
-
#query_data_source_path(data_source_id) ⇒ String (frozen)
Page_path.
-
#request(method, path, options = {}) ⇒ Hash
Response hash.
- #retrieve_comments_path(block_id) ⇒ Object
- #retrieve_comments_request(block_id, query) ⇒ Object
- #search(query) ⇒ Object
- #search_path ⇒ Object
- #send_file_upload_path(id) ⇒ String
- #send_file_upload_request(fname, id, options = {}) ⇒ Hash
- #token=(token) ⇒ Object
- #update_block_request(block_id, payload) ⇒ Object
- #update_comment_request(comment_id, rich_text: nil, markdown: nil) ⇒ Object
-
#update_data_source_request(data_source_id, payload) ⇒ Hash
Response.
-
#update_database_request(database_id, payload) ⇒ Hash
Response.
-
#update_page_request(page_id, payload) ⇒ Hash
Response.
-
#user(id) ⇒ NotionRubyMapping::UserObject
UserObject object or nil.
-
#user_path(user_id) ⇒ String (frozen)
User_path.
-
#user_request(user_id) ⇒ Hash
Response.
-
#users ⇒ NotionRubyMapping::ListObject
List Object for UserObject.
-
#users_path(option = "") ⇒ String (frozen)
User_path.
-
#users_request(query = Query.new) ⇒ Hash
Response.
Constructor Details
#initialize ⇒ NotionCache
Returns a new instance of NotionCache.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 16 def initialize @object_hash = {} @client = Faraday.new "https://api.notion.com" do |conn| conn.request :json conn.response :json conn.headers["Notion-Version"] = NotionRubyMapping::NOTION_VERSION end @notion_token = nil @wait = 0.3333 @debug = false @use_cache = true end |
Instance Attribute Details
#client=(value) ⇒ Object (writeonly)
for test only
29 30 31 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 29 def client=(value) @client = value end |
#debug ⇒ Object
Returns the value of attribute debug.
30 31 32 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 30 def debug @debug end |
#notion_token ⇒ Object
Returns the value of attribute notion_token.
30 31 32 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 30 def notion_token @notion_token end |
#object_hash ⇒ Object (readonly)
Returns the value of attribute object_hash.
28 29 30 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 28 def object_hash @object_hash end |
#use_cache ⇒ Object
Returns the value of attribute use_cache.
30 31 32 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 30 def use_cache @use_cache end |
#wait ⇒ Object
Returns the value of attribute wait.
30 31 32 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 30 def wait @wait end |
Instance Method Details
#append_block_children_block_path(block_id) ⇒ String (frozen)
Returns block_path.
42 43 44 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 42 def append_block_children_block_path(block_id) "v1/blocks/#{block_id}/children" end |
#append_block_children_page_path(page_id) ⇒ String (frozen)
Returns page_path.
48 49 50 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 48 def append_block_children_page_path(page_id) "v1/blocks/#{page_id}/children" end |
#append_block_children_request(id, payload) ⇒ Hash
55 56 57 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 55 def append_block_children_request(id, payload) request :patch, append_block_children_block_path(id), payload end |
#append_comment_request(json) ⇒ Object
59 60 61 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 59 def append_comment_request(json) request :post, comments_path, json end |
#block(id) ⇒ NotionRubyMapping::Base
Returns Block object or nil.
65 66 67 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 65 def block(id) object_for_key(id) { block_request id } end |
#block_children_page_path(page_id, query_string = "") ⇒ String (frozen)
Returns page_path.
71 72 73 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 71 def block_children_page_path(page_id, query_string = "") "v1/blocks/#{page_id}/children#{query_string}" end |
#block_children_request(id, query_string) ⇒ Hash
78 79 80 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 78 def block_children_request(id, query_string) request :get, block_children_page_path(id, query_string) end |
#block_path(block_id) ⇒ String (frozen)
Returns page_path.
84 85 86 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 84 def block_path(block_id) "v1/blocks/#{block_id}" end |
#block_request(block_id) ⇒ Hash
Returns response.
90 91 92 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 90 def block_request(block_id) request :get, block_path(block_id) end |
#clear_object_hash ⇒ Hash
95 96 97 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 95 def clear_object_hash @object_hash = {} end |
#comment_path(comment_id) ⇒ Object
104 105 106 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 104 def comment_path(comment_id) "v1/comments/#{comment_id}" end |
#comment_request(comment_id) ⇒ Object
108 109 110 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 108 def comment_request(comment_id) request :get, comment_path(comment_id) end |
#comments_path ⇒ String (frozen)
100 101 102 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 100 def comments_path "v1/comments" end |
#complete_a_file_upload_path(file_id) ⇒ Object
112 113 114 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 112 def complete_a_file_upload_path(file_id) "v1/file_uploads/#{file_id}/complete" end |
#complete_a_file_upload_request(file_id) ⇒ Object
116 117 118 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 116 def complete_a_file_upload_request(file_id) request :post, complete_a_file_upload_path(file_id) end |
#create_client(notion_token, wait: 0.3333, debug: false) ⇒ NotionRubyMapping::NotionCache
Returns self (NotionCache.instance).
122 123 124 125 126 127 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 122 def create_client(notion_token, wait: 0.3333, debug: false) @notion_token = notion_token @wait = wait @debug = debug self end |
#create_data_source_request(payload) ⇒ Hash
Returns response.
137 138 139 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 137 def create_data_source_request(payload) request :post, data_sources_path, payload end |
#create_database_request(payload) ⇒ Hash
Returns response.
131 132 133 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 131 def create_database_request(payload) request :post, databases_path, payload end |
#create_file_upload_request(payload = {}) ⇒ Hash
Returns response.
143 144 145 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 143 def create_file_upload_request(payload = {}) request :post, file_uploads_path, payload end |
#create_page_request(payload) ⇒ Hash
Returns response.
149 150 151 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 149 def create_page_request(payload) request :post, "v1/pages", payload end |
#data_source(id) ⇒ NotionRubyMapping::Base
Returns DataSource object or nil.
161 162 163 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 161 def data_source(id) object_for_key(id) { data_source_request id } end |
#data_source_path(data_source_id) ⇒ String (frozen)
Returns data_source_path.
173 174 175 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 173 def data_source_path(data_source_id) "v1/data_sources/#{data_source_id}" end |
#data_source_query_request(data_source_id, query) ⇒ Object
186 187 188 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 186 def data_source_query_request(data_source_id, query) request :post, "v1/data_sources/#{data_source_id}/query#{query.database_query_string}", query.query_json end |
#data_source_request(data_source_id) ⇒ Hash
Returns response.
198 199 200 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 198 def data_source_request(data_source_id) request :get, data_source_path(data_source_id) end |
#data_sources_path ⇒ String (frozen)
Returns page_path.
208 209 210 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 208 def data_sources_path "v1/data_sources" end |
#database(id) ⇒ NotionRubyMapping::Base
Returns Database object or nil.
155 156 157 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 155 def database(id) object_for_key(id) { database_request id } end |
#database_path(database_id) ⇒ String (frozen)
Returns database_path.
167 168 169 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 167 def database_path(database_id) "v1/databases/#{database_id}" end |
#database_request(database_id) ⇒ Hash
Returns response.
192 193 194 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 192 def database_request(database_id) request :get, database_path(database_id) end |
#databases_path ⇒ String (frozen)
Returns page_path.
203 204 205 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 203 def databases_path "v1/databases" end |
#destroy_block(id) ⇒ NotionRubyMapping::Base
214 215 216 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 214 def destroy_block(id) Base.create_from_json destroy_block_request(id) end |
#destroy_block_request(id) ⇒ Hash
220 221 222 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 220 def destroy_block_request(id) request :delete, block_path(id) end |
#destroy_comment_request(id) ⇒ Hash
226 227 228 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 226 def destroy_comment_request(id) request :delete, comment_path(id) end |
#file_upload_path(file_id) ⇒ Object
398 399 400 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 398 def file_upload_path(file_id) "v1/file_uploads/#{file_id}" end |
#file_upload_request(file_id) ⇒ Object
394 395 396 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 394 def file_upload_request(file_id) request :get, file_upload_path(file_id) end |
#file_uploads_path ⇒ String
245 246 247 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 245 def file_uploads_path "v1/file_uploads" end |
#hex_id(id) ⇒ String
Returns id without “-”.
252 253 254 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 252 def hex_id(id) id&.gsub "-", "" end |
#inspect ⇒ Object
256 257 258 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 256 def inspect "NotionCache" end |
#list_data_source_templates_path(data_source_id, options = "") ⇒ String
Returns path.
275 276 277 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 275 def list_data_source_templates_path(data_source_id, = "") "v1/data_sources/#{data_source_id}/templates#{}" end |
#list_data_source_templates_request(data_source_id, page_size: nil, start_cursor: nil) ⇒ Hash
Returns response hash.
264 265 266 267 268 269 270 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 264 def list_data_source_templates_request(data_source_id, page_size: nil, start_cursor: nil) = [] << "page_size=#{page_size}" if page_size << "start_cursor=#{start_cursor}" if start_cursor option_str = .empty? ? "" : "?" + .join("&") request :get, list_data_source_templates_path(data_source_id, option_str) end |
#markdown_page_path(page_id) ⇒ String
Returns path.
281 282 283 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 281 def markdown_page_path(page_id) "v1/pages/#{page_id}/markdown" end |
#markdown_page_request(page_id, payload) ⇒ Hash
Returns response hash.
288 289 290 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 288 def markdown_page_request(page_id, payload) request :patch, markdown_page_path(page_id), payload end |
#move_page_path(page_id) ⇒ String
Returns move_page_path.
301 302 303 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 301 def move_page_path(page_id) "v1/pages/#{page_id}/move" end |
#move_page_request(page_id, payload) ⇒ Hash
Returns response hash.
295 296 297 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 295 def move_page_request(page_id, payload) request :post, move_page_path(page_id), payload end |
#multipart_client ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 32 def multipart_client @multipart_client ||= Faraday.new "https://api.notion.com" do |conn| conn.request :multipart, flat_encode: true conn.response :json conn.headers["Notion-Version"] = NotionRubyMapping::NOTION_VERSION end end |
#multipart_request(path, fname, options = {}) ⇒ Hash
Returns response hash.
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 309 def multipart_request(path, fname, = {}) raise "Please call `NotionRubyMapping.configure' before using other methods" unless @notion_token content_type = MIME::Types.type_for(fname).first.to_s sleep @wait body = .map { |k, v| [k, Faraday::Multipart::ParamPart.new(v, "text/plain")] }.to_h file_part = Faraday::Multipart::FilePart.new(fname, content_type, File.basename(fname)) response = multipart_client.send(:post) do |request| request.headers["Authorization"] = "Bearer #{@notion_token}" request.headers["content-Type"] = "multipart/form-data" request.path = path request.body = {file: file_part}.merge body end p response.body if @debug response.body end |
#object_for_key(id) ⇒ NotionRubyMapping::Base
329 330 331 332 333 334 335 336 337 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 329 def object_for_key(id) key = hex_id(id) return @object_hash[key] if @use_cache && @object_hash.key?(key) json = yield(@client) ans = Base.create_from_json json @object_hash[key] = ans if @use_cache ans end |
#page(id) ⇒ NotionRubyMapping::Base
Returns Page object or nil.
341 342 343 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 341 def page(id) object_for_key(id) { page_request id } end |
#page_path(page_id) ⇒ String (frozen)
Returns page_path.
347 348 349 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 347 def page_path(page_id) "v1/pages/#{page_id}" end |
#page_property_path(page_id, property_id) ⇒ String (frozen)
Returns page_property_path.
354 355 356 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 354 def page_property_path(page_id, property_id) [page_path(page_id), "properties/#{property_id}"].join "/" end |
#page_property_request(page_id, property_id, query = {}) ⇒ Hash
Returns response.
361 362 363 364 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 361 def page_property_request(page_id, property_id, query = {}) p "page_id = #{page_id}, property_id = #{property_id}, query = #{query}" if @debug request :get, page_property_path(page_id, property_id), query end |
#page_request(page_id) ⇒ Hash
Returns response.
368 369 370 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 368 def page_request(page_id) request :get, page_path(page_id) end |
#pages_path ⇒ String (frozen)
Returns page_path.
373 374 375 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 373 def pages_path "v1/pages" end |
#query_data_source_path(data_source_id) ⇒ String (frozen)
Returns page_path.
379 380 381 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 379 def query_data_source_path(data_source_id) "v1/data_sources/#{data_source_id}/query" end |
#request(method, path, options = {}) ⇒ Hash
Returns response hash.
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 406 def request(method, path, = {}) raise "Please call `NotionRubyMapping.configure' before using other methods" unless @notion_token sleep @wait response = @client.send(method) do |request| request.headers["Authorization"] = "Bearer #{@notion_token}" case method when :get, :delete request.url path, when :post, :put, :patch request.headers["Content-Type"] = "application/json" request.path = path request.body = .to_json unless .empty? else raise StandardError, "Unknown method: #{method}" end request..merge!(.delete(:request)) if .key? :request end p response.body if @debug response.body end |
#retrieve_comments_path(block_id) ⇒ Object
384 385 386 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 384 def retrieve_comments_path(block_id) "v1/comments?block_id=#{block_id}" end |
#retrieve_comments_request(block_id, query) ⇒ Object
390 391 392 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 390 def retrieve_comments_request(block_id, query) request :get, retrieve_comments_path(block_id), (query&.query_json || {}) end |
#search(query) ⇒ Object
428 429 430 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 428 def search(query) request(:post, search_path, query) end |
#search_path ⇒ Object
432 433 434 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 432 def search_path "v1/search" end |
#send_file_upload_path(id) ⇒ String
240 241 242 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 240 def send_file_upload_path(id) "v1/file_uploads/#{id}/send" end |
#send_file_upload_request(fname, id, options = {}) ⇒ Hash
234 235 236 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 234 def send_file_upload_request(fname, id, = {}) multipart_request(send_file_upload_path(id), fname, ) end |
#token=(token) ⇒ Object
437 438 439 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 437 def token=(token) @notion_token = token end |
#update_block_request(block_id, payload) ⇒ Object
441 442 443 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 441 def update_block_request(block_id, payload) request :patch, block_path(block_id), payload end |
#update_comment_request(comment_id, rich_text: nil, markdown: nil) ⇒ Object
445 446 447 448 449 450 451 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 445 def update_comment_request(comment_id, rich_text: nil, markdown: nil) if rich_text request :patch, comment_path(comment_id), {"rich_text" => rich_text} else request :patch, comment_path(comment_id), {"markdown" => markdown} end end |
#update_data_source_request(data_source_id, payload) ⇒ Hash
Returns response.
468 469 470 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 468 def update_data_source_request(data_source_id, payload) request :patch, data_source_path(data_source_id), payload end |
#update_database_request(database_id, payload) ⇒ Hash
Returns response.
462 463 464 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 462 def update_database_request(database_id, payload) request :patch, database_path(database_id), payload end |
#update_page_request(page_id, payload) ⇒ Hash
Returns response.
475 476 477 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 475 def update_page_request(page_id, payload) request :patch, page_path(page_id), payload end |
#user(id) ⇒ NotionRubyMapping::UserObject
Returns UserObject object or nil.
481 482 483 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 481 def user(id) UserObject.new json: user_request(id) end |
#user_path(user_id) ⇒ String (frozen)
Returns user_path.
487 488 489 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 487 def user_path(user_id) "v1/users/#{user_id}" end |
#user_request(user_id) ⇒ Hash
Returns response.
493 494 495 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 493 def user_request(user_id) request :get, user_path(user_id) end |
#users ⇒ NotionRubyMapping::ListObject
Returns List Object for UserObject.
498 499 500 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 498 def users List.new json: users_request, type: "user_object", value: true end |
#users_path(option = "") ⇒ String (frozen)
Returns user_path.
503 504 505 |
# File 'lib/notion_ruby_mapping/controllers/notion_cache.rb', line 503 def users_path(option = "") "v1/users#{option}" end |