{ "info": { "author": "Jamil Vallis-Walker", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# PandaForce\nA utility package utilizing [pandas](https://github.com/pandas-dev/pandas) and [simple-salesforce](https://github.com/simple-salesforce/simple-salesforce)\n\n## Overview\npandaforce contains the following general utility functions:\n - `convertTo18`:\tConverts the passed Salesforce 15-digit ID to an 18-digit Id\n - `info` gives an overview of the functions and methods within the pandaforce package\n - `isNull`:\t\tReturns boolean value for passed value indicating if it is a Null or NaN value\n - `repairCasing`:\tChanges 18-digit IDs that have had all character's capitalized to a Salesforce viable 18-digit Id\n\nIt also contains a `login` class which initiates a connection to a Salesforce org. It contains the following methods:\n - `checkObject`: Accepts string argument. Returns dict {'isObject':True/False,'Records':count_of_records_in_object}\n - `dml`: Runs the specified bulk CRUD command with the passed data\n - `getdf`: Returns pandas dataframe from passed SOQL query\n - `getObjectFields`: Returns list of all field names in the passed Salesforce object name\n - `getObjectFieldsDict`: Returns all fields of passed Salesforce object name as {label:name} dictionary\n - `getReport`: Returns pandas dataframe from passed Salesforce report Id (15 or 18 digit)\n\n## Connecting to a Salesforce Org\nTo connect to your Salesforce Org, create a `login` class instance with `var = pandaforce.login()`. `login` requires the following parameters:\n - `username` = string of your Salesforce login username\n - `password` = string of your Salesforce login password\n - `orgid` = string of your Salesforce organization id, as found on the **Company Information** setup page of your org\n\nThere are also two optional parameters, `securitytoken` and `sandbox`.\n - `securitytoken` defaults to a blank string (`''`), but can accept your login security token\n - `sandbox` defaults to `False`, but must be passed as `True` to access a sandbox within of your org. If you are accessing a sandbox, you must also append `'.your_sandbox_name'` to the end of your username, as you would when logging in to a normal Salesforce sandbox.\n\nYou can have any number of `login` instances running within a given script. Each instance should be assigned to a different variable. The default example login instance in this document will be `sf`.\n\n## Login Class Methods (Details)\n\n### checkObject\nThe `checkObject` method accepts one string parameter, and searches your Salesforce org for an object with a name matching that parameter. It is not case sensitive. The search is by object name, not object label, so make sure to inlude underscores (`_`) and to append `__c` for custom objects.\n\nThe method returns a dictionary formatted as `{'isObject':True/False,'Records':None or count of records in object}`.\n\n### dml\nThe `dml` method evokes a bulk CRUD (Created, Update, Delete) command into your Salesforce org. These changes are permanent, so be cautious when using this method.\n\n`dml` parameters are as follows:\n - `obj`: the name of the Salesforce object (not its label) as a string\n - `uptype`: the type of CRUD function to be executed. Options are `insert`, `update`, `delete`, and `hard_delete` as a string\n - `data`: this parameter must be a `list` of `dictionaries`. Each value in the list represents a record, and the dictionaries must be formatted as noted below:\n - `insert`: `{'field_names':field_values_as_type_in_salesforce}'\n - `update`: `{'Id':'15_or_18_digit_Id_as_String','field_names':field_values_as_type_in_salesforce}`\n - `delete` and `hard_delete`: `{'Id':'15_or_18_digit_Id_as_String'}\n\n`dml` returns a list of dictionaries, as formatted in the example below:\n```\n[{'success': True, 'created': False, 'id': '0030v000000000000B', 'errors': []},\n {'success': True, 'created': False, 'id': '0030v000000000000N', 'errors': []},\n {'success': False,'created': False,'id': None,'errors': [{'message': 'Please update phone number format to: (XXX) XXX-XXXX',\n 'fields': ['MobilePhone'],\n 'statusCode': 'FIELD_CUSTOM_VALIDATION_EXCEPTION',\n 'extendedErrorDetails': None}]},\n```\nTo capture the `dml` results, assign a variable to the dml command. For example:\n\n```r = sf.dml('Custom_Object__c','delete','myData')```\n\n**Insert Example**\n```\nsf = login(login_criteria_here)\n\nmyData = [{'Name':'First Record','Field_A__c':'A value','Number_Field__c':123},\n 'Name':'Second Record','Field_A__c':'Another value','Number_Field__c':456}]\n\nsf.dml('Custom_Object__c','insert',myData)\n```\n\n**Update Example**\n\n```\nsf = login(login_criteria_here)\n\nmyData = [{'Id':'000000000000001','Name':'First Record','Field_A__c':'A value','Number_Field__c':123},\n 'Id':'000000000000002','Name':'Second Record','Field_A__c':'Another value','Number_Field__c':456}]\n\nsf.dml('Custom_Object__c','update',myData)\n```\n\n**Delete Example**\n```\nsf = login(login_criteria_here)\n\nmyData = [{'Id':'000000000000001'},\n 'Id':'000000000000002'}]\n\nsf.dml('Custom_Object__c','delete',myData)\n```\n\n**Dot Notation Example**\nBecause the `login` class initiates a `Salesforce` class from the [simple-salesforce](https://github.com/simple-salesforce/simple-salesforce) package, you can also run a dml statement through dot notation. A dml statement in this fashion would look like the following:\n\n```sf.Org.Custom_Object__c.update(myData)```\n\nThe `.Org` component between `sf.` and `.Custom_Object__c` is required as the Simple Salesforce `Salesforce` class is housed within the `login` class instance.\n\n### getObjectFields\nThe `getObjectFields` method returns list of all field names in the passed Salesforce object name. The passed value must be a string, and be the name of the Salesforce object, not the label (i.e., `'Custom_Object__c'` rather than `'Custom Object'`)\n\n### getObjectFieldsDict\nThe `getObjectFieldsDict` method returns all fields of passed Salesforce object name as dictionary, using a {label:name} format. Like `getObjectFields`, the passed string must be the name of the Salesforce object, not the label (i.e., `'Custom_Object__c'` rather than `'Custom Object'`)\n\n### getReport\nThe `getReport` method returns a pandas dataframe from passed Salesforce report Id (15- or 18-digit). This method only works on tabular Salesforce reports, and will only return the text value of any hyperlinked text (i.e. The 'Name' field on the report will appear in the dataframe as the text of the name, not a link to the record or the record's 15- or 18-digit Id\n\n## Pandaforce Inheritance\nAs its name implies, Pandaforce heavily utilizes [pandas](https://github.com/pandas-dev/pandas) and [simple-salesforce](https://github.com/simple-salesforce/simple-salesforce), so any functionality of those packages will apply to this package as well. \n\nFor example, dataframes returned from methods such as `getdf()` or `getReport` are pandas DataFrames, so all DataFrame methods from the pandas package will function on it. Likewise, the `Org` variable in each `login` instance is a simple-salesforce Salesforce class, and its methods are accessible as well.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Jwok90/pandaforce", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pandaforce", "package_url": "https://pypi.org/project/pandaforce/", "platform": "", "project_url": "https://pypi.org/project/pandaforce/", "project_urls": { "Homepage": "https://github.com/Jwok90/pandaforce" }, "release_url": "https://pypi.org/project/pandaforce/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "A pandas and simple-salesforce based utility package", "version": "1.0.0" }, "last_serial": 5745832, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "8a9ac2bf2fd3c27ce96d08a1f3c80f55", "sha256": "4323fd6ab69fa6fe553a6a35bab81d3cf81c8e6a6ac3b9a480c955f3d890c1a3" }, "downloads": -1, "filename": "pandaforce-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8a9ac2bf2fd3c27ce96d08a1f3c80f55", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16870, "upload_time": "2019-08-28T21:19:30", "url": "https://files.pythonhosted.org/packages/2b/12/d344869a6c1e01eefea1f69541b8a93949e7bc01b38cec84ee4ef25cae47/pandaforce-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e0af77d9a43c55962b1f71f08f84fb86", "sha256": "a581fb664c40ec9f270b93a9f281e1f176274249fc0fa29aaf78e985faf6875b" }, "downloads": -1, "filename": "pandaforce-1.0.0.tar.gz", "has_sig": false, "md5_digest": "e0af77d9a43c55962b1f71f08f84fb86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9312, "upload_time": "2019-08-28T21:19:32", "url": "https://files.pythonhosted.org/packages/1b/6d/71ce0ea0b627e4769f391ceba5c14614b5e3dc626aaf4c557fdd6af22bff/pandaforce-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8a9ac2bf2fd3c27ce96d08a1f3c80f55", "sha256": "4323fd6ab69fa6fe553a6a35bab81d3cf81c8e6a6ac3b9a480c955f3d890c1a3" }, "downloads": -1, "filename": "pandaforce-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "8a9ac2bf2fd3c27ce96d08a1f3c80f55", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16870, "upload_time": "2019-08-28T21:19:30", "url": "https://files.pythonhosted.org/packages/2b/12/d344869a6c1e01eefea1f69541b8a93949e7bc01b38cec84ee4ef25cae47/pandaforce-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e0af77d9a43c55962b1f71f08f84fb86", "sha256": "a581fb664c40ec9f270b93a9f281e1f176274249fc0fa29aaf78e985faf6875b" }, "downloads": -1, "filename": "pandaforce-1.0.0.tar.gz", "has_sig": false, "md5_digest": "e0af77d9a43c55962b1f71f08f84fb86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9312, "upload_time": "2019-08-28T21:19:32", "url": "https://files.pythonhosted.org/packages/1b/6d/71ce0ea0b627e4769f391ceba5c14614b5e3dc626aaf4c557fdd6af22bff/pandaforce-1.0.0.tar.gz" } ] }