Class: NotionRb::RequestParams

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRequestParams

Returns a new instance of RequestParams.



7
8
9
10
# File 'lib/notion_rb/request_params.rb', line 7

def initialize
  @request_id = SecureRandom.uuid
  @transactions = []
end

Instance Attribute Details

#request_idObject (readonly)

Returns the value of attribute request_id.



5
6
7
# File 'lib/notion_rb/request_params.rb', line 5

def request_id
  @request_id
end

#transactionsObject (readonly)

Returns the value of attribute transactions.



5
6
7
# File 'lib/notion_rb/request_params.rb', line 5

def transactions
  @transactions
end

Instance Method Details

#add_transactionObject



12
13
14
# File 'lib/notion_rb/request_params.rb', line 12

def add_transaction
  Transaction.new.tap { |t| @transactions.push(t) }
end

#to_hObject



16
17
18
19
20
21
# File 'lib/notion_rb/request_params.rb', line 16

def to_h
  {
    requestId: request_id,
    transactions: transactions.map(&:to_h)
  }
end