antares struct
This commit is contained in:
parent
a04f2a709e
commit
6c459eb93e
|
|
@ -1 +1,2 @@
|
|||
/target
|
||||
*.json
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -4,3 +4,6 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.12", features = ["blocking"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
|
|
|
|||
37
src/main.rs
37
src/main.rs
|
|
@ -1,3 +1,36 @@
|
|||
fn main() {
|
||||
|
||||
use std::fs;
|
||||
fn make_url(base: &str, usercode: &str, password: &str, cikkszam: &str) -> String {
|
||||
// Constructs the full URL by injecting user credentials and cikkszam into the base URL.
|
||||
format!(
|
||||
"{}&USERCODE={}&PASSWORD={}&PIN=&cikkszam={}",
|
||||
base, usercode, password, cikkszam
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Separate values
|
||||
let usercode = "orinkkft";
|
||||
let password = "8E7DCB55F3B4ECC52D0451A1F8D851D0EF2193FCE4B83E528C18A8F68F8F2658EFCF2EA08563EC702A1C701934C3FBF5F6880BE894A16387326C7180A9A4C361";
|
||||
let base = "https://b2b.antares.hu/I4stechproductionWebInt/IntAntaresWebCikkDataService.svc/webhttps/Get_CikkInfokWeb?SCHEMA=ANTARESINT";
|
||||
let cikkszam = ""; // supply a value if needed
|
||||
|
||||
let url = make_url(base, usercode, password, cikkszam);
|
||||
|
||||
let response = reqwest::blocking::get(&url)
|
||||
.expect("Failed to send request")
|
||||
.text()
|
||||
.expect("Failed to read response body");
|
||||
|
||||
// Try to parse and pretty-print JSON; otherwise save raw response.
|
||||
match serde_json::from_str::<serde_json::Value>(&response) {
|
||||
Ok(json) => {
|
||||
let pretty = serde_json::to_string_pretty(&json).expect("Failed to format JSON");
|
||||
fs::write("antares.json", pretty).expect("Failed to write antares.json");
|
||||
println!("Saved pretty JSON to antares.json");
|
||||
}
|
||||
Err(_) => {
|
||||
fs::write("antares.json", response).expect("Failed to write antares.json");
|
||||
eprintln!("Warning: response is not valid JSON; saved raw response to antares.json");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
//! Generated structs for Antares JSON response
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct AntaresItem {
|
||||
pub brutto_suly: Option<f64>,
|
||||
pub brutto_suly_mennyisegi_egyseg: Option<String>,
|
||||
pub brutto_suly_szorzo: Option<f64>,
|
||||
pub cikk_jellemzok: Option<Vec<CikkJellemzo>>,
|
||||
pub cikk_kepek: Option<Vec<CikkKep>>,
|
||||
pub cikk_megnevezes: Option<String>,
|
||||
pub cikk_megnevezes_rovid: Option<String>,
|
||||
pub cikkszam: Option<String>,
|
||||
pub kshszam: Option<String>,
|
||||
pub mennyisegi_egyseg_kod: Option<String>,
|
||||
pub muszaki_leiras: Option<String>,
|
||||
pub netto_kisker_ar: Option<f64>,
|
||||
pub suly: Option<f64>,
|
||||
pub suly_mennyisegi_egyseg: Option<String>,
|
||||
pub szabad_keszlet: Option<i64>,
|
||||
pub szarmazasi_orszag_kod: Option<String>,
|
||||
pub utolso_modositas_datum: Option<String>,
|
||||
pub utolso_mozgas_datum: Option<String>,
|
||||
pub vonalkod: Option<String>,
|
||||
pub web: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct CikkJellemzo {
|
||||
pub jellemzo_ertek: Option<String>,
|
||||
pub jellemzo_nev: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct CikkKep {
|
||||
pub url: Option<String>,
|
||||
}
|
||||
|
||||
// Convenience type alias for top-level array
|
||||
pub type Antares = Vec<AntaresItem>;
|
||||
Loading…
Reference in New Issue