cwmiller / broadworks-connector

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

Unset user department error #54

Closed davidraedev closed 4 years ago

davidraedev commented 4 years ago

I've been trying to unset the department assigned to a user, but have been having some trouble.

The best I've gotten is to set the department to NULL like so

$request = ( new UserConsolidatedModifyRequest() )
        ->setUserId( $user_id );
        ->setDepartment( NULL );

But I'm getting back an error

CWM\BroadWorksConnector\Ocip\ErrorResponseException Object
(
    [detail] => Element 'T=DepartmentKey' is abstract and cannot be used in an instance
    [message:protected] => [Error 6004] OCI XML Request validation error
    [string:Exception:private] => 
    [code:protected] => 6004
    [file:protected] => /var/www/broadsoft/vendor/cwm/broadworks-connector/src/OcipClient.php
    [line:protected] => 556

I've also tried setting the GroupDepartmentKey name to NULL.

->setDepartment(
    ( new GroupDepartmentKey() )
        ->setServiceProviderId( $service_provider_id )
        ->setGroupId( $group_id )
        ->setName( NULL )
)

but it throws a FieldNotSetException.

Am I doing this right, or is there a different way?

Possibly related to the DepartmentKey abstract class issue in https://github.com/cwmiller/broadworks-connector/issues/8

cwmiller commented 4 years ago

This has been fixed with version 3.1.2. Your first example with ->setDepartment( NULL ) is the correct method and should work now.

davidraedev commented 4 years ago

Thanks so much! I tested and confirmed its fixed.