salesforce: Minor improvements; imports & types.

This commit is contained in:
neiljp (Neil Pilgrim) 2018-05-27 21:59:42 -07:00 committed by showell
parent 8f0b9adb70
commit efe5b04374

View file

@ -6,7 +6,7 @@ import getpass
import re
import logging
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
This bot can do simple salesforce query requests
@ -73,7 +73,7 @@ def format_result(
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()
qarg = arg.split(' -', 1)[0]
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():
query = command['query']
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))
exclude_keys = [] # type: List[str]
if 'exclude_keys' in command.keys():
@ -136,7 +136,7 @@ class SalesforceHandler(object):
def get_salesforce_response(self, content: str) -> str:
content = content.strip()
if content is None or content == 'help':
if content is '' or content == 'help':
return get_help_text()
if content.startswith('http') and 'force' in content:
return get_salesforce_link_details(content, self.sf)