Commit Graph

13 Commits

Author SHA1 Message Date
cel 🌸 b0cd2d6b8a
make more fields optional 2023-01-16 05:05:27 +00:00
cel 🌸 65a62d6118
make user_name optional 2023-01-16 05:03:20 +00:00
Koen Bolhuis 763b5b62ee Implement Default for raw::Client and wrapper::ListenBrainz
Following clippy recommendations
2021-12-03 12:55:03 +01:00
Koen Bolhuis 0c3125bd14 Add api_url() method to raw::Client and wrapper::ListenBrainz 2021-12-03 12:47:26 +01:00
Koen Bolhuis e9fd33a7b3 Add lints
Add some useful #![deny(...)] lints:
- missing_docs to disallow undocumented public items;
- missing_debug_implementations for public types;
- no unsafe code or unstable features.
2021-10-19 23:58:30 +02:00
Koen Bolhuis c1bb3f39f4 Run rustfmt 2021-09-01 18:14:04 +02:00
Koen Bolhuis c49f40128d Use the attohttpc crate instead of ureq.
This has some implications for Error:
- because attohttpc doesn't distinguish between errors
  when serializing or deserializing request/response
  data, Error::RequestJson and Error::ResponseJson have
  been merged into Error::Json. In practice this shouldn't
  matter much because request data is (usually) well-formed.
- attohttpc also doesn't return errors for HTTP responses
  with statuses in the [400-599] range, so manual conversion
  to an error is needed (this now happens in ResponseType::from_response).
2021-09-01 18:04:56 +02:00
Dom Rodriguez e0d25815f0
Add support for alternative Listenbrainz hosts
This commit adds support for alternative Listenbrainz hosts.

L10 defines the most used official host for Listenbrainz.

I have refactored the Client struct to have the `api_root_url` field.
This is automatically set to the value L10 defines, when a Client is
instantiated with `new()`. On the invocation of `client_with_url(url:
&str)`, the `api_root_url` field is set to the Listenbrainz instance
API root URL passed to the function.

The 1:1 functions <-> API methods have been modified to use
`self.api_root_url` as the base of the `format!()` macro invoked, rather
than the global constant of `API_ROOT_URL`.

This commit has been tested with the examples, and appears to be
functional.

Fixes #2.

Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
2021-08-30 16:26:39 +01:00
Koen Bolhuis 508f697a51 Add rate limiting information to response types
Add the `rate_limit` field to all response types,
which contains rate limiting information such as
maximum and remaining requests in the current
time frame, as well as when the next time frame
starts.

All response types now also implement the `ResponseType`
trait (internal for now). Currently this trait allows
converting from `ureq::Response` to the response type,
by extracting rate limiting information from the response
headers and deserializing the response body into the
response type.
2021-01-30 03:06:02 +01:00
Koen Bolhuis 2ff97ce9d2 Run rustfmt 2021-01-20 01:13:13 +01:00
Koen Bolhuis 9ed9ebfe0f Move Endpoint to raw module 2021-01-20 00:23:35 +01:00
Koen Bolhuis 56a50d936c Move Client to raw module 2021-01-19 23:51:17 +01:00
Koen Bolhuis a22fcff2bf Move low-level models to raw module 2021-01-19 23:41:54 +01:00