helpscout / helpscout-api-php

PHP Wrapper for the Help Scout API
MIT License
99 stars 62 forks source link

Example for how to create an attachment #305

Closed helgatheviking closed 1 year ago

helgatheviking commented 1 year ago

I found this issue concerning adding attachments to a conversation: https://github.com/helpscout/helpscout-api-php/issues/47#issuecomment-289723552

But it's a little confusing to me because I can't tell what $hs->createAttachment($at); is meant to be, nor can I find createAttachment() in the source any more.

helgatheviking commented 1 year ago

Oops... update to say I found:

$factory = new AttachmentFactory(new Filesystem());
$file = $factory->make(__FILE__);
$thread->setAttachments(new Collection([$file]));

in the threads example. Is this the current way to add attachments?

miguelrs commented 1 year ago

@helgatheviking Yes, that's the way to add an attachment to a thread 👍

Just make sure you replace the __FILE__ magic constant with the path of the file you want to upload.