aboutsummaryrefslogtreecommitdiffstats
path: root/src/verify.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2023-03-29 13:08:09 +0200
committerHarald Eilertsen <haraldei@anduin.net>2023-03-29 13:08:09 +0200
commit8100cff32bf0c87dc19fba78f3faac8090f863da (patch)
tree7c6315dbb83162b8d91aae53b920c2e7f20a4268 /src/verify.rs
parenta4b9520f430ce188ba9165dcabd3320763ff2e16 (diff)
downloadrust-zotapi-8100cff32bf0c87dc19fba78f3faac8090f863da.tar.gz
rust-zotapi-8100cff32bf0c87dc19fba78f3faac8090f863da.tar.bz2
rust-zotapi-8100cff32bf0c87dc19fba78f3faac8090f863da.zip
Another reqrite...
Third time must be where it sits I hope. I felt the API was getting a bit too distracted by unnecessary constructs and abstractions, so I'm trying to simplify it by making it more straight forward. The idea now is to have one main API class (ZotApi), and all the various remote API's as public methods on this basic class. Iow, the ZotApi class is mainly based on the existing `Client` class, which is then being phased out. And instead of having each API tied to the data type they return, I'm just adding methods that will return the respective data types. This should reduce coupling between the returned data, and the API calls themselves.
Diffstat (limited to 'src/verify.rs')
-rw-r--r--src/verify.rs23
1 files changed, 3 insertions, 20 deletions
diff --git a/src/verify.rs b/src/verify.rs
index 57e250d..bab1f18 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-use crate::{client::Client, error::Error, XChan, ZotAPI};
+use crate::{error::Error, XChan};
use serde::Deserialize;
use std::convert::TryFrom;
-use zotapi_derive::ZotAPI;
+//use zotapi_derive::ZotAPI;
-#[derive(Deserialize, Debug, ZotAPI)]
+#[derive(Deserialize, Debug)]
pub struct Channel {
#[serde(alias = "channel_id")]
pub id: u32,
@@ -137,20 +137,3 @@ impl<'a> TryFrom<&'a str> for Channel {
Ok(serde_json::from_str(s)?)
}
}
-
-#[derive(Default)]
-pub struct ChannelRequest;
-
-impl ChannelRequest {
- pub async fn fetch_raw(&self, client: &Client) -> Result<String, Error> {
- Ok(client.get("verify").send().await?.text().await?)
- }
-
- pub async fn fetch(&self, client: &Client) -> Result<Channel, Error> {
- let raw = self.fetch_raw(&client).await?;
- let mut channel: Channel = serde_json::from_str(&raw)?;
- channel.xchan = serde_json::from_str(&raw)?;
-
- Ok(channel)
- }
-}