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

Remove entity from campaign method #1140

Merged
merged 4 commits into from
Oct 12, 2024
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
20 changes: 20 additions & 0 deletions parsons/action_builder/action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,26 @@ def update_entity_record(self, identifier, data, campaign=None):

return self._upsert_entity(data=data, campaign=campaign)

def remove_entity_record_from_campaign(self, identifier, campaign=None):
"""
Remove an entity record from a campaign. Records cannot be permanently deleted, but a
record that has been removed from a campaign will not appear in the UI.
`Args:`
identifier: str
The unique identifier for the record being removed. ID strings will need to begin
with the origin system, followed by a colon, e.g. `action_builder:abc123-...`.
campaign: str
Optional. The 36-character "interact ID" of the campaign whose data is to be
retrieved or edited. Not necessary if supplied when instantiating the class.
`Returns:`
Dict with HTTP response.
"""

campaign = self._campaign_check(campaign)

url = f"campaigns/{campaign}/people/{identifier}"
return self.api.delete_request(url=url)

def add_section_field_values_to_record(self, identifier, section, field_values, campaign=None):
"""
Add one or more tags (i.e. custom field value) to an existing entity record in Action
Expand Down
14 changes: 14 additions & 0 deletions test/test_action_builder/test_action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,20 @@ def test_update_entity_record(self, m):

self.assertEqual(person_comp, update_response_comp)

@requests_mock.Mocker()
def test_remove_entity_record_from_campaign(self, m):
m.delete(
f"{self.api_url}/people/{self.fake_entity_id}",
json="{'message': 'Entity has been removed from the campaign'}",
)

remove_response = self.bldr.remove_entity_record_from_campaign(self.fake_entity_id)

self.assertEqual(
remove_response,
"{'message': 'Entity has been removed from the campaign'}",
)

def tagging_callback(self, request, context):
# Internal method for returning the constructed tag data to test

Expand Down
Loading