I'm brand new to Pythonista, and a fairly new Workflow user.
I'm trying to create a contact by passing certain data elements on the clipboard from a running workflow. Someone on the Workflow subreddit said that running a Pythonista script was the best way to do it, and offered the following code in a gist:
import contacts
import clipboard
import webbrowser
name = clipboard.get().split(',')
pers = contacts.Person()
pers.first_name = name[0]
pers.last_name = name[1]
contacts.add_person(pers)
contacts.save()
webbrowser.open('workflow://')
My use is focused on creating contacts that exclusively contain information about businesses. So what I want to do is create a Person() that contains:
- organization
- work address
** street
** city
** state
** zip - phone
** main_phone - URL
My modified code begins as follows:
import contacts
import clipboard
import webbrowser
name = clipboard.get().split('|')
pers = contacts.Person()
pers.organization = bytes(name[0], encoding='UTF-8')
But then I get hung up on how to create an address, because I don't understand how to create Person.address from just reading the docs and reading through this forum.
Thanks for any guidance you can provide.