{ "info": { "author": "Zack Zhu", "author_email": "zhuyuzhou.dev@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta" ], "description": "*****************\r\nJust Salesforce\r\n*****************\r\n\r\n.. image:: https://travis-ci.org/codingrhythm/just-salesforce.svg?branch=master \r\n\r\nJust Salesforce is a basic Salesforce.com REST API client built for Python 2.6, 2.7, 3.2 and 3.3. The goal is to provide a very low-level interface to the REST Resource and APEX API, returning a dictionary of the API JSON response.\r\n\r\nYou can find out more regarding the format of the results in the `Official Salesforce.com REST API Documentation`_\r\n\r\n.. _Official Salesforce.com REST API Documentation: http://www.salesforce.com/us/developer/docs/api_rest/index.htm\r\n\r\nExample\r\n-------\r\nThere are two ways to gain access to Salesforce\r\n\r\nThe first is to simply pass the domain of your Salesforce instance and an access token straight to ``Salesforce()``\r\n\r\nFor example::\r\n\r\n from simple_salesforce import Salesforce\r\n sf = Salesforce(instance='na1.salesforce.com', session_id='')\r\n\r\nIf you have the full URL of your instance (perhaps including the schema, as is included in the OAuth2 request process), you can pass that in instead using ``instance_url``::\r\n\r\n from simple_salesforce import Salesforce\r\n sf = Salesforce(instance_url='https://na1.salesforce.com', session_id='')\r\n\r\nThere are also two means of authentication, one that uses username, password and security token and the other that uses IP filtering, username, password and organizationId\r\n\r\nTo login using the security token method, simply include the Salesforce method and pass in your Salesforce username, password and token (this is usually provided when you change your password)::\r\n\r\n from simple_salesforce import Salesforce\r\n sf = Salesforce(username='myemail@example.com', password='password', security_token='token')\r\n\r\nTo login using IP-whitelist Organization ID method, simply use your Salesforce username, password and organizationId::\r\n\r\n from simple_salesforce import Salesforce\r\n sf = Salesforce(password='password', username='myemail@example.com', organizationId='OrgId')\r\n\r\nIf you'd like to enter a sandbox, simply add ``sandbox=True`` to your ``Salesforce()`` call.\r\n\r\nFor example::\r\n\r\n from simple_salesforce import Salesforce\r\n sf = Salesforce(username='myemail@example.com.sandbox', password='password', security_token='token', sandbox=True)\r\n\r\nNote that specifying if you want to use a sandbox is only necessary if you are using the built-in username/password/security token authentication and is used exclusively during the authentication step.\r\n\r\nRecord Management\r\n-----------------\r\n\r\nTo create a new 'Contact' in Salesforce::\r\n\r\n sf.Contact.create({'LastName':'Smith','Email':'example@example.com'})\r\n\r\nThis will return a dictionary such as ``{u'errors': [], u'id': u'003e0000003GuNXAA0', u'success': True}``\r\n\r\nTo get a dictionary with all the information regarding that record, use::\r\n\r\n contact = sf.Contact.get('003e0000003GuNXAA0')\r\n\r\nTo change that contact's last name from 'Smith' to 'Jones' and add a first name of 'John' use::\r\n\r\n sf.Contact.update('003e0000003GuNXAA0',{'LastName': 'Jones', 'FirstName': 'John'})\r\n\r\nTo delete the contact::\r\n\r\n sf.Contact.delete('003e0000003GuNXAA0')\r\n\r\nTo retrieve a list of deleted records between ``2013-10-20`` to ``2013-10-29`` (datetimes are required to be in UTC)::\r\n\r\n import pytz\r\n import datetime\r\n end = datetime.datetime.now(pytz.UTC) # we need to use UTC as salesforce API requires this!\r\n sf.Contact.deleted(end - datetime.timedelta(days=10), end)\r\n\r\nTo retrieve a list of updated records between ``2014-03-20`` to ``2014-03-22`` (datetimes are required to be in UTC)::\r\n\r\n import pytz\r\n import datetime\r\n end = datetime.datetime.now(pytz.UTC) # we need to use UTC as salesforce API requires this\r\n sf.Contact.updated(end - datetime.timedelta(days=10), end)\r\n\r\nNote that Update, Delete and Upsert actions return the associated `Salesforce HTTP Status Code`_\r\n\r\n.. _Salesforce HTTP Status Code: http://www.salesforce.com/us/developer/docs/api_rest/Content/errorcodes.htm\r\n\r\nQueries\r\n-------\r\n\r\nIt's also possible to write select queries in Salesforce Object Query Language (SOQL) and search queries in Salesforce Object Search Language (SOSL).\r\n\r\nSOQL queries are done via\r\n\r\n::\r\n\r\n sf.query(\"SELECT Id, Email FROM Contact WHERE LastName = 'Jones'\")\r\n\r\nIf, due to an especially large result, Salesforce adds a ``nextRecordsUrl`` to your query result, such as ``\"nextRecordsUrl\" : \"/services/data/v26.0/query/01gD0000002HU6KIAW-2000\"``, you can pull the additional results with either the ID or the full URL (if using the full URL, you must pass 'True' as your second argument)\r\n\r\n::\r\n\r\n sf.query_more(\"01gD0000002HU6KIAW-2000\")\r\n sf.query_more(\"/services/data/v26.0/query/01gD0000002HU6KIAW-2000\", True)\r\n\r\nAs a convenience, to retrieve all of the results in a single local method call use\r\n\r\n::\r\n\r\n sf.query_all(\"SELECT Id, Email FROM Contact WHERE LastName = 'Jones'\")\r\n\r\nSOSL queries are done via::\r\n\r\n sf.search(\"FIND {Jones}\")\r\n\r\nThere is also 'Quick Search', which inserts your query inside the {} in the SOSL syntax. Be careful, there is no escaping!\r\n\r\n::\r\n\r\n sf.quick_search(\"Jones\")\r\n\r\nSearch and Quick Search return ``None`` if there are no records, otherwise they return a dictionary of search results.\r\n\r\nMore details about syntax is available on the `Salesforce Query Language Documentation Developer Website`_\r\n\r\n.. _Salesforce Query Language Documentation Developer Website: http://www.salesforce.com/us/developer/docs/soql_sosl/index.htm\r\n\r\nOther Options\r\n-------------\r\n\r\nTo insert or update (upsert) a record using an external ID, use::\r\n\r\n sf.Contact.upsert('customExtIdField__c/11999',{'LastName': 'Smith','Email': 'smith@example.com'})\r\n\r\nTo retrieve basic metadata use::\r\n\r\n sf.Contact.metadata()\r\n\r\nTo retrieve a description of the object, use::\r\n\r\n sf.Contact.describe()\r\n\r\nTo retrieve a description of the record layout of an object by its record layout unique id, use::\r\n\r\n sf.Contact.describe_layout('39wmxcw9r23r492')\r\n\r\nTo retrieve a list of top level description of instance metadata, user::\r\n\r\n sf.describe()\r\n\r\n for x in sf.describe()[\"sobjects\"]:\r\n print x[\"label\"]\r\n\r\n\r\nUsing Apex\r\n----------\r\n\r\nYou can also use this library to call custom Apex methods::\r\n\r\n payload = {\r\n \"activity\": [\r\n {\"user\": \"12345\", \"action\": \"update page\", \"time\": \"2014-04-21T13:00:15Z\"}\r\n ]\r\n }\r\n result = sf.apexecute('User/Activity', method='POST', data=payload)\r\n\r\nThis would call the endpoint ``https://.salesforce.com/services/apexrest/User/Activity`` with ``data=`` as\r\nthe body content encoded with ``json.dumps``\r\n\r\nYou can read more about Apex on the `Force.com Apex Code Developer's Guide`_\r\n\r\n.. _Force.com Apex Code Developer's Guide: http://www.salesforce.com/us/developer/docs/apexcode\r\n\r\nAdditional Features\r\n-------------------\r\n\r\nThere are a few helper classes that are used internally and available to you.\r\n\r\nIncluded in them are ``SalesforceLogin``, which takes in a username, password, security token, optional boolean sandbox indicator and optional version and returns a touple of ``(session_id, sf_instance)`` where `session_id` is the session ID to use for authentication to Salesforce and ``sf_instance`` is the domain of the instance of Salesforce to use for the session.\r\n\r\nFor example, to use SalesforceLogin for a sandbox account you'd use::\r\n\r\n from simple_salesforce import SalesforceLogin\r\n session_id, instance = SalesforceLogin('myemail@example.com.sandbox', 'password', 'token', True)\r\n\r\nSimply leave off the final ``True`` if you do not wish to use a sandbox.\r\n\r\nAlso exposed is the ``SFType`` class, which is used internally by the ``__getattr__()`` method in the ``Salesforce()`` class and represents a specific SObject type. ``SFType`` requires ``object_name`` (i.e. ``Contact``), ``session_id`` (an authentication ID), ``sf_instance`` (hostname of your Salesforce instance), and an optional ``sf_version``\r\n\r\nTo add a Contact using the default version of the API you'd use::\r\n\r\n from simple_salesforce import SFType\r\n contact = SFType('Contact','sesssionid','na1.salesforce.com')\r\n contact.create({'LastName':'Smith','Email':'example@example.com'})\r\n\r\nTo use a proxy server between your client and the SalesForce endpoint, use the proxies argument when creating SalesForce object.\r\nThe proxy argument is the same as what requests uses, a map of scheme to proxy URL::\r\n\r\n proxies = {\r\n \"http\": \"http://10.10.1.10:3128\",\r\n \"https\": \"http://10.10.1.10:1080\",\r\n }\r\n SalesForce(instance='na1.salesforce.com', session_id='', proxies=proxies)\r\n\r\nAll results are returned as JSON converted OrderedDict to preserve order of keys from REST responses.\r\n\r\nAuthors & License\r\n-----------------\r\n\r\nThis library is a based on `Simple Salesforce`_. It is released under an open source Apache 2.0 license. Contributions are welcome and can be submitted via a pull request on the official `Github Repo`_.\r\n\r\n\r\n.. _Simple Salesforce: https://github.com/neworganizing/simple-salesforce\r\n.. _Github Repo: https://github.com/codingrhythm/just-salesforce", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/codingrhythm/just-salesforce/archive/master.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/codingrhythm/just-salesforce", "keywords": "salesforce", "license": "Apache 2.9", "maintainer": "Zack Zhu", "maintainer_email": "zhuyuzhou.dev@gmail.com", "name": "just-salesforce", "package_url": "https://pypi.org/project/just-salesforce/", "platform": "", "project_url": "https://pypi.org/project/just-salesforce/", "project_urls": { "Download": "https://github.com/codingrhythm/just-salesforce/archive/master.zip", "Homepage": "https://github.com/codingrhythm/just-salesforce" }, "release_url": "https://pypi.org/project/just-salesforce/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "first release", "version": "0.1.0" }, "last_serial": 1205966, "releases": { "0.1.0": [] }, "urls": [] }