Skip to content

Commit bf20b31

Browse files
T3RAN13T3RAN13
authored andcommitted
README update
1 parent de4c5ed commit bf20b31

File tree

1 file changed

+68
-47
lines changed

1 file changed

+68
-47
lines changed

README.md

Lines changed: 68 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,59 @@ composer require t3ran13/php-graphene-node-client
1111
```php
1212
<?php
1313

14-
use GrapheneNodeClient\Commands\GetTrendingCategoriesCommand;
14+
use GrapheneNodeClient\Commands\CommandQueryData;
15+
use GrapheneNodeClient\Commands\DataBase\GetDiscussionsByCreatedCommand;
1516
use GrapheneNodeClient\Connectors\WebSocket\GolosWSConnector;
17+
use GrapheneNodeClient\Connectors\WebSocket\SteemitWSConnector;
1618

17-
$command = new GetTrendingCategoriesCommand(new GolosWSConnector());
1819

19-
$trendingTags = $command->execute(
20+
//Set params for query
21+
$commandQuery = new CommandQueryData();
22+
$data = [
2023
[
21-
"", //'after'
22-
2 //'limit'
24+
'limit' => $limit,
25+
'select_tags' => ['golos'], // for GOLOS
26+
'tag' => 'steemit', // for STEEMIT
2327
]
28+
];
29+
$commandQuery->setParams($data);
30+
31+
//OR
32+
$commandQuery = new CommandQueryData();
33+
$commandQuery->setParamByKey('0:limit', $limit);
34+
$commandQuery->setParamByKey('0:select_tags', [$tag]);
35+
$commandQuery->setParamByKey('0:tag', $tag);
36+
37+
$command = new GetDiscussionsByCreatedCommand(new GolosWSConnector());
38+
$golosPosts = $command->execute(
39+
$commandQuery
2440
);
2541
// will return
2642
// [
27-
// "id" => 2,
43+
// "id" => 1,
2844
// "result" => [
2945
// [
30-
// "name" => "ru--zhiznx",
31-
// "total_payouts": "410233.942 GBG",
46+
// "id": 466628,
47+
// "author": "piranya",
48+
// "permlink": "devyatyi-krug",
3249
// ...
3350
// ],
3451
// ...
3552
// ]
3653
// ]
3754

38-
$trendingTags = $command->execute(
39-
[
40-
"", //'after'
41-
2 //'limit'
42-
],
55+
$command = new GetDiscussionsByCreatedCommand(new SteemitWSConnector());
56+
$steemitPosts = $command->execute(
57+
$commandQuery,
4358
'result',
44-
GolosWSConnector::ANSWER_FORMAT_ARRAY // or GolosWSConnector::ANSWER_FORMAT_OBJECT
59+
SteemitWSConnector::ANSWER_FORMAT_ARRAY // or SteemitWSConnector::ANSWER_FORMAT_OBJECT
4560
);
4661
// will return
4762
// [
4863
// [
49-
// "name" => "ru--zhiznx",
50-
// "total_payouts": "410233.942 GBG",
64+
// "id": 466628,
65+
// "author": "piranya",
66+
// "permlink": "devyatyi-krug",
5167
// ...
5268
// ],
5369
// ...
@@ -60,7 +76,7 @@ $trendingTags = $command->execute(
6076

6177
## Implemented Commands List
6278

63-
namespace: GrapheneNodeClient\Commands;
79+
namespace: GrapheneNodeClient\Commands\DataBase;
6480

6581
- GetContentCommand
6682
- GetDiscussionsByAuthorBeforeDateCommand
@@ -81,17 +97,28 @@ switch between connectors
8197
```php
8298
<?php
8399

84-
use GrapheneNodeClient\Commands\GetContentCommand;
100+
use GrapheneNodeClient\Commands\CommandQueryData;
101+
use GrapheneNodeClient\Commands\DataBase\GetContentCommand;
85102
use GrapheneNodeClient\Connectors\InitConnector;
86103

