Skip to content

Commit

Permalink
fix typespec for URI struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeyson committed Jun 25, 2024
1 parent f5f91d3 commit 1038405
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,47 @@ 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,
port: credential.port,
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,
port: credential.port,
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",
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_typesense/http_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 1038405

Please sign in to comment.