Module: Utils

Included in:
NotionAPI::BlockTemplate, NotionAPI::Core
Defined in:
lib/notion_api/utils.rb

Defined Under Namespace

Classes: BlockComponents, CollectionViewComponents

Constant Summary collapse

URLS =

! defines utility functions and static variables for this application.

{
  GET_BLOCK: 'https://www.notion.so/api/v3/loadPageChunk',
  UPDATE_BLOCK: 'https://www.notion.so/api/v3/saveTransactions',
  GET_COLLECTION: 'https://www.notion.so/api/v3/queryCollection'
}.freeze

Instance Method Summary collapse

Instance Method Details

#build_payload(operations, request_ids) ⇒ Object



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/notion_api/utils.rb', line 498

def build_payload(operations, request_ids)
  # ! properly formats the payload for Notions backend.
  # ! operations -> an array of hashes that define the operations to perform : ``Array[Hash]``
  # ! request_ids -> the unique IDs for the request : ``str``
  request_id = request_ids[:request_id]
  transaction_id = request_ids[:transaction_id]
  space_id = request_ids[:space_id]
  payload = {
    requestId: request_id,
    transactions: [
      {
        id: transaction_id,
        shardId: 955_090,
        spaceId: space_id,
        operations: operations
      }
    ]
  }
  payload
end