Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
add account transactions endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Jun 6, 2023
1 parent 3f9108f commit ef00c84
Show file tree
Hide file tree
Showing 4 changed files with 679 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Api/Endpoints/AccountEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Peerme\MxProviders\Entities\NftCollectionAccount;
use Peerme\MxProviders\Entities\NftCollectionRole;
use Peerme\MxProviders\Entities\TokenDetailedWithBalance;
use Peerme\MxProviders\Entities\Transaction;

class AccountEndpoints
{
Expand Down Expand Up @@ -92,4 +93,14 @@ public function getRolesCollection(string $address, string $collection, array $p
]),
);
}

public function getTransactions(string $address, array $params = []): Collection
{
return Transaction::fromApiResponse(
$this->client->request('GET', "/accounts/{$address}/transactions", [
'query' => $params,
]),
isCollection: true,
);
}
}
10 changes: 9 additions & 1 deletion tests/Api/AccountsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
assertMatchesResponseSnapshot($actual);
});


it('getRolesCollections - gets role collections owned by the user', function () {
$client = createMockedHttpClientWithResponse('accounts/role-collections.json');

Expand All @@ -84,3 +83,12 @@

assertMatchesResponseSnapshot($actual);
});

it('getTransactions - gets transactions of an account', function () {
$client = createMockedHttpClientWithResponse('accounts/transactions.json');

$actual = (new AccountEndpoints($client))
->getTransactions('erd1660va6y429mxz4dkgek0ssny8tccaaaaaaaaaabbbbbbbbbbcccccccccc');

assertMatchesResponseSnapshot($actual);
});
Loading

0 comments on commit ef00c84

Please sign in to comment.