Add the cover_image_url attribute to arguments to create a Book.
This commit is contained in:
@@ -26,18 +26,32 @@ defmodule DecentralisedBookIndex.Metadata do
|
|||||||
:bids,
|
:bids,
|
||||||
:author_roles,
|
:author_roles,
|
||||||
:publisher_id,
|
:publisher_id,
|
||||||
|
{:optional, :cover_image_url},
|
||||||
{:optional, :book_editions_registry_id}
|
{:optional, :book_editions_registry_id}
|
||||||
]
|
]
|
||||||
|
|
||||||
define :add_book_to_related_editions_registry,
|
define :add_book_to_related_editions_registry,
|
||||||
action: :add_book_to_related_editions_registry,
|
action: :add_book_to_related_editions_registry,
|
||||||
args: [:title, :description, :language, :format, :page_count, :published, :bids, :author_roles, :publisher_id, :related_book_id]
|
args: [
|
||||||
|
:title,
|
||||||
|
:description,
|
||||||
|
:language,
|
||||||
|
:format,
|
||||||
|
:page_count,
|
||||||
|
:published,
|
||||||
|
:bids,
|
||||||
|
:author_roles,
|
||||||
|
:publisher_id,
|
||||||
|
:related_book_id,
|
||||||
|
{:optional, :cover_image_url}
|
||||||
|
]
|
||||||
|
|
||||||
define :list_books, action: :read
|
define :list_books, action: :read
|
||||||
define :get_book_by_id, args: [:id], action: :by_id
|
define :get_book_by_id, args: [:id], action: :by_id
|
||||||
define :get_book_by_bid, args: [:type, :bid], action: :by_bid
|
define :get_book_by_bid, args: [:type, :bid], action: :by_bid
|
||||||
define :get_book_alternative_editions, args: [:book], action: :get_alternative_editions
|
define :get_book_alternative_editions, args: [:book], action: :get_alternative_editions
|
||||||
define :get_author_books, args: [:author], action: :get_author_books
|
define :get_author_books, args: [:author], action: :get_author_books
|
||||||
|
define :search_book, action: :search, args: [:query]
|
||||||
define :update_book, action: :update
|
define :update_book, action: :update
|
||||||
define :assign_book_cover_image, args: [:cover_image_url], action: :assign_cover_image
|
define :assign_book_cover_image, args: [:cover_image_url], action: :assign_cover_image
|
||||||
define :destroy_book, action: :destroy
|
define :destroy_book, action: :destroy
|
||||||
@@ -90,6 +104,7 @@ defmodule DecentralisedBookIndex.Metadata do
|
|||||||
define :create_author_role, action: :create, args: [:author_id, :order, :role]
|
define :create_author_role, action: :create, args: [:author_id, :order, :role]
|
||||||
define :list_author_roles, action: :read
|
define :list_author_roles, action: :read
|
||||||
define :get_author_role_by_id, args: [:id], action: :by_id
|
define :get_author_role_by_id, args: [:id], action: :by_id
|
||||||
|
define :get_author_roles_by_book_id, args: [:book_id], action: :by_book_id
|
||||||
define :update_author_role, action: :update
|
define :update_author_role, action: :update
|
||||||
define :destroy_author_role, action: :destroy
|
define :destroy_author_role, action: :destroy
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ defmodule DecentralisedBookIndex.Metadata.Book do
|
|||||||
|
|
||||||
create :create do
|
create :create do
|
||||||
primary? true
|
primary? true
|
||||||
accept [:title, :description, :format, :language, :page_count, :published, :publisher_id, :book_editions_registry_id]
|
accept [:title, :description, :format, :language, :page_count, :published, :publisher_id, :cover_image_url, :book_editions_registry_id]
|
||||||
argument :bids, {:array, :map}
|
argument :bids, {:array, :map}
|
||||||
argument :author_roles, {:array, :map}
|
argument :author_roles, {:array, :map}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ defmodule DecentralisedBookIndex.Metadata.Book do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create :add_book_to_related_editions_registry do
|
create :add_book_to_related_editions_registry do
|
||||||
accept [:title, :description, :format, :language, :page_count, :published, :publisher_id]
|
accept [:title, :description, :format, :language, :page_count, :published, :publisher_id, :cover_image_url]
|
||||||
|
|
||||||
argument :related_book_id, :uuid do
|
argument :related_book_id, :uuid do
|
||||||
allow_nil? false
|
allow_nil? false
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ defmodule DecentralisedBookIndex.Metadata.BookTest do
|
|||||||
publisher = generate(publisher())
|
publisher = generate(publisher())
|
||||||
|
|
||||||
assert {:ok, registry} = Metadata.create_book_editions_registry()
|
assert {:ok, registry} = Metadata.create_book_editions_registry()
|
||||||
assert {:ok, book} = Metadata.create_book("Book", "An description","English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, registry.id)
|
assert {:ok, book} = Metadata.create_book("Book", "An description","English", "Paperback", 256, ~D[2025-03-04], bids, author_roles, publisher.id, nil, registry.id)
|
||||||
assert book.book_editions_registry_id == registry.id
|
assert book.book_editions_registry_id == registry.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user