-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientZagruzka.php
73 lines (56 loc) · 1.35 KB
/
ClientZagruzka.php
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
<?php
/**
* Created by PhpStorm.
* User: Ignatenkov Nikita
* Site: http://ignatenkovnikita.ru/
* Date: 04.07.2016
* Time: 16:25
*/
namespace sevenfloor\zagruzka;
use yii\base\Component;
use yii\helpers\ArrayHelper;
use yii\httpclient\Client;
class ClientZagruzka extends Component
{
/** @var string */
public $url;
/** @var string */
public $login;
/** @var string */
public $pass;
/** @var string */
public $urlCallback;
/** @var \yii\httpclient\Client $_client */
private $_client;
public function init()
{
$this->_client = new Client(['baseUrl' => $this->url]);
parent::init(); // TODO: Change the autogenerated stub
}
private function send($url, $data)
{
$params = ArrayHelper::merge([
'login' => $this->login,
'pass' => $this->pass,
], $data);
return $this->_client->get($url, $params)->send();
}
public function pay($phone, $sum)
{
$data = [
'phone' => $phone,
'sum' => $sum
];
$response = $this->send('api', $data);
if ($response->isOk) {
return $response;
}
}
public function balance()
{
$response = $this->send('balance', []);
if ($response->isOk) {
return $response->getData();
}
}
}