diff --git a/composer.json b/composer.json index d9a7693..b4bd530 100644 --- a/composer.json +++ b/composer.json @@ -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": [ { diff --git a/config/fmp.php b/config/fmp.php index 97fc925..99e694c 100644 --- a/config/fmp.php +++ b/config/fmp.php @@ -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/'), ]; diff --git a/src/Calendars/DividendCalendar.php b/src/Calendars/DividendCalendar.php index 16d4ac2..3869013 100644 --- a/src/Calendars/DividendCalendar.php +++ b/src/Calendars/DividendCalendar.php @@ -10,7 +10,7 @@ class DividendCalendar extends BaseRequest { - const ENDPOINT = 'stock_dividend_calendar?'; + const ENDPOINT = 'v3/stock_dividend_calendar?'; private $query_string = array(); @@ -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); } /** diff --git a/src/Calendars/EarningsCalendar.php b/src/Calendars/EarningsCalendar.php index 5e35774..7a33fcd 100644 --- a/src/Calendars/EarningsCalendar.php +++ b/src/Calendars/EarningsCalendar.php @@ -10,7 +10,7 @@ class EarningsCalendar extends BaseRequest { - const ENDPOINT = 'earning_calendar?'; + const ENDPOINT = 'v3/earning_calendar?'; private $query_string = array(); @@ -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); } /** diff --git a/src/Calendars/EconomicCalendar.php b/src/Calendars/EconomicCalendar.php index 8bfb79e..20478b2 100644 --- a/src/Calendars/EconomicCalendar.php +++ b/src/Calendars/EconomicCalendar.php @@ -10,7 +10,7 @@ class EconomicCalendar extends BaseRequest { - const ENDPOINT = 'economic_calendar?'; + const ENDPOINT = 'v3/economic_calendar?'; private $query_string = array(); @@ -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); } /** diff --git a/src/Calendars/HistoricalEarningsCalendar.php b/src/Calendars/HistoricalEarningsCalendar.php index 76d1e87..c1642b6 100644 --- a/src/Calendars/HistoricalEarningsCalendar.php +++ b/src/Calendars/HistoricalEarningsCalendar.php @@ -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(); diff --git a/src/Calendars/IpoCalendar.php b/src/Calendars/IpoCalendar.php index 1791a4b..deb203e 100644 --- a/src/Calendars/IpoCalendar.php +++ b/src/Calendars/IpoCalendar.php @@ -10,7 +10,7 @@ class IpoCalendar extends BaseRequest { - const ENDPOINT = 'ipo_calendar?'; + const ENDPOINT = 'v3/ipo_calendar?'; private $query_string = array(); @@ -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); } /** diff --git a/src/Calendars/StockSplitCalendar.php b/src/Calendars/StockSplitCalendar.php index 331e936..0965e00 100644 --- a/src/Calendars/StockSplitCalendar.php +++ b/src/Calendars/StockSplitCalendar.php @@ -10,7 +10,7 @@ class StockSplitCalendar extends BaseRequest { - const ENDPOINT = 'stock_split_calendar?'; + const ENDPOINT = 'v3/stock_split_calendar?'; private $query_string = array(); @@ -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); } /** diff --git a/src/Client.php b/src/Client.php index bb5e921..009a515 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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 { @@ -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()); } } } diff --git a/src/CompanyValuation/CountriesList.php b/src/CompanyValuation/CountriesList.php index 5497c88..7595bef 100644 --- a/src/CompanyValuation/CountriesList.php +++ b/src/CompanyValuation/CountriesList.php @@ -7,7 +7,7 @@ class CountriesList extends BaseRequest { - const ENDPOINT = 'get-all-countries'; + const ENDPOINT = 'v3/get-all-countries'; /** * Create constructor. diff --git a/src/CompanyValuation/DiscountedCashFlow.php b/src/CompanyValuation/DiscountedCashFlow.php index 221d83e..f088537 100644 --- a/src/CompanyValuation/DiscountedCashFlow.php +++ b/src/CompanyValuation/DiscountedCashFlow.php @@ -8,7 +8,7 @@ class DiscountedCashFlow extends BaseRequest { - const ENDPOINT = 'discounted-cash-flow/{symbol}'; + const ENDPOINT = 'v3/discounted-cash-flow/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/EarningsSurprises.php b/src/CompanyValuation/EarningsSurprises.php index 10c2ade..21e8543 100644 --- a/src/CompanyValuation/EarningsSurprises.php +++ b/src/CompanyValuation/EarningsSurprises.php @@ -8,7 +8,7 @@ class EarningsSurprises extends BaseRequest { - const ENDPOINT = 'earnings-surpises/{symbol}'; + const ENDPOINT = 'v3/earnings-surpises/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/EtfsList.php b/src/CompanyValuation/EtfsList.php index 535784d..14d6f47 100644 --- a/src/CompanyValuation/EtfsList.php +++ b/src/CompanyValuation/EtfsList.php @@ -7,7 +7,7 @@ class EtfsList extends BaseRequest { - const ENDPOINT = 'etf/list'; + const ENDPOINT = 'v3/etf/list'; /** * Create constructor. @@ -27,4 +27,4 @@ protected function getFullEndpoint(): string { return self::ENDPOINT; } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/HistoricalPriceFull.php b/src/CompanyValuation/HistoricalPriceFull.php new file mode 100644 index 0000000..fcf8eba --- /dev/null +++ b/src/CompanyValuation/HistoricalPriceFull.php @@ -0,0 +1,66 @@ +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!'); + } + } +} diff --git a/src/CompanyValuation/KeyExecutives.php b/src/CompanyValuation/KeyExecutives.php index 35cd3a2..5190683 100644 --- a/src/CompanyValuation/KeyExecutives.php +++ b/src/CompanyValuation/KeyExecutives.php @@ -8,7 +8,7 @@ class KeyExecutives extends BaseRequest { - const ENDPOINT = 'key-executives/{symbol}'; + const ENDPOINT = 'v3/key-executives/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/MarketCapitalization.php b/src/CompanyValuation/MarketCapitalization.php index 2b8e09c..35bcc3a 100644 --- a/src/CompanyValuation/MarketCapitalization.php +++ b/src/CompanyValuation/MarketCapitalization.php @@ -8,7 +8,7 @@ class MarketCapitalization extends BaseRequest { - const ENDPOINT = 'market-capitalization/{symbol}'; + const ENDPOINT = 'v3/market-capitalization/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/Profile.php b/src/CompanyValuation/Profile.php index 80e0fc9..2e30164 100644 --- a/src/CompanyValuation/Profile.php +++ b/src/CompanyValuation/Profile.php @@ -8,7 +8,7 @@ class Profile extends BaseRequest { - const ENDPOINT = 'profile/{symbol}'; + const ENDPOINT = 'v3/profile/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/Quote.php b/src/CompanyValuation/Quote.php index 8bbc61b..8bc8060 100644 --- a/src/CompanyValuation/Quote.php +++ b/src/CompanyValuation/Quote.php @@ -8,7 +8,7 @@ class Quote extends BaseRequest { - const ENDPOINT = 'quote/{symbol}'; + const ENDPOINT = 'v3/quote/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/Rating.php b/src/CompanyValuation/Rating.php index c6e2c8f..ca55101 100644 --- a/src/CompanyValuation/Rating.php +++ b/src/CompanyValuation/Rating.php @@ -8,7 +8,7 @@ class Rating extends BaseRequest { - const ENDPOINT = 'rating/{symbol}'; + const ENDPOINT = 'v3/rating/{symbol}'; /** * Create constructor. @@ -39,4 +39,4 @@ protected function validateParams(): void throw InvalidData::invalidDataProvided('Please provide a symbol to query!'); } } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/StockScreener.php b/src/CompanyValuation/StockScreener.php index 15484a1..214c516 100644 --- a/src/CompanyValuation/StockScreener.php +++ b/src/CompanyValuation/StockScreener.php @@ -7,7 +7,7 @@ class StockScreener extends BaseRequest { - const ENDPOINT = 'stock-screener?'; + const ENDPOINT = 'v3/stock-screener?'; public $query_string = array(); @@ -27,7 +27,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); } /** diff --git a/src/CompanyValuation/SymbolsList.php b/src/CompanyValuation/SymbolsList.php index a90376d..29978b6 100644 --- a/src/CompanyValuation/SymbolsList.php +++ b/src/CompanyValuation/SymbolsList.php @@ -7,7 +7,7 @@ class SymbolsList extends BaseRequest { - const ENDPOINT = 'stock/list'; + const ENDPOINT = 'v3/stock/list'; /** * Create constructor. @@ -27,4 +27,4 @@ protected function getFullEndpoint(): string { return self::ENDPOINT; } -} \ No newline at end of file +} diff --git a/src/CompanyValuation/TradableSymbolsList.php b/src/CompanyValuation/TradableSymbolsList.php index a6daf40..3280499 100644 --- a/src/CompanyValuation/TradableSymbolsList.php +++ b/src/CompanyValuation/TradableSymbolsList.php @@ -7,7 +7,7 @@ class TradableSymbolsList extends BaseRequest { - const ENDPOINT = 'available-traded/list'; + const ENDPOINT = 'v3/available-traded/list'; /** * Create constructor. @@ -27,4 +27,4 @@ protected function getFullEndpoint(): string { return self::ENDPOINT; } -} \ No newline at end of file +} diff --git a/src/Facades/CompanyValuation/HistoricalPriceFull.php b/src/Facades/CompanyValuation/HistoricalPriceFull.php new file mode 100644 index 0000000..93ece32 --- /dev/null +++ b/src/Facades/CompanyValuation/HistoricalPriceFull.php @@ -0,0 +1,13 @@ +query_string); + } + + /** + * @param string $isin + * + * @return ProfileByIsin + */ + public function setIsin(string $isin): self + { + $this->query_string['isin'] = $isin; + + return $this; + } + + /** + * @return bool|void + * @throws InvalidData + */ + protected function validateParams(): void + { + if (empty($this->query_string['isin'])) { + throw InvalidData::invalidDataProvided('Please provide an isin code to query!'); + } + } +} diff --git a/src/Requests/BaseRequest.php b/src/Requests/BaseRequest.php index 8d3b22b..aaa3047 100644 --- a/src/Requests/BaseRequest.php +++ b/src/Requests/BaseRequest.php @@ -54,7 +54,7 @@ public function post(): Collection $this->method = 'POST'; if (empty($this->payload)) { - throw InvalidData::invalidValuesProvided('Payload required to perform a POST request'); + throw InvalidData::invalidDataProvided('Payload required to perform a POST request'); } return $this->send(); diff --git a/src/StockMarket/Actives.php b/src/StockMarket/Actives.php index 23a7e44..de42697 100644 --- a/src/StockMarket/Actives.php +++ b/src/StockMarket/Actives.php @@ -7,7 +7,7 @@ class Actives extends BaseRequest { - const ENDPOINT = 'actives'; + const ENDPOINT = 'v3/actives'; /** * Create constructor. diff --git a/src/StockMarket/Gainers.php b/src/StockMarket/Gainers.php index d7c76ee..7dc65d3 100644 --- a/src/StockMarket/Gainers.php +++ b/src/StockMarket/Gainers.php @@ -7,7 +7,7 @@ class Gainers extends BaseRequest { - const ENDPOINT = 'gainers'; + const ENDPOINT = 'v3/gainers'; /** * Create constructor. diff --git a/src/StockMarket/Losers.php b/src/StockMarket/Losers.php index 5ddfd06..2fc5e35 100644 --- a/src/StockMarket/Losers.php +++ b/src/StockMarket/Losers.php @@ -7,7 +7,7 @@ class Losers extends BaseRequest { - const ENDPOINT = 'losers'; + const ENDPOINT = 'v3/losers'; /** * Create constructor. diff --git a/src/StockMarket/MarketHours.php b/src/StockMarket/MarketHours.php index 0add560..f6ca2a3 100644 --- a/src/StockMarket/MarketHours.php +++ b/src/StockMarket/MarketHours.php @@ -7,7 +7,7 @@ class MarketHours extends BaseRequest { - const ENDPOINT = 'market-hours'; + const ENDPOINT = 'v3/market-hours'; /** * Create constructor. diff --git a/src/StockMarket/SectorsPerformance.php b/src/StockMarket/SectorsPerformance.php index 817a80a..945918d 100644 --- a/src/StockMarket/SectorsPerformance.php +++ b/src/StockMarket/SectorsPerformance.php @@ -7,7 +7,7 @@ class SectorsPerformance extends BaseRequest { - const ENDPOINT = '{endpoint}?'; + const ENDPOINT = 'v3/{endpoint}?'; private $query_string = array();