File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -52,4 +52,23 @@ public function get($field, $value)
5252 return new Struct \GeneralInfo ($ response ->data ->gen_info );
5353 }
5454
55+ /**
56+ * @return Struct\GeneralInfo[]
57+ */
58+ public function find ()
59+ {
60+ $ packet = $ this ->_client ->getPacket ();
61+ $ getTag = $ packet ->addChild ('customer ' )->addChild ('get ' );
62+ $ getTag ->addChild ('filter ' );
63+ $ getTag ->addChild ('dataset ' )->addChild ('gen_info ' );
64+ $ response = $ this ->_client ->request ($ packet , \PleskX \Api \Client::RESPONSE_FULL );
65+
66+ $ customers = [];
67+ foreach ($ response ->xpath ('//result ' ) as $ xmlResult ) {
68+ $ customers [] = new Struct \GeneralInfo ($ xmlResult ->data ->gen_info );
69+ }
70+
71+ return $ customers ;
72+ }
73+
5574}
Original file line number Diff line number Diff line change @@ -11,11 +11,15 @@ class GeneralInfo extends \PleskX\Api\Struct
1111 /** @var string */
1212 public $ login ;
1313
14+ /** @var string */
15+ public $ guid ;
16+
1417 public function __construct ($ apiResponse )
1518 {
1619 $ this ->_initScalarProperties ($ apiResponse , [
1720 ['pname ' => 'personalName ' ],
1821 'login ' ,
22+ 'guid ' ,
1923 ]);
2024 }
2125}
Original file line number Diff line number Diff line change @@ -36,4 +36,26 @@ public function testGet()
3636 $ this ->_client ->customer ()->delete ('id ' , $ customer ->id );
3737 }
3838
39+ public function testFind ()
40+ {
41+ $ this ->_client ->customer ()->create ([
42+ 'pname ' => 'John Smith ' ,
43+ 'login ' => 'customer-a ' ,
44+ 'passwd ' => 'simple-password ' ,
45+ ]);
46+ $ this ->_client ->customer ()->create ([
47+ 'pname ' => 'Mike Black ' ,
48+ 'login ' => 'customer-b ' ,
49+ 'passwd ' => 'simple-password ' ,
50+ ]);
51+
52+ $ customersInfo = $ this ->_client ->customer ()->find ();
53+ $ this ->assertCount (2 , $ customersInfo );
54+ $ this ->assertEquals ('John Smith ' , $ customersInfo [0 ]->personalName );
55+ $ this ->assertEquals ('customer-a ' , $ customersInfo [0 ]->login );
56+
57+ $ this ->_client ->customer ()->delete ('login ' , 'customer-a ' );
58+ $ this ->_client ->customer ()->delete ('login ' , 'customer-b ' );
59+ }
60+
3961}
You can’t perform that action at this time.
0 commit comments