diff --git a/temba_client/v2/__init__.py b/temba_client/v2/__init__.py index 85f6563..ac77748 100644 --- a/temba_client/v2/__init__.py +++ b/temba_client/v2/__init__.py @@ -39,17 +39,17 @@ def __init__(self, host, token, user_agent=None, verify_ssl=None, transformer=No # Fetch object operations # ================================================================================================================== - def get_archives(self, archive_type=None, period=None, before=None, after=None): + def get_archives(self, type=None, period=None, before=None, after=None): """ Gets all matching archives - :param str archive_type: "message" or "run" + :param str type: "message" or "run" :param str period: "daily" or "monthly" :param datetime before: created before :param datetime after: created after :return: archive query """ - params = self._build_params(archive_type=archive_type, period=period, before=before, after=after) + params = self._build_params(type=type, period=period, before=before, after=after) return self._get_query("archives", params, Archive) def get_boundaries(self, geometry=None): diff --git a/temba_client/v2/tests.py b/temba_client/v2/tests.py index 7db1fb4..a7088e7 100644 --- a/temba_client/v2/tests.py +++ b/temba_client/v2/tests.py @@ -178,7 +178,7 @@ def test_get_archives(self, mock_request): self.assertRequest(mock_request, "get", "archives") self.assertEqual(len(results), 4) - self.assertEqual(results[1].archive_type, "message") + self.assertEqual(results[1].type, "message") self.assertEqual(results[1].start_date, datetime(2018, 4, 1, 0, 0, tzinfo=tzone.utc)) self.assertEqual(results[1].period, "monthly") self.assertEqual(results[1].record_count, 10) @@ -187,7 +187,7 @@ def test_get_archives(self, mock_request): self.assertEqual(results[1].download_url, "http://s3-bucket.aws.com/my/archive.jsonl.gz") self.client.get_archives( - archive_type="message", + type="message", period="daily", after=datetime(2018, 1, 1, tzinfo=tzone.utc), before=datetime(2018, 5, 1, tzinfo=tzone.utc), @@ -198,7 +198,7 @@ def test_get_archives(self, mock_request): "get", "archives", params={ - "archive_type": "message", + "type": "message", "period": "daily", "after": "2018-01-01T00:00:00.000000Z", "before": "2018-05-01T00:00:00.000000Z", @@ -336,6 +336,7 @@ def test_get_channels(self, mock_request): self.assertEqual(results[0].name, "Android Phone") self.assertEqual(results[0].address, "+250788123123") self.assertEqual(results[0].country, "RW") + self.assertEqual(results[0].type, "android") self.assertEqual(results[0].device.name, "Nexus 5X") self.assertEqual(results[0].device.power_level, 99) self.assertEqual(results[0].device.power_status, "STATUS_DISCHARGING") diff --git a/temba_client/v2/types.py b/temba_client/v2/types.py index fb14545..651c48e 100644 --- a/temba_client/v2/types.py +++ b/temba_client/v2/types.py @@ -30,7 +30,7 @@ class FieldRef(TembaObject): class Archive(TembaObject): - archive_type = SimpleField() + type = SimpleField() start_date = DatetimeField() period = SimpleField() record_count = IntegerField() @@ -94,9 +94,11 @@ class Device(TembaObject): power_source = SimpleField() network_type = SimpleField() + uuid = SimpleField() name = SimpleField() address = SimpleField() + type=SimpleField() country = SimpleField() device = ObjectField(item_class=Device) last_seen = DatetimeField() diff --git a/test_files/v2/archives.json b/test_files/v2/archives.json index 7339499..1573bc8 100644 --- a/test_files/v2/archives.json +++ b/test_files/v2/archives.json @@ -3,7 +3,7 @@ "previous": null, "results": [ { - "archive_type": "run", + "type": "run", "start_date": "2018-04-01", "period": "monthly", "record_count": 1, @@ -12,7 +12,7 @@ "download_url": "http://s3-bucket.aws.com/my/archive.jsonl.gz" }, { - "archive_type": "message", + "type": "message", "start_date": "2018-04-01", "period": "monthly", "record_count": 10, @@ -21,7 +21,7 @@ "download_url": "http://s3-bucket.aws.com/my/archive.jsonl.gz" }, { - "archive_type": "message", + "type": "message", "start_date": "2018-03-01", "period": "monthly", "record_count": 100, @@ -30,7 +30,7 @@ "download_url": "http://s3-bucket.aws.com/my/archive.jsonl.gz" }, { - "archive_type": "run", + "type": "run", "start_date": "2018-03-01", "period": "monthly", "record_count": 1000, diff --git a/test_files/v2/channels.json b/test_files/v2/channels.json index f669123..79bfe1e 100644 --- a/test_files/v2/channels.json +++ b/test_files/v2/channels.json @@ -6,6 +6,7 @@ "uuid": "09d23a05-47fe-11e4-bfe9-b8f6b119e9ab", "name": "Android Phone", "address": "+250788123123", + "type": "android", "country": "RW", "device": { "name": "Nexus 5X", @@ -19,8 +20,9 @@ }, { "uuid": "9a8b001e-a913-486c-80f4-1356e23f582e", - "name": "Nexmo", + "name": "Vonage", "address": "+250788000001", + "type": "vonage", "country": "RW", "device": null, "last_seen": "2016-03-01T05:31:27.456000+00:00",