Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #89 from niklaslong/78-split
Browse files Browse the repository at this point in the history
Rename Client -> API
  • Loading branch information
niklaslong authored Nov 13, 2020
2 parents 49b8bd5 + 7552541 commit 12fb1c4
Show file tree
Hide file tree
Showing 16 changed files with 250 additions and 244 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[#91]: https://github.com/niklaslong/matrix-elixir-sdk/pull/91

### Changed

* refactor: rename `Client` -> `API` [#89]

[#89]: https://github.com/niklaslong/matrix-elixir-sdk/pull/89

## [0.2.0]

* the `Client` module no longer wraps the `Request` module but is to be used in conjunction with the latter.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ welcome)!
In future, the SDK plans to include:
- an encryption library (currently in development):
[olm-elixir](https://github.com/niklaslong/olm-elixir).
- further abstractions around the `Client` library to handle state.
- further abstractions around the `API` library to handle state.
- a wrapper for the Server-Server API
- & more tbd.

Expand All @@ -48,12 +48,12 @@ endpoint of the client-server API. It is then executed with `do_request/1`.


```elixir
alias MatrixSDK.Client
alias MatrixSDK.Client.Request
alias MatrixSDK.API
alias MatrixSDK.API.Request

"https://matrix.org"
|> Request.spec_versions()
|> Client.do_request()
|> API.do_request()
```

This example will retreive the versions of the specification supported by the `matrix.org` homeserver.
Expand Down
10 changes: 5 additions & 5 deletions examples/guest_login.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alias MatrixSDK.Client
alias MatrixSDK.Client.Request
alias MatrixSDK.API
alias MatrixSDK.API.Request

require Logger

Expand All @@ -15,7 +15,7 @@ url = "https://matrix.org"
{:ok, response} =
url
|> Request.register_guest()
|> Client.do_request()
|> API.do_request()

Logger.debug("Response:")
IO.inspect(response.body)
Expand All @@ -28,7 +28,7 @@ join_room = fn join_room ->
{:ok, response} =
url
|> Request.join_room(token, room)
|> Client.do_request()
|> API.do_request()

if response.body["errcode"] do
IO.gets(
Expand All @@ -51,7 +51,7 @@ Logger.info("Starting sync for room: #{inspect(room)}...")
{:ok, response} =
url
|> Request.sync(token)
|> Client.do_request()
|> API.do_request()

Logger.debug("Response:")
IO.inspect(response.body)
18 changes: 9 additions & 9 deletions lib/matrix_sdk/client.ex → lib/matrix_sdk/api.ex
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
defmodule MatrixSDK.Client do
defmodule MatrixSDK.API do
@moduledoc """
Provides a wrapper around the `MatrixSDK.HTTPClient` and related configuration. In future it
will likely abstract response parsing, error handling and configuration.
Requests are represented by a `MatrixSDK.Client.Request` struct and executed with a call to
`MatrixSDK.Client.do_request/1`:
Requests are represented by a `MatrixSDK.API.Request` struct and executed with a call to
`MatrixSDK.API.do_request/1`:
"https://matrix.org"
|> MatrixSDK.Client.Request.login("token")
|> MatrixSDK.Client.do_request()
|> MatrixSDK.API.Request.login("token")
|> MatrixSDK.API.do_request()
For more information on the currently supported endpoints, see the `MatrixSDK.Client.Request`
For more information on the currently supported endpoints, see the `MatrixSDK.API.Request`
module documentation.
## 3PID API flows
Expand All @@ -31,16 +31,16 @@ defmodule MatrixSDK.Client do
"""

alias MatrixSDK.HTTPClient
alias MatrixSDK.Client.Request
alias MatrixSDK.API.Request

@doc """
Executes a given request through the configured HTTP client.
## Examples
"https://matrix.org"
|> MatrixSDK.Client.Request.sync("token")
|> MatrixSDK.Client.do_request(request)
|> MatrixSDK.API.Request.sync("token")
|> MatrixSDK.API.do_request(request)
"""
@spec do_request(Request.t()) :: HTTPClient.result()
def do_request(request), do: http_client().do_request(request)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule MatrixSDK.Client.Auth do
defmodule MatrixSDK.API.Auth do
@moduledoc """
Convenience functions for building authentication types.
Expand Down
Loading

0 comments on commit 12fb1c4

Please sign in to comment.