Skip to content

Commit

Permalink
refactor(api): reuse new_url
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed Sep 1, 2024
1 parent 81431e0 commit 68cc956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/api/async_telegram_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ pub struct AsyncApi {
}

impl AsyncApi {
/// Create a new `AsyncApi`. You can use `AsyncApi::builder()` for more options.
/// Create a new `AsyncApi`. You can use [`AsyncApi::new_url`] or [`AsyncApi::builder`] for more options.
pub fn new(api_key: &str) -> Self {
let api_url = format!("{}{api_key}", super::BASE_API_URL);
Self::builder().api_url(api_url).build()
Self::new_url(format!("{}{api_key}", super::BASE_API_URL))
}

/// Create a new `AsyncApi`. You can use `AsyncApi::builder()` for more options.
/// Create a new `AsyncApi`. You can use [`AsyncApi::builder`] for more options.
pub fn new_url<T: Into<String>>(api_url: T) -> Self {
Self::builder().api_url(api_url).build()
}
Expand Down
7 changes: 3 additions & 4 deletions src/api/telegram_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ pub struct Api {
}

impl Api {
/// Create a new `Api`. You can use `Api::builder()` for more options.
/// Create a new `Api`. You can use [`Api::new_url`] or [`Api::builder`] for more options.
pub fn new(api_key: &str) -> Self {
let api_url = format!("{}{api_key}", super::BASE_API_URL);
Self::builder().api_url(api_url).build()
Self::new_url(format!("{}{api_key}", super::BASE_API_URL))
}

/// Create a new `Api`. You can use `Api::builder()` for more options.
/// Create a new `Api`. You can use [`Api::builder`] for more options.
pub fn new_url<T: Into<String>>(api_url: T) -> Self {
Self::builder().api_url(api_url).build()
}
Expand Down

0 comments on commit 68cc956

Please sign in to comment.