Skip to content

Commit

Permalink
Merge pull request #456 from MaartenWaegeman/master
Browse files Browse the repository at this point in the history
Update Storable.php
  • Loading branch information
casperbakker authored Jul 1, 2021
2 parents 956b215 + 349e070 commit 7882d66
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Picqer/Financials/Exact/Persistance/Storable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Picqer\Financials\Exact\Persistance;

use Picqer\Financials\Exact\ApiException;
use Picqer\Financials\Exact\Connection;

trait Storable
Expand Down Expand Up @@ -40,6 +41,8 @@ abstract public function url();
abstract public function primaryKeyContent();

/**
* @throws ApiException
*
* @return $this
*/
public function save()
Expand All @@ -53,18 +56,33 @@ public function save()
return $this;
}

/**
* @throws ApiException
*
* @return array|mixed
*/
public function insert()
{
return $this->connection()->post($this->url(), $this->json(0, true));
}

/**
* @throws ApiException
*
* @return array|mixed
*/
public function update()
{
$primaryKey = $this->primaryKeyContent();

return $this->connection()->put($this->url() . "(guid'$primaryKey')", $this->json());
}

/**
* @throws ApiException
*
* @return array|mixed
*/
public function delete()
{
$primaryKey = $this->primaryKeyContent();
Expand Down

0 comments on commit 7882d66

Please sign in to comment.