Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Main
- let dd = Self::get_ns2__AddressValidationRequest(json);
- match dd {
- Ok(v) => {
- let mut o = v.unwrap();
- let soap = unsafe { create_soap() };
- let base_url = "123";
- let mut sr: ns2__AddressValidationReply =
- unsafe { validate_address(soap, CString::new(base_url).unwrap().as_ptr(), &mut *o as *mut ns2__AddressValidationRequest) };
- }
- Err(e) => {
- return Err(vec!["kaka".to_owned()]);
- }
- }
- //get_ns2__AddressValidationRequest
- #[allow(bad_style)]
- fn get_ns2__AddressValidationRequest(
- json: &Value,
- ) -> Result<Option<Box<ns2__AddressValidationRequest>>, Vec<String>> {
- let ClientDetail_res = Self::get_ns2__ClientDetail(json);
- let ClientDetail;
- match ClientDetail_res {
- Ok(v) => {
- ClientDetail = v;
- }
- Err(e) => {
- return Err(e);
- }
- }
- let root_ClientDetail_ov = if ClientDetail.is_some() {
- &mut *ClientDetail.unwrap() as *mut ns2__ClientDetail
- } else {
- std::ptr::null_mut() as *mut ns2__ClientDetail
- };
- let mut seconds: i64 = 1555 as i64;
- let ret = Some(Box::new(ns2__AddressValidationRequest {
- WebAuthenticationDetail: null_mut_ptr!(ns2__WebAuthenticationDetail),
- ClientDetail: root_ClientDetail_ov,
- TransactionDetail: null_mut_ptr!(ns2__TransactionDetail),
- Version: null_mut_ptr!(ns2__VersionId),
- InEffectAsOfTimestamp: item_as_mut_ptr!(seconds, ::std::os::raw::c_long),
- __sizeAddressesToValidate: AddressesToValidate_tmp.len() as i32,
- AddressesToValidate: null_mut_ptr!(ns2__AddressToValidate),
- }));
- Ok(ret)
- }
- // Cliet detail
- #[allow(bad_style)]
- fn get_ns2__ClientDetail(json: &Value) -> Result<Option<Box<ns2__ClientDetail>>, Vec<String>> {
- let real = !json["ClientDetail"].is_null();
- if !real {
- return Err(vec![format!("Required obj '{}' not set", "ClientDetail")]);
- }
- let AccountNumber;
- let AccountNumber_op =
- Self::get_string("AccountNumber", &json["ClientDetail"]["AccountNumber"], true);
- match AccountNumber_op {
- Ok(v) => {
- AccountNumber = v;
- }
- Err(e) => {
- return Err(e);
- }
- }
- let IntegratorId;
- let IntegratorId_op = Self::get_string("IntegratorId", &json["ClientDetail"]["IntegratorId"], false);
- match IntegratorId_op {
- Ok(v) => {
- IntegratorId = v;
- }
- Err(e) => {
- return Err(e);
- }
- }
- let MeterNumber;
- let MeterNumber_op = Self::get_string("MeterNumber", &json["ClientDetail"]["MeterNumber"], true);
- match MeterNumber_op {
- Ok(v) => {
- MeterNumber = v;
- }
- Err(e) => {
- return Err(e);
- }
- }
- let ret = Some(Box::new(ns2__ClientDetail {
- AccountNumber: AccountNumber,
- MeterNumber: MeterNumber,
- IntegratorId: IntegratorId,
- Localization: null_mut_ptr!(ns2__Localization),
- }));
- Ok(ret)
- }
- // Get string
- #[allow(bad_style)]
- fn get_string(
- key: &str,
- json_str: &Value,
- required: bool,
- ) -> Result<*mut std::os::raw::c_char, Vec<String>> {
- if json_str.is_null() {
- if required {
- return Err(vec![format!("Required value '{}' not set", key)]);
- } else {
- return Ok(std::ptr::null_mut() as *mut i8);
- }
- } else {
- let as_str_op = json_str.as_str();
- match as_str_op {
- Some(s) => {
- let str_kk = CString::new(s).unwrap().into_raw();
- return Ok(str_kk);
- }
- None => {
- return Err(vec![format!("Value '{}' is not string as specified", key)]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement