Files
Epi2Exchange/Epi2Exchange/Model/ContactListPayload.cs
2025-02-12 09:46:23 +01:00

81 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RestSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Windows.Forms;
namespace Epi2Exchange.Model
{
class ContactListPayload
{
RestClient epirentserver;
[JsonProperty("primary_key")]
public String PrimaryKey { get; set; }
[JsonProperty("customer_no")]
public String CustomerNumber { get; set; }
[JsonProperty("supplier_no")]
public String SupplierNumber { get; set; }
[JsonProperty("name")]
public String Name { get; set; }
[JsonProperty("name1")]
public String Name1 { get; set; }
[JsonProperty("name2")]
public String Name2 { get; set; }
[JsonProperty("is_customer")]
public bool IsCustomer { get; set; }
[JsonProperty("is_supplier")]
public bool IsSupplier { get; set; }
[JsonProperty("contact_data")]
public ContactListPayloadData ContactListPayloadData { get; set; }
public ContactDetail ContactDetail { get; set; }
public ContactListPayload()
{
epirentserver = new RestClient("http://" + Properties.Settings.Default.EpiServer + ":" + Properties.Settings.Default.EpiPort);
}
public void setContactDetail()
{
ContactDetail = GetContactDetailFromJson(getContactDetailJson());
}
public String getContactDetailJson()
{
RestRequest request = new RestRequest("/v1/contact/" + PrimaryKey + "/filter?ia=1&cl=" + Properties.Settings.Default.EpiMandant, Method.GET);
request.AddHeader("X-EPI-NO-SESSION", "True");
request.AddHeader("X-EPI-ACC-TOK", Properties.Settings.Default.EpiToken);
request.RequestFormat = DataFormat.Json;
return epirentserver.ExecuteAsGet(request, "GET").Content;
}
public Model.ContactDetail GetContactDetailFromJson(String ContactDetailJson)
{
Model.ContactDetail contactDetail = JsonConvert.DeserializeObject<Model.ContactDetail>(ContactDetailJson);
return contactDetail;
}
}
}