Struct espocrm_rs::EspoApiClient
source · pub struct EspoApiClient { /* private fields */ }
Implementations§
source§impl EspoApiClient
impl EspoApiClient
sourcepub fn new(url: &str) -> EspoApiClient
pub fn new(url: &str) -> EspoApiClient
Create an instance of EspoApiClient.
pub fn build(&self) -> Self
sourcepub fn set_url<S: AsRef<str>>(&mut self, url: S) -> &mut EspoApiClient
pub fn set_url<S: AsRef<str>>(&mut self, url: S) -> &mut EspoApiClient
Set the URL where EspoCRM is located.
sourcepub fn set_username<S: AsRef<str>>(&mut self, username: S) -> &mut EspoApiClient
pub fn set_username<S: AsRef<str>>(&mut self, username: S) -> &mut EspoApiClient
Set the username to use for authentication.
If you use this you must also call Self::set_password()
It is not recommended that you use this. Instead you should use API Key authorization or HMAC
sourcepub fn set_password<S: AsRef<str>>(&mut self, password: S) -> &mut EspoApiClient
pub fn set_password<S: AsRef<str>>(&mut self, password: S) -> &mut EspoApiClient
Set the password to use for authentication
If you use this you must also call Self::set_username()
It is not recommended that you use this. Instead you should use API Key authorization or HMAC authorization
sourcepub fn set_api_key<S: AsRef<str>>(&mut self, api_key: S) -> &mut EspoApiClient
pub fn set_api_key<S: AsRef<str>>(&mut self, api_key: S) -> &mut EspoApiClient
Set the API Key to use for authorization
If you only provide the API key, and not the secret_key, API Key authorization will be used.
If you wish to use HMAC authorization, you must also call Self::set_secret_key()
sourcepub fn set_secret_key<S: AsRef<str>>(
&mut self,
secret_key: S
) -> &mut EspoApiClient
pub fn set_secret_key<S: AsRef<str>>(
&mut self,
secret_key: S
) -> &mut EspoApiClient
Set the Secret Key to use for HMAC authorization
If you use this you must also call Self::set_api_key()
sourcepub async fn create_allow_duplicates<T, S>(
&self,
action: S,
data: T
) -> Result<Response>where
T: Serialize + Clone + Debug,
S: AsRef<str>,
pub async fn create_allow_duplicates<T, S>(
&self,
action: S,
data: T
) -> Result<Response>where
T: Serialize + Clone + Debug,
S: AsRef<str>,
Make a POST request to EspoCRM to create an entity.
This request will skip duplicate checks, which would otherwhise result in a HTTP 409
.
For information about what the data
and action
should be, refer to the EspoCRM API Documentation.
Errors
If the request fails
sourcepub async fn create<T, S>(&self, action: S, data: T) -> Result<Response>where
T: Serialize + Clone + Debug,
S: AsRef<str>,
pub async fn create<T, S>(&self, action: S, data: T) -> Result<Response>where
T: Serialize + Clone + Debug,
S: AsRef<str>,
Make a POST request to EspoCRM to create an entity.
This request will perform duplicate checks and return a HTTP 409
if one is found. If you want to avoid this use Self::create_allow_duplicates.
For information about what the data
and action
should be, refer to the EspoCRM API Documentation.
Errors
If the request fails
sourcepub async fn request<T, S>(
&self,
method: Method,
action: S,
data_get: Option<Params>,
data_post: Option<T>
) -> Result<Response>where
T: Serialize + Clone + Debug,
S: AsRef<str> + Debug,
pub async fn request<T, S>(
&self,
method: Method,
action: S,
data_get: Option<Params>,
data_post: Option<T>
) -> Result<Response>where
T: Serialize + Clone + Debug,
S: AsRef<str> + Debug,
Make a request to EspoCRM For more information, see the EspoCRM API Documentation
If you are making a GET request, you will still need to provide a type declaration for T. You can use the type NoGeneric for this.
- method: The HTTP method to be used. E.g GET or POST
- action: On what EspoCRM Object should the action be performed on. E.g “Contact” or “Contact/ID”. Essentially this is everything after “/api/v1/” in the URL.
- data_get: The filter to use on a GET request. Will be serialized according to PHP’s http_build_query function.
- data_post: The data to send on everything that is not a GET request. It will be serialized to JSON and send as the request body.
Trait Implementations§
source§impl Clone for EspoApiClient
impl Clone for EspoApiClient
source§fn clone(&self) -> EspoApiClient
fn clone(&self) -> EspoApiClient
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EspoApiClient
impl Debug for EspoApiClient
source§impl PartialEq<EspoApiClient> for EspoApiClient
impl PartialEq<EspoApiClient> for EspoApiClient
source§fn eq(&self, other: &EspoApiClient) -> bool
fn eq(&self, other: &EspoApiClient) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for EspoApiClient
impl StructuralEq for EspoApiClient
impl StructuralPartialEq for EspoApiClient
Auto Trait Implementations§
impl RefUnwindSafe for EspoApiClient
impl Send for EspoApiClient
impl Sync for EspoApiClient
impl Unpin for EspoApiClient
impl UnwindSafe for EspoApiClient
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_mut()
into the pipe
function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.