Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Add url and send_after options #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions onesignalclient/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ def __init__(self, app_id, mode=SEGMENTS_MODE):
self.contents = {'en': 'Default message.'}
self.headings = {}
self.subtitle = {}
self.send_after = None
self.url = None
self.data = {}
self.small_icon = None
self.large_icon = None
self.ios_badge_type = self.IOS_BADGE_TYPE_NONE
self.ios_badge_count = 0
self.image = None

def _validate_content_dict(self, value):
"""
Expand All @@ -173,9 +175,10 @@ def get_payload_for_request(self):
payload = {
'app_id': self.app_id,
# Should change when template/content_available support be done
'contents': self.contents
'contents': self.contents,
'android_accent_color': 'FFE42D1F',
Copy link
Owner

@joaobarbosa joaobarbosa Sep 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making android_accent_color a property in the class?

}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unwanted space? 😬

# Mode related settings
if self.mode == self.DEVICES_MODE:
payload.update({'include_player_ids': self.include_player_ids})
Expand All @@ -189,6 +192,9 @@ def get_payload_for_request(self):
if len(self.subtitle) > 0:
payload.update({'subtitle': self.subtitle})

if self.send_after:
payload.update({'send_after': self.send_after})

if self.url:
payload.update({'url': self.url})

Expand All @@ -198,6 +204,15 @@ def get_payload_for_request(self):
if self.large_icon:
payload.update({'large_icon': self.large_icon})

if self.image:
payload.update({
'mutable_content': True,
'ios_attachments': {
'id': self.image
},
'big_picture': self.image
})

if self.ios_badge_count > 0:
payload.update({
'ios_badgeType': self.ios_badge_type,
Expand Down