for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Helix\Asana\Task;
use Helix\Asana\Base\AbstractEntity;
use Helix\Asana\Base\AbstractEntity\DeleteTrait;
use Helix\Asana\Task;
/**
* A file attachment.
*
* @see https://developers.asana.com/docs/asana-attachments
* @see https://developers.asana.com/docs/attachment
* @immutable Attachments may only be deleted after creation.
* @method string getCreatedAt ()
* @method string getDownloadUrl ()
* @method string getHost ()
* @method string getName ()
* @method Task getParent ()
* @method string getPermanentUrl () Short, human-friendly.
* @method string getViewUrl ()
*/
class Attachment extends AbstractEntity {
use DeleteTrait;
const TYPE = 'attachment';
protected static $map = [
'parent' => Task::class
];
final public function __toString (): string {
return "attachments/{$this->getGid()}";
}
* Creates the attachment by uploading a file.
* @param string $file
* @return $this
public function upload (string $file) {
// api returns compact version. reload.
$remote = $this->api->upload("{$this->getParent()}/attachments", $file);
$this->data['gid'] = $remote['gid'];
$this->reload();
return $this;