Module: Utils::Notion::Request
- Defined in:
- lib/bas/utils/notion/request.rb
Overview
This module is a Notion utility for sending request to create, update, or delete Notion resources.
Constant Summary collapse
- NOTION_BASE_URL =
"https://api.notion.com/v1"
Class Method Summary collapse
-
.execute(params) ⇒ Object
Implements the request process logic to Notion.
-
.notion_headers(secret) ⇒ Object
Request headers.
Class Method Details
.execute(params) ⇒ Object
Implements the request process logic to Notion.
Params:
-
method
HTTP request method: post, get, put, etc. -
body
Request body (Hash). -
endpoint
Notion resource endpoint. -
secret
Notion secret.
returns HTTParty::Response
27 28 29 30 31 32 33 |
# File 'lib/bas/utils/notion/request.rb', line 27 def self.execute(params) url = "#{NOTION_BASE_URL}/#{params[:endpoint]}" headers = notion_headers(params[:secret]) HTTParty.send(params[:method], url, { body: params[:body].to_json, headers: }) end |
.notion_headers(secret) ⇒ Object
Request headers
37 38 39 40 41 42 43 |
# File 'lib/bas/utils/notion/request.rb', line 37 def self.notion_headers(secret) { "Authorization" => "Bearer #{secret}", "Content-Type" => "application/json", "Notion-Version" => "2022-06-28" } end |