Struct lexoffice::request::RequestWithState[][src]

pub struct RequestWithState<T: Clone, S: Clone> { /* fields omitted */ }

Represents a request to the lexoffice API. Please note that in order to create a working Request the Type variable T must allow requests to be made. The type variable S is an optional argument that allows to share state of the time, for example to make sure that certain functions have been called.

Implementations

impl RequestWithState<T, ()>[src]

Examples

use lexoffice::{ApiKey, Client};
use lexoffice::model::Country;

let client = Client::new(ApiKey::try_default().await?);
let countries = client.request::<Country>().get().await?;
println!("{:#?}", countries);
Ok(())

pub async fn get(self) -> Result<Vec<Country>>[src]

executes the request

impl RequestWithState<T, ()>[src]

pub fn by_id_url<I>(&self, uuid: I) -> Result<Url> where
    I: Into<Uuid> + Send + Sync
[src]

This method creates an Url that is used to address the object identified by uuid.

pub async fn by_id_str(self, uuid: &str) -> Result<Response>[src]

This method requests an object identified by uuid.

pub async fn by_id<I>(self, uuid: I) -> Result<Response> where
    I: Into<Uuid> + Send + Sync
[src]

This method requests an object identified by uuid.

pub async fn upload<P>(self, file_part: P) -> Result<Uuid> where
    P: Into<Part> + Send + Sync
[src]

Uploads a file to lexoffice

pub async fn upload_bytes<B>(
    self,
    mime: &'static Mime,
    bytes: B
) -> Result<Uuid> where
    B: Into<Cow<'static, [u8]>>, 
[src]

Uploads arbitrary data as file to lexoffice

pub async fn upload_path<P>(self, path: P) -> Result<Uuid> where
    P: AsRef<Path> + Send + Sync
[src]

Uploads a file from a path to lexoffice

impl RequestWithState<T, ()>[src]

Examples

use lexoffice::{ApiKey, Client};
use lexoffice::model::PostingCategory;

let client = Client::new(ApiKey::try_default().await?);
let posting_categories = client.request::<PostingCategory>().get().await?;
println!("{:#?}", posting_categories);
Ok(())

pub async fn get(self) -> Result<Vec<PostingCategory>>[src]

executes the request

impl RequestWithState<T, ()>[src]

Examples

use lexoffice::{ApiKey, Client};
use lexoffice::model::Profile;

let client = Client::new(ApiKey::try_default().await?);
let profile = client.request::<Profile>().get().await?;
println!("{:#?}", profile);
Ok(())

pub async fn get(self) -> Result<Profile>[src]

executes the request

impl RequestWithState<Voucherlist, VoucherlistStateUnstarted>[src]

pub fn type_(
    self,
    voucher_type: &VoucherType
) -> RequestWithState<Voucherlist, VoucherlistState<VoucherType, ()>>
[src]

Sets the voucher status for this request. Calling this function is mandatory

pub fn status(
    self,
    voucher_status: &VoucherStatus
) -> RequestWithState<Voucherlist, VoucherlistState<(), VoucherStatus>>
[src]

Sets the voucher status for this request. Calling this function is mandatory

impl<S: Clone> RequestWithState<Voucherlist, VoucherlistState<(), S>>[src]

pub fn type_(
    self,
    voucher_type: &VoucherType
) -> RequestWithState<Voucherlist, VoucherlistState<VoucherType, S>>
[src]

Sets the voucher status for this request. Calling this function is mandatory

impl<T: Clone> RequestWithState<Voucherlist, VoucherlistState<T, ()>>[src]

pub fn status(
    self,
    voucher_status: &VoucherStatus
) -> RequestWithState<Voucherlist, VoucherlistState<T, VoucherStatus>>
[src]

Sets the voucher status for this request. Calling this function is mandatory

impl<T, S> RequestWithState<T, S> where
    Self: Endpoint + ById,
    T: DeserializeOwned + Clone,
    S: Clone
[src]

pub fn by_id_url<I>(&self, uuid: I) -> Result<Url> where
    I: Into<Uuid>, 
[src]

This method creates an Url that is used to address the object identified by uuid. Request<T> must implement the ById trait in order to make this function available.

pub async fn by_id_str(self, uuid: &str) -> Result<T>[src]

This method requests an object identified by uuid. Request<T> must implement the ById trait in order to make this function available.

