本文整理汇总了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