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


Python Salesforce.quick_search方法代码示例

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


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

示例1: __init__

# 需要导入模块: from simple_salesforce import Salesforce [as 别名]
# 或者: from simple_salesforce.Salesforce import quick_search [as 别名]
class SFAccess:
    session = None
    instance = None

    def __init__(self, settings):
        self.sf_user = settings["sfUser"]
        self.sf_pswd = settings["sfPsw"]
        self.sf_token = settings["sfToken"]

    def login(self):
        self.sf = Salesforce(username=self.sf_user,
                             password=self.sf_pswd,
                             security_token=self.sf_token)

        # these can be stored and reused for faster authentication
        self.instance = self.sf.sf_instance
        self.session = self.sf.session_id

    def quick_search(self, name):
        return self.sf.quick_search(name)

    @gen.coroutine
    def get_report(self, report_id=None):
        if report_id is not None:
            # check if we have logged in
            if self.session is None:
                self.login()
            # do the call
            http_client = AsyncHTTPClient()
            future = http_client.fetch(
                "https://%s/services/data/v34.0/analytics/reports/%s" % (self.instance, report_id),
                headers={
                    "Authorization": "Bearer %s" % self.session}
            )
            result = yield future
            # result here brings whole report and you need to decode it then
            # https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_factmap_example.htm
            data = json.loads(result.body.decode("utf-8"))
            return data
        else:
            raise ValueError("You must provide report_id")

    @gen.coroutine
    def get_utilisation_report(self, report_id):
        data = yield self.get_report(report_id)
        # getting useful date range dictionary
        date_range_dict = get_time_range(data)
        # getting employee names and keys
        employee_key_dict = get_employee_names(data)

        # getting final report
        final_report = create_final_util_report(raw_report=data,
                                                time_dict=date_range_dict,
                                                employee_dict=employee_key_dict)
        return final_report

    @gen.coroutine
    def get_billability_report(self, report_id):
        data = yield self.get_report(report_id)
        # getting useful date range dictionary
        date_range_dict = get_time_range(data)
        # getting employee names and keys
        employee_key_dict = get_employee_names(data)
        # getting final report
        final_report = create_final_billability_report(raw_report=data,
                                                       time_dict=date_range_dict,
                                                       employee_dict=employee_key_dict)
        return final_report

    @gen.coroutine
    def get_billability_groupings_report(self, report_id):
        data = yield self.get_report(report_id)
        # getting useful date range dictionary
        date_range_dict = get_time_range(data)
        # getting final report
        groups = get_groups(data)

        final_report = create_sub_totals_report(raw_report=data,
                                                time_dict=date_range_dict,
                                                group_dict=groups)
        return final_report
开发者ID:iselu,项目名称:tornado-analytics,代码行数:83,代码来源:sfclient.py


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