From 6a6987bee634ddb970ff1503e16ad59c9e7859a4 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 2 Apr 2025 09:31:30 +0300 Subject: [PATCH] Update the JSON API endpoint to /authors for Author. --- lib/decentralised_book_index/metadata.ex | 2 +- .../sync/sync_tasks/sync_authors_task.ex | 2 +- .../sync/api_clients/fetch_json_test.exs | 2 +- .../sync/api_clients/fetch_jsons_test.exs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/decentralised_book_index/metadata.ex b/lib/decentralised_book_index/metadata.ex index 52e1100..6624ee5 100644 --- a/lib/decentralised_book_index/metadata.ex +++ b/lib/decentralised_book_index/metadata.ex @@ -14,7 +14,7 @@ defmodule DecentralisedBookIndex.Metadata do related :publisher, :read, primary?: true end - base_route "/author", Metadata.Author do + base_route "/authors", Metadata.Author do get :read index :search end diff --git a/lib/decentralised_book_index/sync/sync_tasks/sync_authors_task.ex b/lib/decentralised_book_index/sync/sync_tasks/sync_authors_task.ex index 243b1b5..0e6e182 100644 --- a/lib/decentralised_book_index/sync/sync_tasks/sync_authors_task.ex +++ b/lib/decentralised_book_index/sync/sync_tasks/sync_authors_task.ex @@ -6,7 +6,7 @@ defmodule DecentralisedBookIndex.SyncTasks.SyncAuthorsTask do alias DecentralisedBookIndex.Metadata.DBIServer def sync(%DBIServer{} = server) do - url = "#{server.url}/api/v1/json/author" + url = "#{server.url}/api/v1/json/authors" FetchJsons.get(url, sync_author_closure(server)) server diff --git a/test/decentralised_book_index/sync/api_clients/fetch_json_test.exs b/test/decentralised_book_index/sync/api_clients/fetch_json_test.exs index 985da0a..31abde4 100644 --- a/test/decentralised_book_index/sync/api_clients/fetch_json_test.exs +++ b/test/decentralised_book_index/sync/api_clients/fetch_json_test.exs @@ -11,7 +11,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonTest do test "get an author" do {:ok, author} = Metadata.create_author("Author", "An description") - assert {:ok, data} = FetchJson.get("#{@test_server_endpoint}/api/v1/json/author/#{author.id}") + assert {:ok, data} = FetchJson.get("#{@test_server_endpoint}/api/v1/json/authors/#{author.id}") assert data["data"]["id"] == author.id end end diff --git a/test/decentralised_book_index/sync/api_clients/fetch_jsons_test.exs b/test/decentralised_book_index/sync/api_clients/fetch_jsons_test.exs index ca2e3a9..038af9d 100644 --- a/test/decentralised_book_index/sync/api_clients/fetch_jsons_test.exs +++ b/test/decentralised_book_index/sync/api_clients/fetch_jsons_test.exs @@ -14,7 +14,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do Metadata.create_author!("Author#{number}", "An description#{number}") end - assert {:ok, records} = FetchJsons.get("#{@test_server_endpoint}/api/v1/json/author") + assert {:ok, records} = FetchJsons.get("#{@test_server_endpoint}/api/v1/json/authors") assert length(records) == 11 end @@ -28,7 +28,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do end assert {:ok, records} = - FetchJsons.get("#{@test_server_endpoint}/api/v1/json/author", get_author_names) + FetchJsons.get("#{@test_server_endpoint}/api/v1/json/authors", get_author_names) assert length(records) == 11 assert Enum.all?(records, fn author -> String.contains?(author, "Author") end)