Skip to content

Commit 4d41efb

Browse files
committed
Add RetrieveMintedNftRequest
1 parent 45110cd commit 4d41efb

5 files changed

Lines changed: 111 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
use Sprain\NftPort\Data\Blockchain;
4+
use Sprain\NftPort\Request\Minting\RetrieveMintedNftRequest;
5+
6+
require_once __DIR__ . '/../../vendor/autoload.php';
7+
require_once __DIR__ . '/../credentials.php';
8+
9+
10+
// Retrieve a minted NFT
11+
// https://docs.nftport.xyz/docs/nftport/b3A6MjE2NjM5MDU-retrieve-a-minted-nft
12+
13+
$response = (new RetrieveMintedNftRequest(
14+
$apiKey,
15+
'0x1a3dfdec04379f3aec147afcbc4548e91ce5e159f7d7aa5d22218097ecaff09c', // See examples/Contracts/2-customizable-mint.php
16+
Blockchain::Polygon->name()
17+
))->execute();
18+
19+
print_r($response);

examples/Ownership/1-owned-by-account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
$response = (new RetrieveOwnedByAccountRequest(
1414
$apiKey,
15-
$ethAddress,
15+
'0x0841c4dcFe6C3D55F3f093cc19D3a2c5e42D2c1e',
1616
Blockchain::Polygon->name(),
1717
))->execute();
1818

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sprain\NftPort\Request\Minting;
6+
7+
use JMS\Serializer\Annotation\Exclude;
8+
use JMS\Serializer\Annotation\SerializedName;
9+
use Sprain\NftPort\Request\IdRequestInterface;
10+
use Sprain\NftPort\Request\Request;
11+
use Sprain\NftPort\Request\RequestCommonsTrait;
12+
use Sprain\NftPort\Response\Minting\RetrieveMintedNftResponse;
13+
14+
class RetrieveMintedNftRequest extends Request implements IdRequestInterface
15+
{
16+
use RequestCommonsTrait;
17+
18+
public const API_PATH = '/mints/{id}';
19+
public const RESPONSE_CLASS = RetrieveMintedNftResponse::class;
20+
public const HTTP_METHOD = self::HTTP_METHOD_GET;
21+
22+
public function __construct(
23+
#[Exclude]
24+
protected string $apiKey,
25+
private string $id,
26+
#[SerializedName('chain')]
27+
private string $chain,
28+
) {
29+
parent::__construct($apiKey);
30+
}
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sprain\NftPort\Response\Minting;
6+
7+
use JMS\Serializer\Annotation\SerializedName;
8+
use JMS\Serializer\Annotation\Type;
9+
use Sprain\NftPort\Response\ResponseInterface;
10+
11+
class RetrieveMintedNftResponse implements ResponseInterface
12+
{
13+
#[SerializedName('response')]
14+
public ?string $response = null;
15+
16+
#[SerializedName('chain')]
17+
public ?string $chain = null;
18+
19+
#[SerializedName('contract_address')]
20+
public ?int $contractAddress = null;
21+
22+
#[SerializedName('token_id')]
23+
public ?string $tokenId = null;
24+
25+
#[SerializedName('error')]
26+
public ?string $error = null;
27+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Sprain\NftPort\Tests\Request\Ownership;
4+
5+
use Sprain\NftPort\Request\Minting\RetrieveMintedNftRequest;
6+
use Sprain\NftPort\Request\Request;
7+
use Sprain\NftPort\Response\Minting\RetrieveMintedNftResponse;
8+
use Sprain\NftPort\Tests\Request\CommonRequestTest;
9+
use Sprain\NftPort\Data\Blockchain;
10+
11+
class RetrieveMintedNftRequestTest extends CommonRequestTest
12+
{
13+
public function testErrorResponse(): void
14+
{
15+
$this->doTestErrorResponse();
16+
}
17+
18+
public function testSuccessfulResponse(): void
19+
{
20+
$this->doTestSuccessfulResponse(
21+
RetrieveMintedNftResponse::class
22+
);
23+
}
24+
25+
protected function getRequest(): Request
26+
{
27+
return new RetrieveMintedNftRequest(
28+
'apiKey',
29+
'someTransactionHash',
30+
Blockchain::Polygon->name()
31+
);
32+
}
33+
}

0 commit comments

Comments
 (0)