Skip to content

Commit

Permalink
Updated the client to support version 1.6 (#136)
Browse files Browse the repository at this point in the history
* Update to API Version 1.5.13 and added check_code.php

* API Version 1.5.13 - Field Update - Documentation Wrong

* Update to API Version 1.5.14

* Update to API Version 1.5.14

* Updated client for API version 1.6

* API 1.6 Update

* API 1.6.1 Update

* Update src/Client.php

Co-Authored-By: SirPoot- <[email protected]>
  • Loading branch information
devinhyden authored and reynolek committed Jan 25, 2019
1 parent 6af7dc4 commit b39e65b
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/AutotaskObjects/AccountNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class AccountNote extends Entity
// Optional
public $CompletedDateTime;
public $ContactID;
public $CreateDateTime;
public $ImpersonatorCreatorResourceID;
public $ImpersonatorUpdaterResourceID;
public $LastModifiedDate;
public $Name;
public $Note;
Expand Down
3 changes: 2 additions & 1 deletion src/AutotaskObjects/BillingItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class BillingItem extends Entity
public $AccountID;
public $AccountManagerWhenApprovedID;
public $AllocationCodeID;
public $ApprovedTime;
public $BusinessDivisionSubdivisionID;
public $ContractCostID;
public $ContractID;
Expand All @@ -33,6 +32,8 @@ class BillingItem extends Entity
public $LineItemID;
public $MilestoneID;
public $OurCost;
public $PostedDate;
public $PostedOnTime;
public $ProjectCostID;
public $ProjectID;
public $PurchaseOrderNumber;
Expand Down
10 changes: 10 additions & 0 deletions src/AutotaskObjects/ContactGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace ATWS\AutotaskObjects;

class ContactGroup extends Entity
{
// v1.6+ Required
// Required
public $Name;
public $Active;
}
10 changes: 10 additions & 0 deletions src/AutotaskObjects/ContactGroupContact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace ATWS\AutotaskObjects;

class ContactGroupContact extends Entity
{
// v1.6+ Required
// Required
public $ContactGroupID;
public $ContactID ;
}
3 changes: 3 additions & 0 deletions src/AutotaskObjects/ContractNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class ContractNote extends Entity
public $Title;

// Optional
public $CreateDateTime;
public $CreatorResourceID;
public $ImpersonatorCreatorResourceID;
public $ImpersonatorUpdaterResourceID;
public $LastActivityDate;
}
33 changes: 33 additions & 0 deletions src/AutotaskObjects/InstalledProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class InstalledProduct extends Entity
public $HourlyCost;
public $InstalledByContactID;
public $InstalledByID;
public $LastActivityPersonID;
public $LastActivityPersonType;
public $LastModifiedTime;
public $Location;
public $MonthlyCost;
Expand All @@ -76,6 +78,37 @@ class InstalledProduct extends Entity
public $PerUseCost;
public $ReferenceNumber;
public $ReferenceTitle;
public $RMMDeviceAuditAntivirusStatusID;
public $RMMDeviceAuditArchitectureID;
public $RMMDeviceAuditBackupStatusID;
public $RMMDeviceAuditDescription;
public $RMMDeviceAuditDeviceTypeID;
public $RMMDeviceAuditDisplayAdaptorID;
public $RMMDeviceAuditDomainID;
public $RMMDeviceAuditExternalIPAddress;
public $RMMDeviceAuditHostname;
public $RMMDeviceAuditIPAddress;
public $RMMDeviceAuditLastUser;
public $RMMDeviceAuditMacAddress;
public $RMMDeviceAuditManufacturerID;
public $RMMDeviceAuditMemoryBytes;
public $RMMDeviceAuditMissingPatchCount;
public $RMMDeviceAuditMobileNetworkOperatorID;
public $RMMDeviceAuditMobileNumber;
public $RMMDeviceAuditModelID;
public $RMMDeviceAuditMotherboardID;
public $RMMDeviceAuditOperatingSystem;
public $RMMDeviceAuditPatchStatusID;
public $RMMDeviceAuditProcessorID;
public $RMMDeviceAuditServicePackID;
public $RMMDeviceAuditSNMPContact;
public $RMMDeviceAuditSNMPLocation;
public $RMMDeviceAuditSNMPName;
public $RMMDeviceAuditSoftwareStatusID;
public $RMMDeviceAuditStorageBytes;
public $RMMDeviceID;
public $RMMDeviceUID;
public $RMMOpenAlertCount;
public $SerialNumber;
public $ServiceBundleID;
public $ServiceID;
Expand Down
3 changes: 3 additions & 0 deletions src/AutotaskObjects/ProjectNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class ProjectNote extends Entity
public $Title;

