Skip to content

Commit

Permalink
chore: deprecate Client methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fekie committed May 11, 2023
1 parent ef18262 commit b82fe8d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions examples/post_trade_ad.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Parser;
use roli::{trade_ads, Client};
use roli::{trade_ads, ClientBuilder};

// To post a trade ad where you offer space hair for "any":
// cargo run --example --roli-verification xxx post_trade_ad -- --player-id 123456789 --offer-item-ids 564449640 --request-tags "any"
Expand Down Expand Up @@ -51,7 +51,9 @@ async fn main() {
})
.collect();

let client = Client::with_roli_verification(args.roli_verification);
let client = ClientBuilder::new()
.set_roli_verification(args.roli_verification)
.build();

let create_trade_ad_params = trade_ads::CreateTradeAdParams {
player_id: args.player_id,
Expand Down
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ pub(crate) enum Code {
/// Used to interact with the rest of the rRolimons api wrapper.
///
/// Contains any necessary authentication and the reqwest client. All
/// [`Client`] methods make exactly one api call.
/// `Client` methods make exactly one api call.
///
/// Created using a [`ClientBuilder`].
#[derive(Clone, Debug, Default)]
pub struct Client {
roli_verification: Option<String>,
Expand Down Expand Up @@ -158,6 +160,7 @@ impl std::fmt::Display for Code {
}

impl Client {
#[deprecated(since = "0.6.7", note = "Use ClientBuilder::new().build() instead.")]
/// Constructs a client without providing a roli verification token or custom
/// reqwest client.
///
Expand All @@ -166,6 +169,10 @@ impl Client {
Self::default()
}

#[deprecated(
since = "0.6.7",
note = "Use ClientBuilder::new().set_roli_verification(roli_verification).build() instead."
)]
/// Constructs a new [`Client`] with a roli verification token.
pub fn with_roli_verification(roli_verification: String) -> Self {
Self {
Expand All @@ -174,6 +181,10 @@ impl Client {
}
}

#[deprecated(
since = "0.6.7",
note = "Use ClientBuilder::new().set_roli_verification(roli_verification).build() instead."
)]
/// Sets the value for the optional `roli_verification` field.
pub fn set_roli_verification(&mut self, roli_verification: String) {
self.roli_verification = Some(roli_verification);
Expand Down
2 changes: 1 addition & 1 deletion src/trade_ads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Client {
///
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
/// let client = roli::Client::with_roli_verification("xxx".to_string());
/// let client = roli::ClientBuilder::new().set_roli_verification("xxx".to_string()).build();
///
/// let request_tag = trade_ads::RequestTag::Any;
///
Expand Down

0 comments on commit b82fe8d

Please sign in to comment.