Skip to content

Commit

Permalink
Merge pull request #14 from noir04/Add-invoice-booking-functionality
Browse files Browse the repository at this point in the history
Add invoice booking functionality
  • Loading branch information
LasseRafn authored Nov 23, 2020
2 parents 4f6063f + c37306b commit 8d9cff1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Builders/BookingBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php namespace LasseRafn\Dinero\Builders;

use LasseRafn\Dinero\Models\Book;
use LasseRafn\Dinero\Responses\ListResponse;
use LasseRafn\Dinero\Utils\Request;

class BookingBuilder extends Builder
{
protected $entity = 'book';
protected $model = Book::class;
protected $collectionName = 'Book';
protected $responseClass = ListResponse::class;

public function __construct( Request $request, $entity ) {
$this->entity = $entity;
parent::__construct( $request );
}
}
7 changes: 7 additions & 0 deletions src/Dinero.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException;
use LasseRafn\Dinero\Builders\BookingBuilder;
use LasseRafn\Dinero\Builders\ContactBuilder;
use LasseRafn\Dinero\Builders\CreditnoteBuilder;
use LasseRafn\Dinero\Builders\DepositAccountBuilder;
Expand All @@ -14,6 +15,7 @@
use LasseRafn\Dinero\Builders\PurchaseVoucherBuilder;
use LasseRafn\Dinero\Exceptions\DineroRequestException;
use LasseRafn\Dinero\Exceptions\DineroServerException;
use LasseRafn\Dinero\Requests\BookingRequestBuilder;
use LasseRafn\Dinero\Requests\ContactRequestBuilder;
use LasseRafn\Dinero\Requests\CreditnoteRequestBuilder;
use LasseRafn\Dinero\Requests\DepositAccountRequestBuilder;
Expand Down Expand Up @@ -104,6 +106,11 @@ public function paymentsForInvoice($invoiceId)
return new PaymentRequestBuilder(new PaymentBuilder($this->request, "invoices/{$invoiceId}/payments"));
}

public function bookInvoice($invoiceId)
{
return new BookingRequestBuilder(new BookingBuilder($this->request, "invoices/{$invoiceId}/book"));
}

public function products()
{
return new ProductRequestBuilder(new ProductBuilder($this->request));
Expand Down
13 changes: 13 additions & 0 deletions src/Models/Book.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php namespace LasseRafn\Dinero\Models;

use LasseRafn\Dinero\Utils\Model;

class Book extends Model
{
protected $entity = 'book';
protected $primaryKey = 'Guid';

public $Guid;
public $Number;
public $Timestamp;
}
14 changes: 14 additions & 0 deletions src/Requests/BookingRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php namespace LasseRafn\Dinero\Requests;

use LasseRafn\Dinero\Builders\Builder;
use LasseRafn\Dinero\Utils\RequestBuilder;

class BookingRequestBuilder extends RequestBuilder
{
public function __construct( Builder $builder )
{
$this->parameters['fields'] = 'Guid,Number,Timestamp';

parent::__construct( $builder );
}
}

0 comments on commit 8d9cff1

Please sign in to comment.