// Optional
public $CreateDateTime;
public $CreatorResourceID;
public $ImpersonatorCreatorResourceID;
public $ImpersonatorUpdaterResourceID;
public $LastActivityDate;
}
1 change: 1 addition & 0 deletions src/AutotaskObjects/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Resource extends Entity
public $FirstName;
public $HireDate;
public $LastName;
public $LicenseType;
public $LocationID;
public $NumberFormat;
public $PayrollType;
Expand Down
3 changes: 3 additions & 0 deletions src/AutotaskObjects/TaskNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ class TaskNote extends Entity
public $Title;

// Optional
public $CreateDateTime;
public $CreatorResourceID;
public $ImpersonatorCreatorResourceID;
public $ImpersonatorUpdaterResourceID;
}
4 changes: 4 additions & 0 deletions src/AutotaskObjects/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class Ticket extends Entity
public $ContractServiceBundleID;
public $ContractServiceID;
public $CreateDate;
public $CreateDateTime;
public $CreatorResourceID;
public $CreatorType;
public $CurrentServiceThermometerRating;
public $Description;
public $EstimatedHours;
public $ExternalID;
Expand All @@ -52,6 +54,7 @@ class Ticket extends Entity
public $MonitorID;
public $MonitorTypeID;
public $OpportunityId;
public $PreviousServiceThermometerRating;
public $ProblemTicketId;
public $ProjectID;
public $PurchaseOrderNumber;
Expand All @@ -64,6 +67,7 @@ class Ticket extends Entity
public $ServiceLevelAgreementHasBeenMet;
public $ServiceLevelAgreementID;
public $ServiceLevelAgreementPausedNextEventHours;
public $ServiceThermometerTemperature;
public $Source;
public $SubIssueType;
public $TicketCategory;
Expand Down
10 changes: 10 additions & 0 deletions src/AutotaskObjects/TicketAdditionalInstalledProduct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace ATWS\AutotaskObjects;

class TicketAdditionalInstalledProduct extends Entity
{
// v1.6+ Required
// Required
public $InstalledProductID;
public $TicketID ;
}
13 changes: 13 additions & 0 deletions src/AutotaskObjects/TicketHistory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace ATWS\AutotaskObjects;

class TicketHistory extends Entity
{
// v1.6+ Required
// Required
public $TicketID;
public $Action;
public $Detail;
public $Date;
public $ResourceID;
}
3 changes: 3 additions & 0 deletions src/AutotaskObjects/TicketNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class TicketNote extends Entity
public $Title;

// Optional
public $CreateDateTime;
public $CreatorResourceID;
public $ImpersonatorCreatorResourceID;
public $ImpersonatorUpdaterResourceID;
public $LastActivityDate;
}
2 changes: 2 additions & 0 deletions src/AutotaskObjects/TimeEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class TimeEntry extends Entity
public $EndDateTime;
public $HoursToBill;
public $HoursWorked;
public $ImpersonatorCreatorResourceID;
public $ImpersonatorUpdaterResourceID;
public $InternalAllocationCodeID;
public $InternalNotes;
public $LastModifiedDateTime;
Expand Down
30 changes: 25 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php
namespace ATWS;

use \ATWS\AutotaskObjects;

