Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BaseRequest.php #10

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"type": "library",
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"php": "^8.1",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0.1",
"illuminate/support": "8.*"
"illuminate/support": "*",
"guzzlehttp/guzzle": "^7.4"
},
"require-dev": {
"orchestra/testbench": "6.*",
"phpunit/phpunit": "^9.3.3"
"orchestra/testbench": "7.*",
"phpunit/phpunit": "^9.5"
},
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion config/fmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
|
*/

'base_url' => env('FMP_BASE_URL', 'https://financialmodelingprep.com/api/v3/'),
'base_url' => env('FMP_BASE_URL', 'https://financialmodelingprep.com/api/'),

];
4 changes: 2 additions & 2 deletions src/Calendars/DividendCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class DividendCalendar extends BaseRequest
{
const ENDPOINT = 'stock_dividend_calendar?';
const ENDPOINT = 'v3/stock_dividend_calendar?';

private $query_string = array();

Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct(Fmp $api)
*/
protected function getFullEndpoint(): string
{
return self::ENDPOINT.http_build_query($this->query_string);
return self::ENDPOINT . http_build_query($this->query_string);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Calendars/EarningsCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class EarningsCalendar extends BaseRequest
{
const ENDPOINT = 'earning_calendar?';
const ENDPOINT = 'v3/earning_calendar?';

private $query_string = array();

Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct(Fmp $api)
*/
protected function getFullEndpoint(): string
{
return self::ENDPOINT.http_build_query($this->query_string);
return self::ENDPOINT . http_build_query($this->query_string);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Calendars/EconomicCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class EconomicCalendar extends BaseRequest
{
const ENDPOINT = 'economic_calendar?';
const ENDPOINT = 'v3/economic_calendar?';

private $query_string = array();

Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct(Fmp $api)
*/
protected function getFullEndpoint(): string
{
return self::ENDPOINT.http_build_query($this->query_string);
return self::ENDPOINT . http_build_query($this->query_string);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Calendars/HistoricalEarningsCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class HistoricalEarningsCalendar extends BaseRequest
{
const ENDPOINT = 'historical/earning_calendar/{symbol}?';
const ENDPOINT = 'v3/historical/earning_calendar/{symbol}?';

private $query_string = array();

Expand Down
4 changes: 2 additions & 2 deletions src/Calendars/IpoCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class IpoCalendar extends BaseRequest
{
const ENDPOINT = 'ipo_calendar?';
const ENDPOINT = 'v3/ipo_calendar?';

private $query_string = array();

Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct(Fmp $api)
*/
protected function getFullEndpoint(): string
{
return self::ENDPOINT.http_build_query($this->query_string);
return self::ENDPOINT . http_build_query($this->query_string);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Calendars/StockSplitCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class StockSplitCalendar extends BaseRequest
{
const ENDPOINT = 'stock_split_calendar?';
const ENDPOINT = 'v3/stock_split_calendar?';

private $query_string = array();

Expand Down Expand Up @@ -40,7 +40,7 @@ public function __construct(Fmp $api)
*/
protected function getFullEndpoint(): string
{
return self::ENDPOINT.http_build_query($this->query_string);
return self::ENDPOINT . http_build_query($this->query_string);
}

/**
Expand Down
31 changes: 15 additions & 16 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
class Client implements Fmp
{
/**
* @var Guzzle|null
*/
* @var Guzzle|null
*/
private $client = null;

/**
* Client constructor.
*
* @param Guzzle $client
*/
* Client constructor.
*
* @param Guzzle $client
*/
public function __construct(Guzzle $client)
{
$this->client = $client;
}

/**
* @param RequestInterface $request
* @param array $options
*
* @return ResponseInterface
* @throws GuzzleException
* @throws InvalidData
*/
* @param RequestInterface $request
* @param array $options
*
* @return ResponseInterface
* @throws GuzzleException
* @throws InvalidData
*/
public function send(RequestInterface $request, array $options = []): ResponseInterface
{
try {
Expand All @@ -43,9 +43,8 @@ public function send(RequestInterface $request, array $options = []): ResponseIn
return $this->client->send($request, [
'query' => array_merge($this->client->getConfig('query') ?? [], $query)
]);
}
catch (ClientException $e) {
throw InvalidData::invalidValuesProvided($e->getMessage());
} catch (ClientException $e) {
throw InvalidData::invalidDataProvided($e->getMessage());
}
}
}
2 changes: 1 addition & 1 deletion src/CompanyValuation/CountriesList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class CountriesList extends BaseRequest
{
const ENDPOINT = 'get-all-countries';
const ENDPOINT = 'v3/get-all-countries';

/**
* Create constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/CompanyValuation/DiscountedCashFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class DiscountedCashFlow extends BaseRequest
{
const ENDPOINT = 'discounted-cash-flow/{symbol}';
const ENDPOINT = 'v3/discounted-cash-flow/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/EarningsSurprises.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class EarningsSurprises extends BaseRequest
{
const ENDPOINT = 'earnings-surpises/{symbol}';
const ENDPOINT = 'v3/earnings-surpises/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/EtfsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class EtfsList extends BaseRequest
{
const ENDPOINT = 'etf/list';
const ENDPOINT = 'v3/etf/list';

/**
* Create constructor.
Expand All @@ -27,4 +27,4 @@ protected function getFullEndpoint(): string
{
return self::ENDPOINT;
}
}
}
66 changes: 66 additions & 0 deletions src/CompanyValuation/HistoricalPriceFull.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Leijman\FmpApiSdk\CompanyValuation;

use Leijman\FmpApiSdk\Contracts\Fmp;
use Leijman\FmpApiSdk\Exceptions\InvalidData;
use Leijman\FmpApiSdk\Requests\BaseRequest;

class HistoricalPriceFull extends BaseRequest
{
const ENDPOINT = 'v3/historical-price-full/{symbol}?';

/**
* Create constructor.
*
* @param Fmp $api
*/
public function __construct(Fmp $api)
{
parent::__construct($api);
}

/**
*
* @return string
*/
protected function getFullEndpoint(): string
{
return str_replace('{symbol}', $this->symbol, self::ENDPOINT) . http_build_query($this->query_string);
}

/**
* @param string $date_from
*
* @return HistoricalPriceFull
*/
public function setDateFrom(string $date_from): self
{
$this->query_string['from'] = $date_from;

return $this;
}

/**
* @param string $date_to
*
* @return HistoricalPriceFull
*/
public function setDateTo(string $date_to): self
{
$this->query_string['to'] = $date_to;

return $this;
}

/**
* @return bool|void
* @throws InvalidData
*/
protected function validateParams(): void
{
if (empty($this->symbol)) {
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/KeyExecutives.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class KeyExecutives extends BaseRequest
{
const ENDPOINT = 'key-executives/{symbol}';
const ENDPOINT = 'v3/key-executives/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/MarketCapitalization.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MarketCapitalization extends BaseRequest
{
const ENDPOINT = 'market-capitalization/{symbol}';
const ENDPOINT = 'v3/market-capitalization/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Profile extends BaseRequest
{
const ENDPOINT = 'profile/{symbol}';
const ENDPOINT = 'v3/profile/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Quote extends BaseRequest
{
const ENDPOINT = 'quote/{symbol}';
const ENDPOINT = 'v3/quote/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
4 changes: 2 additions & 2 deletions src/CompanyValuation/Rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Rating extends BaseRequest
{
const ENDPOINT = 'rating/{symbol}';
const ENDPOINT = 'v3/rating/{symbol}';

/**
* Create constructor.
Expand Down Expand Up @@ -39,4 +39,4 @@ protected function validateParams(): void
throw InvalidData::invalidDataProvided('Please provide a symbol to query!');
}
}
}
}
Loading