Skip to content

Commit

Permalink
added market book price projections
Browse files Browse the repository at this point in the history
  • Loading branch information
danieledangeli committed Jan 8, 2015
1 parent f822d42 commit dec4d4e
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 408 deletions.
3 changes: 2 additions & 1 deletion src/Betfair/AbstractBetfair.php
Expand Up @@ -82,8 +82,9 @@ public function getAll($method)
return $this->adapter->adaptResponse($response);
}

public function executeCustomQuery(ParamInterface $param, $method)
public function executeCustomQuery(ParamInterface $param, $method = null)
{
$method = $method !== null ? $method : $this::METHOD;
$response = $this->doSportApiNgRequest($method, json_encode($param));
return $this->adapter->adaptResponse($response);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Betfair/Client/BetfairClient.php
Expand Up @@ -21,10 +21,10 @@ class BetfairClient implements BetfairClientInterface
/** @var BetfairJsonRpcClientInterface */
protected $httpClient;

public function __construct(CredentialInterface $credential, BetfairJsonRpcClientInterface $httpClientInterface)
public function __construct(CredentialInterface $credential, BetfairJsonRpcClientInterface $httpClientInterface = null)
{
$this->credential = $credential;
$this->httpClient = $httpClientInterface;
$this->httpClient = $httpClientInterface !== null ? $httpClientInterface : new JsonRpcClient();

}

Expand Down
4 changes: 2 additions & 2 deletions src/Betfair/Model/Param.php
Expand Up @@ -57,9 +57,9 @@ public function getMarketProjection()


/**
* @param MarketFilter $filter
* @param MarketFilterInterface $filter
*/
public function setFilter(MarketFilter $filter)
public function setFilter(MarketFilterInterface $filter)
{
$this->filter = $filter;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Betfair/Model/ParamInterface.php
Expand Up @@ -12,6 +12,5 @@

interface ParamInterface
{
public function getFilter();
public function getMaxResults();
public function jsonSerialize();
}
58 changes: 50 additions & 8 deletions src/Betfair/Model/ParamMarketBook.php
@@ -1,19 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: danieledangeli
* Date: 5/5/14
* Time: 5:04 AM
*/

namespace Betfair\Model;


class ParamMarketBook extends BetfairSerializable
class ParamMarketBook extends BetfairSerializable implements ParamInterface
{
/** @var array */
protected $marketIds;

protected $priceProjection;

/**
* @param array $marketIds
*/
Expand All @@ -30,4 +25,51 @@ public function getMarketIds()
return $this->marketIds;
}

public function addPriceProjection($priceProjection)
{
$this->priceProjection[] = $priceProjection;
}

/**
* @param mixed $priceProjection
*/
public function setPriceProjection($priceProjection)
{
$this->priceProjection = $priceProjection;
}

/**
* @return mixed
*/
public function getPriceProjection()
{
return $this->priceProjection;
}

/**
* (PHP 5 &gt;= 5.4.0)<br/>
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
*/
public function jsonSerialize()
{
$array = array();
$properties = get_object_vars($this);
foreach($properties as $key => $value) {
if(null !== $value) {
if($key == 'priceProjection') {
$priceProjections = new \stdClass;
$priceProjections->priceData = $value;
$array[$key] = $priceProjections;
} else {
$array[$key] = $value;
}
}

}

return $array;
}
}
30 changes: 30 additions & 0 deletions src/Betfair/Model/PriceProjection.php
@@ -0,0 +1,30 @@
<?php
/**
* This file is part of the Betfair library.
*
* (c) Daniele D'Angeli <dangeli88.daniele@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Betfair\Model;

abstract class PriceProjection
{
const SP_AVAILABLE = "SP_AVAILABLE";
const SP_TRADED = "SP_TRADED";
const EX_BEST_OFFERS = "EX_BEST_OFFERS";
const EX_ALL_OFFERS = "EX_ALL_OFFERS";
const EX_TRADED = "EX_TRADED";

public static function getAll()
{
return array(
self::SP_AVAILABLE,
self::SP_TRADED,
self::EX_BEST_OFFERS,
self::EX_ALL_OFFERS,
self::EX_TRADED,
);
}
}
39 changes: 0 additions & 39 deletions src/examples/Adapter/CustomAdapter.php

This file was deleted.

0 comments on commit dec4d4e

Please sign in to comment.