Skip to content

Commit

Permalink
Add endpoints for Option contracts (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
levidurfee authored Dec 11, 2023
1 parent 577dfdf commit b3e734b
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Rest/Options/Contract.php
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);
}
}
13 changes: 13 additions & 0 deletions src/Rest/Options/Contracts.php
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);
}
}
27 changes: 27 additions & 0 deletions tests/Rest/Options/ContractTest.php
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');
}
}
27 changes: 27 additions & 0 deletions tests/Rest/Options/ContractsTest.php
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');
}
}

0 comments on commit b3e734b

Please sign in to comment.