using Newtonsoft.Json; using SimpleJSON; using System; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.UI; public class RequestPriceFromCieblink : MonoBehaviour { //[DllImport("__Internal")] //private static extern void SendPostRequestWithJson(string url, string formdata); //[DllImport("__Internal")] //public static extern string SendFromJSToUnity(); //[DllImport("__Internal")] //public static extern void OpenOptionExtended(string cab); //[DllImport("__Internal")] //public static extern void OpenRecipeConfigurator(string recipe); //static RequestPriceFromCieblink _instance; //public static RequestPriceFromCieblink Instance { get { return _instance; } } //public GameObject LoadingCirclePrice; //private string PostURL = ""; //public string jsonString = ""; //public string extractedNode = ""; //[SerializeField] CalculatePrices _calculatePrices; //[SerializeField] Text _priceValue; //int _objectNum; //Cabinet _cabinet; //void Initialize() //{ // if (_instance == null) // { // _instance = this; // } // else // { // Destroy(this); // return; // } // if (_calculatePrices == null) // { // _calculatePrices = GetComponent(); // } //} //private void Awake() //{ // Initialize(); //} //[ContextMenu("Request Price")] //public void RequestPrice() //{ // string test = "btnRECAL"; // //PostURL = "https://lab.cieblink.com/ciemetric/calculation/price?key=" + _G.PATH; // //Debug.Log("Request Price"); // // new version // string env = _G._CIEMETRIC_ENV; // //Debug.Log(_G._CIEMETRIC_ENV); // env = env?.Substring(env.Length - 1, 1) == "/" ? env : env + "/"; // PostURL = _G._CIEMETRIC_ENV + "ciemetric/calculation/price?key=" + _G.PATH; // //Debug.Log(PostURL); // Initialize(); // Root root = new Root() // { // cabinets = new List(), // }; // //Debug.Log("Is Loading Circle Price Null == " + LoadingCirclePrice == null); // LoadingCirclePrice.SetActive(true); // //Debug.Log("Is Price Value Text Null == " + _priceValue == null); // _priceValue.enabled = false; // //Debug.Log("Is CalculatePrices Ref Null == " + _calculatePrices == null); // _calculatePrices.GetAllProductINFO(); // for (var i = 0; i < _calculatePrices.ListCabNoNewLine2.Count; i++) // { // Cabinet myObject = CreateCabinetObjectFromADN(_calculatePrices.ListCabNoNewLine2[i], _calculatePrices._currentObjNumbers[i]); // root.cabinets.Add(myObject); // } // jsonString = JsonUtility.ToJson(root); // //Debug.Log(jsonString); // SendPostRequestWithJson(PostURL, jsonString); //} //private Cabinet CreateCabinetObjectFromADN(string cabData, int objNumber) //{ // //_keepRequestPrice = false; // string[] _textSplit = cabData.Split(char.Parse(",")); // Cabinet myObject = new Cabinet(); // myObject.sku = _textSplit[0]; // myObject.quantity = 1; // string[] _widtHeightDepth = _textSplit[1].Split(char.Parse("_")); // myObject.width = _widtHeightDepth[0]; // myObject.height = _widtHeightDepth[1]; // myObject.depth = _widtHeightDepth[2]; // myObject.unitSystem = _textSplit[2]; // Option myOption1 = new Option(); // myOption1.question = "fournisseur-porte"; // myOption1.answer = _textSplit[3]; // Option myOption2 = new Option(); // myOption2.question = "modele-porte"; // myOption2.answer = _textSplit[4]; // Option myOption3 = new Option(); // myOption3.question = "couleur-porte"; // myOption3.answer = _textSplit[5]; // Option myOption4 = new Option(); // myOption4.question = "cote-fini"; // myOption4.answer = _textSplit[11]; // Option myOption5 = new Option(); // myOption5.question = "mat-interieur"; // myOption5.answer = _textSplit[7]; // string[] _matSplit = _textSplit[8].Split(char.Parse("?")); // Option myOption6 = new Option(); // myOption6.question = "mat-exterieur"; // myOption6.answer = _matSplit[0]; // Option myOption7 = new Option(); // myOption7.question = "modele-poignee"; // myOption7.answer = _textSplit[9]; // Option myOption8 = new Option(); // myOption8.question = "cote-pentures"; // myOption8.answer = _textSplit[10]; // List