|
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\Adapter\AdapterInterface; |
|
13
|
|
|
use Betfair\Client\BetfairClientInterface; |
|
14
|
|
|
use Betfair\Factory\MarketFilterFactoryInterface; |
|
15
|
|
|
use Betfair\Factory\ParamFactoryInterface; |
|
16
|
|
|
use Betfair\Model\MarketFilterInterface; |
|
17
|
|
|
use Betfair\Model\ParamInterface; |
|
18
|
|
|
|
|
19
|
|
|
abstract class AbstractBetfair |
|
20
|
|
|
{ |
|
21
|
|
|
const API_METHOD_NAME = "default"; |
|
22
|
|
|
|
|
23
|
|
|
protected $betfairClient; |
|
24
|
|
|
|
|
25
|
|
|
protected $endPointUrl; |
|
26
|
|
|
|
|
27
|
|
|
protected $adapter; |
|
28
|
|
|
|
|
29
|
|
|
protected $marketFilterFactory; |
|
30
|
|
|
|
|
31
|
|
|
protected $paramFactory; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param BetfairClientInterface $betfairClient |
|
35
|
|
|
* @param AdapterInterface $adapter |
|
36
|
|
|
* @param ParamFactoryInterface $paramFactory |
|
37
|
|
|
* @param MarketFilterFactoryInterface $marketFilterFactory |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct( |
|
40
|
|
|
BetfairClientInterface $betfairClient, |
|
41
|
|
|
AdapterInterface $adapter, |
|
42
|
|
|
ParamFactoryInterface $paramFactory, |
|
43
|
|
|
MarketFilterFactoryInterface $marketFilterFactory |
|
44
|
|
|
) { |
|
45
|
|
|
$this->betfairClient = $betfairClient; |
|
46
|
|
|
$this->adapter = $adapter; |
|
47
|
|
|
$this->marketFilterFactory = $marketFilterFactory; |
|
48
|
|
|
$this->paramFactory = $paramFactory; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function executeCustomQuery(ParamInterface $param, $method = null, $type = "betting") |
|
52
|
|
|
{ |
|
53
|
|
|
$method = $method !== null ? $method : $this::API_METHOD_NAME; |
|
54
|
|
|
$response = $this->apiNgRequest($method, $param, $type); |
|
55
|
|
|
return $this->adapter->adaptResponse($response); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param string $operation |
|
60
|
|
|
* @param ParamInterface $param |
|
61
|
|
|
* @param string $type |
|
62
|
|
|
* @internal param $params |
|
63
|
|
|
* @return mixed |
|
64
|
|
|
*/ |
|
65
|
|
|
public function apiNgRequest($operation, ParamInterface $param, $type = "betting") |
|
66
|
|
|
{ |
|
67
|
|
|
$requestContent = $this->betfairClient->apiNgRequest( |
|
68
|
|
|
$operation, |
|
69
|
|
|
$param, |
|
70
|
|
|
$type |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
return $requestContent; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function createMarketFilter() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->marketFilterFactory->create(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function createParam(MarketFilterInterface $marketFilter = null) |
|
82
|
|
|
{ |
|
83
|
|
|
$param = $this->paramFactory->create(); |
|
84
|
|
|
|
|
85
|
|
|
if ($marketFilter !== null) { |
|
86
|
|
|
$param->setMarketFilter($marketFilter); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return $param; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|