revert part of the typings for single requests

This commit is contained in:
TotallyNot 2022-09-19 00:42:34 +02:00
parent 102d02d390
commit 77c50fac64
7 changed files with 97 additions and 72 deletions

View file

@ -180,18 +180,25 @@ where
A: ApiCategoryResponse,
{
request: ApiRequest<A>,
id: Option<i64>,
}
impl<A> Default for ApiRequestBuilder<A>
where
A: ApiCategoryResponse,
{
fn default() -> Self {
Self {
request: Default::default(),
id: None,
}
}
}
impl<A> ApiRequestBuilder<A>
where
A: ApiCategoryResponse,
{
pub(crate) fn new() -> Self {
Self {
request: ApiRequest::default(),
}
}
#[must_use]
pub fn selections(mut self, selections: &[A::Selection]) -> Self {
self.request
@ -217,6 +224,15 @@ where
self.request.comment = Some(comment);
self
}
#[must_use]
pub fn id<I>(mut self, id: I) -> Self
where
I: num_traits::AsPrimitive<i64>,
{
self.id = Some(id.as_());
self
}
}
#[cfg(test)]
@ -259,11 +275,7 @@ pub(crate) mod tests {
async fn reqwest() {
let key = setup();
Client::default()
.torn_api(key)
.user(None, |b| b)
.await
.unwrap();
Client::default().torn_api(key).user(|b| b).await.unwrap();
}
#[cfg(feature = "awc")]