-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from kg-bot/master
Where not able to change fields externally, this has fixed it now
- Loading branch information
Showing
13 changed files
with
221 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Builders; | ||
|
||
use LasseRafn\Dinero\Exceptions\DineroRequestException; | ||
use LasseRafn\Dinero\Exceptions\DineroServerException; | ||
use LasseRafn\Dinero\Models\DepositAccount; | ||
|
||
class DepositAccountBuilder extends Builder | ||
{ | ||
protected $entity = 'accounts/deposit'; | ||
protected $model = DepositAccount::class; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function get($parameters = '') | ||
{ | ||
try { | ||
$dineroApiResponse = $this->request->curl->get("{$this->entity}{$parameters}"); | ||
|
||
$jsonResponse = json_decode($dineroApiResponse->getBody()->getContents()); | ||
} catch (ClientException $exception) { | ||
throw new DineroRequestException($exception); | ||
} catch (ServerException $exception) { | ||
throw new DineroServerException($exception); | ||
} | ||
|
||
$request = $this->request; | ||
|
||
$items = array_map(function ($item) use ($request) { | ||
return new $this->model($request, $item); | ||
}, $jsonResponse); | ||
|
||
return (object)['items' => $items]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Builders; | ||
|
||
use LasseRafn\Dinero\Exceptions\DineroRequestException; | ||
use LasseRafn\Dinero\Exceptions\DineroServerException; | ||
use LasseRafn\Dinero\Models\EntryAccount; | ||
|
||
class EntryAccountBuilder extends Builder | ||
{ | ||
protected $entity = 'accounts/entry'; | ||
protected $model = EntryAccount::class; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function get($parameters = '') | ||
{ | ||
try { | ||
$dineroApiResponse = $this->request->curl->get("{$this->entity}{$parameters}"); | ||
|
||
$jsonResponse = json_decode($dineroApiResponse->getBody()->getContents()); | ||
} catch (ClientException $exception) { | ||
throw new DineroRequestException($exception); | ||
} catch (ServerException $exception) { | ||
throw new DineroServerException($exception); | ||
} | ||
|
||
$request = $this->request; | ||
|
||
$items = array_map(function ($item) use ($request) { | ||
return new $this->model($request, $item); | ||
}, $jsonResponse); | ||
|
||
return (object)['items' => $items]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Builders; | ||
|
||
use LasseRafn\Dinero\Models\PurchaseVoucher; | ||
|
||
class PurchaseVoucherBuilder extends Builder | ||
{ | ||
protected $entity = 'vouchers/purchase'; | ||
protected $model = PurchaseVoucher::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Models; | ||
|
||
use LasseRafn\Dinero\Utils\Model; | ||
|
||
class DepositAccount extends Model | ||
{ | ||
protected $entity = 'accounts/deposit'; | ||
protected $primaryKey = 'AccountNumber'; | ||
|
||
public $AccountNumber; | ||
public $Name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Models; | ||
|
||
use LasseRafn\Dinero\Utils\Model; | ||
|
||
class EntryAccount extends Model | ||
{ | ||
protected $entity = 'accounts/entry'; | ||
protected $primaryKey = 'AccountNumber'; | ||
|
||
public $AccountNumber; | ||
public $Name; | ||
public $VatCode; | ||
public $Category; | ||
public $IsHidden; | ||
public $IsDefaultSalesAccount; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Models; | ||
|
||
use LasseRafn\Dinero\Utils\Model; | ||
|
||
class PurchaseVoucher extends Model | ||
{ | ||
protected $entity = 'vouchers/purchase'; | ||
protected $primaryKey = 'Guid'; | ||
|
||
public $PaymentDate; | ||
public $VoucherDate; | ||
public $Status; | ||
public $ContactGuid; | ||
public $Guid; | ||
public $TimeStamp; | ||
public $VoucherNumber; | ||
public $FileGuid; | ||
public $RegionKey; | ||
public $DepositAccountNumber; | ||
public $ExternalReference; | ||
|
||
/** @var array */ | ||
public $Lines; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Requests; | ||
|
||
use LasseRafn\Dinero\Builders\Builder; | ||
use LasseRafn\Dinero\Utils\RequestBuilder; | ||
|
||
class DepositAccountRequestBuilder extends RequestBuilder | ||
{ | ||
public function __construct( Builder $builder ) { | ||
$this->parameters['fields'] = 'Name,AccountNumber'; | ||
|
||
parent::__construct( $builder ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Requests; | ||
|
||
use LasseRafn\Dinero\Builders\Builder; | ||
use LasseRafn\Dinero\Utils\RequestBuilder; | ||
|
||
class EntryAccountRequestBuilder extends RequestBuilder | ||
{ | ||
public function __construct( Builder $builder ) { | ||
$this->parameters['fields'] = 'Name,AccountNumber,VatCode,Category,IsHidden,IsDefaultSalesAccount'; | ||
|
||
parent::__construct( $builder ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace LasseRafn\Dinero\Requests; | ||
|
||
use LasseRafn\Dinero\Builders\Builder; | ||
use LasseRafn\Dinero\Utils\RequestBuilder; | ||
|
||
class PurchaseVoucherRequestBuilder extends RequestBuilder | ||
{ | ||
public function __construct(Builder $builder) | ||
{ | ||
$this->parameters['fields'] = 'Number,Guid,ContactGuid,VoucherDate,PaymentDate,Status,Timestamp,VoucherNumber,FileGuid,RegionKey,$DepositAccountNumber,ExternalReference'; | ||
|
||
parent::__construct($builder); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters