OpenAPI documentation for Payments. (#3223)

* Working on API docs for payments

* Fixes for OpenAPI documentation

* Fix for conditionals in invoice calculator
This commit is contained in:
David Bomba 2020-01-19 11:19:10 +10:00 committed by GitHub
parent 67c485c1b8
commit 770f0763f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 32 deletions

View File

@ -58,7 +58,7 @@ class InvoiceItemSum
public function process()
{
if (!$this->invoice->line_items || !isset($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
if (!$this->invoice->line_items || !isset($this->invoice->line_items) || !is_array($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
$this->items = [];
return $this;
}

View File

@ -57,7 +57,7 @@ class InvoiceItemSumInclusive
public function process()
{
if (!$this->invoice->line_items || count($this->invoice->line_items) == 0) {
if (!$this->invoice->line_items || !is_array($this->invoice->line_items) || count($this->invoice->line_items) == 0) {
$this->items = [];
return $this;
}

View File

@ -0,0 +1,10 @@
<?php
/**
* @OA\Schema(
* schema="CreditPaymentable",
* type="object",
* @OA\Property(property="credit_id", type="string", example="Opnel5aKBz", description="______"),
* @OA\Property(property="amount", type="string", example="2", description="______"),
*
* )
*/

View File

@ -0,0 +1,10 @@
<?php
/**
* @OA\Schema(
* schema="InvoicePaymentable",
* type="object",
* @OA\Property(property="invoice_id", type="string", example="Opnel5aKBz", description="______"),
* @OA\Property(property="amount", type="string", example="2", description="______"),
*
* )
*/

View File

@ -19,5 +19,23 @@
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* @OA\Property(property="archived_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* @OA\Property(property="company_gateway_id", type="string", example="3", description="The company gateway id"),
* @OA\Property(property="paymentables",ref="#/components/schemas/Paymentable"),
* @OA\Property(
* property="invoices",
* type="array",
* description="",
* @OA\Items(
* ref="#/components/schemas/InvoicePaymentable",
* ),
* ),
* @OA\Property(
* property="credits",
* type="array",
* description="",
* @OA\Items(
* ref="#/components/schemas/CreditPaymentable",
* ),
* ),
*
* )
*/

View File

@ -0,0 +1,14 @@
<?php
/**
* @OA\Schema(
* schema="Paymentable",
* type="object",
* @OA\Property(property="id", type="string", example="AS3df3A", description="The paymentable hashed id"),
* @OA\Property(property="invoice_id", type="string", example="AS3df3A", description="The invoice hashed id"),
* @OA\Property(property="credit_id", type="string", example="AS3df3A", description="The credit hashed id"),
* @OA\Property(property="refunded", type="number", format="float", example="10.00", description="______"),
* @OA\Property(property="amount", type="number", format="float", example="10.00", description="______"),
* @OA\Property(property="updated_at", type="number", format="integer", example="1434342123", description="Timestamp"),
* @OA\Property(property="created_at", type="number", format="integer", example="1434342123", description="Timestamp"),*
* )
*/

View File

@ -181,36 +181,7 @@ class PaymentController extends BaseController
* @OA\RequestBody(
* description="The payment request",
* required=true,
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* type="object",
* @OA\Property(
* property="amount",
* description="The payment amount",
* type="number",
* format="float",
* ),
* @OA\Property(
* property="date",
* example="2019/12/1",
* description="The payment date",
* type="string",
* ),
* @OA\Property(
* property="transation_reference",
* example="sdfasdfs98776d6kbkfd",
* description="The transaction reference for the payment",
* type="string",
* ),
* @OA\Property(
* property="invoices",
* example="j7s76d,s8765afk,D8fj3Sfdj",
* description="A comma separated list of invoice hashed ids that this payment relates to",
* type="string",
* )
* )
* )
* @OA\JsonContent(ref="#/components/schemas/Payment"),
* ),
* @OA\Response(
* response=200,

View File

@ -42,6 +42,7 @@ class PaymentableTransformer extends EntityTransformer
'id' => $this->encodePrimaryKey($paymentable->id),
$entity_key => $this->encodePrimaryKey($paymentable->paymentable_id),
'amount' => (float)$paymentable->amount,
'refunded' => (float)$paymentable->refunded,
'created_at' => (int) $paymentable->created_at,
'updated_at' => (int) $paymentable->updated_at,
];