Ejemplo n.º 1
0
def build_sf_dict():
	# Connect to SalesForce using my credentials
	while True:
		try:
			sf = Connection(username=sfuser, password=sfpassword,
							security_token=sftoken)
			report = sf.get_report(sfreport)
			print "Connection to SalesForce was successful, report opened successfully."
			parser = salesforce_reporting.ReportParser(report)
			# Return a dictionary of the Open Engineering Escalations Report
			dictionary = parser.records_dict()
			return dictionary
			break
		except:
			print "Connect to SalesForce was unsuccessful, trying to connect again."
			break
	def build_sf_dict(self):
		# Connect to SalesForce using my credentials
		while True:
			try:
				sf = Connection(username=sfuser, password=sfpassword,
								security_token=sftoken)

				report = sf.get_report(sfreport)
				print "Connection to SalesForce was successful, report opened successfully."

				parser = salesforce_reporting.ReportParser(report)
				# Return a dictionary of the Open Engineering Escalations Report
				dictionary = parser.records_dict()

				return dictionary
				break
			except:
				print "Connect to SalesForce was unsuccessful, trying to connect again."
				print("Unexpected error:", sys.exc_info()[0])
				break
def create_salesforce_client():
    """
    Create Salesforce Client using credential files
    """

    dirname = os.path.dirname(__file__)
    sf_creds = os.path.join(dirname, 'salesforce-creds.yaml')

    sf_creds_file = os.path.expanduser(sf_creds)
    with open(sf_creds_file) as f:
        sf_creds = yaml.safe_load(f)

    print(sf_creds)

    sf = Connection(username=sf_creds["username"],
                    password=base64.b64decode(sf_creds["password"]).decode(),
                    security_token=sf_creds["access_token"])

    return sf
Ejemplo n.º 4
0
import requests
import json
import openpyxl as xl
from salesforce_reporting import Connection, ReportParser
import datetime
import smtplib
from credentials import login

sf = Connection(username=login['sfEmail'],
                password=login['password'],
                security_token=login['token'])

excel_report_template = xl.load_workbook(
    '/Users/rubinj30/Google Drive/OB Sales Reports/OB-ISR-template.xlsx')

# get variables for API call and labeling Excel files
today_month = datetime.datetime.now().strftime('%m')
today_day = datetime.datetime.now().strftime('%d')
today_month_day = today_month + today_day
yesterday = datetime.datetime.now() - datetime.timedelta(days=1)
yesterday_month = yesterday.strftime('%m')
yesterday_day = yesterday.strftime('%d')
yesterday_year = yesterday.strftime('%Y')
yesterday_month_day = yesterday_month + '-' + yesterday_day

call_data_list = []
names = [
    'first_name last_name', 'first_name last_name', 'first_name last_name',
    'first_name last_name', 'first_name last_name'
]
url_for_api_call = f'https://my.vonagebusiness.com/appserver/rest/usersummarymetricsresource?chartType=summary&startDateInGMT=2017-{yesterday_month_day}T00:00:00Z&endDateInGMT=2017-{today_month+}-{today_day}T00:00:00Z&lineChartType=Total%20Calls&accountId=25016'
Ejemplo n.º 5
0
 def test_sandbox_url_with_different_api(self):
     self.assertEquals(Connection._get_login_url(True, 'v33.0'),
                       'https://test.salesforce.com/services/Soap/u/v33.0')
Ejemplo n.º 6
0
 def test_default_login_url(self):
     self.assertEquals(Connection._get_login_url(False, 'v29.0'),
                       'https://login.salesforce.com/services/Soap/u/v29.0')
Ejemplo n.º 7
0
import os
from pathlib import Path
from salesforce_reporting import Connection, ReportParser

from src.data.load_data import load_sf_reports
from src.data.prep_data import prep_data
from src.helpers.helpers import generate_date_files

load_dotenv()

SF_PASS = os.environ.get("SF_PASS")
SF_USERNAME = os.environ.get("SF_USERNAME")
SF_TOKEN = os.environ.get("SF_TOKEN")

sf = Connection(username=SF_USERNAME,
                password=SF_PASS,
                security_token=SF_TOKEN)

data_files = generate_date_files()

raw_data = Path(".") / "data" / "raw"


def main():
    load_sf_reports(data_files, sf, raw_data)
    prep_data(data_files)


if __name__ == "__main__":
    main()
Ejemplo n.º 8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
from salesforce_reporting import Connection
import salesforce_reporting
import os

sf = Connection(username='******',password='******', security_token="4fNUFqwEbGVP3NUiJo2Un33PY")

report = sf.get_report('00O1N0000091uFSUAY',details=True)
print(dir(sf.get_report))
parser = salesforce_reporting.ReportParser(report)

#print(parser._get_field_labels())
lines = parser.records()
#for i in items:
#    print (i

reportCsvFile = csv.writer(open(os.path.join(os.path.dirname(__file__), 'AndromacoContenido.csv'), 'a', encoding='UTF-8'))
reportCsvFile.writerows(lines)
Ejemplo n.º 9
0
 def test_sandbox_url_with_different_api(self):
     self.assertEquals(Connection._get_login_url(True, 'v33.0'),
                       'https://test.salesforce.com/services/Soap/u/v33.0')
Ejemplo n.º 10
0
 def test_default_login_url(self):
     self.assertEquals(
         Connection._get_login_url(False, 'v29.0'),
         'https://login.salesforce.com/services/Soap/u/v29.0')