detain/myadmin-pleskautomation-webhosting

View on GitHub
bin/activateSubscription.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

include_once __DIR__.'/../../../../include/functions.inc.php';
$ppaConnector = get_webhosting_ppa_instance();
// let us form an array with account data
$password = _randomstring(10);
$data = $GLOBALS['tf']->accounts->read(2773);
[$first, $last] = explode(' ', $data['name']);
$accountId = 127;
$serviceTemplateId = 24;
$request = [
    'account_id' => $accountId,
    'service_template_id' => $serviceTemplateId
];
// Make the pem.addAccount call.
// The PPAConnector instance will form a proper XML-RPC request by itself.
// Note that the method is called without the pem prefix as it will be added by the PPAConnector instance.
$result = $ppaConnector->activateSubscription($request);
echo 'Result:';
var_dump($result);
echo "\n";
// Parse the response
try {
    PPAConnector::checkResponse($result);
} catch (\Exception $e) {
    echo 'Caught exception: '.$e->getMessage().PHP_EOL;
}
echo "Success.\nGot Subscription ID: {$result['result']['subscription_id']}\n";