Struct slack_morphism::SlackClientHttpApiUri
source · pub struct SlackClientHttpApiUri;Implementations§
source§impl SlackClientHttpApiUri
impl SlackClientHttpApiUri
sourcepub fn create_method_uri_path(method_relative_uri: &str) -> String
pub fn create_method_uri_path(method_relative_uri: &str) -> String
Examples found in repository?
More examples
src/client.rs (line 88)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
fn http_get<'a, 'p, RS, PT, TS>(
&'a self,
method_relative_uri: &str,
params: &'p PT,
context: SlackClientApiCallContext<'a>,
) -> BoxFuture<'a, ClientResult<RS>>
where
RS: for<'de> serde::de::Deserialize<'de> + Send + 'a,
PT: std::iter::IntoIterator<Item = (&'p str, Option<&'p TS>)> + Clone,
TS: std::string::ToString + 'p + 'a + Send,
{
let full_uri = SlackClientHttpApiUri::create_url_with_params(
&SlackClientHttpApiUri::create_method_uri_path(method_relative_uri),
params,
);
self.http_get_uri(full_uri, context)
}
fn http_post_uri<'a, RQ, RS>(
&'a self,
full_uri: Url,
request_body: &'a RQ,
context: SlackClientApiCallContext<'a>,
) -> BoxFuture<'a, ClientResult<RS>>
where
RQ: serde::ser::Serialize + Send + Sync,
RS: for<'de> serde::de::Deserialize<'de> + Send + 'a + Send + 'a;
fn http_post<'a, RQ, RS>(
&'a self,
method_relative_uri: &str,
request: &'a RQ,
context: SlackClientApiCallContext<'a>,
) -> BoxFuture<'a, ClientResult<RS>>
where
RQ: serde::ser::Serialize + Send + Sync,
RS: for<'de> serde::de::Deserialize<'de> + Send + 'a,
{
let full_uri = SlackClientHttpApiUri::create_url(
&SlackClientHttpApiUri::create_method_uri_path(method_relative_uri),
);
self.http_post_uri(full_uri, request, context)
}src/api/oauth.rs (line 28)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
pub async fn oauth2_access(
&self,
req: &SlackOAuthV2AccessTokenRequest,
) -> ClientResult<SlackOAuthV2AccessTokenResponse> {
let full_uri: Url = SlackClientHttpApiUri::create_url_with_params(
&SlackClientHttpApiUri::create_method_uri_path("oauth.v2.access"),
&vec![
("code", Some(req.code.value())),
(
"redirect_uri",
req.redirect_uri
.as_ref()
.map(|url| url.as_str().to_string())
.as_ref(),
),
],
);
self.http_api
.connector
.http_get_with_client_secret(full_uri, &req.client_id, &req.client_secret)
.await
}sourcepub fn create_url_with_params<'p, PT, TS>(url_str: &str, params: &'p PT) -> Urlwhere
PT: IntoIterator<Item = (&'p str, Option<&'p TS>)> + Clone,
TS: ToString + 'p,
pub fn create_url_with_params<'p, PT, TS>(url_str: &str, params: &'p PT) -> Urlwhere
PT: IntoIterator<Item = (&'p str, Option<&'p TS>)> + Clone,
TS: ToString + 'p,
Examples found in repository?
More examples
src/client.rs (lines 87-90)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
fn http_get<'a, 'p, RS, PT, TS>(
&'a self,
method_relative_uri: &str,
params: &'p PT,
context: SlackClientApiCallContext<'a>,
) -> BoxFuture<'a, ClientResult<RS>>
where
RS: for<'de> serde::de::Deserialize<'de> + Send + 'a,
PT: std::iter::IntoIterator<Item = (&'p str, Option<&'p TS>)> + Clone,
TS: std::string::ToString + 'p + 'a + Send,
{
let full_uri = SlackClientHttpApiUri::create_url_with_params(
&SlackClientHttpApiUri::create_method_uri_path(method_relative_uri),
params,
);
self.http_get_uri(full_uri, context)
}src/api/oauth.rs (lines 27-39)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
pub async fn oauth2_access(
&self,
req: &SlackOAuthV2AccessTokenRequest,
) -> ClientResult<SlackOAuthV2AccessTokenResponse> {
let full_uri: Url = SlackClientHttpApiUri::create_url_with_params(
&SlackClientHttpApiUri::create_method_uri_path("oauth.v2.access"),
&vec![
("code", Some(req.code.value())),
(
"redirect_uri",
req.redirect_uri
.as_ref()
.map(|url| url.as_str().to_string())
.as_ref(),
),
],
);
self.http_api
.connector
.http_get_with_client_secret(full_uri, &req.client_id, &req.client_secret)
.await
}