From 44ec05f6125d7dc47a9a83f7d444caf91885c87e Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Wed, 10 Apr 2024 15:14:56 -0500 Subject: [PATCH] Remove get_channel_events and get_definitions --- temba_client/v2/__init__.py | 25 --------------- temba_client/v2/tests.py | 63 ------------------------------------- temba_client/v2/types.py | 19 ----------- 3 files changed, 107 deletions(-) diff --git a/temba_client/v2/__init__.py b/temba_client/v2/__init__.py index 8ee20bd..b4b0678 100644 --- a/temba_client/v2/__init__.py +++ b/temba_client/v2/__init__.py @@ -6,10 +6,8 @@ Campaign, CampaignEvent, Channel, - ChannelEvent, Classifier, Contact, - Export, Field, Flow, FlowStart, @@ -101,18 +99,6 @@ def get_channels(self, uuid=None, address=None): params = self._build_params(uuid=uuid, address=address) return self._get_query("channels", params, Channel) - def get_channel_events(self, id=None, contact=None, before=None, after=None): - """ - Gets all matching channel events - :param id: event id - :param contact: contact object or UUID - :param datetime before: created before - :param datetime after: created after - :return: channel event query - """ - params = self._build_params(id=id, contact=contact, before=before, after=after) - return self._get_query("channel_events", params, ChannelEvent) - def get_classifiers(self, uuid=None): """ Gets all matching NLU classifiers @@ -139,17 +125,6 @@ def get_contacts(self, uuid=None, urn=None, group=None, deleted=None, before=Non ) return self._get_query("contacts", params, Contact) - def get_definitions(self, flows=(), campaigns=(), dependencies=None): - """ - Gets an export of specified definitions - :param flows: flow objects or UUIDs to include - :param campaigns: campaign objects or UUIDs to include - :param dependencies: whether to include dependencies - :return: definitions export - """ - params = self._build_params(flow=flows, campaign=campaigns, dependencies=dependencies) - return Export.deserialize(self._get_raw("definitions", params)) - def get_fields(self, key=None): """ Gets all matching contact fields diff --git a/temba_client/v2/tests.py b/temba_client/v2/tests.py index 80cb0b6..6b66f40 100644 --- a/temba_client/v2/tests.py +++ b/temba_client/v2/tests.py @@ -375,46 +375,6 @@ def test_get_classifiers(self, mock_request): self.assertRequest(mock_request, "get", "classifiers", params={"uuid": "09d23a05-47fe-11e4-bfe9-b8f6b119e9ab"}) - def test_get_channel_events(self, mock_request): - # check no params - mock_request.return_value = MockResponse(200, self.read_json("channel_events")) - - # check with no params - results = self.client.get_channel_events().all() - - self.assertRequest(mock_request, "get", "channel_events") - self.assertEqual(len(results), 2) - - self.assertEqual(results[0].id, 12345) - self.assertEqual(results[0].type, "in") - self.assertEqual(results[0].contact.uuid, "d33e9ad5-5c35-414c-abd4-e7451c69ff1d") - self.assertEqual(results[0].contact.name, "Frank McFlow") - self.assertEqual(results[0].channel.uuid, "9a8b001e-a913-486c-80f4-1356e23f582e") - self.assertEqual(results[0].channel.name, "Nexmo") - self.assertEqual(results[0].extra, {"foo": "bar"}) - self.assertEqual(results[0].occurred_on, datetime(2016, 1, 6, 15, 35, 3, 675716, tzone.utc)) - self.assertEqual(results[0].created_on, datetime(2016, 1, 6, 15, 33, 0, 813162, tzone.utc)) - - # check with all params - self.client.get_channel_events( - id=12345, - contact="5079cb96-a1d8-4f47-8c87-d8c7bb6ddab9", - after=datetime(2014, 12, 12, 22, 34, 36, 978123, tzone.utc), - before=datetime(2014, 12, 12, 22, 56, 58, 917123, tzone.utc), - ).all() - - self.assertRequest( - mock_request, - "get", - "channel_events", - params={ - "id": 12345, - "contact": "5079cb96-a1d8-4f47-8c87-d8c7bb6ddab9", - "after": "2014-12-12T22:34:36.978123Z", - "before": "2014-12-12T22:56:58.917123Z", - }, - ) - def test_get_contacts(self, mock_request): # check no params mock_request.return_value = MockResponse(200, self.read_json("contacts")) @@ -465,29 +425,6 @@ def test_get_contacts(self, mock_request): }, ) - def test_get_definitions(self, mock_request): - mock_request.return_value = MockResponse(200, self.read_json("definitions")) - - # check with all params - definitions = self.client.get_definitions( - flows=["04a4752b-0f49-480e-ae60-3a3f2bea485c", "ffce0fbb-4fe1-4052-b26a-91beb2ebae9a"], - campaigns=[], - dependencies=False, - ) - - self.assertRequest( - mock_request, - "get", - "definitions", - params={ - "flow": ["04a4752b-0f49-480e-ae60-3a3f2bea485c", "ffce0fbb-4fe1-4052-b26a-91beb2ebae9a"], - "campaign": [], - "dependencies": 0, - }, - ) - - self.assertEqual(definitions.version, "10.1") - def test_get_fields(self, mock_request): # check no params mock_request.return_value = MockResponse(200, self.read_json("fields")) diff --git a/temba_client/v2/types.py b/temba_client/v2/types.py index 5db6066..f1af8e5 100644 --- a/temba_client/v2/types.py +++ b/temba_client/v2/types.py @@ -103,16 +103,6 @@ class Device(TembaObject): created_on = DatetimeField() -class ChannelEvent(TembaObject): - id = IntegerField() - type = SimpleField() - contact = ObjectField(item_class=ObjectRef) - channel = ObjectField(item_class=ObjectRef) - extra = SimpleField() - occurred_on = DatetimeField() - created_on = DatetimeField() - - class Classifier(TembaObject): uuid = SimpleField() type = SimpleField() @@ -135,15 +125,6 @@ class Contact(TembaObject): last_seen_on = DatetimeField() -class Export(TembaObject): - version = SimpleField() - flows = ListField() - campaigns = ListField() - triggers = ListField() - fields = ListField() - groups = ListField() - - class Field(TembaObject): key = SimpleField() name = SimpleField()