Skip to content

Commit

Permalink
[TOOLSLIBS-394] Attributes++ Listing and Lookup Support (#169)
Browse files Browse the repository at this point in the history
* adds attributes, email, and named_user information

* adds channel listing and lookup items

* unicode!
  • Loading branch information
aschuman0 authored Nov 3, 2021
1 parent c36a946 commit 2dc79d9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

---

Expand Down
32 changes: 30 additions & 2 deletions urbanairship/devices/devicelist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import logging

from urbanairship import common

logger = logging.getLogger("urbanairship")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 2dc79d9

Please sign in to comment.