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


Python Intercom.get方法代码示例

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


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

示例1: it_handles_no_error_type

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
    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,代码行数:36,代码来源:test_request.py

示例2: find

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
    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,代码行数:14,代码来源:find.py

示例3: it_raises_a_multiple_matching_users_error

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 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,代码行数:18,代码来源:test_request.py

示例4: it_raises_a_service_unavailable_error

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 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,代码行数:18,代码来源:test_request.py

示例5: it_raises_rate_limit_exceeded

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 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,代码行数:18,代码来源:test_request.py

示例6: it_raises_resource_not_found_by_type

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 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,代码行数:18,代码来源:test_request.py

示例7: it_raises_a_multiple_matching_users_error_when_receiving_a_conflict

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 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,代码行数:20,代码来源:test_user.py

示例8: it_raises_an_unexpected_untyped_error

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 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,代码行数:21,代码来源:test_request.py

示例9: it_raises_an_authentication_error

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
    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,代码行数:21,代码来源:test_request.py

示例10: it_raises_a_bad_request_error

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
    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,代码行数:22,代码来源:test_request.py

示例11: it_raises_an_unexpected_typed_error

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 def it_raises_an_unexpected_typed_error(self):
     payload = {
         'type': 'error.list',
         'errors': [
             {
                 'type': 'hopper',
                 'message': 'The first compiler.'
             }
         ]
     }
     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_("The error of type 'hopper' is not recognized" in err.message)  # noqa
             eq_(err.context['http_code'], 200)
             eq_(err.context['application_error_code'], 'hopper')
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:23,代码来源:test_request.py

示例12: load

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
    def load(self):
        from intercom import Intercom
        cls = self.__class__
        collection = utils.resource_class_to_collection_name(cls)
        if hasattr(self, 'id'):
            response = Intercom.get("/%s/%s" % (collection, self.id))
        else:
            raise Exception(
                "Cannot load %s as it does not have a valid id." % (cls))

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

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

示例13: get_page

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
    def get_page(self, url, params={}):
        # get a page of results
        from intercom import Intercom

        # if there is no url stop iterating
        if url is None:
            raise StopIteration

        response = Intercom.get(url, **params)
        if response is None:
            raise HttpError('Http Error - No response entity returned')

        collection = response[self.collection]
        # if there are no resources in the response stop iterating
        if collection is None:
            raise StopIteration

        # create the resource iterator
        self.resources = iter(collection)
        # grab the next page URL if one exists
        self.next_page = self.extract_next_link(response)
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:23,代码来源:collection_proxy.py

示例14: count

# 需要导入模块: from intercom import Intercom [as 别名]
# 或者: from intercom.Intercom import get [as 别名]
 def count(cls):
     from intercom import Intercom
     response = Intercom.get("/counts/")
     return response[utils.resource_class_to_name(cls)]['count']
开发者ID:50onRed,项目名称:python-intercom-1,代码行数:6,代码来源:count.py


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