Module: Castle::Payload::Prepare

Defined in:
lib/castle/payload/prepare.rb

Overview

prepares payload based on the request

Class Method Summary collapse

Class Method Details

.call(payload_options, request, options = {}) ⇒ Hash

Parameters:

  • payload_options (Hash)
  • request (Request)
  • options (Hash) (defaults to: {})

    required for context preparation

Returns:

  • (Hash)


12
13
14
15
16
17
18
19
20
21
# File 'lib/castle/payload/prepare.rb', line 12

def call(payload_options, request, options = {})
  context = Castle::Context::Prepare.call(request, payload_options.merge(options))

  payload = Castle::Utils::DeepSymbolizeKeys.call(payload_options || {}).merge(context: context)
  payload[:timestamp] ||= Castle::Utils::GetTimestamp.call

  warn '[DEPRECATION] use user_traits instead of traits key' if payload.key?(:traits)

  payload
end