This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IQBuzz.php
91 lines (73 loc) · 1.93 KB
/
IQBuzz.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace wowkaster\iqbuzzapi;
use wowkaster\iqbuzzapi\interfaces\IQuery;
/**
* Class IQBuzz
*/
class IQBuzz {
/**
* @var string
*/
private $login;
/**
* @var string
*/
private $apiCode;
private $request;
/**
* @var IQuery
*/
private $queryObject;
public function __construct($login, $apiCode) {
$this->login = $login;
$this->apiCode = $apiCode;
$this->request = new IQBuzzRequest();
$this->request->setParam('login', $login);
$this->request->setParam('apiCode', $apiCode);
}
/**
* @param IQuery $object
* @return $this
*/
public function setQueryObject(IQuery $object) {
$this->queryObject = $object;
return $this;
}
/**
* @return IQBuzz
*/
public function getPrepare() {
$this->request->setUr($this->queryObject->getQueryUrl());
$this->request->setParam('login', $this->login);
$this->request->setParam('apiCode', $this->apiCode);
foreach($this->queryObject->getQueryParams() as $param => $value) {
$this->request->setParam($param, $value);
}
foreach ($this->queryObject->getCurlOptions() as $param => $value) {
$this->request->setOptions($param, $value);
}
return $this;
}
/**
* @return IQBuzzResponse
*/
public function getResult() {
return new IQBuzzResponse($this->request->getResult());
}
/**
* @return array
*/
public function getDebug() {
return array(
'url' => $this->queryObject->getQueryUrl(),
'params' => $this->queryObject->getParams(),
'queryParams' => array_merge(
array(
'login' => $this->login,
'apiCode' => $this->apiCode
),
$this->queryObject->getQueryParams()
)
);
}
}