class Client extends \SoapClient
{
protected $version;

public static $classMap = array(
'Account' => 'ATWS\AutotaskObjects\Account',
'AccountAlert' => 'ATWS\AutotaskObjects\AccountAlert',
Expand Down Expand Up @@ -45,6 +48,8 @@ class Client extends \SoapClient
'ContractCost' => 'ATWS\AutotaskObjects\ContractCost',
'ContractExclusionAllocationCode' => 'ATWS\AutotaskObjects\ContractExclusionAllocationCode',
'ContractFactor' => 'ATWS\AutotaskObjects\ContractFactor',
'ContactGroup' => 'ATWS\AutotaskObjects\ContactGroup',
'ContactGroupContact' => 'ATWS\AutotaskObjects\ContactGroupContact',
'ContractMilestone' => 'ATWS\AutotaskObjects\ContractMilestone',
'ContractNote' => 'ATWS\AutotaskObjects\ContractNote',
'ContractRate' => 'ATWS\AutotaskObjects\ContractRate',
Expand Down Expand Up @@ -147,11 +152,13 @@ class Client extends \SoapClient
'TaxRegion' => 'ATWS\AutotaskObjects\TaxRegion',
'Ticket' => 'ATWS\AutotaskObjects\Ticket',
'TicketAdditionalContact' => 'ATWS\AutotaskObjects\TicketAdditionalContact',
'TicketAdditionalInstalledProduct' => 'ATWS\AutotaskObjects\TicketAdditionalInstalledProduct',
'TicketCategory' => 'ATWS\AutotaskObjects\TicketCategory',
'TicketCategoryFieldDefaults' => 'ATWS\AutotaskObjects\TicketCategoryFieldDefaults',
'TicketChangeRequestApproval' => 'ATWS\AutotaskObjects\TicketChangeRequestApproval',
'TicketChecklistItem' => 'ATWS\AutotaskObjects\TicketChecklistItem',
'TicketCost' => 'ATWS\AutotaskObjects\TicketCost',
'TicketHistory' => 'ATWS\AutotaskObjects\TicketHistory',
'TicketNote' => 'ATWS\AutotaskObjects\TicketNote',
'TicketSecondaryResource' => 'ATWS\AutotaskObjects\TicketSecondaryResource',
'TimeEntry' => 'ATWS\AutotaskObjects\TimeEntry',
Expand All @@ -162,21 +169,27 @@ class Client extends \SoapClient
);

// @codeCoverageIgnoreStart
public function __construct($wsdl, $soapOpts = array())
public function __construct($wsdl, $soapOpts = array(), $integrationCode = null)
{
foreach (static::$classMap as $external => $internal) {
if (!isset($soapOpts['classmap'][$external])) {
$soapOpts['classmap'][$external] = $internal;
}
}

$parts = explode('/', $wsdl);
$this->version = $parts[4];

if (!is_null($integrationCode)) {
$this->setIntegrationCode($integrationCode);
}
parent::__construct($wsdl, $soapOpts);
}

public function setIntegrationCode($code)
{
$header = new \SOAPHeader(
'http://autotask.net/ATWS/v1_5/',
'http://autotask.net/ATWS/v' . str_replace('.', '_', $this->version) .'/',
'AutotaskIntegrations',
array(
'IntegrationCode' => $code,
Expand Down Expand Up @@ -205,10 +218,10 @@ public function bulkCreate(array $objs)
}
$createObjs = null;
foreach ($objs as $obj) {
if (!$createObjs){
$createObjs = new AutotaskObjects\CreateParam($obj);
if (!$createObjs) {
$createObjs = new AutotaskObjects\CreateParam($obj);
} else {
$createObjs->Entities[] = $obj;
$createObjs->Entities[] = $obj;
}
}
return $this->_call('create', array($createObjs));
Expand Down Expand Up @@ -310,6 +323,13 @@ public function getInvoiceMarkup($invoiceId, $type)

public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
if (strpos($action, 'getZoneInfo') === false &&
$this->version >= 1.6 &&
empty($this->__default_headers[0]->data['IntegrationCode'])
) {
throw new ATWSException('Integration code required with this version of the API.');
}

return parent::__doRequest($request, $location, $action, $version, $one_way);
}

Expand Down

0 comments on commit b39e65b

Please sign in to comment.