-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use Sprain\NftPort\Data\Blockchain; | ||
use Sprain\NftPort\Request\Minting\RetrieveMintedNftRequest; | ||
|
||
require_once __DIR__ . '/../../vendor/autoload.php'; | ||
require_once __DIR__ . '/../credentials.php'; | ||
|
||
|
||
// Retrieve a minted NFT | ||
// https://docs.nftport.xyz/docs/nftport/b3A6MjE2NjM5MDU-retrieve-a-minted-nft | ||
|
||
$response = (new RetrieveMintedNftRequest( | ||
$apiKey, | ||
'0x1a3dfdec04379f3aec147afcbc4548e91ce5e159f7d7aa5d22218097ecaff09c', // See examples/Contracts/2-customizable-mint.php | ||
Blockchain::Polygon->name() | ||
))->execute(); | ||
|
||
print_r($response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sprain\NftPort\Request\Minting; | ||
|
||
use JMS\Serializer\Annotation\Exclude; | ||
use JMS\Serializer\Annotation\SerializedName; | ||
use Sprain\NftPort\Request\IdRequestInterface; | ||
use Sprain\NftPort\Request\Request; | ||
use Sprain\NftPort\Request\RequestCommonsTrait; | ||
use Sprain\NftPort\Response\Minting\RetrieveMintedNftResponse; | ||
|
||
class RetrieveMintedNftRequest extends Request implements IdRequestInterface | ||
{ | ||
use RequestCommonsTrait; | ||
|
||
public const API_PATH = '/mints/{id}'; | ||
public const RESPONSE_CLASS = RetrieveMintedNftResponse::class; | ||
public const HTTP_METHOD = self::HTTP_METHOD_GET; | ||
|
||
public function __construct( | ||
#[Exclude] | ||
protected string $apiKey, | ||
private string $id, | ||
#[SerializedName('chain')] | ||
private string $chain, | ||
) { | ||
parent::__construct($apiKey); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
lib/NftPort/Response/Minting/RetrieveMintedNftResponse.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sprain\NftPort\Response\Minting; | ||
|
||
use JMS\Serializer\Annotation\SerializedName; | ||
use JMS\Serializer\Annotation\Type; | ||
use Sprain\NftPort\Response\ResponseInterface; | ||
|
||
class RetrieveMintedNftResponse implements ResponseInterface | ||
{ | ||
#[SerializedName('response')] | ||
public ?string $response = null; | ||
|
||
#[SerializedName('chain')] | ||
public ?string $chain = null; | ||
|
||
#[SerializedName('contract_address')] | ||
public ?int $contractAddress = null; | ||
|
||
#[SerializedName('token_id')] | ||
public ?string $tokenId = null; | ||
|
||
#[SerializedName('error')] | ||
public ?string $error = null; | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/NftPort/Tests/Request/Minting/RetrieveMintedNftRequestTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Sprain\NftPort\Tests\Request\Ownership; | ||
|
||
use Sprain\NftPort\Request\Minting\RetrieveMintedNftRequest; | ||
use Sprain\NftPort\Request\Request; | ||
use Sprain\NftPort\Response\Minting\RetrieveMintedNftResponse; | ||
use Sprain\NftPort\Tests\Request\CommonRequestTest; | ||
use Sprain\NftPort\Data\Blockchain; | ||
|
||
class RetrieveMintedNftRequestTest extends CommonRequestTest | ||
{ | ||
public function testErrorResponse(): void | ||
{ | ||
$this->doTestErrorResponse(); | ||
} | ||
|
||
public function testSuccessfulResponse(): void | ||
{ | ||
$this->doTestSuccessfulResponse( | ||
RetrieveMintedNftResponse::class | ||
); | ||
} | ||
|
||
protected function getRequest(): Request | ||
{ | ||
return new RetrieveMintedNftRequest( | ||
'apiKey', | ||
'someTransactionHash', | ||
Blockchain::Polygon->name() | ||
); | ||
} | ||
} |