move-coop / parsons

A python library of connectors for the progressive community.
https://www.parsonsproject.org/
Other
258 stars 128 forks source link

feat: add nation builder connector #848

Closed gcollazo closed 1 year ago

gcollazo commented 1 year ago

NOTE: This is the second attempt at merging this feature. The first attempt had issues when running under Python 3.7.17. This new PR makes sure that the class types are compatible with that version of Python.


This PR adds a new Nation Builder connector.

The connector implements the following public methods:

Examples

The following examples help illustrate the API usage.

from dotenv import load_dotenv

from parsons.nation_builder.nation_builder import NationBuilder

load_dotenv()

nb = NationBuilder()

# get all people and return a Table
people_table = nb.get_people()
people_table.to_csv("nbexport.csv")

# update person by id
data = {"email": "foo@example.com", "tags": ["foo", "bar"]}
updated_person_1 = nb.update_person("123456789", data)

# update or create a person
data = {"email": "foo@example.com", "tags": ["dogs", "cats"]}
created, person = nb.upsert_person(data)

if created:
    print("Person created:", person)
else:
    print("Person updated:", person)