当前位置: 首页>>代码示例>>Python>>正文


Python intercom.Intercom类代码示例

本文整理汇总了Python中intercom.Intercom的典型用法代码示例。如果您正苦于以下问题:Python Intercom类的具体用法?Python Intercom怎么用?Python Intercom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Intercom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_users_params

    def test_get_users_params(self):
        resp = Intercom.get_users()
        ok_('params' in resp)
        ok_('page' not in resp['params'])
        ok_('per_page' not in resp['params'])
        ok_('tag_id' not in resp['params'])
        ok_('tag_id' not in resp['params'])

        resp = Intercom.get_users(page=20)
        ok_('params' in resp)
        ok_('page' in resp['params'])
        eq_(resp['params']['page'], 20)

        resp = Intercom.get_users(per_page=10)
        ok_('params' in resp)
        ok_('per_page' in resp['params'])
        eq_(resp['params']['per_page'], 10)

        resp = Intercom.get_users(tag_id=100)
        ok_('params' in resp)
        ok_('tag_id' in resp['params'])
        eq_(resp['params']['tag_id'], 100)

        resp = Intercom.get_users(tag_name="starter")
        ok_('params' in resp)
        ok_('tag_name' in resp['params'])
        eq_(resp['params']['tag_name'], "starter")
开发者ID:uservidya,项目名称:python-intercom,代码行数:27,代码来源:test_intercom.py

示例2: it_handles_no_error_type

    def it_handles_no_error_type(self):
        payload = {
            'errors': [
                {
                    'code': 'unique_user_constraint',
                    'message': 'User already exists.'
                }
            ],
            'request_id': '00000000-0000-0000-0000-000000000000',
            'type': 'error.list'
        }
        content = json.dumps(payload).encode('utf-8')
        resp = mock_response(content)
        with patch('requests.request') as mock_method:
            mock_method.return_value = resp
            with assert_raises(intercom.MultipleMatchingUsersError):
                Intercom.get('/users')

        payload = {
            'errors': [
                {
                    'code': 'parameter_not_found',
                    'message': 'missing data parameter'
                }
            ],
            'request_id': None,
            'type': 'error.list'
        }
        content = json.dumps(payload).encode('utf-8')
        resp = mock_response(content)
        with patch('requests.request') as mock_method:
            mock_method.return_value = resp
            with assert_raises(intercom.BadRequestError):
                Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:34,代码来源:test_request.py

示例3: find

    def find(cls, **params):
        from intercom import Intercom
        collection = utils.resource_class_to_collection_name(cls)
        if 'id' in params:
            response = Intercom.get("/%s/%s" % (collection, params['id']))
        else:
            response = Intercom.get("/%s" % (collection), **params)

        if response is None:
            raise HttpError('Http Error - No response entity returned')

        return cls(**response)
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:12,代码来源:find.py

示例4: save

 def save(self):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(self.__class__)
     params = self.attributes
     if self.id_present and not self.posted_updates:
         # update
         response = Intercom.put('/%s/%s' % (collection, self.id), **params)
     else:
         # create
         params.update(self.identity_hash)
         response = Intercom.post('/%s' % (collection), **params)
     if response:
         return self.from_response(response)
开发者ID:ArabellaTech,项目名称:python-intercom,代码行数:13,代码来源:save.py

示例5: it_raises_a_service_unavailable_error

 def it_raises_a_service_unavailable_error(self):
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'type': 'service_unavailable',
                 'message': 'Zzzzz.'
             }
         ]
     }
     content = json.dumps(payload).encode('utf-8')
     resp = mock_response(content)
     with patch('requests.request') as mock_method:
         mock_method.return_value = resp
         with assert_raises(intercom.ServiceUnavailableError):
             Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:16,代码来源:test_request.py

示例6: it_raises_rate_limit_exceeded

 def it_raises_rate_limit_exceeded(self):
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'type': 'rate_limit_exceeded',
                 'message': 'Fair use please.'
             }
         ]
     }
     content = json.dumps(payload).encode('utf-8')
     resp = mock_response(content)
     with patch('requests.request') as mock_method:
         mock_method.return_value = resp
         with assert_raises(intercom.RateLimitExceeded):
             Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:16,代码来源:test_request.py

示例7: reply

 def reply(self, **reply_data):
     from intercom import Intercom
     collection = utils.resource_class_to_collection_name(self.__class__)
     url = "/%s/%s/reply" % (collection, self.id)
     reply_data['conversation_id'] = self.id
     response = Intercom.post(url, **reply_data)
     return self.from_response(response)
