-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoints for Option contracts (#18)
- Loading branch information
1 parent
577dfdf
commit b3e734b
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace PolygonIO\Rest\Options; | ||
|
||
use PolygonIO\Rest\RestResource; | ||
|
||
class Contract extends RestResource | ||
{ | ||
public function get($optionsTicker, $params = []): array | ||
{ | ||
return $this->_get('/v3/reference/options/contracts/' . $optionsTicker, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace PolygonIO\Rest\Options; | ||
|
||
use PolygonIO\Rest\RestResource; | ||
|
||
class Contracts extends RestResource | ||
{ | ||
public function get($params = []): array | ||
{ | ||
return $this->_get('/v3/reference/options/contracts', $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace PolygonIO\Tests\Rest\Options; | ||
|
||
use PolygonIO\Rest\Options\Contract; | ||
use PolygonIO\Tests\Concerns\MocksHttp; | ||
|
||
class ContractTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
use MocksHttp; | ||
|
||
public function testContractGetCall() | ||
{ | ||
$requestsContainer = []; | ||
|
||
$contract = new Contract('fake-api-key'); | ||
$contract->httpClient = $this->getHttpMock( | ||
$requestsContainer, [ | ||
'results' => [], | ||
] | ||
); | ||
|
||
$contract->get('O:EVRI240119C00002500'); | ||
|
||
$this->assertPath($requestsContainer, '/v3/reference/options/contracts/O:EVRI240119C00002500'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace PolygonIO\Tests\Rest\Options; | ||
|
||
use PolygonIO\Rest\Options\Contracts; | ||
use PolygonIO\Tests\Concerns\MocksHttp; | ||
|
||
class ContractsTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
use MocksHttp; | ||
|
||
public function testContractGetCall() | ||
{ | ||
$requestsContainer = []; | ||
|
||
$contract = new Contracts('fake-api-key'); | ||
$contract->httpClient = $this->getHttpMock( | ||
$requestsContainer, [ | ||
'results' => [], | ||
] | ||
); | ||
|
||
$contract->get(); | ||
|
||
$this->assertPath($requestsContainer, '/v3/reference/options/contracts'); | ||
} | ||
} |