public static string CreateQuote(string customername, string customersurname, string companyname, string dealid, string customeremail, string expirydate, string terms, string endpoint) { string bodystring = @" { 'fields': { 'TITLE':'Quote for " + customername + " " + customersurname + "-" + companyname + @"', 'TYPE_ID':'SDWAN', 'STAGE_ID':'NEW', 'DEAL_ID':'" + dealid + @"', 'CLIENT_EMAIL':'" + customeremail + @"', 'CURRENCY_ID':'ZAR', 'CATEGORY_ID':'2', 'CLOSEDATE':'" + expirydate + @"', 'TERMS':'" + terms + @"' } }"; JObject body = JObject.Parse(bodystring); var result = WebServicesFactory.FetchData(body.ToString(), endpoint); var jsonresult = result.Content.ReadAsStringAsync(); var status = JToken.Parse(jsonresult.Result)["result"].ToString(); return(status); }
public static string CreateDeal(string paramtitle, string companyID, string contactid, string endpoint) { string bodystring = @" { 'fields':{ 'TITLE':'" + paramtitle + @"', 'TYPE_ID':'SD_WAN', 'COMPANY_ID':'" + companyID + @"', 'CONTACT_ID':'" + contactid + @"', 'OPENED':'Y', 'ASSIGNED_BY_ID':'13', 'ORIGINATOR_ID':'QUOTE_CHAT_BOT', 'CATEGORY_ID':'2' } }"; JObject body = JObject.Parse(bodystring); var result = WebServicesFactory.FetchData(body.ToString(), endpoint); var jsonresult = result.Content.ReadAsStringAsync(); var dealID = JToken.Parse(jsonresult.Result)["result"].ToString(); return(dealID); }
public static string saveCustomerInformation(string name, string surname, string companyid, string email, string phonenumber) { string bodystring = @" {'fields': { 'NAME':'" + name + @"', 'LAST_NAME':'" + surname + @"', 'OPENED':'Y', 'ASSIGNED_BY_ID': '13', 'TYPE_ID':'CLIENT', 'SOURCE_ID':'CHATBOT', 'COMPANY_ID':'" + companyid + @"', 'EMAIL':'" + email + @"', 'PHONE':[ { 'VALUE':'0" + phonenumber + @"', 'VALUE_TYPE':'WORK' } ] } } "; JObject body = JObject.Parse(bodystring); var response = WebServicesFactory.FetchData(body.ToString(), "crm.contact.add"); var jsonresult = response.Content.ReadAsStringAsync(); //extract var contactId = JToken.Parse(jsonresult.Result)["result"].ToString(); return(contactId); }
public static List <CustomerModel> getCustomerByPhoneNumber(string Phone) { string jsonData = @"{ 'order': { 'DATE_CREATE': 'ASC' }, 'filter': { 'PHONE':'0" + Phone.ToString() + @"' }, 'select': [ 'ID', 'NAME', 'TYPE_ID', 'LAST_NAME', 'PHONE', 'EMAIL', 'COMPANY_ID' ] }"; JObject body = JObject.Parse(jsonData); var result = WebServicesFactory.FetchData(body.ToString(), endpoint); var jsonresult = result.Content.ReadAsStringAsync(); List <CustomerModel> customers = new List <CustomerModel>() { }; foreach (var item in (JToken.Parse(jsonresult.Result)["result"])) { var customer = item.ToString(); customers.Add(JsonConvert.DeserializeObject <CustomerModel>(customer)); } return(customers); }
public static string AddProductsToQuote(string quoteid, List <BitrixProductRowModel> productlist, string endpoint) { string requestbody = @" { 'id': '" + quoteid + @"', 'rows':" + JsonConvert.SerializeObject(productlist) + @" }"; JObject body = JObject.Parse(requestbody); var result = WebServicesFactory.FetchData(body.ToString(), endpoint); var jsonresult = result.Content.ReadAsStringAsync(); return(JToken.Parse(jsonresult.Result)["result"].ToString()); }
public static string GetCompanyById(string CompanyID) { //put together the body of the request var request = @" { 'ID':'" + Int32.Parse(CompanyID) + @"' }"; //send to bitrix JObject body = JObject.Parse(request); var response = WebServicesFactory.FetchData(body.ToString(), "crm.company.get"); var jsonresult = response.Content.ReadAsStringAsync(); var companydata = JToken.Parse(jsonresult.Result); return(companydata["result"]["TITLE"].ToString()); //extract //var companyObject = JsonConvert.DeserializeObject<CompanyModel>(companydata.ToString()); //return companyObject; }
public static string SaveCompanyDetails(string Companytitle) { //put together the body of the request var request = @" {'fields': { 'TITLE':'" + Companytitle + @"', 'COMPANY_TYPE':'CUSTOMER', 'OPENED': 'Y', 'ASSIGNED_BY_ID': '13' } }"; //send to bitrix JObject body = JObject.Parse(request); var response = WebServicesFactory.FetchData(body.ToString(), "crm.company.add"); var jsonresult = response.Content.ReadAsStringAsync(); //extract var companyID = JToken.Parse(jsonresult.Result)["result"].ToString(); //return JToken.Parse(jsonresult.Result).ToString(); //return body.ToString(); return(companyID); }