开发者ID:ArabellaTech,项目名称:python-intercom,代码行数:7,代码来源:reply.py

示例8: it_raises_resource_not_found_by_type

 def it_raises_resource_not_found_by_type(self):
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'type': 'not_found',
                 'message': 'Waaaaally?'
             }
         ]
     }
     content = json.dumps(payload).encode('utf-8')
     resp = mock_response(content)
     with patch('requests.request') as mock_method:
         mock_method.return_value = resp
         with assert_raises(intercom.ResourceNotFound):
             Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:16,代码来源:test_request.py

示例9: create

    def create(cls, **params):
        from intercom import Intercom

        collection = utils.resource_class_to_collection_name(cls)
        response = Intercom.post("/%s/" % (collection), **params)
        if response:  # may be empty if we received a 202
            return cls(**response)
开发者ID:NiekvanderLinden,项目名称:python-intercom,代码行数:7,代码来源:save.py

示例10: it_raises_a_multiple_matching_users_error

 def it_raises_a_multiple_matching_users_error(self):
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'type': 'conflict',
                 'message': 'Two many cooks.'
             }
         ]
     }
     content = json.dumps(payload).encode('utf-8')
     resp = mock_response(content)
     with patch('requests.request') as mock_method:
         mock_method.return_value = resp
         with assert_raises(intercom.MultipleMatchingUsersError):
             Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:16,代码来源:test_request.py

示例11: it_raises_a_multiple_matching_users_error_when_receiving_a_conflict

 def it_raises_a_multiple_matching_users_error_when_receiving_a_conflict(self):  # noqa
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'code': 'conflict',
                 'message': 'Multiple existing users match this email address - must be more specific using user_id'  # noqa
             }
         ]
     }
     # create bytes content
     content = json.dumps(payload).encode('utf-8')
     # create mock response
     resp = mock_response(content)
     with patch('requests.request') as mock_method:
         mock_method.return_value = resp
         with assert_raises(MultipleMatchingUsersError):
             Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:18,代码来源:test_user.py

示例12: it_raises_an_authentication_error

    def it_raises_an_authentication_error(self):
        payload = {
            'type': 'error.list',
            'errors': [
                {
                    'type': 'unauthorized',
                    'message': 'Your name\'s not down.'
                }
            ]
        }
        for code in ['unauthorized', 'forbidden']:
            payload['errors'][0]['type'] = code

            content = json.dumps(payload).encode('utf-8')
            resp = mock_response(content)
            with patch('requests.request') as mock_method:
                mock_method.return_value = resp
                with assert_raises(intercom.AuthenticationError):
                    Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:19,代码来源:test_request.py

示例13: it_raises_an_unexpected_untyped_error

 def it_raises_an_unexpected_untyped_error(self):
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'message': 'UNIVAC'
             }
         ]
     }
     content = json.dumps(payload).encode('utf-8')
     resp = mock_response(content)
     with patch('requests.request') as mock_method:
         mock_method.return_value = resp
         try:
             Intercom.get('/users')
             self.fail('UnexpectedError not raised.')
         except (UnexpectedError) as err:
             ok_("An unexpected error occured." in err.message)
             eq_(err.context['application_error_code'], None)
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:19,代码来源:test_request.py

示例14: it_raises_a_bad_request_error

    def it_raises_a_bad_request_error(self):
        payload = {
            'type': 'error.list',
            'errors': [
                {
                    'type': None,
                    'message': 'email is required'
                }
            ]
        }

        for code in ['missing_parameter', 'parameter_invalid', 'bad_request']:
            payload['errors'][0]['type'] = code

            content = json.dumps(payload).encode('utf-8')
            resp = mock_response(content)
            with patch('requests.request') as mock_method:
                mock_method.return_value = resp
                with assert_raises(intercom.BadRequestError):
                    Intercom.get('/users')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:20,代码来源:test_request.py

示例15: test_update_user_valid

    def test_update_user_valid(self):
        companies = [{
            'id':1,
            'name':'Intercom',
            'created_at': 1331764344}]

        resp = Intercom.update_user(
                email='[email protected]', custom_data={'age': '42'}, companies=companies)
        self.assertEqual(None, resp['user_id'])
        self.assertEqual('[email protected]', resp['email'])
        self.assertEqual('42', resp['custom_data']['age'])
开发者ID:cameronmaske,项目名称:python-intercom,代码行数:11,代码来源:test_intercom.py


注:本文中的intercom.Intercom类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。