コード例 #1
0
    def build(self, options):
        ValidatorsPresent.call(options, 'event')
        context = ContextMerger.call(self.context, options.get('context'))
        context = ContextSanitizer.call(context)
        options.update({'sent_at': timestamp(), 'context': context})

        return Command(method='post', path='track', data=options)
コード例 #2
0
ファイル: identify.py プロジェクト: ngenator/castle-python
    def build(self, options):
        ValidatorsPresent.call(options, 'user_id')
        ValidatorsNotSupported.call(options, 'properties')
        context = ContextMerger.call(self.context, options.get('context'))
        context = ContextSanitizer.call(context)
        options.update({'sent_at': timestamp(), 'context': context})

        return Command(method='post', path='identify', data=options)
コード例 #3
0
ファイル: impersonate.py プロジェクト: ngenator/castle-python
    def build(self, options):
        ValidatorsPresent.call(options, 'user_id')

        context = ContextMerger.call(self.context, options.get('context'))
        context = ContextSanitizer.call(context)
        ValidatorsPresent.call(context, 'user_agent', 'ip')

        options.update({'sent_at': timestamp(), 'context': context})

        method = ('delete' if options.get('reset', False) else 'post')

        return Command(method=method, path='impersonate', data=options)
コード例 #4
0
ファイル: utils_test.py プロジェクト: ngenator/castle-python
 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(timestamp(), expected)