diff --git a/.gitignore b/.gitignore index c422267..76b8c52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ composer.phar /vendor/ +.idea/ # Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -# composer.lock +composer.lock + +build-docs/ diff --git a/README.md b/README.md index 553ff5d..924563c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,43 @@ # cardano-php-api -A open-source project to allow users to connect to the Cardano API using PHP. +An open-source project to allow users to connect to the Cardano API using PHP. There will be two APIs included in this Wrapper: +- Explorer Wrapper - Wrapper for the [Cardano Explorer API](https://cardanodocs.com/technical/explorer/api/). +- (Upcoming) Cardano-SL Wallet API Wrapper - Wrapper for the [Cardano SL Wallet Backend](https://cardanodocs.com/technical/wallet-backend/). + +## Installation + +Install with composer: + +```bash +composer require codybutz/cardano-php-api +``` + +## Usage + +This package contains two components: Explorer Wrapper and Cardano-SL Wallet API Wrapper. + +### Using the Explorer API + +```php +getAddressSummary('DdzFF...'); // Returns an AddressSummary object. +``` + +### Using the Wrapper API + +TODO + +## Run tests + +Invoke the test runner as follows: + + phpunit + +## License + +This code is licensed under the MIT License + +## Submitting bugs and feature requests + +If any problems are found please email me at codyjbutz@gmail.com or submit an issue to this repository. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3eece84 --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "codybutz/cardano-php-api", + "version": "0.0.1", + "description": "An open-source project to allow users to connect to the Cardano API using PHP.", + "authors": [ + { + "name": "Cody Butz", + "email": "codyjbutz@gmail.com" + } + ], + "require": { + "php": "^5.6|^7.0", + "stephenhill/base58": "^1.1", + "guzzlehttp/guzzle": "^6.3", + "cvuorinen/phpdoc-markdown-public": "^0.2.0" + }, + + "require-dev": { + "phpunit/phpunit": "^7.0", + "evert/phpdoc-md": "^0.2.0" + }, + "autoload": { + "psr-4": { + "Butz\\Cardano\\": "src/", + "Butz\\Tests\\": "test/" + } + }, + "scripts": { + "test": "./vendor/bin/phpunit" + } +} diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..2958a6f --- /dev/null +++ b/docs/README.md @@ -0,0 +1,1567 @@ +# Cardano API + +## Table of Contents + +* [AddressNotFoundException](#addressnotfoundexception) +* [AddressSummary](#addresssummary) + * [fromRequest](#fromrequest) + * [getAddress](#getaddress) + * [getType](#gettype) + * [getTxNum](#gettxnum) + * [getBalance](#getbalance) + * [getTxList](#gettxlist) + * [isRedeemed](#isredeemed) +* [BlockEntry](#blockentry) + * [fromResponse](#fromresponse) + * [getEpoch](#getepoch) + * [getSlot](#getslot) + * [getBlockHash](#getblockhash) + * [getTimeIssued](#gettimeissued) + * [getTxNum](#gettxnum-1) + * [getTotalSent](#gettotalsent) + * [getSize](#getsize) + * [getBlockLead](#getblocklead) + * [getFees](#getfees) +* [BlockPageSummary](#blockpagesummary) + * [fromResponse](#fromresponse-1) + * [getTotalSlots](#gettotalslots) + * [getEntries](#getentries) +* [BlockSummary](#blocksummary) + * [fromResponse](#fromresponse-2) + * [getEntry](#getentry) + * [getPrevHash](#getprevhash) + * [getNextHash](#getnexthash) + * [getMerkleRoot](#getmerkleroot) +* [Coin](#coin) + * [fromRequest](#fromrequest-1) + * [getCoin](#getcoin) +* [ExplorerAPI](#explorerapi) + * [__construct](#__construct) + * [getAddressSummary](#getaddresssummary) + * [getBlockPages](#getblockpages) + * [getBlockPageTotal](#getblockpagetotal) + * [getBlockSummary](#getblocksummary) + * [getBlockTransactions](#getblocktransactions) + * [getGenesisAddresses](#getgenesisaddresses) + * [getGenesisAddressesPages](#getgenesisaddressespages) + * [getGenesisSummary](#getgenesissummary) + * [getLastTxs](#getlasttxs) + * [getTransactionSummary](#gettransactionsummary) +* [ExplorerException](#explorerexception) +* [GenesisAddressInfo](#genesisaddressinfo) + * [fromRequest](#fromrequest-2) + * [getAddress](#getaddress-1) + * [getAmount](#getamount) + * [isRedeemed](#isredeemed-1) +* [GenesisSummary](#genesissummary) + * [fromRequest](#fromrequest-3) + * [getTotal](#gettotal) + * [getRedeemed](#getredeemed) + * [getNotRedeemed](#getnotredeemed) + * [getAmountRedeemed](#getamountredeemed) + * [getAmountNotRedeemed](#getamountnotredeemed) +* [TransactionBrief](#transactionbrief) + * [fromRequest](#fromrequest-4) + * [getId](#getid) + * [getTimeIssued](#gettimeissued-1) + * [getInputSum](#getinputsum) + * [getOutputSum](#getoutputsum) + * [getInputs](#getinputs) + * [getOutputs](#getoutputs) +* [TransactionEntry](#transactionentry) + * [fromRequest](#fromrequest-5) + * [getId](#getid-1) + * [getTimeIssued](#gettimeissued-2) + * [getAmount](#getamount-1) +* [TransactionIO](#transactionio) + * [fromRequest](#fromrequest-6) + * [getAddress](#getaddress-2) + * [getCoin](#getcoin-1) +* [TransactionSummary](#transactionsummary) + * [fromRequest](#fromrequest-7) + * [getId](#getid-2) + * [getTimeIssued](#gettimeissued-3) + * [getBlockTimeIssued](#getblocktimeissued) + * [getBlockHeight](#getblockheight) + * [getBlockEpoch](#getblockepoch) + * [getBlockSlot](#getblockslot) + * [getBlockHash](#getblockhash-1) + * [getRelayedBy](#getrelayedby) + * [getTotalInput](#gettotalinput) + * [getTotalOutput](#gettotaloutput) + * [getFees](#getfees-1) + * [getInputs](#getinputs-1) + * [getOutputs](#getoutputs-1) + +## AddressNotFoundException + +Class AddressNotFoundException + + + +* Full name: \Butz\Cardano\Explorer\Exceptions\AddressNotFoundException +* Parent class: \Butz\Cardano\Explorer\Exceptions\ExplorerException + + +## AddressSummary + +Class AddressSummary + + + +* Full name: \Butz\Cardano\Explorer\Models\AddressSummary + + +### fromRequest + +Transforms the API response into an AddressSummary. + +```php +AddressSummary::fromRequest( $data ): \Butz\Cardano\Explorer\Models\AddressSummary +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getAddress + +The address + +```php +AddressSummary::getAddress( ): string +``` + + + + + + + +--- + +### getType + +The type + +```php +AddressSummary::getType( ): string +``` + + + + + + + +--- + +### getTxNum + +The transaction number + +```php +AddressSummary::getTxNum( ): integer +``` + + + + + + + +--- + +### getBalance + +The balance + +```php +AddressSummary::getBalance( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getTxList + +The transaction list. + +```php +AddressSummary::getTxList( ): array +``` + + + + + + + +--- + +### isRedeemed + +Is redeemed? + +```php +AddressSummary::isRedeemed( ): boolean +``` + + + + + + + +--- + +## BlockEntry + +Class BlockEntry + + + +* Full name: \Butz\Cardano\Explorer\Models\BlockEntry + + +### fromResponse + +Takes an API response and transforms into a BlockEntry. + +```php +BlockEntry::fromResponse( $data ): \Butz\Cardano\Explorer\Models\BlockEntry +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getEpoch + +The epoch + +```php +BlockEntry::getEpoch( ): integer +``` + + + + + + + +--- + +### getSlot + +The slot + +```php +BlockEntry::getSlot( ): integer +``` + + + + + + + +--- + +### getBlockHash + +The block hash + +```php +BlockEntry::getBlockHash( ): string +``` + + + + + + + +--- + +### getTimeIssued + +The time issued + +```php +BlockEntry::getTimeIssued( ): integer +``` + + + + + + + +--- + +### getTxNum + +The transaction number + +```php +BlockEntry::getTxNum( ): integer +``` + + + + + + + +--- + +### getTotalSent + +The total sent + +```php +BlockEntry::getTotalSent( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getSize + +The size of the block + +```php +BlockEntry::getSize( ): integer +``` + + + + + + + +--- + +### getBlockLead + +The block leader + +```php +BlockEntry::getBlockLead( ): string +``` + + + + + + + +--- + +### getFees + +The fees + +```php +BlockEntry::getFees( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +## BlockPageSummary + +Class BlockPageSummary + + + +* Full name: \Butz\Cardano\Explorer\Models\BlockPageSummary + + +### fromResponse + +Transforms an API response into a BlockPageSummary. + +```php +BlockPageSummary::fromResponse( $data ): \Butz\Cardano\Explorer\Models\BlockPageSummary +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getTotalSlots + +The total slots + +```php +BlockPageSummary::getTotalSlots( ): string +``` + + + + + + + +--- + +### getEntries + +The entries + +```php +BlockPageSummary::getEntries( ): array +``` + + + + + + + +--- + +## BlockSummary + +Class BlockSummary + + + +* Full name: \Butz\Cardano\Explorer\Models\BlockSummary + + +### fromResponse + +Build a BlockSummary from the API. + +```php +BlockSummary::fromResponse( $data ): \Butz\Cardano\Explorer\Models\BlockSummary +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getEntry + +Gets associated BlockEntry to this summary. + +```php +BlockSummary::getEntry( ): \Butz\Cardano\Explorer\Models\BlockEntry +``` + + + + + + + +--- + +### getPrevHash + +Retrieves the previous hash to this block. + +```php +BlockSummary::getPrevHash( ): string +``` + + + + + + + +--- + +### getNextHash + +Retrieves the next hash to this block + +```php +BlockSummary::getNextHash( ): string|null +``` + + + + + + + +--- + +### getMerkleRoot + +Gets the root node in the merkle tree. + +```php +BlockSummary::getMerkleRoot( ): string +``` + + + + + + + +--- + +## Coin + +Class Coin + + + +* Full name: \Butz\Cardano\Explorer\Models\Coin + + +### fromRequest + +Takes an object from a response and translates into a Coin Object. + +```php +Coin::fromRequest( $data ): \Butz\Cardano\Explorer\Models\Coin +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getCoin + +The coin + +```php +Coin::getCoin( ): string +``` + + + + + + + +--- + +## ExplorerAPI + +Class ExplorerAPI + + + +* Full name: \Butz\Cardano\Explorer\ExplorerAPI + + +### __construct + +ExplorerAPI constructor. + +```php +ExplorerAPI::__construct( \GuzzleHttp\HandlerStack|null $handler = null ) +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$handler` | **\GuzzleHttp\HandlerStack|null** | | + + + + +--- + +### getAddressSummary + +Get summary information about an address. + +```php +ExplorerAPI::getAddressSummary( $address ): \Butz\Cardano\Explorer\Models\AddressSummary +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$address` | **** | | + + + + +--- + +### getBlockPages + +Get summary info from a block page. + +```php +ExplorerAPI::getBlockPages( integer $page = 1, integer $pageSize = 10 ): \Butz\Cardano\Explorer\Models\BlockPageSummary +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$page` | **integer** | | +| `$pageSize` | **integer** | | + + + + +--- + +### getBlockPageTotal + +Get total blocks. + +```php +ExplorerAPI::getBlockPageTotal( integer $pageSize = 10 ): integer +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$pageSize` | **integer** | | + + + + +--- + +### getBlockSummary + +Get summary information about an block. + +```php +ExplorerAPI::getBlockSummary( $hash ): \Butz\Cardano\Explorer\Models\BlockSummary +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$hash` | **** | | + + + + +--- + +### getBlockTransactions + +Get transactions that took place during an block. + +```php +ExplorerAPI::getBlockTransactions( $hash ): array +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$hash` | **** | | + + + + +--- + +### getGenesisAddresses + +Get all genesis addresses. + +```php +ExplorerAPI::getGenesisAddresses( integer $page = 1, integer $pageSize = 15, string $filter = 'all' ): array +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$page` | **integer** | | +| `$pageSize` | **integer** | | +| `$filter` | **string** | | + + + + +--- + +### getGenesisAddressesPages + +Get the number of pages for a particular genesis address query. + +```php +ExplorerAPI::getGenesisAddressesPages( integer $pageSize = 15, string $filter = 'all' ): integer +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$pageSize` | **integer** | | +| `$filter` | **string** | | + + + + +--- + +### getGenesisSummary + +Gets the summary of the Genesis Addresses. + +```php +ExplorerAPI::getGenesisSummary( ): \Butz\Cardano\Explorer\Models\GenesisSummary +``` + + + + + + + +--- + +### getLastTxs + +Get information about the N latest transactions. + +```php +ExplorerAPI::getLastTxs( ): array +``` + + + + + + + +--- + +### getTransactionSummary + +Get information about the N latest transactions. + +```php +ExplorerAPI::getTransactionSummary( $txid ): \Butz\Cardano\Explorer\Models\TransactionSummary +``` + + + + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$txid` | **** | | + + + + +--- + +## ExplorerException + +Class ExplorerException + + + +* Full name: \Butz\Cardano\Explorer\Exceptions\ExplorerException +* Parent class: + + +## GenesisAddressInfo + +Class GenesisAddressInfo + + + +* Full name: \Butz\Cardano\Explorer\Models\GenesisAddressInfo + + +### fromRequest + +Takes an object from a response and translates into a Coin Object. + +```php +GenesisAddressInfo::fromRequest( $data ): \Butz\Cardano\Explorer\Models\GenesisAddressInfo +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getAddress + +The address + +```php +GenesisAddressInfo::getAddress( ): string +``` + + + + + + + +--- + +### getAmount + +The amount + +```php +GenesisAddressInfo::getAmount( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### isRedeemed + +Is redeemed? + +```php +GenesisAddressInfo::isRedeemed( ): boolean +``` + + + + + + + +--- + +## GenesisSummary + +Class GenesisSummary + + + +* Full name: \Butz\Cardano\Explorer\Models\GenesisSummary + + +### fromRequest + +Transforms an API response to a Genesis Summary + +```php +GenesisSummary::fromRequest( $data ): \Butz\Cardano\Explorer\Models\GenesisSummary +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getTotal + +The total + +```php +GenesisSummary::getTotal( ): integer +``` + + + + + + + +--- + +### getRedeemed + +The redeemed address count + +```php +GenesisSummary::getRedeemed( ): integer +``` + + + + + + + +--- + +### getNotRedeemed + +The not redeemed address count + +```php +GenesisSummary::getNotRedeemed( ): integer +``` + + + + + + + +--- + +### getAmountRedeemed + +The amount redeemed + +```php +GenesisSummary::getAmountRedeemed( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getAmountNotRedeemed + +The amount not redeemed. + +```php +GenesisSummary::getAmountNotRedeemed( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +## TransactionBrief + +Class TransactionBrief + + + +* Full name: \Butz\Cardano\Explorer\Models\TransactionBrief + + +### fromRequest + +Takes an object from a response and translates into a TransactionBrief Object. + +```php +TransactionBrief::fromRequest( $data ): \Butz\Cardano\Explorer\Models\TransactionBrief +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getId + +The tx id + +```php +TransactionBrief::getId( ): string +``` + + + + + + + +--- + +### getTimeIssued + +The time issued + +```php +TransactionBrief::getTimeIssued( ): integer +``` + + + + + + + +--- + +### getInputSum + +The input sum + +```php +TransactionBrief::getInputSum( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getOutputSum + +The output sum + +```php +TransactionBrief::getOutputSum( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getInputs + +The inputs + +```php +TransactionBrief::getInputs( ): array +``` + + + + + + + +--- + +### getOutputs + +The outputs + +```php +TransactionBrief::getOutputs( ): array +``` + + + + + + + +--- + +## TransactionEntry + +Class TransactionEntry + + + +* Full name: \Butz\Cardano\Explorer\Models\TransactionEntry + + +### fromRequest + +Takes an object from a response and translates into a TransactionEntry Object. + +```php +TransactionEntry::fromRequest( $data ): \Butz\Cardano\Explorer\Models\TransactionEntry +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getId + +The id + +```php +TransactionEntry::getId( ): string +``` + + + + + + + +--- + +### getTimeIssued + +The time issued + +```php +TransactionEntry::getTimeIssued( ): integer +``` + + + + + + + +--- + +### getAmount + +The amount + +```php +TransactionEntry::getAmount( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +## TransactionIO + +Class TransactionIO + + + +* Full name: \Butz\Cardano\Explorer\Models\TransactionIO + + +### fromRequest + +Takes an object from a response and translates into a Coin Object. + +```php +TransactionIO::fromRequest( $data ): \Butz\Cardano\Explorer\Models\TransactionIO +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getAddress + +The address + +```php +TransactionIO::getAddress( ): string +``` + + + + + + + +--- + +### getCoin + +The coin + +```php +TransactionIO::getCoin( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +## TransactionSummary + +Class TransactionSummary + + + +* Full name: \Butz\Cardano\Explorer\Models\TransactionSummary + + +### fromRequest + +Takes an object from a response and translates into a TransactionSummary Object. + +```php +TransactionSummary::fromRequest( $data ): \Butz\Cardano\Explorer\Models\TransactionSummary +``` + + + +* This method is **static**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------|-------------| +| `$data` | **** | | + + + + +--- + +### getId + +The id + +```php +TransactionSummary::getId( ): string +``` + + + + + + + +--- + +### getTimeIssued + +Get time issued. + +```php +TransactionSummary::getTimeIssued( ): integer +``` + + + + + + + +--- + +### getBlockTimeIssued + +The block time issued + +```php +TransactionSummary::getBlockTimeIssued( ): integer +``` + + + + + + + +--- + +### getBlockHeight + +The block height + +```php +TransactionSummary::getBlockHeight( ): integer +``` + + + + + + + +--- + +### getBlockEpoch + +The block epoch + +```php +TransactionSummary::getBlockEpoch( ): integer +``` + + + + + + + +--- + +### getBlockSlot + +The block slot + +```php +TransactionSummary::getBlockSlot( ): integer +``` + + + + + + + +--- + +### getBlockHash + +The block hash + +```php +TransactionSummary::getBlockHash( ): string +``` + + + + + + + +--- + +### getRelayedBy + +The relayed bby network address + +```php +TransactionSummary::getRelayedBy( ): string +``` + + + + + + + +--- + +### getTotalInput + +The total input + +```php +TransactionSummary::getTotalInput( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getTotalOutput + +The total output + +```php +TransactionSummary::getTotalOutput( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getFees + +The fees + +```php +TransactionSummary::getFees( ): \Butz\Cardano\Explorer\Models\Coin +``` + + + + + + + +--- + +### getInputs + +The inputs + +```php +TransactionSummary::getInputs( ): array +``` + + + + + + + +--- + +### getOutputs + +The outputs + +```php +TransactionSummary::getOutputs( ): array +``` + + + + + + + +--- + + + +-------- +> This document was automatically generated from source code comments on 2018-04-22 using [phpDocumentor](http://www.phpdoc.org/) and [cvuorinen/phpdoc-markdown-public](https://github.com/cvuorinen/phpdoc-markdown-public) diff --git a/phpdoc.xml b/phpdoc.xml new file mode 100644 index 0000000..8b93db5 --- /dev/null +++ b/phpdoc.xml @@ -0,0 +1,37 @@ + + + + + Cardano API + + build-docs + + + docs + + +