pub struct ResourcesResource<'a> { /* private fields */ }Expand description
client.resources()
Implementations§
Source§impl<'a> ResourcesResource<'a>
impl<'a> ResourcesResource<'a>
Sourcepub fn create(&self, body: &ResourceCreate) -> Result<Resource>
pub fn create(&self, body: &ResourceCreate) -> Result<Resource>
Create a resource
POST /resources
Creates an individual bookable resource. Returns 402 when the licensed resource limit is reached.
§Example
let body = models::ResourceCreate {
name: "Main Hall".into(),
resource_type_id: 2,
sort_key: 1,
..Default::default()
};
let result = client.resources().create(&body)?;
println!("{}", result.name);Sourcepub fn delete(&self, resource_id: impl Display) -> Result<()>
pub fn delete(&self, resource_id: impl Display) -> Result<()>
Delete a resource
DELETE /resources/{resourceId}
Deletes the resource.
§Example
client.resources().delete(7)?;Sourcepub fn get(&self, resource_id: impl Display) -> Result<Resource>
pub fn get(&self, resource_id: impl Display) -> Result<Resource>
Get a resource
GET /resources/{resourceId}
Returns one resource and its booking settings. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its adminIds. Use include[] to resolve administrators.
Use Self::get_with to pass query parameters.
§Example
let resource = client.resources().get(7)?;
println!("{}", resource.name);Sourcepub fn get_with(
&self,
resource_id: impl Display,
query: &GetResourcesResourceIdQuery,
) -> Result<Resource>
pub fn get_with( &self, resource_id: impl Display, query: &GetResourcesResourceIdQuery, ) -> Result<Resource>
Get a resource
Like Self::get, with query parameters.
GET /resources/{resourceId}
Returns one resource and its booking settings. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its adminIds. Use include[] to resolve administrators.
Sourcepub fn get_statistics(
&self,
resource_id: impl Display,
) -> Result<ResourceStatistics>
pub fn get_statistics( &self, resource_id: impl Display, ) -> Result<ResourceStatistics>
Count pending booking occurrences
GET /resources/{resourceId}/statistics
Returns the number of pending booking occurrences from now onward for this resource. Recurring bookings can contribute more than one occurrence. Candidate series are selected using a ten-year lookahead window, then expanded from now without an upper date limit. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its adminIds.
§Example
let statistic = client.resources().get_statistics(7)?;
println!("{}", statistic.num_requested_bookings_in_future);Sourcepub fn list(&self) -> Result<Vec<Resource>>
pub fn list(&self) -> Result<Vec<Resource>>
List visible resources
GET /resources
Returns all resources visible to the current user. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its adminIds. Use include[] to resolve administrators.
Use Self::list_with to pass query parameters.
§Example
for resource in client.resources().list()? {
println!("{}", resource.name);
}Sourcepub fn list_with(&self, query: &GetResourcesQuery) -> Result<Vec<Resource>>
pub fn list_with(&self, query: &GetResourcesQuery) -> Result<Vec<Resource>>
List visible resources
Like Self::list, with query parameters.
GET /resources
Returns all resources visible to the current user. A resource is visible when the user has permission to view it or administer its bookings, or is listed in its adminIds. Use include[] to resolve administrators.
Sourcepub fn update(
&self,
resource_id: impl Display,
body: &ResourceUpdate,
) -> Result<Resource>
pub fn update( &self, resource_id: impl Display, body: &ResourceUpdate, ) -> Result<Resource>
Update a resource
PUT /resources/{resourceId}
Replaces the resource configuration.
§Example
let body = models::ResourceUpdate {
name: "Main Hall".into(),
resource_type_id: 2,
sort_key: 1,
..Default::default()
};
let result = client.resources().update(7, &body)?;
println!("{}", result.name);