diff --git a/src/Collection/AssetsRecord.php b/src/Collection/AssetsRecord.php new file mode 100644 index 0000000..e830854 --- /dev/null +++ b/src/Collection/AssetsRecord.php @@ -0,0 +1,18 @@ +apiKey = $apiKey; + } + + public function getProviderClassName(): string + { + return CryptoMonitor::class; + } + + public function fetch(ImportConnector $connector): \Iterator + { + $response = \json_decode( + (string) $connector->fetch( + CryptoMonitor::buildExchangeApiUrl( + "v1/assets" + ) + ), + true + ); + + $assets = new \ArrayIterator($response); + + return new AssetsRecord($assets, count($assets), $this); + } +} diff --git a/src/Resource/GetExchanges.php b/src/Resource/GetExchanges.php new file mode 100644 index 0000000..22b4509 --- /dev/null +++ b/src/Resource/GetExchanges.php @@ -0,0 +1,42 @@ +apiKey = $apiKey; + } + + public function getProviderClassName(): string + { + return CryptoMonitor::class; + } + + public function fetch(ImportConnector $connector): \Iterator + { + $response = \json_decode( + (string) $connector->fetch( + CryptoMonitor::buildExchangeApiUrl( + "v1/exchanges" + ) + ), + true + ); + + $exchanges = new \ArrayIterator($response); + + return new ExchangesRecord($exchanges, count($exchanges), $this); + } +} diff --git a/tests/Functional/GetAssetsTest.php b/tests/Functional/GetAssetsTest.php new file mode 100644 index 0000000..b2b355c --- /dev/null +++ b/tests/Functional/GetAssetsTest.php @@ -0,0 +1,27 @@ +import(new ImportSpecification(new GetAssets($this->apiKey))); + + foreach ($assets as $assetRecord) { + $this->assertArrayHasKey('asset_id', $assetRecord); + $this->assertArrayHasKey('name', $assetRecord); + $this->assertArrayHasKey('type_is_crypto', $assetRecord); + } + } +} diff --git a/tests/Functional/GetExchangesTest.php b/tests/Functional/GetExchangesTest.php new file mode 100644 index 0000000..3a710ff --- /dev/null +++ b/tests/Functional/GetExchangesTest.php @@ -0,0 +1,27 @@ +import(new ImportSpecification(new GetExchanges($this->apiKey))); + + foreach ($exchanges as $exchangeRecord) { + $this->assertArrayHasKey('exchange_id', $exchangeRecord); + $this->assertArrayHasKey('website', $exchangeRecord); + $this->assertArrayHasKey('name', $exchangeRecord); + } + } +}