From e81ce3317c17af424a13abc5cdecb62e19181fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 8 Feb 2020 11:51:04 +0100 Subject: [PATCH 1/2] API: Unified attachment_* and model_* for Attachments --- app/Api/V1/Requests/AttachmentStoreRequest.php | 16 ++++++++-------- app/Api/V1/Requests/AttachmentUpdateRequest.php | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Api/V1/Requests/AttachmentStoreRequest.php b/app/Api/V1/Requests/AttachmentStoreRequest.php index e7b0326bb9..6fc7a89354 100644 --- a/app/Api/V1/Requests/AttachmentStoreRequest.php +++ b/app/Api/V1/Requests/AttachmentStoreRequest.php @@ -57,8 +57,8 @@ class AttachmentStoreRequest extends Request 'filename' => $this->string('filename'), 'title' => $this->string('title'), 'notes' => $this->nlString('notes'), - 'model' => $this->string('model'), - 'model_id' => $this->integer('model_id'), + 'model' => $this->string('attachable_type'), + 'model_id' => $this->integer('attachable_id'), ]; } @@ -77,14 +77,14 @@ class AttachmentStoreRequest extends Request str_replace('FireflyIII\\Models\\', '', TransactionJournal::class), ] ); - $model = $this->string('model'); + $model = $this->string('attachable_type'); return [ - 'filename' => 'required|between:1,255', - 'title' => 'between:1,255', - 'notes' => 'between:1,65000', - 'model' => sprintf('required|in:%s', $models), - 'model_id' => ['required', 'numeric', new IsValidAttachmentModel($model)], + 'filename' => 'required|between:1,255', + 'title' => 'between:1,255', + 'notes' => 'between:1,65000', + 'attachable_type' => sprintf('required|in:%s', $models), + 'attachable_id' => ['required', 'numeric', new IsValidAttachmentModel($model)], ]; } } diff --git a/app/Api/V1/Requests/AttachmentUpdateRequest.php b/app/Api/V1/Requests/AttachmentUpdateRequest.php index f5675b7f53..60a69c612b 100644 --- a/app/Api/V1/Requests/AttachmentUpdateRequest.php +++ b/app/Api/V1/Requests/AttachmentUpdateRequest.php @@ -52,8 +52,8 @@ class AttachmentUpdateRequest extends Request 'filename' => $this->string('filename'), 'title' => $this->string('title'), 'notes' => $this->nlString('notes'), - 'model' => $this->string('model'), - 'model_id' => $this->integer('model_id'), + 'model' => $this->string('attachable_type'), + 'model_id' => $this->integer('attachable_id'), ]; } From 5aae8b77436cd3be3381dae7dc33110ab17d96ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 7 Feb 2020 12:03:13 +0100 Subject: [PATCH 2/2] API: Add link_type_id when reading TransactionLink --- app/Transformers/TransactionLinkTransformer.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Transformers/TransactionLinkTransformer.php b/app/Transformers/TransactionLinkTransformer.php index 204e5d7cd2..319859f32a 100644 --- a/app/Transformers/TransactionLinkTransformer.php +++ b/app/Transformers/TransactionLinkTransformer.php @@ -60,13 +60,14 @@ class TransactionLinkTransformer extends AbstractTransformer { $notes = $this->repository->getLinkNoteText($link); $data = [ - 'id' => (int)$link->id, - 'created_at' => $link->created_at->toAtomString(), - 'updated_at' => $link->updated_at->toAtomString(), - 'inward_id' => $link->source_id, - 'outward_id' => $link->destination_id, - 'notes' => '' === $notes ? null : $notes, - 'links' => [ + 'id' => (int)$link->id, + 'created_at' => $link->created_at->toAtomString(), + 'updated_at' => $link->updated_at->toAtomString(), + 'inward_id' => $link->source_id, + 'outward_id' => $link->destination_id, + 'link_type_id' => $link->link_type_id, + 'notes' => '' === $notes ? null : $notes, + 'links' => [ [ 'rel' => 'self', 'uri' => '/transaction_links/' . $link->id,