1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace vasadibt\onesignal\service; |
4
|
|
|
|
5
|
|
|
use vasadibt\onesignal\resolver\ResolverFactory; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Apps |
9
|
|
|
* @package vasadibt\onesignal\service |
10
|
|
|
*/ |
11
|
|
|
class Apps extends Request |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* {@inheritdoc} |
15
|
|
|
*/ |
16
|
|
|
public $methodName = self::APPS; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Get information about application with provided ID. |
20
|
|
|
* |
21
|
|
|
* @param string $id ID of your application |
22
|
|
|
* |
23
|
|
|
* @return array |
24
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
25
|
|
|
* @throws \yii\web\BadRequestHttpException |
26
|
|
|
*/ |
27
|
|
|
public function getOne($id) |
28
|
|
|
{ |
29
|
|
|
return $this->get($id); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Get information about all your created applications. |
34
|
|
|
* |
35
|
|
|
* @return array |
36
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
37
|
|
|
* @throws \yii\web\BadRequestHttpException |
38
|
|
|
*/ |
39
|
|
|
public function getAll() |
40
|
|
|
{ |
41
|
|
|
return $this->get(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Create a new application with provided data. |
46
|
|
|
* |
47
|
|
|
* @param array $data Application data |
48
|
|
|
* |
49
|
|
|
* @return array |
50
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
51
|
|
|
* @throws \yii\web\BadRequestHttpException |
52
|
|
|
*/ |
53
|
|
|
public function add(array $data) |
54
|
|
|
{ |
55
|
|
|
return $this->post(null, ResolverFactory::createAppResolver()->resolve($data)); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Update application with provided data. |
60
|
|
|
* |
61
|
|
|
* @param string $id ID of your application |
62
|
|
|
* @param array $data New application data |
63
|
|
|
* |
64
|
|
|
* @return array |
65
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
66
|
|
|
* @throws \yii\web\BadRequestHttpException |
67
|
|
|
*/ |
68
|
|
|
public function update($id, array $data) |
69
|
|
|
{ |
70
|
|
|
return $this->put($id, ResolverFactory::createAppResolver()->resolve($data)); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|