salesforce: Minor improvements; imports & types.
This commit is contained in:
parent
8f0b9adb70
commit
efe5b04374
|
@ -6,7 +6,7 @@ import getpass
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from zulip_bots.bots.salesforce.utils import *
|
from zulip_bots.bots.salesforce.utils import commands, object_types, link_query, default_query
|
||||||
|
|
||||||
base_help_text = '''Salesforce bot
|
base_help_text = '''Salesforce bot
|
||||||
This bot can do simple salesforce query requests
|
This bot can do simple salesforce query requests
|
||||||
|
@ -73,7 +73,7 @@ def format_result(
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def query_salesforce(arg: str, sf: Any, command: Dict[str, Any]) -> str:
|
def query_salesforce(arg: str, salesforce: simple_salesforce.Salesforce, command: Dict[str, Any]) -> str:
|
||||||
arg = arg.strip()
|
arg = arg.strip()
|
||||||
qarg = arg.split(' -', 1)[0]
|
qarg = arg.split(' -', 1)[0]
|
||||||
split_args = [] # type: List[str]
|
split_args = [] # type: List[str]
|
||||||
|
@ -91,7 +91,7 @@ def query_salesforce(arg: str, sf: Any, command: Dict[str, Any]) -> str:
|
||||||
if 'query' in command.keys():
|
if 'query' in command.keys():
|
||||||
query = command['query']
|
query = command['query']
|
||||||
object_type = object_types[command['object']]
|
object_type = object_types[command['object']]
|
||||||
res = sf.query(query.format(
|
res = salesforce.query(query.format(
|
||||||
object_type['fields'], object_type['table'], qarg, limit_num))
|
object_type['fields'], object_type['table'], qarg, limit_num))
|
||||||
exclude_keys = [] # type: List[str]
|
exclude_keys = [] # type: List[str]
|
||||||
if 'exclude_keys' in command.keys():
|
if 'exclude_keys' in command.keys():
|
||||||
|
@ -136,7 +136,7 @@ class SalesforceHandler(object):
|
||||||
|
|
||||||
def get_salesforce_response(self, content: str) -> str:
|
def get_salesforce_response(self, content: str) -> str:
|
||||||
content = content.strip()
|
content = content.strip()
|
||||||
if content is None or content == 'help':
|
if content is '' or content == 'help':
|
||||||
return get_help_text()
|
return get_help_text()
|
||||||
if content.startswith('http') and 'force' in content:
|
if content.startswith('http') and 'force' in content:
|
||||||
return get_salesforce_link_details(content, self.sf)
|
return get_salesforce_link_details(content, self.sf)
|
||||||
|
|
Loading…
Reference in a new issue