#[allow(unused_imports)]
use crate::generated::*;
#[allow(unused_imports)]
use crate::{
BalanceSnapshot, Client, CountrySpecifications, CreateFileRequest, FileDownload,
FulfillUploadRequest, OpenFileLinkRequest, RequestOptions, RequestSpec, Result,
};
#[derive(Clone)]
pub struct Customers {
client: Client,
}
impl Customers {
pub(crate) fn new(client: Client) -> Self {
Self { client }
}
pub async fn create(&self, request: &CreateCustomerRequest) -> Result<Customer> {
self.create_with_options(request, RequestOptions::default())
.await
}
pub async fn create_with_options(
&self,
request: &CreateCustomerRequest,
options: RequestOptions,
) -> Result<Customer> {
self.client
.request_resource(
RequestSpec {
method: "POST",
path: "/customers/create",
operation: "customers.create",
field: Some("customer"),
authenticated: true,
},
Some(request),
options,
)
.await
}
pub async fn lookup(&self, request: &LookupCustomerRequest) -> Result<Customer> {
self.lookup_with_options(request, RequestOptions::default())
.await
}
pub async fn lookup_with_options(
&self,
request: &LookupCustomerRequest,
options: RequestOptions,
) -> Result<Customer> {
self.client
.request_resource(
RequestSpec {
method: "POST",
path: "/customers/lookup",
operation: "customers.lookup",
field: Some("customer"),
authenticated: true,
},
Some(request),
options,
)
.await
}
pub async fn update(&self, request: &UpdateCustomerRequest) -> Result<Customer> {
self.update_with_options(request, RequestOptions::default())
.await
}
pub async fn update_with_options(
&self,
request: &UpdateCustomerRequest,
options: RequestOptions,
) -> Result<Customer> {
self.client
.request_resource(
RequestSpec {
method: "POST",
path: "/customers/update",
operation: "customers.update",
field: Some("customer"),
authenticated: true,
},
Some(request),
options,
)
.await
}
pub async fn page(&self, request: &PageCustomersRequest) -> Result<CustomerPage> {
self.page_with_options(request, RequestOptions::default())
.await
}
pub async fn page_with_options(
&self,
request: &PageCustomersRequest,
options: RequestOptions,
) -> Result<CustomerPage> {
self.client
.request_resource(
RequestSpec {
method: "POST",
path: "/customers/page",
operation: "customers.page",
field: Some("page"),
authenticated: true,
},
Some(request),
options,
)
.await
}
pub async fn search(&self, request: &ResourceSearchRequest) -> Result<ResourceSearchPage> {
self.search_with_options(request, RequestOptions::default())
.await
}
pub async fn search_with_options(
&self,
request: &ResourceSearchRequest,
options: RequestOptions,
) -> Result<ResourceSearchPage> {
self.client
.request_resource(
RequestSpec {
method: "POST",
path: "/customers/search",
operation: "customers.search",
field: Some("search"),
authenticated: true,
},
Some(request),
options,
)
.await
}
}