@@ -11,43 +11,59 @@ composer require t3ran13/php-graphene-node-client
11
11
``` php
12
12
<?php
13
13
14
- use GrapheneNodeClient\Commands\GetTrendingCategoriesCommand;
14
+ use GrapheneNodeClient\Commands\CommandQueryData;
15
+ use GrapheneNodeClient\Commands\DataBase\GetDiscussionsByCreatedCommand;
15
16
use GrapheneNodeClient\Connectors\WebSocket\GolosWSConnector;
17
+ use GrapheneNodeClient\Connectors\WebSocket\SteemitWSConnector;
16
18
17
- $command = new GetTrendingCategoriesCommand(new GolosWSConnector());
18
19
19
- $trendingTags = $command->execute(
20
+ //Set params for query
21
+ $commandQuery = new CommandQueryData();
22
+ $data = [
20
23
[
21
- "", //'after'
22
- 2 //'limit'
24
+ 'limit' => $limit,
25
+ 'select_tags' => ['golos'], // for GOLOS
26
+ 'tag' => 'steemit', // for STEEMIT
23
27
]
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
24
40
);
25
41
// will return
26
42
// [
27
- // "id" => 2 ,
43
+ // "id" => 1 ,
28
44
// "result" => [
29
45
// [
30
- // "name" => "ru--zhiznx",
31
- // "total_payouts": "410233.942 GBG",
46
+ // "id": 466628,
47
+ // "author": "piranya",
48
+ // "permlink": "devyatyi-krug",
32
49
// ...
33
50
// ],
34
51
// ...
35
52
// ]
36
53
// ]
37
54
38
- $trendingTags = $command->execute(
39
- [
40
- "", //'after'
41
- 2 //'limit'
42
- ],
55
+ $command = new GetDiscussionsByCreatedCommand(new SteemitWSConnector());
56
+ $steemitPosts = $command->execute(
57
+ $commandQuery,
43
58
'result',
44
- GolosWSConnector ::ANSWER_FORMAT_ARRAY // or GolosWSConnector ::ANSWER_FORMAT_OBJECT
59
+ SteemitWSConnector ::ANSWER_FORMAT_ARRAY // or SteemitWSConnector ::ANSWER_FORMAT_OBJECT
45
60
);
46
61
// will return
47
62
// [
48
63
// [
49
- // "name" => "ru--zhiznx",
50
- // "total_payouts": "410233.942 GBG",
64
+ // "id": 466628,
65
+ // "author": "piranya",
66
+ // "permlink": "devyatyi-krug",
51
67
// ...
52
68
// ],
53
69
// ...
@@ -60,7 +76,7 @@ $trendingTags = $command->execute(
60
76
61
77
## Implemented Commands List
62
78
63
- namespace: GrapheneNodeClient\Commands;
79
+ namespace: GrapheneNodeClient\Commands\DataBase ;
64
80
65
81
- GetContentCommand
66
82
- GetDiscussionsByAuthorBeforeDateCommand
@@ -81,17 +97,28 @@ switch between connectors
81
97
``` php
82
98
<?php
83
99
84
- use GrapheneNodeClient\Commands\GetContentCommand;
100
+ use GrapheneNodeClient\Commands\CommandQueryData;
101
+ use GrapheneNodeClient\Commands\DataBase\GetContentCommand;
85
102
use GrapheneNodeClient\Connectors\InitConnector;
86
103
87
104
$command = new GetContentCommand(InitConnector::getConnector(InitConnector::PLATFORM_STEEMIT));
88
105
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(
90
113
[
91
114
0 => "author",
92
115
1 => "permlink"
93
116
]
94
117
);
118
+
119
+ $content = $command->execute(
120
+ $commandQuery
121
+ );
95
122
// will return
96
123
// [
97
124
// "id" => 1,
@@ -135,48 +162,42 @@ class MyConnector implements ConnectorInterface
135
162
136
163
namespace My\App\Commands;
137
164
138
- use GrapheneNodeClient\Commands\CommandAbstract;
165
+ use GrapheneNodeClient\Commands\DataBase\ CommandAbstract;
139
166
use GrapheneNodeClient\Connectors\ConnectorInterface;
140
167
141
168
class MyCommand extends CommandAbstract
142
169
{
143
170
protected $method = 'method_name';
144
171
145
172
//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
156
185
],
157
186
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,
166
192
]
167
193
];
168
194
169
195
170
196
//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'.
180
201
//];
181
202
}
182
203
0 commit comments