Exemplo n.º 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)
Exemplo n.º 2
0
def default_command_with_data(**data):
    """What we expect the authenticate command to look like."""
    return Command(
        method='post',
        path='track',
        data=dict(sent_at=mock.sentinel.timestamp, **data)
    )
Exemplo n.º 3
0
    def call(device_token):
        ValidatorsPresent.call({'device_token': device_token}, 'device_token')

        return Command(
            method='get',
            path="devices/{device_token}".format(device_token=device_token),
            data=None)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    def build(self, review_id):
        if review_id is None or review_id == '':
            raise InvalidParametersError

        return Command(
            method='get',
            endpoint="reviews/{review_id}".format(review_id=review_id),
            data=None
        )
Exemplo n.º 6
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)
Exemplo n.º 7
0
    def build(self, options):
        validate(options, 'user_id')

        if options.get('properties'):
            raise InvalidParametersError(
                'properties are not supported in identify calls')

        return Command(method='post',
                       endpoint='identify',
                       data=self.build_context(options))
Exemplo n.º 8
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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
def command():
    return Command(method='post', path='authenticate', data={})
Exemplo n.º 11
0
def default_reset_command_with_data(**data):
    """What we expect the impersonate command to look like."""
    return Command(method='delete',
                   path='impersonate',
                   data=dict(sent_at=mock.sentinel.timestamp, **data))
Exemplo n.º 12
0
    def build(review_id):
        ValidatorsPresent.call({'review_id': review_id}, 'review_id')

        return Command(method='get',
                       path="reviews/{review_id}".format(review_id=review_id),
                       data=None)
Exemplo n.º 13
0
    def call(user_id):
        ValidatorsPresent.call({'user_id': user_id}, 'user_id')

        return Command(method='get',
                       path="users/{user_id}/devices".format(user_id=user_id),
                       data=None)
Exemplo n.º 14
0
    def build(self, options):
        validate(options, 'event')

        return Command(method='post',
                       endpoint='track',
                       data=self.build_context(options))
Exemplo n.º 15
0
def command():
    return Command(method='post',
                   endpoint='authenticate',
                   data={'event': '$login.authenticate'})
Exemplo n.º 16
0
def command():
    return Command(method='post', endpoint='authenticate', data={})
Exemplo n.º 17
0
    def build(self, options):
        validate(options, 'event', 'user_id')

        return Command(method='post',
                       endpoint='authenticate',
                       data=self.build_context(options))