pub async fn by_id<I>(self, uuid: I) -> Result<T> where
    I: Into<Uuid> + Send
[src]

This method requests an object identified by uuid. Request<T> must implement the ById trait in order to make this function available.

impl<T, S> RequestWithState<T, S> where
    Self: Endpoint + Deletable + ById,
    T: Serialize + DeserializeOwned + HasId + Clone,
    S: Clone
[src]

pub async fn delete_str(self, uuid: &str) -> Result<()>[src]

This method requests an object identified by uuid. Request<T> must implement the ById trait in order to make this function available.

pub async fn delete<I>(self, uuid: I) -> Result<()> where
    I: Into<Uuid> + Send
[src]

This method requests an object identified by uuid. Request<T> must implement the ById trait in order to make this function available.

impl<T, S> RequestWithState<T, S> where
    Self: Endpoint + Paginated + Sync + Send + Clone,
    T: DeserializeOwned + Sync + Send + Clone + 'static,
    S: Sync + Send + Clone
[src]

pub async fn page_size(self, page: usize, size: usize) -> Result<Page<T>>[src]

This method gets a page that contains items of type T from the API. It also allows to define a number of items to request per page. RequestWithState<T, S> must implement the Paginated trait in order to make this function available.

pub async fn page(self, page: usize) -> Result<Page<T>>[src]

This method gets a page that contains items of type T from the API RequestWithState<T, S> must implement the Paginated trait in order to make this function available.

pub fn stream(self) -> PageStream<T, S>[src]

Creates a PageStream from this request.

impl<T, S> RequestWithState<T, S> where
    Self: Endpoint + Storable,
    T: DeserializeOwned + Serialize + Clone,
    S: Clone
[src]

pub async fn save<I>(self, object: I) -> Result<ResultInfo<T>> where
    I: Into<T> + Send
[src]

This method allows to save a new model object. Please note, that Request<T> must implement the Storable trait in order to make this function available.

impl<T, S> RequestWithState<T, S> where
    Self: Endpoint + Updatable,
    T: Serialize + DeserializeOwned + Clone,
    S: Clone
[src]

pub async fn update<I>(self, object: I) -> Result<ResultInfo<T>> where
    I: Into<T> + Send + HasId
[src]

This method allows to update an existing model object. Please note, that Request<T> must implement the Updatable trait in order to make this function available.

pub async fn update_with_id<I, U>(
    self,
    uuid: U,
    object: I
) -> Result<ResultInfo<T>> where
    I: Into<T> + Send + HasId,
    U: Into<Uuid>, 
[src]

This method allows to update an existing model object. Please note, that Request<T> must implement the Updatable trait in order to make this function available.

impl<T: Clone, S: Clone> RequestWithState<T, S>[src]

pub fn new(client: Client) -> Self[src]

Creates a new Request based with a Client

Trait Implementations

impl<T: Clone, S: Clone> Clone for RequestWithState<T, S>[src]

impl<T: Debug + Clone, S: Debug + Clone> Debug for RequestWithState<T, S>[src]

impl<S: Clone> Endpoint for RequestWithState<Voucherlist, S>[src]

impl<T, S> From<RequestWithState<T, S>> for PageStream<T, S> where
    RequestWithState<T, S>: Paginated + Clone + Endpoint,
    T: DeserializeOwned + Sync + Send + Clone + 'static,
    S: Sync + Send + Clone + 'static, 
[src]

impl Paginated for RequestWithState<Voucherlist, VoucherlistStateFinished>[src]

Examples

use lexoffice::{ApiKey, Client};
use lexoffice::model::Voucherlist;
use lexoffice::model::voucherlist::{VoucherStatus, VoucherType};

let client = Client::new(ApiKey::try_default().await?);
let voucherlist = client
       .request::<Voucherlist>()
       .type_(&VoucherType::Invoice)
       .status(&VoucherStatus::Open)
       .page(0).await?;
println!("{:#?}", voucherlist);

Auto Trait Implementations

impl<T, S> !RefUnwindSafe for RequestWithState<T, S>

impl<T, S> Send for RequestWithState<T, S> where
    S: Send,
    T: Send

impl<T, S> Sync for RequestWithState<T, S> where
    S: Sync,
    T: Sync

impl<T, S> Unpin for RequestWithState<T, S> where
    S: Unpin,
    T: Unpin

impl<T, S> !UnwindSafe for RequestWithState<T, S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.