Skip to content

Commit

Permalink
Add Attachment result ID fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Nov 29, 2023
1 parent 85f48f4 commit ab6b9e6
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/AbraFlexi/Priloha.php
Expand Up @@ -105,7 +105,7 @@ public static function getFirstAttachment($object)
public static function getAttachment($attachmentID, $options = [])
{
$result = null;
$downloader = new Priloha($attachmentID, $options);
$downloader = new self($attachmentID, $options);
if ($downloader->lastResponseCode == 200) {
$downloader->doCurlRequest(self::getDownloadURL($downloader), 'GET');
if ($downloader->lastResponseCode == 200) {
Expand Down Expand Up @@ -210,20 +210,12 @@ public static function addAttachment(
$attachment,
$contentType
) {
$attached = new Priloha();
$headersBackup = $object->defaultHttpHeaders;
$codeBackup = $object->lastResponseCode;
$responseBackup = $object->lastCurlResponse;
$object->postFields = $attachment;
$object->defaultHttpHeaders['Content-Type'] = $contentType;
$attached = new self();
$attached->postFields = $attachment;
$attached->defaultHttpHeaders['Content-Type'] = $contentType;
$url = $object->getAbraFlexiURL() . '/prilohy/new/' . $filename;
$response = $object->performRequest($url, 'PUT');
$object->defaultHttpHeaders = $headersBackup;
$response = $attached->performRequest($url, 'PUT');
$attached->setMyKey($response[0]['id']);
$attached->lastResponseCode = $object->lastResponseCode;
$attached->lastCurlResponse = $object->lastCurlResponse;
$object->lastResponseCode = $codeBackup;
$object->lastCurlResponse = $responseBackup;
return $attached;
}

Expand Down

0 comments on commit ab6b9e6

Please sign in to comment.