cwmiller / broadworks-connector

Simple library for connecting to BroadWorks OCI-P API
MIT License
8 stars 5 forks source link

SearchCriteriaDeviceMACAddress #14

Closed TwinMist closed 6 years ago

TwinMist commented 6 years ago

Hi If possible can you write a example of how to build a search request trying to search for a DeviceMACAddress with the below code i am getting: Error 6004] OCI XML Request validation error tired use CWM\BroadWorksConnector\Ocip\Models\SearchCriteria; use CWM\BroadWorksConnector\Ocip\Models\SearchCriteriaDeviceMACAddress; use CWM\BroadWorksConnector\Ocip\Models\SystemEndpointGetListRequest; use CWM\BroadWorksConnector\Ocip\Models\SystemEndpointGetListResponse;

$DeviceMACAddress = (new SearchCriteriaDeviceMACAddress()) ->setmode('CONTAINS') ->setvalue('XXXXXX') ->setisCaseInsensitive('true');

$request = (new SystemEndpointGetListRequest()) ->setsearchCriteriaDeviceMACAddress($DeviceMACAddress);

try { $response = $ocip->SystemEndpointGetListRequest($request); foreach ($response->getendpointTable()->getRow() as $row) { echo $row->getCol()[0] . PHP_EOL; } } catch (ErrorResponseException $e) { echo $e->getMessage() . PHP_EOL; exit(); } thanks

cwmiller commented 6 years ago

Two issues: 1) CONTAINS should be Contains 2) setSearchCriteriaDeviceMACAddress expects an array

$DeviceMACAddress = (new SearchCriteriaDeviceMACAddress())
->setMode('Contains')
->setValue('XXXXXX')
->setIsCaseInsensitive(true);

$request = (new SystemEndpointGetListRequest())
->setSearchCriteriaDeviceMACAddress([$DeviceMACAddress]);