use std::num::NonZeroU64;
use crate::client::StClient;
use crate::client::{ClientError, RequestPriority};
use crate::types;
impl StClient {
pub async fn jettison(
&self,
ship_symbol: &str,
symbol: types::TradeSymbol,
units: NonZeroU64,
) -> Result<types::JettisonResponse, ClientError> {
self.jettison_with_priority(ship_symbol, symbol, units, RequestPriority::Normal)
.await
}
pub async fn jettison_with_priority(
&self,
ship_symbol: &str,
symbol: types::TradeSymbol,
units: NonZeroU64,
priority: RequestPriority,
) -> Result<types::JettisonResponse, ClientError> {
let body = types::JettisonBody { symbol, units };
self.send_mutating("jettison", priority, || {
self.inner.jettison(ship_symbol, &body)
})
.await
}
pub async fn sell_cargo(
&self,
ship_symbol: &str,
symbol: types::TradeSymbol,
units: NonZeroU64,
) -> Result<types::SellCargo201Response, ClientError> {
self.sell_cargo_with_priority(ship_symbol, symbol, units, RequestPriority::Normal)
.await
}
pub async fn sell_cargo_with_priority(
&self,
ship_symbol: &str,
symbol: types::TradeSymbol,
units: NonZeroU64,
priority: RequestPriority,
) -> Result<types::SellCargo201Response, ClientError> {
let body = types::SellCargoRequest { symbol, units };
self.send_mutating("sell_cargo", priority, || {
self.inner.sell_cargo(ship_symbol, &body)
})
.await
}
pub async fn purchase_cargo(
&self,
ship_symbol: &str,
symbol: types::TradeSymbol,
units: NonZeroU64,
) -> Result<types::PurchaseCargo201Response, ClientError> {
self.purchase_cargo_with_priority(ship_symbol, symbol, units, RequestPriority::Normal)
.await
}
pub async fn purchase_cargo_with_priority(
&self,
ship_symbol: &str,
symbol: types::TradeSymbol,
units: NonZeroU64,
priority: RequestPriority,
) -> Result<types::PurchaseCargo201Response, ClientError> {
let body = types::PurchaseCargoRequest { symbol, units };
self.send_mutating("purchase_cargo", priority, || {
self.inner.purchase_cargo(ship_symbol, &body)
})
.await
}
pub async fn transfer_cargo(
&self,
ship_symbol: &str,
trade_symbol: types::TradeSymbol,
units: NonZeroU64,
target_ship_symbol: &str,
) -> Result<types::TransferCargo200Response, ClientError> {
self.transfer_cargo_with_priority(
ship_symbol,
trade_symbol,
units,
target_ship_symbol,
RequestPriority::Normal,
)
.await
}
pub async fn transfer_cargo_with_priority(
&self,
ship_symbol: &str,
trade_symbol: types::TradeSymbol,
units: NonZeroU64,
target_ship_symbol: &str,
priority: RequestPriority,
) -> Result<types::TransferCargo200Response, ClientError> {
let body = types::TransferCargoRequest {
trade_symbol,
units,
ship_symbol: target_ship_symbol.to_string(),
};
self.send_mutating("transfer_cargo", priority, || {
self.inner.transfer_cargo(ship_symbol, &body)
})
.await
}
pub async fn negotiate_contract(
&self,
ship_symbol: &str,
) -> Result<types::NegotiateContract201Response, ClientError> {
self.negotiate_contract_with_priority(ship_symbol, RequestPriority::Normal)
.await
}
pub async fn negotiate_contract_with_priority(
&self,
ship_symbol: &str,
priority: RequestPriority,
) -> Result<types::NegotiateContract201Response, ClientError> {
self.send_mutating("negotiate_contract", priority, || {
self.inner.negotiate_contract(ship_symbol)
})
.await
}
}