Skip to content

Commit

Permalink
* save function will now return object returned by the API
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicLegend committed Apr 19, 2022
1 parent 83cedf6 commit d43bc94
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/Rest/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,17 @@ public function __construct(Session $session, array $fromData = null)
}
}

public function save($updateObject = false): void
/**
* @param bool $updateObject
* @return array|string|null
* @throws RestResourceException
* @throws RestResourceRequestException
* @throws \JsonException
* @throws \Psr\Http\Client\ClientExceptionInterface
* @throws \Shopify\Exception\MissingArgumentException
* @throws \Shopify\Exception\UninitializedContextException
*/
public function save(bool $updateObject = false)
{
$data = self::dataDiff($this->toArray(), $this->originalState);

Expand All @@ -71,11 +81,22 @@ public function save($updateObject = false): void

self::createInstance($body[$this->getJsonBodyName()], $this->session, $this);
}

return $response->getDecodedBody();
}

public function saveAndUpdate(): void
/**
* @return array|string|null
* @throws RestResourceException
* @throws RestResourceRequestException
* @throws \JsonException
* @throws \Psr\Http\Client\ClientExceptionInterface
* @throws \Shopify\Exception\MissingArgumentException
* @throws \Shopify\Exception\UninitializedContextException
*/
public function saveAndUpdate()
{
$this->save(true);
return $this->save(true);
}

public function __get(string $name)
Expand Down

0 comments on commit d43bc94

Please sign in to comment.