mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #649 from sakalauskas/dev-api
Add ability to include invoice invitations via API
This commit is contained in:
commit
c0531a8a06
21
app/Ninja/Transformers/InvitationTransformer.php
Normal file
21
app/Ninja/Transformers/InvitationTransformer.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php namespace App\Ninja\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Account;
|
||||||
|
use App\Models\Contact;
|
||||||
|
use App\Models\Invitation;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
class InvitationTransformer extends EntityTransformer
|
||||||
|
{
|
||||||
|
public function transform(Invitation $invitation)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => (int) $invitation->public_id,
|
||||||
|
'key' => $invitation->getName(),
|
||||||
|
'status' => $invitation->getStatus(),
|
||||||
|
'link' => $invitation->getLink(),
|
||||||
|
'sent_date' => $invitation->sent_date,
|
||||||
|
'viewed_date' => $invitation->sent_date,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -25,12 +25,22 @@ class InvoiceTransformer extends EntityTransformer
|
|||||||
'payments'
|
'payments'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $availableIncludes = [
|
||||||
|
'invitations',
|
||||||
|
];
|
||||||
|
|
||||||
public function includeInvoiceItems(Invoice $invoice)
|
public function includeInvoiceItems(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$transformer = new InvoiceItemTransformer($this->account, $this->serializer);
|
$transformer = new InvoiceItemTransformer($this->account, $this->serializer);
|
||||||
return $this->includeCollection($invoice->invoice_items, $transformer, ENTITY_INVOICE_ITEMS);
|
return $this->includeCollection($invoice->invoice_items, $transformer, ENTITY_INVOICE_ITEMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeInvitations(Invoice $invoice)
|
||||||
|
{
|
||||||
|
$transformer = new InvitationTransformer($this->account, $this->serializer);
|
||||||
|
return $this->includeCollection($invoice->invitations, $transformer, ENTITY_INVITATION);
|
||||||
|
}
|
||||||
|
|
||||||
public function includePayments(Invoice $invoice)
|
public function includePayments(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$transformer = new PaymentTransformer($this->account, $this->serializer);
|
$transformer = new PaymentTransformer($this->account, $this->serializer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user