use vika::{record::QueryParameters, Vika};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
//create vika api
let vika = Vika::new("api.vika.cn", "usk1234567890");
// get spaces list
let spaces = vika.spaces.query_all().await?;
println!("{:#?}", spaces);
//get nodes belong spaces
let sm = vika.spaces.space("spcnYxNW7xxLa");
println!("{:#?}", &sm.nodes.query_all().await?);
println!("{:#?}", &sm.nodes.node("fodfwXDrcac53").await?);
//get a specific fields of datasheet
let flds = vika
.spaces
.space("spcnYxNW7xxLa")
.datasheets
.datasheet("dstyc7DlpKFenubN2L")
.fields
.query_all()
.await?;
println!("{:#?}", flds);
// query all reords
let rcd = vika
.spaces
.space("spcnYxNW7xxLa")
.datasheets
.datasheet("dstyc7DlpKFenubN2L")
.records
.query_all()
.await?;
println!("{:#?}", rcd);
//query records by parameter
let rcd = vika
.spaces
.space("spcnYxNW7xxLa")
.datasheets
.datasheet("dstyc7DlpKFenubN2L")
.records
.query_with_params(&QueryParameters {
field_key: vika::record::FieldKey::Id,
..Default::default()
})
.await?;
println!("{:#?}", rcd);
//query records by parameter
let viw = vika
.spaces
.space("spcnYxNW7xxLa")
.datasheets
.datasheet("dstyc7DlpKFenubN2L")
.views
.query_all()
.await?;
println!("{:#?}", viw);
anyhow::Ok(())
}