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; |
11
|
|
|
|
12
|
|
|
use Betfair\AccountApi\AccountDetails; |
13
|
|
|
use Betfair\AccountApi\AccountFunds; |
14
|
|
|
use Betfair\Adapter\AdapterInterface; |
15
|
|
|
use Betfair\Adapter\ArrayRpcAdapter; |
16
|
|
|
use Betfair\BettingApi\MarketType\MarketType; |
17
|
|
|
use Betfair\BettingApi\Order\ClearedOrder; |
18
|
|
|
use Betfair\BettingApi\Order\CurrentOrder; |
19
|
|
|
use Betfair\BettingApi\Venues\Venues; |
20
|
|
|
use Betfair\Client\BetfairClientInterface; |
21
|
|
|
use Betfair\BettingApi\Competition\Competition; |
22
|
|
|
use Betfair\BettingApi\Country\Country; |
23
|
|
|
use Betfair\BettingApi\Event\Event; |
24
|
|
|
use Betfair\BettingApi\Event\EventType; |
25
|
|
|
use Betfair\Factory\MarketFilterFactory; |
26
|
|
|
use Betfair\Factory\ParamFactory; |
27
|
|
|
use Betfair\BettingApi\MarketBook\MarketBook; |
28
|
|
|
use Betfair\BettingApi\MarketCatalogue\MarketCatalogue; |
29
|
|
|
use Betfair\BettingApi\TimeRange\TimeRange; |
30
|
|
|
use Betfair\Model\ParamInterface; |
31
|
|
|
|
32
|
|
|
class Betfair |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Version. |
36
|
|
|
* @see http://semver.org/ |
37
|
|
|
*/ |
38
|
|
|
const VERSION = '1.0.0-dev'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The adapter to use. |
42
|
|
|
* |
43
|
|
|
* @var AdapterInterface |
44
|
|
|
*/ |
45
|
|
|
protected $adapter; |
46
|
|
|
|
47
|
|
|
/** @var BetfairClientInterface */ |
48
|
|
|
protected $betfairClient; |
49
|
|
|
|
50
|
|
|
/** @var \Betfair\BetfairGeneric */ |
51
|
|
|
protected $genericBetfair; |
52
|
|
|
|
53
|
|
|
/** @var \Betfair\Factory\ParamFactory */ |
54
|
|
|
protected $paramFactory; |
55
|
|
|
|
56
|
|
|
/** @var \Betfair\Factory\MarketFilterFactory */ |
57
|
|
|
protected $marketFilterFactory; |
58
|
|
|
|
59
|
|
|
/** @var BetfairGeneric */ |
60
|
|
|
protected $betfairGeneric; |
61
|
|
|
|
62
|
|
|
public function __construct( |
63
|
|
|
BetfairClientInterface $client, |
64
|
|
|
AdapterInterface $adapter = null |
65
|
|
|
) { |
66
|
|
|
$this->betfairClient = $client; |
67
|
|
|
$this->adapter = (null !== $adapter) ? $adapter : new ArrayRpcAdapter(); |
68
|
|
|
$this->paramFactory = new ParamFactory(); |
69
|
|
|
$this->marketFilterFactory = new MarketFilterFactory(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function api(ParamInterface $param, $method) |
73
|
|
|
{ |
74
|
|
|
$betfairGeneric = $this->getBetfairGeneric(); |
75
|
|
|
return $betfairGeneric->executeCustomQuery($param, $method); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return BetfairGeneric |
80
|
|
|
*/ |
81
|
|
|
public function getBetfairGeneric() |
82
|
|
|
{ |
83
|
|
|
$this->betfairGeneric = new BetfairGeneric($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
84
|
|
|
return $this->betfairGeneric; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return EventType |
89
|
|
|
*/ |
90
|
|
|
public function getBetfairEventType() |
91
|
|
|
{ |
92
|
|
|
return new EventType($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return Event |
97
|
|
|
*/ |
98
|
|
|
public function getBetfairEvent() |
99
|
|
|
{ |
100
|
|
|
return new Event($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return MarketCatalogue |
105
|
|
|
*/ |
106
|
|
|
public function getBetfairMarketCatalogue() |
107
|
|
|
{ |
108
|
|
|
return new MarketCatalogue($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return MarketBook |
113
|
|
|
*/ |
114
|
|
|
public function getBetfairMarketBook() |
115
|
|
|
{ |
116
|
|
|
return new MarketBook($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return Country |
121
|
|
|
*/ |
122
|
|
|
public function getBetfairCountry() |
123
|
|
|
{ |
124
|
|
|
return new Country($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return Competition |
129
|
|
|
*/ |
130
|
|
|
public function getBetfairCompetition() |
131
|
|
|
{ |
132
|
|
|
return new Competition($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return TimeRange |
137
|
|
|
*/ |
138
|
|
|
public function getBetfairTimeRange() |
139
|
|
|
{ |
140
|
|
|
return new TimeRange($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return MarketType |
145
|
|
|
*/ |
146
|
|
|
public function getBetfairMarketType() |
147
|
|
|
{ |
148
|
|
|
return new MarketType($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return ClearedOrder |
153
|
|
|
*/ |
154
|
|
|
public function getBetfairClearedOrder() |
155
|
|
|
{ |
156
|
|
|
return new ClearedOrder($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return CurrentOrder |
161
|
|
|
*/ |
162
|
|
|
public function getBetfairCurrentOrder() |
163
|
|
|
{ |
164
|
|
|
return new CurrentOrder($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function getVenues() |
168
|
|
|
{ |
169
|
|
|
return new Venues($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function getBetfairAccountFunds() |
173
|
|
|
{ |
174
|
|
|
return new AccountFunds($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function getBetfairAccountDetails() |
178
|
|
|
{ |
179
|
|
|
return new AccountDetails($this->betfairClient, $this->adapter, $this->paramFactory, $this->marketFilterFactory); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|