<?php

require_once '../objects/AcTicket.class.php';
$ticket = AcTicket::load('http://dev.rowleycontrols.com', '20-MEhaRilS50HcW34ldiDXmEaMPP3jcPHPjPP1X2IQ', 2, 39);
echo '<h1>Load Dump</h1>';
echo '<pre>';
var_dump($ticket);
echo '</pre>';
$ticket->setVisibility(1);
$ticket->setDueOn(null);
$ticket->setPriority(0);
$ticket->save();
//$ticket = AcTicket::create('http://dev.rowleycontrols.com', '20-MEhaRilS50HcW34ldiDXmEaMPP3jcPHPjPP1X2IQ', 2, 'This is another ticket.', 'This is the body of the new ticket.', 'test ticket, api', 0, 2, '2010-09-15', array(array(20, 22), 20), 406, 364);
echo '<h1>Save Dump</h1>';
echo '<pre>';
var_dump($ticket);
echo '</pre>';
$ticket->complete();
 public function save($acBaseUrl = null, $userApiKey = null)
 {
     $tagsComma = "";
     for ($i = 0; $i < count($this->tags); ++$i) {
         $tagsComma .= $i != 0 ? ', ' : '';
         $tagsComma .= $this->tags[$i];
     }
     $post_params = AcTicket::createTicketPostArray($this->name, $this->body, $tagsComma, $this->visibility, $this->priority, $this->due_on, $this->assignees, $this->milestone_id, $this->parrent_id);
     $baseUrl = $this->acBaseUrl;
     if ($acBaseUrl != null && is_string($acBaseUrl) && $acBaseUrl != "") {
         $baseUrl = $acBaseUrl;
     }
     $apiKey = $this->userApiKey;
     if ($userApiKey != null && is_string($userApiKey) && $userApiKey != "") {
         $apiKey = $userApiKey;
     }
     $rawTicket = AcHelper::sendPostRequest('/projects/' . $this->project_id . '/tickets/' . $this->ticket_id . '/edit', $post_params, $baseUrl, $apiKey);
     $this->populate($rawTicket);
     echo '<h2>Save</h2>';
     echo '<pre>';
     //var_dump($post_params);
     //var_dump($rawTicket);
     var_dump($this);
     echo '</pre>';
 }