# Tehama Wireless API Elixir Client
`tehama_client_ex` is an elixir client library for interacting with the [Tehama Wireless](https://www.tehamawireless.com/) API.
You can view the API documentation [here](./docs/API%20for%20Daily%20Report%20Data%202022.pdf).
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `tehama_client_ex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:tehama_client_ex, "~> 0.1.0"}
]
end
```
## Usage
### Authenticate
Basic usage is to authenticate to get a token...
```elixir
# on success auth will be %TehamaClient.Auth{token: "usertoken...."}
auth = TehamaClient.auth!("username", "password")
```
### Sites
Then you can get a list of **[Site](./lib/tehama_client/objects/site.ex)** objects...
```elixir
# on success sites will be a list of %TehamaClient.Site{}
sites = TehamaClient.site_list(auth)
```
### Devices
And finally using a site, you can get a list of **[Device](./lib/tehama_client/objects/device.ex)** objects...
```elixir
# on success sites will be a list of %TehamaClient.Device{}
readings = TehamaClient.report_data(auth, List.first(sites))
```
### Readings
Using a device you can get a list of device **[Reading](./lib/tehama_client/objects/reading.ex)** objects...
```elixir
# readings will be a list of %TehamaClient.Reading{}
%TehamaClient.Device{readings: readings} = List.first(readings)
```
## Examples
This repository comes with some examples. The examples require some environment variables to be set.
To run an example, go to the repository and run these command line commands:
- [Site List](./examples/site_list.ex): `mix run examples/site_list.ex` - This will authenticate and print a list of sites.
- [Basic Data](./examples/data.ex): `mix run examples/data.ex` - This will authenticate and print data for a given site.
## Documentation
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/tehama_client_ex>.