ya_client/activity/
requestor.rs1use crate::web::{WebClient, WebInterface};
3use crate::Result;
4use ya_client_model::activity::ACTIVITY_API_PATH;
5
6pub mod control;
7pub mod state;
8
9#[derive(Clone)]
10pub struct ActivityRequestorApi {
11 control: control::ActivityRequestorControlApi,
12 state: state::ActivityRequestorStateApi,
13 client: WebClient,
14}
15
16impl WebInterface for ActivityRequestorApi {
17 const API_URL_ENV_VAR: &'static str = crate::activity::ACTIVITY_URL_ENV_VAR;
18 const API_SUFFIX: &'static str = ACTIVITY_API_PATH;
19
20 fn from_client(client: WebClient) -> Self {
21 Self {
22 control: WebInterface::from_client(client.clone()),
23 state: WebInterface::from_client(client.clone()),
24 client,
25 }
26 }
27}
28
29impl ActivityRequestorApi {
30 pub fn control(&self) -> &control::ActivityRequestorControlApi {
31 &self.control
32 }
33
34 pub fn state(&self) -> &state::ActivityRequestorStateApi {
35 &self.state
36 }
37
38 pub async fn get_agreement(&self, activity_id: &str) -> Result<String> {
40 let uri = url_format!("activity/{activity_id}/agreement");
41 self.client.get(&uri).send().json().await
42 }
43}