def djangoClient(nombre, lat, long, user): nombre = nombre lat = lat long = long user = user c = api.OAuthClient( client_id, client_secret, username, password, ) c.Item.create(app_id, item(nombre, lat, long, user)) return c
def __init__(self, username): try: podio_details = PodioKey.objects.get(podio_user__user_name='%s' % username) self.auth = api.OAuthClient( podio_details.client_id, podio_details.client_secret, podio_details.podio_user.user_name, podio_details.podio_user.user_password, ) except PodioKey.DoesNotExist: self.auth = None except transport.TransportException: self.auth = None
def main(): API = api.OAuthClient(client_settings.client_id, client_settings.client_secret, client_settings.username, client_settings.password) for org in API.Org.get_all(): logging.info(org['url']) for space in API.Space.find_all_for_org(org['org_id']): logging.info(space['url']) apps = {} for app in API.Application.list_in_space(space['space_id']): logging.info(app['url']) items = API.Application.get_items(app['app_id'], limit=500) apps[app['config']['name']] = items['items'] for item in items['items']: logging.info(item['link']) if apps.get('Mediaplan') and apps.get('Campaign'): stats = calc_statistic(apps.get('Mediaplan'), apps.get('Campaign')) return stats
def approveAndCreate(): client_id = 'fors' client_secret = '9W0pxSqKo61LG4qTToZrw9Dc41ICbtppjq1066yrt5i6bwKBx9nagxqCZi9VU19f' username = emailAddress password = userPassword searchFor = {"query": compName, "ref_type": 'item', "search_fields": 'title'} phoneNumberString = str(phNumber) phoneArray = [phoneNumberString] contactValues = {'name': name, 'phone': phoneArray} podio = api.OAuthClient( client_id, client_secret, username, password, ) found = podio.Search.searchApp(8014787, searchFor) foundString = str(found) foundRightString = foundString.find(compName) contactValues = {'name': name, 'phone': phoneArray} if foundRightString == -1: destroyErrorMessage() profileID = podio.Contact.create(2209982, contactValues) values = {'fields': {62123631: compName, 62124685: orgNumber, 62124688: [122654776, 177185617], 62124687: profileID['profile_id'], 62124690: 8, 62124689: 1, 62124686: location, 62128871: 18 }} podio.Item.create(8014787, values) print(foundRightString) else: defineErrorMessage("Företaget finns redan i Podio") print(foundString) print(foundRightString)
# coding=utf-8 client_id = "podio-translations-puller" client_secret = "EQQS1IAeRzTesrVLb4KQSekVdra8lHoqOHScFhnosakjxKvrnMD40Eq7bO03XTkt" username = "******" password = "******" from pypodio2 import api #create empty lists engTranslations = [] dutTranslations = [] espTranslations = [] sloTranslations = [] client = api.OAuthClient(client_id, client_secret, username, password) #Create empty class for translation items class TranslationItem: def __init__(self, key, value): self.key = key self.value = value #Loop through items to find relevant data translations = client.Application.get_items(23043195, limit=500) for item in translations['items']: engTranslation = TranslationItem('', '') #Set empty objects with two parameters into which the keys and values will be written dutTranslation = TranslationItem('', '') espTranslation = TranslationItem('', '') sloTranslation = TranslationItem('', '') for field in item['fields']: for value in field['values']:
def _get_user_client(self): """ Gets a client item from pypodio, from the app_id given to the podioApi object when it was created. Optionally it receives an app_token; in that case it doesn't need to fetch it from the database """ return api.OAuthClient(settings.CLIENT_ID, settings.CLIENT_SECRET, settings.USER, settings.PASSWORD)
def main(): #set the log file, extfile and load the CSV file (filename) passed from main notNamedG.logfile = sys.argv[2] extfile = sys.argv[1] import re, StringIO, csv notNamedG.log('reading ext data') #function that pulls data from our proprietary database notNamedG.vars = extvalue_import_dat() #This is setting the results of the query to local variables to push #All should be text fields full_name = notNamedG.vars['TAS_FROM'] email = notNamedG.vars['EMAIL'] phone = notNamedG.vars['PHONE'] address = notNamedG.vars['ADDRESS_1']+ " " + notNamedG.vars['CITY'] + " " + notNamedG.vars['STATE'] + " " + notNamedG.vars['ZIP'] nature = notNamedG.vars['NATURE'] interest = notNamedG.vars['INTEREST'] how_heard = notNamedG.vars['HOW_HEARD'] project = notNamedG.vars['PROJECT'] occupied = notNamedG.vars['OCCUPIED'] subject = notNamedG.vars['REASON'] #Making sure no blank fields are put in, they will crash the API push if full_name == "": full_name = "N/A" if email == "": email = "N/A" if phone == "": phone = "N/A" if address == "": address = "N/A" if subject == "": subject = "N/A" if interest == "": interest = "N/A" if project == "Z.OTHER": project = "OTHER" #They hava a typo, unfortunately I have to match it. if project == "RETAIL": project = "RETIAL" if how_heard == "Z.OTHER": how_heard = "OTHER" #in their coding, the "Advertisement" option has a trailing space, leading to sync errors #I add the space here to create a match. if how_heard == "ADVERTISEMENT": how_heard = "ADVERTISEMENT " #The following information is given by client, as they set me up in their system. client_id = "" client_secret = "" username="" password="" app_id = try: #Opening up the connection to Podio push_API = api.OAuthClient( client_id, client_secret, username, password, ) #creating a new item with fields #If fields change, we can go to Podio and search the app number item = { "fields":{ "full-name-2":full_name, "description":interest, "address":address, "email":email, "subject":subject, "phone":phone, "nature-of-inquiry":nature, "will-the-project-worksite-be-occupied":occupied, "how-did-you-hear-about-us":how_heard, "category":project} } #Pushing the item to their Podio App push_API.Item.create(app_id, item) notNamedG.log ("API Push Successful") webbrowser.open("http://portal.westparkcom.net/134/goodpage.asp",new=2) time.sleep(5) except Exception, e: exc_type, exc_value, exc_traceback = sys.exc_info() #notNamedG.log ( 'Error: message: ' + order_num ) notNamedG.log ( '!!!!! Shutting down - uncaught exception:\n{0}'.format ( '\n'.join(traceback.format_exception(exc_type, exc_value, exc_traceback)) ) ) webbrowser.open("http://portal.westparkcom.net/134/badpage.asp",new=2) #notNamedG.log ("Error:") return 1
def __init__(self, cid=client_id, cs=client_secret, uname=username, passwd=password): self.con = api.OAuthClient(cid,cs,uname,password)