# rescale()

## Signature

```php
public function rescale(ProductHosting $productHosting, array $productOptionMapping, array $deltaProductOptionMapping, ProductHostingRescale $rescale): ServerHostingRescaledResponse
```

### Parameters

1. #### $productHosting

   The ProductHosting model where the action gets executed on
2. $productOptionMapping\
   A key-value mapping of all [productOptions](https://docs.hostware.io/developer-documentation/module/hosting-module/hosting-handler/getavailableproductoptions), including the new/changed ones
3. $deltaProductOptionMapping\
   Sames as 2., but only the delta/changed productOptions which have changed
4. $rescale\
   The ProductHostingRescale model which may be useful sometimes (most cases: ignore it)

## Description

Performs a rescale (up/downgrade) of the hosting. The function will get triggered asynchronous in a queue and only after the upgrade was paid.&#x20;

This should only send the changed options to the integration, the entire billing part etc. is handled by hostware.

## Return value

An empty ServerHostingRescaledResponse for success, Exception with the mesage on error. If you return an error, the rescale will be marked as pending and e.g. will be executed by an admin in the future. The new productOptions / new pricing will only be applied to the user once the rescale was successfull.\
Example:

```php
return new ServerHostingRescaledResponse()
```

## Example

```php
/**
 * @param ProductHosting $productHosting
 * @return ServerHostingDeletedResponse
 * @throws GuzzleException
 */
public function unlock(ProductHosting $productHosting): ServerHostingDeletedResponse{
        // API request to delete the user
        $res = $this->getClient($productHosting->host)->killUser($productHosting->custom_fields['nextcloudUser']);
        
        // error handling
        if (isset($res['meta']) && $res['meta']['statuscode'] !== "100") {
		throw new Exception(json_encode($res));
        }

        // success
	return new ServerHostingDeletedResponse();
}
```
