forked from smsapi/smsapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
97 lines (67 loc) · 2.82 KB
/
Copy pathmodels.py
File metadata and controls
97 lines (67 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- coding: utf-8 -*-
from smsapi.models import Model
class PushShipment(Model):
def __init__(self, id=None, app_id=None, status=None, date_created=None,
scheduled_date=None, payload=None, summary=None,
dispatch_details=None, fallback=None, app=None):
super(PushShipment, self).__init__()
self.id = id
self.app_id = app_id
self.status = status
self.date_created = date_created
self.scheduled_date = scheduled_date
self.payload = payload
self.summary = summary
self.dispatch_details = dispatch_details
self.fallback = fallback
self.app = app
@classmethod
def from_dict(cls, data, **kwargs):
data.update({
'app': PushApp.from_dict(data.pop('app', {})),
'summary': PushShipmentSummary.from_dict(data.pop('summary', {})),
'payload': PushShipmentPayload.from_dict(data.pop('payload', {})),
'fallback': PushShipmentFallback.from_dict(data.pop('fallback', {})),
'dispatch_details': PushShipmentDispatchDetails.from_dict(data.pop('dispatch_details', {})),
})
return cls(**data)
class PushShipmentDispatchDetails(Model):
def __init__(self, channels=None, device_ids=None, device_type=None):
super(PushShipmentDispatchDetails, self).__init__()
self.device_type = device_type or []
self.device_ids = device_ids or []
self.channels = channels or []
class PushShipmentPayload(Model):
def __init__(self, alert=None, badge=None, sound=None, category=None,
content_available=None, title=None, uri=None):
super(PushShipmentPayload, self).__init__()
self.alert = alert
self.badge = badge
self.sound = sound
self.category = category
self.content_available = content_available
self.title = title
self.uri = uri
class PushApp(Model):
def __init__(self, id=None, name=None, icon=None):
super(PushApp, self).__init__()
self.id = id
self.name = name
self.icon = icon
class PushShipmentSummary(Model):
def __init__(self, points=None, recipients_count=None, error_code=None):
super(PushShipmentSummary, self).__init__()
self.points = points
self.recipients_count = recipients_count
self.error_code = error_code
class PushShipmentFallback(Model):
def __init__(self, message=None, from_=None, delay=None, status=None):
super(PushShipmentFallback, self).__init__()
self.message = message
self.from_ = from_
self.delay = delay
self.status = status
@classmethod
def from_dict(cls, data, **kwargs):
data['from_'] = data.pop('from', None)
return super(PushShipmentFallback, cls).from_dict(data, **kwargs)