Skip to content
This repository was archived by the owner on Aug 26, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ List of API methods to be covered by our client.
- [U] Create an app
- [U] Update an app
- [A] View devices
- View device
- ~~View device~~
- [U] Add a device
- Edit device
- [U] New session
Expand Down
13 changes: 11 additions & 2 deletions onesignalclient/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ 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
Expand Down Expand Up @@ -172,9 +174,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
Copy Markdown
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
Copy Markdown
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,12 @@ 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})

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

Expand Down
4 changes: 4 additions & 0 deletions onesignalclient/user_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ def view_apps(self):
def view_app(self, app_id):
endpoint = 'apps/%s' % (app_id)
return self.get(self._url(endpoint))

def view_device(self, player_id, app_id):
endpoint = 'players/%s?%s' % (player_id, app_id)
return self.get(self._url(endpoint))
8 changes: 8 additions & 0 deletions tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class BaseTest():
'uri': re.compile('%s/apps/(\w|\-)+' % (base_url)),
'status': codes.not_found
},
'test_view_device': {
'uri': re.compile('%s/players/(\w|\-)+' % (base_url)),
'body': '{"identifier": "ce777617da7f548fe7a9ab6febb56cf39fba6d2"}'
},
'test_view_device_not_found': {
'uri': re.compile('%s/players/(\w|\-)+' % (base_url)),
'status': codes.not_found
},
'test_create_notification': {
'method': responses.POST,
'uri': '%s/notifications' % (base_url),
Expand Down
8 changes: 8 additions & 0 deletions tests/test_user_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ def test_view_app(self, user_client, app_id):
def test_view_app_not_found(self, user_client, app_id):
with pytest.raises(HTTPError):
user_client.view_app(app_id)

def test_view_device(self, user_client, player_id_1, app_id):
device = user_client.view_device(player_id_1, app_id)
assert device.get('identifier', False)

def test_view_device_not_found(self, user_client, player_id_1, app_id):
with pytest.raises(HTTPError):
user_client.view_device(player_id_1, app_id)