def get_conn(self):
        """
        Initialize a pardot instance.
        :param email:       The email address associated with the account.
        :type string:       string
        :param password:    The password associated with the account.
        :type string:       string
        :param user_key:    The issued user_key associated with the account.
        :type user_key:     string
        :param api_version: The version of the Pardot API that the account uses.
                            This is set on the account level within Pardot.
                            Possible values include:
                                - 3
                                - 4
        :type api_version:  integer
        """
        if self.pardot:
            return self.pardot

        self.connection = self.get_connection(self.conn_id)
        self.extras = self.connection.extra_dejson
        pardot = PardotAPI(email=self.extras['email'],
                           password=self.extras['password'],
                           user_key=self.extras['user_key'],
                           version=self.extras['api_version'])

        pardot.authenticate()
        self.pardot = pardot

        return pardot
def pardot_login():
  p = PardotAPI(
    email=PARDOT_EMAIL,
    password=PARDOT_PASS,
    user_key=PARDOT_API_KEY
  )

  p.authenticate()
  return p
Beispiel #3
0
    def setUp(self):
        self.pardot = PardotAPI(email=PARDOT_USER, password=PARDOT_PASSWORD, user_key=PARDOT_USER_KEY)
        self.pardot.authenticate()

        self.email_address = '*****@*****.**'
        self.first_name = 'Pickles'
        self.last_name = 'Zardnif'

        # Make sure there isn't an existing prospect in the test account.
        try:
            self.pardot.prospects.delete_by_email(email=self.email_address)
        except PardotAPIError as e:
            # Error code 4 is raised if the prospect doesn't exist.
            if e.err_code != 4:
                raise e
def get_client(config=None):
    global CLIENT
    if CLIENT is None:
        if not config:
            raise KeyError("Need to set config")

        sf_consumer_key = config["consumer_key"]
        sf_consumer_secret = config["consumer_secret"]
        sf_refresh_token = config["refresh_token"]
        business_unit_id = config["business_unit_id"]
        version = config.get("version", 3)

        CLIENT = PardotAPI(sf_consumer_key=sf_consumer_key,
                           sf_consumer_secret=sf_consumer_secret,
                           sf_refresh_token=sf_refresh_token,
                           business_unit_id=business_unit_id,
                           version=version)
    return CLIENT
Beispiel #5
0
    def setUp(self, delete=False):
        self.pardot = PardotAPI(email=PARDOT_USER,
                                password=PARDOT_PASSWORD,
                                user_key=PARDOT_USER_KEY,
                                version=3)
        self.pardot.authenticate()

        self.sample_record = {
            'email': '*****@*****.**',
            'first_name': 'Pickles',
            'last_name': 'Zardnif'
        }

        # Make sure there isn't an existing prospect in the test account.
        if delete:
            try:
                self.pardot.prospects.delete_by_email(
                    email=self.sample_record['email'])
            except PardotAPIError as e:
                # Error code 4 is raised if the prospect doesn't exist.
                if e.err_code != 4:
                    raise e
Beispiel #6
0
 def _auth_pardot_client(self):
     return PardotAPI(email=self.email,
                      password=self.password,
                      user_key=self.user_key)
Beispiel #7
0
import sys
from importlib import reload
reload(sys)
from pypardot.client import PardotAPI

visitor_id = sys.argv[1]
email = sys.argv[2]
password = sys.argv[3]
key = sys.argv[4]
list_id = '98751'
api_version = 3
p = PardotAPI(
  email=email,
  password=password,
  user_key=key,
  version=api_version
  )
p.authenticate()
visitor = p.visitors.read(visitor_id)['visitor']
prospect_id = visitor['prospect']['id']
is_a_member = p.listmemberships.read(list_id, prospect_id)
response = "Already a member"
if not is_a_member:
  response = p.listmemberships.create(list_id, prospect_id)
print(response)
Beispiel #8
0
 def setUp(self):
     self.pardot = PardotAPI(email=PARDOT_USER,
                             password=PARDOT_PASSWORD,
                             user_key=PARDOT_USER_KEY)
     self.pardot.authenticate()