cwmiller / broadworks-connector

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

setAuthorizedQuantity #41

Closed TwinMist closed 5 years ago

TwinMist commented 5 years ago

Hi is there a way within the request, if the setquantity($total) is not set then use ->setUnlimited(true) and vise versa? thanks. $request = (new GroupServiceModifyAuthorizationListRequest()) ->setServiceProviderId($serviceProviderId) ->setGroupId($groupId) ->setServicePackAuthorization([ (new ServicePackAuthorization()) ->setServicePackName($service) ->setAuthorizedQuantity( (new UnboundedPositiveInt()) ->setquantity($total)),

cwmiller commented 5 years ago

You can just pass an instance of UnboundedPositiveInt that you create ahead of time.


$total = 'Unlimited'; // or 100
$unboundedPositiveInt = new UnboundedPositiveInt();
if ($total === 'Unlimited') {
    $unboundedPositiveInt->setUnlimited(true);
} else {
    $unboundedPositiveInt->setQuantity($total);
}

$request = (new GroupServiceModifyAuthorizationListRequest())
    ->setServiceProviderId($serviceProviderId)
    ->setGroupId($groupId)
    ->setServicePackAuthorization([
        (new ServicePackAuthorization())
            ->setServicePackName($service)
            ->setAuthorizedQuantity($unboundedPositiveInt)
    ]);