{"id":20701864,"url":"https://github.com/timgabets/dhi-xml","last_synced_at":"2025-03-11T04:19:00.086Z","repository":{"id":57618780,"uuid":"268620239","full_name":"timgabets/dhi-xml","owner":"timgabets","description":"A library for TSYS DHI (Device Host Interface) XML messages serialization/deserialization","archived":false,"fork":false,"pushed_at":"2020-07-06T16:42:34.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T07:25:24.123Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timgabets.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-01T20:03:04.000Z","updated_at":"2021-11-09T18:04:27.000Z","dependencies_parsed_at":"2022-09-14T12:40:26.761Z","dependency_job_id":null,"html_url":"https://github.com/timgabets/dhi-xml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timgabets%2Fdhi-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timgabets%2Fdhi-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timgabets%2Fdhi-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timgabets%2Fdhi-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timgabets","download_url":"https://codeload.github.com/timgabets/dhi-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242967689,"owners_count":20214318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T00:43:24.516Z","updated_at":"2025-03-11T04:19:00.065Z","avatar_url":"https://github.com/timgabets.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## DHI XML\n![License: MIT](https://img.shields.io/crates/l/dhi-xml)\n[![Build Status](https://travis-ci.org/timgabets/dhi-xml.svg?branch=master)](https://travis-ci.org/timgabets/dhi-xml)\n[![Crates.io](https://img.shields.io/crates/v/dhi_xml.svg)](https://crates.io/crates/dhi-xml)\n\nRust community library for serializaing/deserializing TSYS DHI (Device Host Interface) XML messages.\n\n### Usage\n\n```rust\nuse dhi_xml::{DHIRequest, DHIResponse};\n```\n\nDHI requests:\n```rust\n// JSON payload (for example, from HTTP request)\nlet iso_data = r#\"{\n    \"i000\": \"0100\",\n    \"i002\": \"555544******0895\",\n    \"i007\": \"Transmission date \u0026 time \",\n    \"i011\": \"STAN\",\n    \"i012\": \"hhmmss\",\n    \"i013\": \"MMDD\",\n    \"i037\": \"Retrieval Reference Number\"\n}\"#;\n\n// Deserializing request from the given JSON payload\nlet r: DHIRequest = DHIRequest::new(serde_json::from_str(\u0026iso_data).unwrap());\n\n// The data may now be accessed with\nassert_eq!(r.iso_fields[\"i002\"], \"555544******0895\");\n\n// Serialization\nlet msg = r.serialize().unwrap();\n\n// The message may be sent through the TCP stream\nlet s = TcpStream::connect(host);\ns.write_all(\u0026msg.as_bytes());\n```\n\nDHI response:\n```rust\n\nlet s = r##\"\n    \u003c?xml version=\"1.0\"?\u003e\n    \u003cRequestResponse\u003e\n        \u003cHeader/\u003e\n        \u003cResult\u003e\u003cCode\u003e0\u003c/Code\u003e\u003cDescription\u003eOK\u003c/Description\u003e\u003c/Result\u003e\n     \t\u003cISO8583-87\u003e\u003ci000\u003e0110\u003c/i000\u003e\u003ci002\u003e555544******0961\u003c/i002\u003e\u003ci003\u003e300000\u003c/i003\u003e\u003ci004\u003e000000000000\u003c/i004\u003e\u003ci007\u003e2804114717\u003c/i007\u003e\u003c/ISO8583-87\u003e\"\n    \u003c/RequestResponse\u003e\n\"##;\n\n// Deserialization from the XML payload\nlet resp: DHIResponse = from_reader(s.as_bytes()).unwrap();\n\n// Accessing data\nassert_eq!(resp.res.code, 0);\nassert_eq!(resp.res.description, \"OK\");\nassert_eq!(resp.iso_fields[\"i000\"], \"0110\");\nassert_eq!(resp.iso_fields[\"i002\"], \"555544******0961\");\n\n// Serializing response to JSON\nlet msg = resp.serialize().unwrap();\n\n// Sending as payload in HTTP response\nOk(HttpResponse::Ok()\n    .content_type(\"application/json\")\n    .header(\"X-Hdr\", \"sample\")\n    .body(msg)),\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimgabets%2Fdhi-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimgabets%2Fdhi-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimgabets%2Fdhi-xml/lists"}