Skip to content

Commit

Permalink
Merge pull request #91 from rapidpro/remove_deprecated
Browse files Browse the repository at this point in the history
Remove deprecated `get_channel_events` and `get_definitions`
  • Loading branch information
rowanseymour authored Apr 10, 2024
2 parents 6a18ac8 + 44ec05f commit 3904f32
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 107 deletions.
25 changes: 0 additions & 25 deletions temba_client/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
Campaign,
CampaignEvent,
Channel,
ChannelEvent,
Classifier,
Contact,
Export,
Field,
Flow,
FlowStart,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
63 changes: 0 additions & 63 deletions temba_client/v2/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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"))
Expand Down
19 changes: 0 additions & 19 deletions temba_client/v2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 3904f32

Please sign in to comment.