コード例 #1
0
    def __init__(self, user_name, password, security_token):
        """Constructor for salesforce api which open session with salesforce with given credentials
           Args: * user_name: salesforce user
                 * password: salesforce password
                 * security_token: salesforcesecurity_token """

        self.sf = beatbox._tPartnerNS
        self.svc = beatbox.Client()
        self.svc.login(user_name, password + security_token)
コード例 #2
0
def _fetch_matching_ids(salesforce_object_type, id_attribute, query_condition):
    beatbox_client = beatbox.Client()
    beatbox_client.login(
        CONFIG['salesforce_username'],
        CONFIG['salesforce_password'] + CONFIG['salesforce_security_token'])

    soql_query = 'SELECT %s FROM %s WHERE %s' % (
        id_attribute, salesforce_object_type, query_condition.replace(
            '"', "'"))

    return [
        str(record[2]) for record in beatbox_client.queryAll(soql_query)
        [beatbox._tPartnerNS.records:] if str(record[2])
    ]
コード例 #3
0
def login(sf):
    print 'SET USERNAME AND PASSWORD'
    # Get login credentials
    if __debug_mode__:
        st_username = '******'
        st_password = '******'
        st_token = '3jpjJo3quesH7nUOfLYY4DQR'
    else:
        st_username = str(
            raw_input("-                         Enter username: "******"- Enter password, without security token: "))
        st_token = str(raw_input("-        Enter security token, if needed: "))

    # Log in to Salesforce
    svc = beatbox.Client()
    st_password_and_token = st_password + st_token
    svc.login(st_username, st_password_and_token)
    return svc
コード例 #4
0
ファイル: snippet.py プロジェクト: someburner/GistsHub
def main():
    refname = sys.argv[1]
    oldrev = sys.argv[2]
    newrev = sys.argv[3]

    # grab the list of commits in this update
    missed_revs = Popen(["git", "rev-list", oldrev + ".." + newrev],
                        stdout=PIPE).communicate()[0].split("\n")

    # grab the commit messages
    commit_msgs = []
    for rev in missed_revs:
        if (len(rev) > 0):
            msg = Popen(["git", "cat-file", "commit", rev],
                        stdout=PIPE).communicate()[0]
            commit_msgs.append(msg)

    # login to salesforce.com
    sf = beatbox._tPartnerNS
    svc = beatbox.Client()
    loginResult = svc.login(username, password)

    # make chatter FeedPost objects, one for each commit message
    # feel free to parse and otherwize futz with msg as needed
    # if you want to commit messages to goto a group instead of
    # the users wall, swap the parentId value for the Id of the group
    posts = []
    for msg in commit_msgs:
        post = {
            'type': 'FeedPost',
            'body': 'Git commit\r\n' + msg,
            'ParentId': str(loginResult[sf.userId])
        }
        posts.append(post)

    svc.create(posts)

    return 0
コード例 #5
0
import os
import sys
import beatbox
import datetime

sf = beatbox._tPartnerNS

# "salesforceusername and password"
username = '******'
password = "******"
token = 'cXHXhY4XKqZxa2TuAQcG2rcm'
"""connectt and authenticate"""
svc = beatbox.Client()
svc.login(username, password + token)
"""execut SOQL query"""
# res = svc.query("SELECT Id, Email FROM Contact WHERE LastName = 'xMedina'")

print("\ncreate")
a = {
    'type': 'Account',
    'Name': 'My 3rd Account from API',
    'Website': 'http://www.hectormedinaphoto.com/',
    'Description': 'This is a new field I inserted on xml'
}
sr = svc.create([a])

if str(sr[sf.success]) == 'true':
    print("id " + str(sr[sf.id]))
    #self.__idToDelete = str(sr[sf.id])
else:
    print("error " + str(sr[sf.errors][sf.statusCode]) + ":" +