Skip to main content

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:


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

    def create_contact(self, last_name, email_address):
    """ Create a contact in Salesforce
        {'LastName': last_name,'Email': email_address})

Create a config file with essential settings:

# config.yaml

AMQP_URI: 'pyamqp://guest:guest@localhost'
    SANDBOX: False

Run the service providing your Salesforce credentials:

  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.

Files for nameko-salesforce, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size nameko_salesforce-1.2.0-py3-none-any.whl (24.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size nameko-salesforce-1.2.0.tar.gz (19.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page