1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Betfair library. |
4
|
|
|
* |
5
|
|
|
* (c) Daniele D'Angeli <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace Betfair\BettingApi\MarketBook; |
11
|
|
|
|
12
|
|
|
use Betfair\AbstractBetfair; |
13
|
|
|
use Betfair\Adapter\AdapterInterface; |
14
|
|
|
use Betfair\Client\BetfairClientInterface; |
15
|
|
|
use Betfair\Factory\MarketFilterFactoryInterface; |
16
|
|
|
use Betfair\Factory\ParamFactoryInterface; |
17
|
|
|
use Betfair\Model\PriceProjection; |
18
|
|
|
|
19
|
|
|
class MarketBook extends AbstractBetfair |
20
|
|
|
{ |
21
|
|
|
const API_METHOD_NAME = "listMarketBook"; |
22
|
|
|
|
23
|
|
|
private $marketIds = []; |
24
|
|
|
private $priceProjection; |
25
|
|
|
private $orderProjection; |
26
|
|
|
private $matchProjection; |
27
|
|
|
private $currencyCode; |
28
|
|
|
private $locale; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param BetfairClientInterface $betfairClient |
32
|
|
|
* @param AdapterInterface $adapter |
33
|
|
|
* @param ParamFactoryInterface $paramFactory |
34
|
|
|
* @param MarketFilterFactoryInterface $marketFilterFactory |
35
|
|
|
*/ |
36
|
|
|
public function __construct( |
37
|
|
|
BetfairClientInterface $betfairClient, |
38
|
|
|
AdapterInterface $adapter, |
39
|
|
|
ParamFactoryInterface $paramFactory, |
40
|
|
|
MarketFilterFactoryInterface $marketFilterFactory |
41
|
|
|
) { |
42
|
|
|
parent::__construct($betfairClient, $adapter, $paramFactory, $marketFilterFactory); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getResults() |
46
|
|
|
{ |
47
|
|
|
$param = $this->createParam(); |
48
|
|
|
$param->setMarketIds($this->marketIds) |
49
|
|
|
->setPriceProjection($this->priceProjection) |
|
|
|
|
50
|
|
|
->setOrderProjection($this->orderProjection) |
51
|
|
|
->setMarketProjection($this->matchProjection) |
|
|
|
|
52
|
|
|
->setCurrencyCode($this->currencyCode) |
53
|
|
|
->setLocale($this->locale); |
54
|
|
|
|
55
|
|
|
$this->restoreDefaults(); |
56
|
|
|
return $this->executeCustomQuery($param, self::API_METHOD_NAME); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
View Code Duplication |
public function getMarketBookFilterByMarketIds(array $marketIds) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
$param = $this->createParam(); |
62
|
|
|
|
63
|
|
|
$param->setMarketIds($marketIds); |
64
|
|
|
|
65
|
|
|
$this->restoreDefaults(); |
66
|
|
|
|
67
|
|
|
return $this->adapter->adaptResponse( |
68
|
|
|
$this->apiNgRequest(self::API_METHOD_NAME, $param) |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
View Code Duplication |
public function getMarketBookFilterByMarketIdsWithPriceData(array $marketIds, array $priceData) |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
$param = $this->createParam(); |
75
|
|
|
|
76
|
|
|
$param->setMarketIds($marketIds) |
77
|
|
|
->setPriceProjection(new PriceProjection($priceData)); |
78
|
|
|
|
79
|
|
|
$this->restoreDefaults(); |
80
|
|
|
|
81
|
|
|
return $this->adapter->adaptResponse( |
82
|
|
|
$this->apiNgRequest(self::API_METHOD_NAME, $param) |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
View Code Duplication |
public function getMarketBookFilterByMarketIdsWithPriceProjection(array $marketIds, PriceProjection $priceProjection) |
|
|
|
|
87
|
|
|
{ |
88
|
|
|
$param = $this->createParam() |
89
|
|
|
->setMarketIds($marketIds) |
90
|
|
|
->setPriceProjection($priceProjection); |
91
|
|
|
|
92
|
|
|
$this->restoreDefaults(); |
93
|
|
|
|
94
|
|
|
return $this->adapter->adaptResponse( |
95
|
|
|
$this->apiNgRequest(self::API_METHOD_NAME, $param) |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function withMarketIds($marketIds) |
100
|
|
|
{ |
101
|
|
|
$this->marketIds = $marketIds; |
102
|
|
|
return $marketIds; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function withPriceProjection(PriceProjection $priceProjection) |
106
|
|
|
{ |
107
|
|
|
$this->priceProjection = $priceProjection; |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function withOrderProjection($orderProjection) |
112
|
|
|
{ |
113
|
|
|
$this->orderProjection = $orderProjection; |
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function withMatchProjection($matchProjection) |
118
|
|
|
{ |
119
|
|
|
$this->matchProjection = $matchProjection; |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function withCurrencyCode($currencyCode) |
124
|
|
|
{ |
125
|
|
|
$this->currencyCode = $currencyCode; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function withLocale($locale) |
130
|
|
|
{ |
131
|
|
|
$this->locale = $locale; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
private function restoreDefaults() |
135
|
|
|
{ |
136
|
|
|
$this->marketIds = null; |
|
|
|
|
137
|
|
|
$this->priceProjection = null; |
138
|
|
|
$this->orderProjection = null; |
139
|
|
|
$this->matchProjection = null; |
140
|
|
|
$this->currencyCode = null; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: