Jump to content

Sean

Members
  • Posts

    7
  • Joined

  • Last visited

Reputation Activity

  1. Upvote
    Sean got a reaction from lyoder in RMM Configuration, Org, Location and PSA Customers   
    Is there a reason there is no sync or way to associate RMM Organizations with clients in the PSA?
    I'd half expect to at least be able to import clients from the PSA into the RMM.  Searching the forums there are one or two mentions around this, but surprised there isn't more documentation on this.  I even read that systems don't sync into the PSA until they raise a ticket and when they do you have to manually assign them to the correct client.

    Am I missing something?
  2. Like
    Sean reacted to MaxITGarrett in [PHP] WHMCS Hook to Automatically Add to PSA   
    For those of you who would like to use WHMCS (Automated web hosting platform) but wish to use Pulseway PSA for your main ticketing software and for managing your consulting business if you are an MSP like us, I had to make a hook for WHMCS which takes the client details and automatically makes a client account for them within PSA and grants them access to the ticketing system, using the same password for WHMCS. This vastly simplifies things for the client, and conforms the tickets into one system.
    Once this file is created, it needs to be placed into the following directory with any name:
    \includes\hooks\AddClientToPSA.php YOU WILL NEED TO QUERY SOME VALUES YOURSELF THROUGH THE API TO MAKE THE HOOK VALID (mentioned as comments) (if you need help with this, I can provide code)
    <?php add_hook('ClientAdd', 1, function($vars) { // Setup the curl request for PSA $curl = curl_init(); // Set the endpoint curl_setopt($curl, CURLOPT_URL, "https://psa.pulseway.com/api/token"); // POST Request curl_setopt($curl, CURLOPT_POST, true); // Credentials for Authorization curl_setopt($curl, CURLOPT_POSTFIELDS, "grant_type=password&username=username&password=userpassword&tenant=companyname"); // Proper header information curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); // Return the transfer as a string curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Get the response $response = json_decode(curl_exec($curl)); // Close the curl curl_close($curl); // Extract the token $token = $response->access_token; // Now to create a new company $curl = curl_init(); // Set the endpoint curl_setopt($curl, CURLOPT_URL, "https://psa.pulseway.com/api/crm/accounts"); // POST Request curl_setopt($curl, CURLOPT_POST, true); // Gather current datetime $date = new DateTime(); // Gather a company name, if specified $companyName = $vars['companyname']; // If they don't have a company name, make it their first name and last name if (empty($companyName)) { $companyName = $vars['firstname'] . $vars['lastname']; } // Build the JSON to go with the request $account = json_encode(array( "AccountCode" => (string)$vars['userid'], "AccountTypeId" => 12345, // UNIQUE TO YOU "AccountName" => $companyName, "Description" => "From WHMCS.", "Website" => null, "BusinessTypeId" => 0, "ServiceTypeId" => 123, // UNIQUE TO YOU "CurrencyId" => 1, "SalesTaxItemId" => null, "AccountManagerId" => 12345, // UNIQUE TO YOU "IsActive" => true, "IsBilling" => true, "AcquiredDate" => $date->format('Y-m-d\TH:i:s.u'), "CreditLimit" => null, "NetDays" => null, "Locations" => [array( "LocationName" => "Main", "IsActive" => true, "IsMain" => true, "Addresses" => [array( "Address1" => $vars['address1'], "Address2" => $vars['address2'], "City" => $vars['city'], "State" => $vars['state'], "ZipCode" => $vars['postcode'], "Phone" => $vars['phonenumber'], "Latitude" => null, "Longitude" => null, "EmailAddress" => $vars['email'], "Fax" => null, "AddressTypeId" => 1 )] )] )); // Add the JSON to the request curl_setopt($curl, CURLOPT_POSTFIELDS, $account); // Set the header, with the authorization token curl_setopt($curl, CURLOPT_HTTPHEADER, array( "Authorization: Bearer " . $token, "Content-Type: application/json", "Accept: application/json" )); // Return the transfer as a string curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Get the response $response = curl_exec($curl); // Close the curl curl_close($curl); // Get the ID of the new account $response_json = json_decode($response); $account_id = $response_json->{'Id'}; // Create a new Contact now $curl = curl_init(); // Set the endpoint curl_setopt($curl, CURLOPT_URL, "https://psa.pulseway.com/api/Import/contacts"); // POST Request curl_setopt($curl, CURLOPT_POST, true); // Build the JSON to go with the request $contact = json_encode(array( "AccountName" => $companyName, "LocationName" => "Main", "FirstName" => $vars['firstname'], "LastName" => $vars['lastname'], "Email" => $vars['email'], "Phone" => $vars['phonenumber'], "JobTitle" => "Client", "Poc" => true, "IsClientPortal" => true, "PortalUsername" => $vars['email'], "PortalPassword" => $vars['password'], "PortalSecurityLevel" => "External User" )); // To conform with Pulseway API format $contact = '[' . $contact . ']'; // Add the JSON to the request curl_setopt($curl, CURLOPT_POSTFIELDS, $contact); // Set the header, with the authorization key curl_setopt($curl, CURLOPT_HTTPHEADER, array( "Authorization: Bearer " . $token, "Content-Type: application/json", "Accept: application/json" )); // Return the transfer as a string curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Close the curl curl_close($curl); }); ?>  
×
×
  • Create New...