1+ <?php
2+
3+ namespace Parse ;
4+
5+ /**
6+ * ParsePushStatus - Representation of PushStatus for push notifications
7+ *
8+ * @author Ben Friedman <ben@axolsoft.com>
9+ */
10+ class ParsePushStatus extends ParseObject
11+ {
12+ public static $ parseClassName = '_PushStatus ' ;
13+
14+ /**
15+ * Returns a push status object or null from an id
16+ *
17+ * @param string $id Id to get this push status by
18+ * @return ParsePushStatus|null
19+ */
20+ public static function getFromId ($ id )
21+ {
22+ try {
23+ // return the associated PushStatus object
24+ $ query = new ParseQuery (self ::$ parseClassName );
25+ return $ query ->get ($ id , true );
26+
27+ } catch (ParseException $ pe ) {
28+ // no push found
29+ return null ;
30+
31+ }
32+
33+ }
34+
35+ /**
36+ * Gets the time this push was sent at
37+ *
38+ * @return \DateTime
39+ */
40+ public function getPushTime ()
41+ {
42+ return new \DateTime ($ this ->get ("pushTime " ));
43+
44+ }
45+
46+ /**
47+ * Gets the query used to send this push
48+ *
49+ * @return ParseQuery
50+ */
51+ public function getPushQuery ()
52+ {
53+ $ query = $ this ->get ("query " );
54+
55+ // get the conditions
56+ $ queryConditions = json_decode ($ query , true );
57+
58+ // setup a query
59+ $ query = new ParseQuery (self ::$ parseClassName );
60+
61+ // set the conditions
62+ $ query ->_setConditions ($ queryConditions );
63+
64+ return $ query ;
65+
66+ }
67+
68+ /**
69+ * Gets the payload
70+ *
71+ * @return array
72+ */
73+ public function getPushPayload ()
74+ {
75+ return json_decode ($ this ->get ("payload " ), true );
76+
77+ }
78+
79+ /**
80+ * Gets the source of this push
81+ *
82+ * @return string
83+ */
84+ public function getPushSource ()
85+ {
86+ return $ this ->get ("source " );
87+
88+ }
89+
90+ /**
91+ * Gets the status of this push
92+ *
93+ * @return string
94+ */
95+ public function getPushStatus ()
96+ {
97+ return $ this ->get ("status " );
98+
99+ }
100+
101+ /**
102+ * Gets the number of pushes sent
103+ *
104+ * @return int
105+ */
106+ public function getPushesSent ()
107+ {
108+ return $ this ->get ("numSent " );
109+
110+ }
111+
112+ /**
113+ * Gets the hash for this push
114+ *
115+ * @return string
116+ */
117+ public function getPushHash ()
118+ {
119+ return $ this ->get ("pushHash " );
120+
121+ }
122+
123+ /**
124+ * Gets the number of pushes failed
125+ *
126+ * @return int
127+ */
128+ public function getPushesFailed ()
129+ {
130+ return $ this ->get ("numFailed " );
131+
132+ }
133+ }
0 commit comments