87104
$command = new GetContentCommand(InitConnector::getConnector(InitConnector::PLATFORM_STEEMIT));
88105

89-
$content = $command->execute(
106+
$commandQuery = new CommandQueryData();
107+
$commandQuery->setParamByKey('0', 'author');
108+
$commandQuery->setParamByKey('1', 'permlink');
109+
110+
//OR
111+
$commandQuery = new CommandQueryData();
112+
$commandQuery->setParams(
90113
[
91114
0 => "author",
92115
1 => "permlink"
93116
]
94117
);
118+
119+
$content = $command->execute(
120+
$commandQuery
121+
);
95122
// will return
96123
// [
97124
// "id" => 1,
@@ -135,48 +162,42 @@ class MyConnector implements ConnectorInterface
135162

136163
namespace My\App\Commands;
137164

138-
use GrapheneNodeClient\Commands\CommandAbstract;
165+
use GrapheneNodeClient\Commands\DataBase\CommandAbstract;
139166
use GrapheneNodeClient\Connectors\ConnectorInterface;
140167

141168
class MyCommand extends CommandAbstract
142169
{
143170
protected $method = 'method_name';
144171

145172
//If different for platforms
146-
protected $requiredParams = [
147-
ConnectorInterface::PLATFORM_GOLOS => [
148-
// for list params
149-
0 => [
150-
'param_key1', //this key will be required
151-
'param_key2', //this key will be required
152-
]
153-
//or
154-
//'param_key1', //this key will be required
155-
//'param_key2', //this key will be required
173+
protected $queryDataMap = [
174+
ConnectorInterface::PLATFORM_GOLOS => [
175+
//on the left is array keys and on the right is validators
176+
//validators for ani list element have to be have '*'
177+
'*:limit' => ['integer'], //the discussions return amount top limit
178+
'*:select_tags:*' => ['nullOrString'], //list of tags to include, posts without these tags are filtered
179+
'*:select_authors:*' => ['nullOrString'], //list of authors to select
180+
'*:truncate_body' => ['nullOrInteger'], //the amount of bytes of the post body to return, 0 for all
181+
'*:start_author' => ['nullOrString'], //the author of discussion to start searching from
182+
'*:start_permlink' => ['nullOrString'], //the permlink of discussion to start searching from
183+
'*:parent_author' => ['nullOrString'], //the author of parent discussion
184+
'*:parent_permlink' => ['nullOrString'] //the permlink of parent discussion
156185
],
157186
ConnectorInterface::PLATFORM_STEEMIT => [
158-
// for list params
159-
0 => [
160-
'some_other_key1', //this key will be required
161-
'some_other_key2', //this key will be required
162-
]
163-
//or
164-
//'some_other_key1', //this key will be required
165-
//'some_other_key2', //this key will be required
187+
//for list params
188+
'*:tag' => ['nullOrString'], //'author',
189+
'*:limit' => ['integer'], //'limit'
190+
'*:start_author' => ['nullOrString'], //'start_author' for pagination,
191+
'*:start_permlink' => ['nullOrString'] //'start_permlink' for pagination,
166192
]
167193
];
168194

169195

170196
//If the same for platforms
171-
//protected $requiredParams = [
172-
// // for list params
173-
// 0 => [
174-
// 'param_key1', //this key will be required
175-
// 'param_key2', //this key will be required
176-
// ]
177-
// //or
178-
// //'param_key1', //this key will be required
179-
// //'param_key2', //this key will be required
197+
//protected $queryDataMap = [
198+
// route example: 'key:123:array' => $_SESSION['key'][123]['array']
199+
// 'some_array_key:some_other_key' => ['integer'], // available validators are 'required', 'array', 'string',
200+
// 'integer', 'nullOrArray', 'nullOrString', 'nullOrInteger'.
180201
//];
181202
}
182203

0 commit comments

Comments
 (0)