Esempio n. 1
0
    def call(self, options):
        ValidatorsPresent.call(options, 'event')
        context = ContextMerge.call(self.context, options.get('context'))
        context = ContextSanitize.call(context)
        if context:
            options.update({'context': context})
        options.update({'sent_at': generate_timestamp.call()})

        return Command(method='post', path='risk', data=options)
Esempio n. 2
0
    def call(self, options):
        ValidatorsPresent.call(options, 'user_id')

        context = ContextMerge.call(self.context, options.get('context'))
        context = ContextSanitize.call(context)
        ValidatorsPresent.call(context, 'user_agent', 'ip')

        if context:
            options.update({'context': context})
        options.update({'sent_at': generate_timestamp.call()})

        return Command(method='delete', path='impersonate', data=options)
Esempio n. 3
0
    def call(payload_options, request, options=None):
        if options is None:
            options = {}

        context = ContextPrepare.call(
            request, UtilsMerge.call(payload_options, options))

        payload_options.setdefault('context', context)
        payload_options.setdefault('timestamp', generate_timestamp.call())

        if 'traits' in payload_options:
            warnings.warn('use user_traits instead of traits key',
                          DeprecationWarning)

        return payload_options
Esempio n. 4
0
 def test_it_should_use_iso_format(self, mock_datetime):
     mock_datetime.utcnow.return_value = datetime(2018, 1, 2, 3, 4, 5,
                                                  678901)
     expected = '2018-01-02T03:04:05.678901'
     self.assertEqual(UtilsTimestamp.call(), expected)