Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ $attachment_content = $ticket_article->getAttachmentContent(23);

In the above example 23 is the ID of the attachment. This ID can be found within the `attachments` array of the ticket article data. Usually you want to loop over this array to fetch the content of all attachments.

`getAttachmentContent()` returns the attachment content as a string, ready to use.

### Updating Resource objects
If you fetched a `Resource` object and changed some values, you have to send your changes to Zammad. You do this with a simple call:
```php
Expand Down
3 changes: 3 additions & 0 deletions src/Resource/TicketArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public function getAttachmentContent($attachment_id)
}

$content = $response->getBody();
if ( $content instanceof \Psr\Http\Message\StreamInterface ) {
$content = $content->getContents();
}
return $content;
}
}
2 changes: 1 addition & 1 deletion test/ZammadAPIClient/Resource/TicketArticleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function testCreate( $values, $expected_success )

// Fetch attachment content
$content = $object->getAttachmentContent( $attachment['id'] );
$this->assertEquals(
$this->assertSame(
$expected_content,
$content,
"Content of file $filename must match expected one."
Expand Down