{
"Message": {
"SenderId": "12345",
"ReceiverId": "67890",
"ClientId": "ABCDE",
"MessageId": "XYZ123",
"MessageDate": "2024-02-09T08:00:00Z",
"MessageFunction": "FunctionABC",
"Schema": "SchemaXYZ",
"Namespace": "NamespaceABC"
},
"MetaData": [
{
"Name": "Meta1",
"Content": "Content1"
},
{
"Name": "Meta2",
"Content": "Content2"
}
],
"Partys": [
{
"PartyId": "P001",
"Agency": "Google Inc.",
"Type": "Technology",
"Name": "Google",
"Identifier": "GOOG",
"ImageLink": "https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/1200px-Google_%22G%22_Logo.svg.png",
"Phone": "+1-650-253-0000",
"Mobile": "+1-650-253-0000",
"Fax": "+1-650-253-0001",
"Email": "info@google.com",
"Website": "https://www.google.com",
"Language": "English",
"VatId": "US0123456789",
"TaxId": "US0123456789",
"Tags": "Search, Technology, Advertising",
"Remarks": "Remarks for Google Inc.",
"IsCustomer": true,
"IsSupplier": false,
"TaxAllocation": "Technology",
"DebtorAccount": "Google Inc.",
"VendorAccount": "Google Inc.",
"System1Name": "Google System 1",
"System1Code": "G-001",
"System2Name": "Google System 2",
"System2Code": "G-002",
"System3Name": "Google System 3",
"System3Code": "G-003",
"Addresses": [
{
"Type": "Headquarters",
"Name": "Googleplex",
"Name2": "Main Campus",
"Street": "1600 Amphitheatre Parkway",
"Street2": "",
"ZipCode": "94043",
"City": "Mountain View",
"State": "California",
"Country": "United States",
"ContactPerson": "John Smith",
"Email": "john.smith@google.com",
"Phone": "+1-650-253-0000",
"Mobile": "+1-650-253-0000",
"Remarks": "Headquarters of Google",
"Latitude": 37.422,
"Longitude": -122.084
},
{
"Type": "Branch Office",
"Name": "Google New York",
"Name2": "Manhattan Office",
"Street": "111 8th Avenue",
"Street2": "4th Floor",
"ZipCode": "10011",
"City": "New York",
"State": "New York",
"Country": "United States",
"ContactPerson": "Jane Doe",
"Email": "jane.doe@google.com",
"Phone": "+1-212-565-0000",
"Mobile": "+1-212-565-0000",
"Remarks": "Google's office in New York",
"Latitude": 40.740,
"Longitude": -74.002
}
],
"Accounts": [
{
"BankName": "Chase Bank",
"OwnerName": "Google Inc.",
"IBAN": "US0123456789",
"BIC": "CHASUS33",
"SWIFT": "CHASUS33XXX",
"Number": "0123456789",
"Currency": "USD",
"IsDefault": true
},
{
"BankName": "Bank of America",
"OwnerName": "Google Inc.",
"IBAN": "US9876543210",
"BIC": "BOFAUS3N",
"SWIFT": "BOFAUS3NXXX",
"Number": "9876543210",
"Currency": "USD",
"IsDefault": false
}
]
},
{
"PartyId": "P002",
"Agency": "Apple Inc.",
"Type": "Technology",
"Name": "Apple",
"Identifier": "AAPL",
"ImageLink": "https://upload.wikimedia.org/wikipedia/commons/f/fa/Apple_logo_black.svg",
"Phone": "+1-800-MY-APPLE",
"Mobile": "+1-800-MY-APPLE",
"Fax": "+1-800-MY-APPLE",
"Email": "info@apple.com",
"Website": "https://www.apple.com",
"Language": "English",
"VatId": "US0123456789",
"TaxId": "US0123456789",
"Tags": "Technology, Electronics, Software",
"Remarks": "Remarks for Apple Inc.",
"IsCustomer": false,
"IsSupplier": true,
"TaxAllocation": "Technology",
"DebtorAccount": "Apple Inc.",
"VendorAccount": "Apple Inc.",
"System1Name": "Apple System 1",
"System1Code": "A-001",
"System2Name": "Apple System 2",
"System2Code": "A-002",
"System3Name": "Apple System 3",
"System3Code": "A-003",
"Addresses": [
{
"Type": "Headquarters",
"Name": "Apple Park",
"Name2": "",
"Street": "1 Apple Park Way",
"Street2": "",
"ZipCode": "95014",
"City": "Cupertino",
"State": "California",
"Country": "United States",
"ContactPerson": "Steve Jobs",
"Email": "steve.jobs@apple.com",
"Phone": "+1-800-MY-APPLE",
"Mobile": "+1-800-MY-APPLE",
"Remarks": "Headquarters of Apple",
"Latitude": 37.331,
"Longitude": -122.030
}
],
"Accounts": []
}
]
}
Java classes with public properties (draft)
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Optional;
public class DocThorMessage {
@JsonProperty("SenderId")
public String SenderId;
@JsonProperty("ReceiverId")
public String ReceiverId;
@JsonProperty("ClientId")
public String ClientId;
@JsonProperty("MessageId")
public String MessageId;
@JsonProperty("MessageDate")
public Optional<String> MessageDate; // Use Optional for nullable types
@JsonProperty("MessageFunction")
public String MessageFunction;
@JsonProperty("Schema")
public String Schema;
@JsonProperty("Namespace")
public String Namespace;
}
class DocThorMetaDataItem {
public String Name;
public String Content;
}
class BaseDataParty {
public DocThorMessage Message;
public List<DocThorMetaDataItem> MetaData;
public List<BaseDataParty> Parties;
class BaseDataPartyAddress {
public String Type;
public String Name;
public String Name2;
public String Street;
public String Street2;
public String ZipCode;
public String City;
public String State;
public String Country;
public String ContactPerson;
public String Email;
public String Phone;
public String Mobile;
public String Remarks;
public Optional<Double> Latitude; // Use Optional for nullable types
public Optional<Double> Longitude; // Use Optional for nullable types
}
class BaseDataPartyAccount {
public String BankName;
public String OwnerName;
public String IBAN;
public String BIC;
public String SWIFT;
public String Number;
public String Currency;
public Optional<Boolean> IsDefault; // Use Optional for nullable types
}
}
Java classes (draft)
import java.util.List;
import java.util.Optional;
public class DocThorMessage {
private String SenderId;
private String ReceiverId;
private String ClientId;
private String MessageId;
private Optional<String> MessageDate;
private String MessageFunction;
private String Schema;
private String Namespace;
// Getters and setters
public String getSenderId() {
return SenderId;
}
public void setSenderId(String SenderId) {
this.SenderId = SenderId;
}
public String getReceiverId() {
return ReceiverId;
}
public void setReceiverId(String ReceiverId) {
this.ReceiverId = ReceiverId;
}
public String getClientId() {
return ClientId;
}
public void setClientId(String ClientId) {
this.ClientId = ClientId;
}
public String getMessageId() {
return MessageId;
}
public void setMessageId(String MessageId) {
this.MessageId = MessageId;
}
public Optional<String> getMessageDate() {
return MessageDate;
}
public void setMessageDate(Optional<String> MessageDate) {
this.MessageDate = MessageDate;
}
public String getMessageFunction() {
return MessageFunction;
}
public void setMessageFunction(String MessageFunction) {
this.MessageFunction = MessageFunction;
}
public String getSchema() {
return Schema;
}
public void setSchema(String Schema) {
this.Schema = Schema;
}
public String getNamespace() {
return Namespace;
}
public void setNamespace(String Namespace) {
this.Namespace = Namespace;
}
}
class DocThorMetaDataItem {
public String Name;
public String Content;
// Getters and setters
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getContent() {
return Content;
}
public void setContent(String Content) {
this.Content = Content;
}
}
class BaseDataParty {
public DocThorMessage Message;
public List<DocThorMetaDataItem> MetaData;
public List<BaseDataParty> Partys;
class BaseDataPartyAddress {
public String Type;
public String Name;
public String Name2;
public String Street;
public String Street2;
public String ZipCode;
public String City;
public String State;
public String Country;
public String ContactPerson;
public String Email;
public String Phone;
public String Mobile;
public String Remarks;
public Optional<Double> Latitude;
public Optional<Double> Longitude;
// Getters and setters
public String getType() {
return Type;
}
public void setType(String Type) {
this.Type = Type;
}
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getName2() {
return Name2;
}
public void setName2(String Name2) {
this.Name2 = Name2;
}
public String getStreet() {
return Street;
}
public void setStreet(String Street) {
this.Street = Street;
}
public String getStreet2() {
return Street2;
}
public void setStreet2(String Street2) {
this.Street2 = Street2;
}
public String getZipCode() {
return ZipCode;
}
public void setZipCode(String ZipCode) {
this.ZipCode = ZipCode;
}
public String getCity() {
return City;
}
public void setCity(String City) {
this.City = City;
}
public String getState() {
return State;
}
public void setState(String State) {
this.State = State;
}
public String getCountry() {
return Country;
}
public void setCountry(String Country) {
this.Country = Country;
}
public String getContactPerson() {
return ContactPerson;
}
public void setContactPerson(String ContactPerson) {
this.ContactPerson = ContactPerson;
}
public String getEmail() {
return Email;
}
public void setEmail(String Email) {
this.Email = Email;
}
public String getPhone() {
return Phone;
}
public void setPhone(String Phone) {
this.Phone = Phone;
}
public String getMobile() {
return Mobile;
}
public void setMobile(String Mobile) {
this.Mobile = Mobile;
}
public String getRemarks() {
return Remarks;
}
public void setRemarks(String Remarks) {
this.Remarks = Remarks;
}
public Optional<Double> getLatitude() {
return Latitude;
}
public void setLatitude(Optional<Double> Latitude) {
this.Latitude = Latitude;
}
public Optional<Double> getLongitude() {
return Longitude;
}
public void setLongitude(Optional<Double> Longitude) {
this.Longitude = Longitude;
}
}
class BaseDataPartyAccount {
public String BankName;
public String OwnerName;
public String IBAN;
public String BIC;
public String SWIFT;
public String Number;
public String Currency;
public Optional<Boolean> IsDefault;
// Getters and setters
public String getBankName() {
return BankName;
}
public void setBankName(String BankName) {
this.BankName = BankName;
}
public String getOwnerName() {
return OwnerName;
}
public void setOwnerName(String OwnerName) {
this.OwnerName = OwnerName;
}
public String getIban() {
return IBAN;
}
public void setIban(String Iban) {
this.IBAN = Iban;
}
public String getBic() {
return BIC;
}
public void setBic(String Bic) {
this.BIC = Bic;
}
public String getSwift() {
return SWIFT;
}
public void setSwift(String Swift) {
this.SWIFT = Swift;
}
public String getNumber() {
return Number;
}
public void setNumber(String Number) {
this.Number = Number;
}
public String getCurrency() {
return Currency;
}
public void setCurrency(String Currency) {
this.Currency = Currency;
}
public Optional<Boolean> getIsDefault() {
return IsDefault;
}
public void setIsDefault(Optional<Boolean> IsDefault) {
this.IsDefault = IsDefault;
}
}
}
Python classes (draft)
import json
import xml.etree.ElementTree as ET
from typing import List, Optional
from datetime import datetime
class DocThorMessage:
def __init__(self):
self.SenderId: Optional[str] = None
self.ReceiverId: Optional[str] = None
self.ClientId: Optional[str] = None
self.MessageId: Optional[str] = None
self.MessageDate: Optional[datetime] = None
self.MessageFunction: Optional[str] = None
self.Schema: Optional[str] = None
self.Namespace: Optional[str] = None
class DocThorMetaDataItem:
def __init__(self):
self.Name: Optional[str] = None
self.Content: Optional[str] = None
class PartyBaseData:
def __init__(self):
self.Message: Optional[DocThorMessage] = None
self.MetaData: Optional[List[DocThorMetaDataItem]] = None
self.Partys: Optional[List[BaseDataParty]] = None
# Remaining methods...
class BaseDataParty:
def __init__(self):
self.PartyId: Optional[str] = None
self.Agency: Optional[str] = None
self.Type: Optional[str] = None
self.Name: Optional[str] = None
self.Identifier: Optional[str] = None
self.ImageLink: Optional[str] = None
self.Phone: Optional[str] = None
self.Mobile: Optional[str] = None
self.Fax: Optional[str] = None
self.Email: Optional[str] = None
self.Website: Optional[str] = None
self.Language: Optional[str] = None
self.VatId: Optional[str] = None
self.TaxId: Optional[str] = None
self.Tags: Optional[str] = None
self.Remarks: Optional[str] = None
self.IsCustomer: Optional[bool] = None
self.IsSupplier: Optional[bool] = None
self.TaxAllocation: Optional[str] = None
self.DebtorAccount: Optional[str] = None
self.VendorAccount: Optional[str] = None
self.System1Name: Optional[str] = None
self.System1Code: Optional[str] = None
self.System2Name: Optional[str] = None
self.System2Code: Optional[str] = None
self.System3Name: Optional[str] = None
self.System3Code: Optional[str] = None
self.Addresses: Optional[List[BaseDataPartyAddress]] = None
self.Accounts: Optional[List[BaseDataPartyAccount]] = None
# Remaining methods...
class BaseDataPartyAddress:
def __init__(self):
self.Type: Optional[str] = None
self.Name: Optional[str] = None
self.Name2: Optional[str] = None
self.Street: Optional[str] = None
self.Street2: Optional[str] = None
self.ZipCode: Optional[str] = None
self.City: Optional[str] = None
self.State: Optional[str] = None
self.Country: Optional[str] = None
self.ContactPerson: Optional[str] = None
self.Email: Optional[str] = None
self.Phone: Optional[str] = None
self.Mobile: Optional[str] = None
self.Remarks: Optional[str] = None
self.Latitude: Optional[float] = None
self.Longitude: Optional[float] = None
class BaseDataPartyAccount:
def __init__(self):
self.BankName: Optional[str] = None
self.OwnerName: Optional[str] = None
self.IBAN: Optional[str] = None
self.BIC: Optional[str] = None
self.SWIFT: Optional[str] = None
self.Number: Optional[str] = None
self.Currency: Optional[str] = None
self.IsDefault: Optional[bool] = None
Javascript classes (draft)
class DocThorMessage {
constructor() {
this.SenderId = null;
this.ReceiverId = null;
this.ClientId = null;
this.MessageId = null;
this.MessageDate = null;
this.MessageFunction = null;
this.Schema = null;
this.Namespace = null;
}
}
class DocThorMetaDataItem {
constructor() {
this.Name = null;
this.Content = null;
}
}
class PartyBaseData {
constructor() {
this.Message = new DocThorMessage();
this.MetaData = [];
this.Partys = [];
}
// Serialize to XML from object asynchronously
serializeToXml(indent = false) {
// Implementation for XML serialization
}
// Deserialize from XML string asynchronously
static deserializeFromXml(xml) {
// Implementation for XML deserialization
}
// Serialize to JSON from object asynchronously
serializeToJson() {
return JSON.stringify(this, null, 4);
}
// Deserialize from JSON string asynchronously
static deserializeFromJson(json) {
return JSON.parse(json);
}
}
class BaseDataParty {
constructor() {
this.PartyId = null;
this.Agency = null;
this.Type = null;
this.Name = null;
this.Identifier = null;
this.ImageLink = null;
this.Phone = null;
this.Mobile = null;
this.Fax = null;
this.Email = null;
this.Website = null;
this.Language = null;
this.VatId = null;
this.TaxId = null;
this.Tags = null;
this.Remarks = null;
this.IsCustomer = null;
this.IsSupplier = null;
this.TaxAllocation = null;
this.DebtorAccount = null;
this.VendorAccount = null;
this.System1Name = null;
this.System1Code = null;
this.System2Name = null;
this.System2Code = null;
this.System3Name = null;
this.System3Code = null;
this.Addresses = [];
this.Accounts = [];
}
}
class BaseDataPartyAddress {
constructor() {
this.Type = null;
this.Name = null;
this.Name2 = null;
this.Street = null;
this.Street2 = null;
this.ZipCode = null;
this.City = null;
this.State = null;
this.Country = null;
this.ContactPerson = null;
this.Email = null;
this.Phone = null;
this.Mobile = null;
this.Remarks = null;
this.Latitude = null;
this.Longitude = null;
}
}
class BaseDataPartyAccount {
constructor() {
this.BankName = null;
this.OwnerName = null;
this.IBAN = null;
this.BIC = null;
this.SWIFT = null;
this.Number = null;
this.Currency = null;
this.IsDefault = null;
}
}
C# classes with async and sync cile functions and serialization and deserialization functions (Draft)
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using Formatting = Newtonsoft.Json.Formatting;
namespace DocthorBaseData
{
public partial class DocThorMessage
{
public string SenderId { get; set; }
public string ReceiverId { get; set; }
public string ClientId { get; set; }
public string MessageId { get; set; }
public DateTime? MessageDate { get; set; }
public string MessageFunction { get; set; }
public string Schema { get; set; }
public string Namespace { get; set; }
}
public class DocThorMetaDataItem
{
public string Name { get; set; }
public string Content { get; set; }
}
public class PartyBaseData
{
public DocThorMessage Message { get; set; }
public List<DocThorMetaDataItem> MetaData { get; set; }
public List<BaseDataParty> Partys { get; set; }
// Serialize to XML from object asynchronously
public string SerializeToXml(bool indent = false)
{
XmlSerializer serializer = new XmlSerializer(typeof(PartyBaseData));
StringBuilder xmlStringBuilder = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings
{
Encoding = Encoding.UTF8,
Indent = indent // Optional: Set to true if you want indented XML
};
using (StringWriter stringWriter = new StringWriter(xmlStringBuilder))
{
using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, settings))
{
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add("", "https://schemas.cargobytes.com/DocThor/PartyBaseData/V103"); // Add your namespace here
serializer.Serialize(xmlWriter, this, namespaces);
}
}
return xmlStringBuilder.ToString();
}
// Deserialize from XML string asynchronously
public static PartyBaseData DeserializeFromXml(string xml)
{
XmlSerializer serializer = new XmlSerializer(typeof(PartyBaseData));
using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
{
return (PartyBaseData)serializer.Deserialize(memoryStream);
}
}
// Serialize to XML and save to file asynchronously
public async Task SerializeToXmlFileAsync(string fileName)
{
await File.WriteAllTextAsync(fileName, SerializeToXml(), Encoding.UTF8);
}
// Deserialize from XML file asynchronously
public static async Task<PartyBaseData> DeserializeFromXmlFileAsync(string fileName)
{
string xml = await File.ReadAllTextAsync(fileName, Encoding.UTF8);
return DeserializeFromXml(xml);
}
// Serialize to JSON from object asynchronously
public string SerializeToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
}
// Deserialize from JSON string asynchronously
public static PartyBaseData DeserializeFromJson(string json)
{
return JsonConvert.DeserializeObject<PartyBaseData>(json);
}
// Serialize to JSON and save to file synchronously
public void SerializeToJsonFile(string fileName)
{
File.WriteAllText(fileName, SerializeToJson(), Encoding.UTF8);
}
// Serialize to JSON and save to file asynchronously
public async Task SerializeToJsonFileAsync(string fileName)
{
await File.WriteAllTextAsync(fileName, SerializeToJson(), Encoding.UTF8);
}
// Deserialize from JSON file synchronously
public static PartyBaseData DeserializeFromJsonFile(string fileName)
{
string json = File.ReadAllText(fileName, Encoding.UTF8);
return DeserializeFromJson(json);
}
// Deserialize from JSON file asynchronously
public static async Task<PartyBaseData> DeserializeFromJsonFileAsync(string fileName)
{
string json = await File.ReadAllTextAsync(fileName, Encoding.UTF8);
return DeserializeFromJson(json);
}
}
public class BaseDataParty
{
public string PartyId { get; set; }
public string Agency { get; set; }
public string Type { get; set; }
public string Name { get; set; }
public string Identifier { get; set; }
public string ImageLink { get; set; }
public string Phone { get; set; }
public string Mobile { get; set; }
public string Fax { get; set; }
public string Email { get; set; }
public string Website { get; set; }
public string Language { get; set; }
public string VatId { get; set; }
public string TaxId { get; set; }
public string Tags { get; set; }
public string Remarks { get; set; }
public bool? IsCustomer { get; set; }
public bool? IsSupplier { get; set; }
public string TaxAllocation { get; set; }
public string DebtorAccount { get; set; }
public string VendorAccount { get; set; }
public string System1Name { get; set; }
public string System1Code { get; set; }
public string System2Name { get; set; }
public string System2Code { get; set; }
public string System3Name { get; set; }
public string System3Code { get; set; }
public List<BaseDataPartyAddress> Addresses { get; set; }
public List<BaseDataPartyAccount> Accounts { get; set; }
}
public class BaseDataPartyAddress
{
public string Type { get; set; }
public string Name { get; set; }
public string Name2 { get; set; }
public string Street { get; set; }
public string Street2 { get; set; }
public string ZipCode { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
public string ContactPerson { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Mobile { get; set; }
public string Remarks { get; set; }
public double? Latitude { get; set; }
public double? Longitude { get; set; }
}
public class BaseDataPartyAccount
{
public string BankName { get; set; }
public string OwnerName { get; set; }
public string IBAN { get; set; }
public string BIC { get; set; }
public string SWIFT { get; set; }
public string Number { get; set; }
public string Currency { get; set; }
public bool? IsDefault { get; set; }
}
}
