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

Add unique ID list creation to ActionNetwork handler #1241

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions parsons/action_network/action_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1946,3 +1946,20 @@ def get_unique_id_list(self, unique_id_list_id):
https://actionnetwork.org/docs/v2/unique_id_lists
"""
return self.api.get_request(f"unique_id_lists/{unique_id_list_id}")

def create_unique_id_list(self, list_name, unique_ids):
"""
`Args:`
list_name:
The name for the new list
unique_ids:
An array of unique IDs to upload
`Returns:`
A JSON response with the unique ID list details
`Documentation Reference`:
https://actionnetwork.org/docs/v2/unique_id_lists
"""
return self.api.post_request(
"unique_id_lists",
data=json.dumps({"name": list_name, "unique_ids": unique_ids}),
)
25 changes: 25 additions & 0 deletions test/test_action_network/test_action_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,13 @@ def setUp(self, m):
},
"event_id": "fake-id",
}
self.fake_unique_id_list = {
"name": "fake_list_name",
"unique_ids": [
"ee48622d-a584-46a4-b817-2e6f2e4bf51b",
"1b0012d2-214a-4188-9c82-08f21ee54b27",
],
}

# Advocacy Campaigns
self.fake_advocacy_campaigns = {
Expand Down Expand Up @@ -4320,3 +4327,21 @@ def test_get_unique_id_list(self, m):
self.an.get_unique_id_list("123"),
self.fake_unique_id_lists["_embedded"][list(self.fake_unique_id_lists["_embedded"])[0]],
)

@requests_mock.Mocker()
def test_create_unique_id_list(self, m):
m.post(
f"{self.api_url}/unique_id_lists",
text=json.dumps(
{
"name": self.fake_unique_id_list["name"],
"count": len(self.fake_unique_id_list["unique_ids"]),
}
),
)
self.assertEqual(
len(self.fake_unique_id_list["unique_ids"]),
self.an.create_unique_id_list(
self.fake_unique_id_list["name"], self.fake_unique_id_list["unique_ids"]
)["count"],
)
Loading