diff --git a/get_attachment_example.php b/get_attachment_example.php new file mode 100644 index 0000000..805bf43 --- /dev/null +++ b/get_attachment_example.php @@ -0,0 +1,35 @@ + $username, + 'password' => $password, + 'trace' => 1, // Allows us to debug by getting the XML requests sent +); + +$opts = array('trace' => 1); +$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl'; +$client = new ATWS\Client($authWsdl, $opts); +$zoneInfo = $client->getZoneInfo($username); + +$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL); +$client = new ATWS\Client($wsdl, $postAuthOpts); + +$ticketId = 225975; +$attachmentInfo = new \ATWS\AutotaskObjects\Query('AttachmentInfo'); +$parentidQueryfield = new \ATWS\AutotaskObjects\QueryField('parentid'); +$parentidQueryfield->addExpression('equals',$ticketId); +$attachmentInfo->addField($parentidQueryfield); +$attachments = $client->query($attachmentInfo)->queryResult->EntityResults->Entity; +$attachments = (count($attachments) > 1 ? $attachments : [$attachments]); +foreach ($attachments as $attachment) +{ + $result = $client->GetAttachment($attachment); + $save = file_put_contents($result->GetAttachmentResult->Info->FullPath, $result->GetAttachmentResult->Data); +} diff --git a/src/AutotaskObjects/GetAttachment.php b/src/AutotaskObjects/GetAttachment.php new file mode 100644 index 0000000..7855e31 --- /dev/null +++ b/src/AutotaskObjects/GetAttachment.php @@ -0,0 +1,11 @@ +attachmentId = $param; + } +} diff --git a/src/AutotaskObjects/GetAttachmentResponse.php b/src/AutotaskObjects/GetAttachmentResponse.php new file mode 100644 index 0000000..8352280 --- /dev/null +++ b/src/AutotaskObjects/GetAttachmentResponse.php @@ -0,0 +1,7 @@ + 'ATWS\AutotaskObjects\ExpenseItem', 'ExpenseReport' => 'ATWS\AutotaskObjects\ExpenseReport', 'Field' => 'ATWS\AutotaskObjects\Field', + 'GetAttachment' => 'ATWS\AutotaskObjects\GetAttachment', + 'GetAttachmentResponse' => 'ATWS\AutotaskObjects\GetAttachmentResponse', 'getUDFInfo' => 'ATWS\AutotaskObjects\UDFParam', 'getUDFInfoResponse' => 'ATWS\AutotaskObjects\UDFInfoResponse', 'InstalledProduct' => 'ATWS\AutotaskObjects\InstalledProduct', @@ -205,6 +207,12 @@ public function bulkDelete(array $objs) return $this->_call('delete', array($deleteObjs)); } + public function GetAttachment(AutotaskObjects\Entity $obj) + { + $params = new AutotaskObjects\GetAttachment($obj); + return $this->_call('GetAttachment', array($params)); + } + public function CreateAttachment(AutotaskObjects\Entity $obj) { $params = new AutotaskObjects\CreateAttachment($obj);