Skip to content

Commit

Permalink
request expected references
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-prosser committed Jul 25, 2024
1 parent ca6d538 commit 1120770
Showing 1 changed file with 43 additions and 54 deletions.
97 changes: 43 additions & 54 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ impl Client {
integration: &NewIntegration,
) -> Result<PostIntegrationResponse> {
self.request(
Method::POST,
self.endpoints.integration(name)?,
Some(PostIntegrationRequest {
&Method::POST,
&self.endpoints.integration(name)?,
&Some(PostIntegrationRequest {
integration: integration.clone(),
}),
None::<()>,
Retry::No,
&None::<()>,
&Retry::No,
)
}

Expand All @@ -477,13 +477,13 @@ impl Client {
integration: &NewIntegration,
) -> Result<PutIntegrationResponse> {
self.request(
Method::PUT,
self.endpoints.integration(name)?,
Some(PutIntegrationRequest {
&Method::PUT,
&self.endpoints.integration(name)?,
&Some(PutIntegrationRequest {
integration: integration.clone(),
}),
None::<()>,
Retry::No,
&None::<()>,
&Retry::No,
)
}

Expand All @@ -509,11 +509,11 @@ impl Client {
no_charge: bool,
) -> Result<PutCommentsResponse> {
self.request(
Method::PUT,
self.endpoints.put_comments(source_name)?,
Some(PutCommentsRequest { comments }),
Some(NoChargeQuery { no_charge }),
Retry::No,
&Method::PUT,
&self.endpoints.put_comments(source_name)?,
&Some(PutCommentsRequest { comments }),
&Some(NoChargeQuery { no_charge }),
&Retry::No,
)
}

Expand Down Expand Up @@ -582,11 +582,11 @@ impl Client {
no_charge: bool,
) -> Result<SyncCommentsResponse> {
self.request(
Method::POST,
self.endpoints.sync_comments(source_name)?,
Some(SyncCommentsRequest { comments }),
Some(NoChargeQuery { no_charge }),
Retry::Yes,
&Method::POST,
&self.endpoints.sync_comments(source_name)?,
&Some(SyncCommentsRequest { comments }),
&Some(NoChargeQuery { no_charge }),
&Retry::Yes,
)
}

Expand Down Expand Up @@ -614,15 +614,15 @@ impl Client {
no_charge: bool,
) -> Result<SyncRawEmailsResponse> {
self.request(
Method::POST,
self.endpoints.sync_comments_raw_emails(source_name)?,
Some(SyncRawEmailsRequest {
&Method::POST,
&self.endpoints.sync_comments_raw_emails(source_name)?,
&Some(SyncRawEmailsRequest {
documents,
transform_tag,
include_comments,
}),
Some(NoChargeQuery { no_charge }),
Retry::Yes,
&Some(NoChargeQuery { no_charge }),
&Retry::Yes,
)
}

Expand All @@ -648,11 +648,11 @@ impl Client {
no_charge: bool,
) -> Result<PutEmailsResponse> {
self.request(
Method::PUT,
self.endpoints.put_emails(bucket_name)?,
Some(PutEmailsRequest { emails }),
Some(NoChargeQuery { no_charge }),
Retry::Yes,
&Method::PUT,
&self.endpoints.put_emails(bucket_name)?,
&Some(PutEmailsRequest { emails }),
&Some(NoChargeQuery { no_charge }),
&Retry::Yes,
)
}

Expand Down Expand Up @@ -1151,7 +1151,7 @@ impl Client {
LocationT: IntoUrl + Display + Clone,
for<'de> SuccessT: Deserialize<'de>,
{
self.request(Method::GET, url, None::<()>, None::<()>, Retry::Yes)
self.request(&Method::GET, &url, &None::<()>, &None::<()>, &Retry::Yes)
}

fn get_query<LocationT, QueryT, SuccessT>(
Expand All @@ -1164,7 +1164,7 @@ impl Client {
QueryT: Serialize,
for<'de> SuccessT: Deserialize<'de>,
{
self.request(Method::GET, url, None::<()>, Some(query), Retry::Yes)
self.request(&Method::GET, &url, &None::<()>, &Some(query), &Retry::Yes)
}

fn delete<LocationT>(&self, url: LocationT) -> Result<()>
Expand Down Expand Up @@ -1229,7 +1229,7 @@ impl Client {
RequestT: Serialize,
for<'de> SuccessT: Deserialize<'de>,
{
self.request(Method::POST, url, Some(request), None::<()>, retry)
self.request(&Method::POST, &url, &Some(request), &None::<()>, &retry)
}

fn put<LocationT, RequestT, SuccessT>(
Expand All @@ -1242,7 +1242,7 @@ impl Client {
RequestT: Serialize,
for<'de> SuccessT: Deserialize<'de>,
{
self.request(Method::PUT, url, Some(request), None::<()>, Retry::Yes)
self.request(&Method::PUT, &url, &Some(request), &None::<()>, &Retry::Yes)
}

fn raw_request<LocationT, RequestT, QueryT>(
Expand Down Expand Up @@ -1301,13 +1301,8 @@ impl Client {
for<'de> SuccessT: Deserialize<'de> + ReducableResponse + Clone + Debug,
{
debug!("Attempting {method} `{url}`");
let result: Result<SuccessT> = self.request(
method.clone(),
url.clone(),
Some(body.clone()),
query.clone(),
retry.clone(),
);
let result: Result<SuccessT> =
self.request(&method, &url, &Some(body.clone()), &query, &retry);

match result {
Ok(response) => Ok(SplitableRequestResponse {
Expand All @@ -1320,13 +1315,7 @@ impl Client {
let mut response = SuccessT::empty();

body.split().iter().for_each(|request| {
match self.request(
method.clone(),
url.clone(),
Some(request),
query.clone(),
retry.clone(),
) {
match self.request(&method, &url, &Some(request), &query, &retry) {
Ok(r) => response = SuccessT::merge(response.clone(), r),
Err(_) => num_failed += 1,
}
Expand Down Expand Up @@ -1355,11 +1344,11 @@ impl Client {

fn request<LocationT, RequestT, SuccessT, QueryT>(
&self,
method: Method,
url: LocationT,
body: Option<RequestT>,
query: Option<QueryT>,
retry: Retry,
method: &Method,
url: &LocationT,
body: &Option<RequestT>,
query: &Option<QueryT>,
retry: &Retry,
) -> Result<SuccessT>
where
LocationT: IntoUrl + Display + Clone,
Expand All @@ -1368,7 +1357,7 @@ impl Client {
for<'de> SuccessT: Deserialize<'de>,
{
debug!("Attempting {} `{}`", method, url);
let http_response = self.raw_request(&method, &url, &body, &query, &retry)?;
let http_response = self.raw_request(method, url, body, query, retry)?;

let status = http_response.status();

Expand Down

0 comments on commit 1120770

Please sign in to comment.