Update
This commit is contained in:
parent
f0321d6409
commit
197b4e2ecf
1 changed files with 15 additions and 0 deletions
15
src/lib.rs
15
src/lib.rs
|
@ -288,6 +288,7 @@ pub struct Client {
|
||||||
pub api_url: url::Url,
|
pub api_url: url::Url,
|
||||||
pub rpc_url: url::Url,
|
pub rpc_url: url::Url,
|
||||||
pub client_name: String,
|
pub client_name: String,
|
||||||
|
pub user_agent: String,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
pub session: Option<String>,
|
pub session: Option<String>,
|
||||||
|
@ -304,6 +305,7 @@ impl Client {
|
||||||
pub async fn login_rpc(&mut self) -> Result<RpcLogin> {
|
pub async fn login_rpc(&mut self) -> Result<RpcLogin> {
|
||||||
let resp: RpcResponse<RpcLogin> = reqwest::Client::new()
|
let resp: RpcResponse<RpcLogin> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.json(&json!({
|
.json(&json!({
|
||||||
|
@ -346,6 +348,7 @@ impl Client {
|
||||||
pub async fn login_api(&mut self) -> Result<String> {
|
pub async fn login_api(&mut self) -> Result<String> {
|
||||||
let jwt = reqwest::Client::new()
|
let jwt = reqwest::Client::new()
|
||||||
.get(self.api_url.join("token/new")?)
|
.get(self.api_url.join("token/new")?)
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(
|
.header(
|
||||||
reqwest::header::COOKIE,
|
reqwest::header::COOKIE,
|
||||||
self.session.as_ref().context("Not logged in")?,
|
self.session.as_ref().context("Not logged in")?,
|
||||||
|
@ -369,6 +372,7 @@ impl Client {
|
||||||
pub async fn logout(&mut self) -> Result<()> {
|
pub async fn logout(&mut self) -> Result<()> {
|
||||||
let resp: RpcResponse<RpcEmptyResult> = reqwest::Client::new()
|
let resp: RpcResponse<RpcEmptyResult> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -396,6 +400,7 @@ impl Client {
|
||||||
pub async fn classes(&self) -> Result<Vec<RpcClass>> {
|
pub async fn classes(&self) -> Result<Vec<RpcClass>> {
|
||||||
let resp: RpcResponse<Vec<RpcClass>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcClass>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -426,6 +431,7 @@ impl Client {
|
||||||
pub async fn subjects(&self) -> Result<Vec<RpcSubject>> {
|
pub async fn subjects(&self) -> Result<Vec<RpcSubject>> {
|
||||||
let resp: RpcResponse<Vec<RpcSubject>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcSubject>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -456,6 +462,7 @@ impl Client {
|
||||||
pub async fn rooms(&self) -> Result<Vec<RpcRoom>> {
|
pub async fn rooms(&self) -> Result<Vec<RpcRoom>> {
|
||||||
let resp: RpcResponse<Vec<RpcRoom>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcRoom>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -486,6 +493,7 @@ impl Client {
|
||||||
pub async fn departments(&self) -> Result<Vec<RpcDepartment>> {
|
pub async fn departments(&self) -> Result<Vec<RpcDepartment>> {
|
||||||
let resp: RpcResponse<Vec<RpcDepartment>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcDepartment>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -516,6 +524,7 @@ impl Client {
|
||||||
pub async fn holidays(&self) -> Result<Vec<RpcHoliday>> {
|
pub async fn holidays(&self) -> Result<Vec<RpcHoliday>> {
|
||||||
let resp: RpcResponse<Vec<RpcHoliday>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcHoliday>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -546,6 +555,7 @@ impl Client {
|
||||||
pub async fn timegrid(&self) -> Result<Vec<RpcTimegridDay>> {
|
pub async fn timegrid(&self) -> Result<Vec<RpcTimegridDay>> {
|
||||||
let resp: RpcResponse<Vec<RpcTimegridDay>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcTimegridDay>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -576,6 +586,7 @@ impl Client {
|
||||||
pub async fn current_schoolyear(&self) -> Result<RpcSchoolyear> {
|
pub async fn current_schoolyear(&self) -> Result<RpcSchoolyear> {
|
||||||
let resp: RpcResponse<RpcSchoolyear> = reqwest::Client::new()
|
let resp: RpcResponse<RpcSchoolyear> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -606,6 +617,7 @@ impl Client {
|
||||||
pub async fn schoolyears(&self) -> Result<Vec<RpcSchoolyear>> {
|
pub async fn schoolyears(&self) -> Result<Vec<RpcSchoolyear>> {
|
||||||
let resp: RpcResponse<Vec<RpcSchoolyear>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcSchoolyear>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -641,6 +653,7 @@ impl Client {
|
||||||
) -> Result<Vec<RpcSubstitution>> {
|
) -> Result<Vec<RpcSubstitution>> {
|
||||||
let resp: RpcResponse<Vec<RpcSubstitution>> = reqwest::Client::new()
|
let resp: RpcResponse<Vec<RpcSubstitution>> = reqwest::Client::new()
|
||||||
.get(self.rpc_url.as_str())
|
.get(self.rpc_url.as_str())
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
|
@ -679,6 +692,7 @@ impl Client {
|
||||||
pub async fn current_tenant(&self) -> Result<ApiTenant> {
|
pub async fn current_tenant(&self) -> Result<ApiTenant> {
|
||||||
let resp: ApiDataResponse = reqwest::Client::new()
|
let resp: ApiDataResponse = reqwest::Client::new()
|
||||||
.get(self.api_url.join("rest/view/v1/app/data")?)
|
.get(self.api_url.join("rest/view/v1/app/data")?)
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
reqwest::header::COOKIE,
|
reqwest::header::COOKIE,
|
||||||
|
@ -701,6 +715,7 @@ impl Client {
|
||||||
url.query_pairs_mut().append_pair("type", "2");
|
url.query_pairs_mut().append_pair("type", "2");
|
||||||
let resp: ApiTeachersResponse = reqwest::Client::new()
|
let resp: ApiTeachersResponse = reqwest::Client::new()
|
||||||
.get(url)
|
.get(url)
|
||||||
|
.header(reqwest::header::USER_AGENT, &self.user_agent)
|
||||||
.header(reqwest::header::ACCEPT, "application/json")
|
.header(reqwest::header::ACCEPT, "application/json")
|
||||||
.header(
|
.header(
|
||||||
reqwest::header::COOKIE,
|
reqwest::header::COOKIE,
|
||||||
|
|
Loading…
Reference in a new issue