Skip to content

Commit d03c4f6

Browse files
committed
Change addAttachment so it will accept filename and resource.
This will support anything, and not only files.
1 parent 6e314ab commit d03c4f6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Picqer/Financials/Moneybird/Entities/SalesInvoice.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,23 @@ public function duplicateToCreditInvoice()
204204
/**
205205
* Add Attachment to this invoice
206206
*
207-
* @param string $file
207+
* You can use fopen('/path/to/file', 'r') in $resource.
208+
*
209+
* @param string $filename The filename of the attachment
210+
* @param resource $contents A StreamInterface/resource/string, @see http://docs.guzzlephp.org/en/stable/request-options.html?highlight=multipart#multipart
208211
*
209212
* @return \Picqer\Financials\Moneybird\Entities\SalesInvoice
210213
*
211214
* @throws \Picqer\Financials\Moneybird\Exceptions\ApiException
212215
*/
213-
public function addAttachment($file)
216+
public function addAttachment($filename, $contents)
214217
{
215218
$this->connection()->upload($this->endpoint . '/' . $this->id . '/attachments', [
216219
'multipart' => [
217220
[
218221
'name' => 'file',
219-
'contents' => fopen($file, 'r'),
222+
'contents' => $contents,
223+
'filename' => $filename,
220224
],
221225
]
222226
]);

0 commit comments

Comments
 (0)