asterisk_ari/apis/endpoints/
mod.rs1pub mod models;
2pub mod params;
3
4use crate::apis::client::Client;
5use std::fmt::Display;
6
7pub struct Endpoints<'c> {
8 client: &'c Client,
9}
10
11impl<'c> Endpoints<'c> {
12 pub fn new(client: &'c Client) -> Self {
13 Self { client }
14 }
15}
16
17impl Endpoints<'_> {
18 pub async fn list(&self) -> crate::errors::Result<Vec<models::Endpoint>> {
20 self.client.get("/endpoints").await
21 }
22
23 pub async fn list_by_technology(
25 &self,
26 tech: impl Into<String> + Display + Send,
27 ) -> crate::errors::Result<Vec<models::Endpoint>> {
28 self.client.get(format!("/endpoints/{tech}").as_str()).await
29 }
30
31 pub async fn get(
33 &self,
34 tech: impl Into<String> + Send,
35 resource: impl Into<String> + Send,
36 ) -> crate::errors::Result<models::Endpoint> {
37 self.client
38 .get(format!("/endpoints/{}/{}", tech.into(), resource.into()).as_str())
39 .await
40 }
41
42 pub async fn send_message(
44 &self,
45 request: params::SendMessageRequest,
46 ) -> crate::errors::Result<()> {
47 self.client
48 .put_with_query("/endpoints/sendMessage", &request.variables, &request)
49 .await
50 }
51
52 pub async fn send_message_to_endpoint(
54 &self,
55 request: params::SendMessageToEndpointRequest,
56 ) -> crate::errors::Result<()> {
57 self.client
58 .put_with_query(
59 format!(
60 "/endpoints/{}/{}/sendMessage",
61 request.tech, request.resource
62 )
63 .as_str(),
64 &request.variables,
65 &request,
66 )
67 .await
68 }
69
70 pub async fn refer(&self, request: params::ReferRequest) -> crate::errors::Result<()> {
72 self.client
73 .put_with_query("/endpoints/refer", &request.variables, &request)
74 .await
75 }
76
77 pub async fn refer_to_endpoint(
79 &self,
80 request: params::ReferToEndpointRequest,
81 ) -> crate::errors::Result<()> {
82 self.client
83 .post_with_query(
84 format!("/endpoints/{}/{}/refer", request.tech, request.resource).as_str(),
85 &request.variables,
86 &request,
87 )
88 .await
89 }
90}