nuxeo/mkto-pd-sync-app

Name: mkto-pd-sync-app

Owner: Nuxeo

Description: Flask application that synchronizes data between Marketo and Pipedrive.

Created: 2017-02-16 14:52:46.0

Updated: 2018-03-16 14:14:00.0

Pushed: 2018-03-16 14:13:59.0

Homepage:

Size: 964

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

MKTO-PD Sync App

Travis Build Status

MKTO-PD Sync App is a Flask application running on a Google App Engine that synchronizes data between marketing software Marketo and CRM Pipedrive.

Features

The application handles user requests asynchronously using task (push) queues.

                 app.yaml      Application       queue.yaml                       worker.yaml
                    +          enqueues task         +                                 +
                    |                +               |                                 |
         +----------+----------+     |     +---------+----------+           +----------+----------+
         |                     |     |     |                    |           |                     |
         |     Application     |     |     | Task Queue Service |           |       Worker        |
TP POST  |                     |     |     |                    | HTTP POST |                     |
--+----->+ +-----------------+ +-----+---->+ +----------------+ +---------->+ +-----------------+ |
  |      | |Flask Application| |           | |   Push Queue   | |           | |Flask Application| |
  |      | +-----------------+ +<----+-----+ +----------------+ +<----+-----+ +-----------------+ |
  |      +---------------------+     |     +--------------------+     |     +---------------------+
  |                                  |                                |                |
  +                                  +                                +                +
 calls API                     Returns task                        Returns   Worker executes task
                               name and ETA                        sync
                                                                   status
Marketo module

Simple Python client for the Marketo REST API.

Features

Lead, opportunities, roles and companies are classes that can be instantiated given a Marketo client instance.

All fields are loaded and available for reading and a defined subset for each entity is available for updating.

An entity also has an “id field” that will be used to match an existing entity.

An existing entity can be loaded given an identifier to the constructor and an eventual id field to look for different from its actual one which can be any exiting field for leads but should be a “searchable field” for opportunities, roles and companies.

An entity can be saved: it is then created or updated depending on if it matches an existing one.

An entity can be deleted.

Usage
rt sync.marketo as marketo

 = marketo.MarketoClient(IDENTITY_ENDPOINT, CLIENT_ID, CLIENT_SECRET, API_ENDPOINT)

t a lead by id
 = marketo.Lead(mkto, "12345")

t a lead by email
 = marketo.Lead(mkto, "lead@mail.com", "email")

date lead data
.firstName = "New Name"
.save()

lete lead
.delete()
Pipedrive module

Simple Python client for the Pipedrive REST API.

Features

People, organizations, deals and activities are classes that can be instantiated given a Pipedrive client instance.

All fields are loaded and available for reading and updating.

An existing entity can be loaded given an identifier or a name if the “id field” parameter is given as “name”. A lead can also be loaded given a custom filter a the “id field”. Currently supported filters are “email domain” and “marketo id”.

Custom fields can be read using the snake case display name rather than their hash key.

Some entities are related to other and can be loaded as well if so.

An entity can be saved: it is then created or updated depending on if it matches an existing one.

For related entities, only the association can be updated (no cascade update).

An entity can be deleted.

Usage
rt sync.pipedrive as pipedrive

 pipedrive.PipedriveClient(PD_API_TOKEN)

t a person by id
on = pipedrive.Person(pd, "12345")

t an organization by name
nization = pipedrive.Organization(pd, "MyCompany", "name")

t a person custom field with its nicer name
on.lead_score  # or getattr(person, {HASH KEY})

t a person related organization
nization = person.organization

date person data
on.name = "New Name"
on.save()

lete person
on.delete()
API reference

All requests to the API must be made over SSL (https not http) and validated against the prod key (see configuration).

List of endpoints

Actually synchronizes data if and only if it is new or it has changed.

Actually synchronizes data if and only if it is new or it has changed.

Actually synchronizes data if and only if it is new or it has changed.

Actually synchronizes data if and only if it is new or it has changed.

Mapping

A mapping file describes how Marketo and Pipedrive entity fields should be matched.

Structure
ING_NAME = {
to_field_key_1: {
    "fields": [from_field_key_1, [from_field_key_2...]],
    ["mode": "join"/"choose",]
    ["pre_adapter": function,]
    ["post_adapter": function]
},
to_field_key_2: {
    "transformer": function
}

Development
Requirements
Installation

Assuming you already have Python 2.7 installed:

Configuration

DEBUG and TESTING are logging control variables.

Running
appserver.py -A sync-app app.yaml worker.yaml  # Start the local development server
Testing

Marketo and Pipedrive clients are tested in the tests module but should not be continuously run as they actually call Marketo and Pipedrive APIs.

The application is also tested in this module where calls to the APIs have been mocked (see files in the resources folder under tests).

Launch the test:

rt GOOGLE_APP_ENGINE={PATH_TO_YOUR_GOOGLE_SDK}/platform/google_appengine
on -m tests.test_sync

To run the test in Eclipse, you must change the Working directory to Default (see this screenshot) and set an environment variable for GOOGLE_APP_ENGINE pointing to the directory where you extracted the SDK (see this other screenshot) in your configuration.

To run a single unit test in Eclipse you can use the keybinding CTRL + F9 while the file open.

Deployment

You can upload the application running the following command from within the root directory of the project (don't forget the config.py file):

ud app deploy app.yaml worker.yaml queue.yaml [--project [YOUR_PROJECT_ID]]

or

ud config set project marketo-1041
ud components update
ud app deploy app.yaml worker.yaml queue.yaml

Otherwise, this project is continuously delivered (tested and deployed) with Travis and triggered by a push to the master branch of this repository


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.