From 2dc79d9b41daa6e456a9751fced1f2f42d12fb4b Mon Sep 17 00:00:00 2001 From: Aaron Schuman Date: Wed, 3 Nov 2021 15:40:37 -0700 Subject: [PATCH] [TOOLSLIBS-394] Attributes++ Listing and Lookup Support (#169) * adds attributes, email, and named_user information * adds channel listing and lookup items * unicode! --- CHANGELOG | 3 ++- urbanairship/devices/devicelist.py | 32 ++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e2a960b..36efd0b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ - Adds iOS platform options for: interruption_level, relevance_score, and target_content_id - Adds amazon platform options for: notification_tag, notification_channel, icon, icon_color +- Adds attributes, device_attributes, named_user_id, commercial_opted_in, commercial_opted_out, transactional_opted_in, transactional_opted_out to channel look up and listing. - Adds support for setting attributes on channel ids and named user ids - Adds support for removing attributes from channel ids and named user ids @@ -45,7 +46,7 @@ ## 5.3.1 -- Fixes an issue where SegmentsList URL was not being bulit properly. +- Fixes an issue where SegmentsList URL was not being built properly. --- diff --git a/urbanairship/devices/devicelist.py b/urbanairship/devices/devicelist.py index 700587d..23ee3c3 100644 --- a/urbanairship/devices/devicelist.py +++ b/urbanairship/devices/devicelist.py @@ -1,5 +1,6 @@ import datetime import logging + from urbanairship import common logger = logging.getLogger("urbanairship") @@ -29,7 +30,20 @@ class ChannelInfo(object): :ivar open: Open channel specific information, e.g. ``identifiers`` and ``open_platform_name``. :ivar web: Web notify specific information, e.g. ``subscription``. - + :ivar named_user_id: A customer-chosen ID that represents the device user. + :ivar device_attributes: Native attribute properties that Airship gathers + automatically assigns to a channel. Varies by channel type. + :ivar attributes: A dictionary of attributes that you've associated with the + channel. + :ivar commercial_opted_in: The date-time when a user gave explicit permission + to receive commercial emails. + :ivar commcercial_opted_out: The date-time when a user explicitly denied permission + to receive commercial emails. + :ivar transactional_opted_in: The date-time when a user gave explicit permission to + receive transactional emails. Users do not need to opt-in to receive + transactional emails unless they have previously opted out. + :ivar transactional_opted_out: The date-time when a user explicitly denied + permission to receive transactional emails. """ airship = None @@ -48,6 +62,13 @@ class ChannelInfo(object): ios = None open = None web = None + named_user_id = None + device_attributes = None + attributes = None + commercial_opted_in = None + commercial_opted_out = None + transactional_opted_in = None + transactional_opted_out = None def __init__(self, airship): self.airship = airship @@ -60,7 +81,14 @@ def from_payload(cls, payload, device_key, airship): if airship: obj.airship = airship for key in payload: - if key in ("created", "last_registration"): + if key in ( + "created", + "last_registration", + "commercial_opted_in", + "commercial_opted_out", + "transactional_opted_in", + "transactional_opted_out", + ): try: payload[key] = datetime.datetime.strptime( payload[key], "%Y-%m-%dT%H:%M:%S"