Update the JSON API endpoint to /authors for Author.

dev
KKlochko 3 months ago
parent 71c7ce3501
commit 6a6987bee6

@ -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

@ -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

@ -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

@ -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)

Loading…
Cancel
Save