From 103840570ff2813fd1e191d086de627d25fc55d3 Mon Sep 17 00:00:00 2001 From: jaeyson Date: Tue, 25 Jun 2024 09:25:00 +0800 Subject: [PATCH] fix typespec for URI struct --- README.md | 26 ++++++++++++++++++++++---- lib/ex_typesense/http_client.ex | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 61a894b..57e808d 100644 --- a/README.md +++ b/README.md @@ -89,10 +89,11 @@ defmodule MyApp.Credential do end ``` +using Connection struct + ```elixir credential = MyApp.Credential |> where(id: ^8888) |> Repo.one() -# using Connection struct conn = %ExTypesense.Connection{ host: credential.node, api_key: credential.secret_key, @@ -100,7 +101,12 @@ conn = %ExTypesense.Connection{ scheme: "https" } -# or maps, as long as the keys matches in ExTypesense.Connection.t() +ExTypesense.search(conn, collection_name, query) +``` + +or maps, as long as the keys matches in `ExTypesense.Connection.t()` + +```elixir conn = %{ host: credential.node, api_key: credential.secret_key, @@ -108,10 +114,22 @@ conn = %{ scheme: "https" } -# or convert your struct to map, as long as the keys matches in ExTypesense.Connection.t() +ExTypesense.search(conn, collection_name, query) + +``` + +or convert your struct to map, as long as the keys matches in `ExTypesense.Connection.t()` + +```elixir conn = Map.from_struct(MyApp.Credential) -# or you don't want to change the fields in your schema, thus you convert it to map +ExTypesense.search(conn, collection_name, query) + +``` + +or you don't want to change the fields in your schema, thus you convert it to map + +```elixir conn = %Credential{ node: "localhost", secret_key: "xyz", diff --git a/lib/ex_typesense/http_client.ex b/lib/ex_typesense/http_client.ex index fbf4f24..39e914f 100644 --- a/lib/ex_typesense/http_client.ex +++ b/lib/ex_typesense/http_client.ex @@ -137,7 +137,7 @@ defmodule ExTypesense.HttpClient do @doc since: "0.3.0" @deprecated "Use request/2 instead" - @spec httpc_run(URI.__struct__(), atom(), String.t(), list()) :: {:ok, map()} | {:error, map()} + @spec httpc_run(URI.t(), atom(), String.t(), list()) :: {:ok, map()} | {:error, map()} def httpc_run(uri, method, payload, content_type \\ ~c"application/json") do uri = %URI{ scheme: get_scheme(),