Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenField Class #1044

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
69 changes: 69 additions & 0 deletions docs/openfield.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
OpenField
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great but don't forget to add a link to the connector to the sidebar

=========

********
Overview
********

`OpenField <https://openfield.ai/>`_ is a canvassing and VPB tool for organizing and election campaigns.
`OpenField REST API <https://openfield.ai/wp-content/uploads/2024/02/redoc-static.html>`_

.. note::
Authentication
OpenField requires `HTTP Basic Auth <https://en.wikipedia.org/wiki/Basic_access_authentication>`_.
Clients with an OpenField account can obtain the domain, username, and password needed
to access the OpenField API.

**********
Quickstart
**********

To instantiate the OpenField class, you can either store your OpenField API
domain, username, and password as environmental variables (``OPENFIELD_DOMAIN``,
``OPENFIELD_USERNAME``, and ``OPENFIELD_PASSWORD``, respectively) or pass in your
domain, username, and password as arguments:

.. code-block:: python

from parsons import OpenField

# First approach: Use API credentials via environmental variables
openfield = OpenField()

# Second approach: Pass API credentials as arguments
openfield = OpenField(domain='myorg.openfield.ai', username='my_name', password='1234')

You can then call various endpoints:

.. code-block:: python

# Create a new person
person = {
"first_name": 'John',
"last_name": 'Smith',
"prov_city": 'Boston',
"prov_state": 'MA',
"prov_zip_5": '02108'
"email1": '[email protected]',
"phone1": '2345678901',
}
openfield.create_person(person=person)

# Fetch person
person = openfield.retrieve_person(person_id=123)

# Update person fields
data= {
"phone1": '5558765432',
}
updated_person = openfield.update_person(person_id=123, data=data)

# Delete person
openfield.destroy_person(person_id=123)

***
API
***

.. autoclass :: parsons.OpenField
:inherited-members:
1 change: 1 addition & 0 deletions parsons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
("parsons.mobilize_america.ma", "MobilizeAmerica"),
("parsons.nation_builder.nation_builder", "NationBuilder"),
("parsons.newmode.newmode", "Newmode"),
("parsons.openfield.openfield", "OpenField"),
("parsons.ngpvan.van", "VAN"),
("parsons.notifications.gmail", "Gmail"),
("parsons.notifications.slack", "Slack"),
Expand Down
3 changes: 3 additions & 0 deletions parsons/openfield/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from parsons.openfield.openfield import OpenField

__all__ = ["OpenField"]
Loading
Loading