Nameko extension for easy communication with Salesforce (Including Streaming API)
Project description
Nameko Salesforce
A Nameko extension with entrypoints for handling Salesforce Streaming API events and a dependency provider for easy communication with Salesforce REST API.
The Streaming API extension is based on Nameko Cometd Bayeux Client and the REST API dependency id based on Simple Salesforce.
Quick Start
Install from PyPI:
pip install nameko-salesforce
Create a service which handles Salesforce Contact objects changes and also has an RPC endpoint for creating new Contact objects in Salesforce:
# service.py
from nameko.rpc import rpc
from nameko_salesforce.streaming import handle_sobject_notification
from nameko_salesforce.api import SalesforceAPI
class Service:
name = 'some-service'
salesforce = SalesforceAPI()
@handle_sobject_notification('Contact', exclude_current_user=False)
def handle_contact_updates(
self, sobject_type, record_type, notification
):
""" Handle Salesforce contacts updates
"""
print(notification)
@rpc
def create_contact(self, last_name, email_address):
""" Create a contact in Salesforce
"""
self.salesforce.Contact.create(
{'LastName': last_name,'Email': email_address})
Create a config file with essential settings:
# config.yaml
AMQP_URI: 'pyamqp://guest:guest@localhost'
SALESFORCE:
USERNAME: ${SALESFORCE_USERNAME}
PASSWORD: ${SALESFORCE_PASSWORD}
SECURITY_TOKEN: ${SALESFORCE_SECURITY_TOKEN}
SANDBOX: False
Run the service providing your Salesforce credentials:
$ SALESFORCE_USERNAME=rocky \
SALESFORCE_PASSWORD=*** \
SALESFORCE_SECURITY_TOKEN=*** \
nameko run --config config.yaml service
Finally, open another shell and call the RPC endpoint to create a new user:
$ nameko shell --config config.yaml
In [1]: n.rpc['some-service'].create_contact('Yo', 'yo@yo.yo')
You should see a new contact created in Salesforce and your service should get a notification. In the first shell you’ll find the notification printed:
{'event': {'replayId': 1, 'type': 'created' ...
For more checkout the documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nameko-salesforce-1.0.2.tar.gz
.
File metadata
- Download URL: nameko-salesforce-1.0.2.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff5dae02ef7ae703db5fcd2e5ec43deb3bf38aaa1ece1bcb721feba388e90ec8 |
|
MD5 | 222a0f3139cf701cd34dd3796cdb4d61 |
|
BLAKE2b-256 | c3ea1f3aa47be43a22f60ae110de2c5ff34ca9c3a94070860e65d2dc8f1ac954 |
File details
Details for the file nameko_salesforce-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: nameko_salesforce-1.0.2-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b20ec292879b212bb4595bbf3b4d184a06fa196f592a7ce5956d7d3daf1c65d |
|
MD5 | 5c575e58f1a823b0d4afb6d7ef04c13b |
|
BLAKE2b-256 | f304fdee44f7635ff5193cfa3c352d38f97c4e58eede26e156e8c867b84b765a |