Skip to content

Commit

Permalink
Modified SuiteCRM endpoint API
Browse files Browse the repository at this point in the history
  • Loading branch information
bensonpaul committed Jun 21, 2024
1 parent 280a3fb commit c849ebd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions static/js/main-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,14 @@ var settings = {
$.ajax(settings).done(function (response) {
var form = new FormData();
form.append("grant_type", "client_credentials");
form.append("client_id", "220df659-3f88-9184-7aae-64d0ca060409");
//form.append("client_id", "220df659-3f88-9184-7aae-64d0ca060409");
form.append("client_id", "2876ba3c-cae4-e1a5-7d8e-6673cf6a799f");
//form.append("client_secret", "ioDlA7#09yyM");
form.append("client_secret", "ioDlA7#09yyM");
var settings = {
"async": true,
"crossDomain": true,
"url": "https://devl-crm.unblock.health/legacy/Api/access_token",
"url": "https://uat.crm.unblock.health/legacy/Api/access_token",
"method": "POST",
"headers": {
"Accept": "application/vnd.api+json"
Expand All @@ -182,15 +184,15 @@ $.ajax(settings).done(function (response) {
var obj = $.parseJSON(response);
var access_token = obj.access_token;
var settings = {
"url": "https://devl-crm.unblock.health/legacy/Api/V8/module",
"url": "https://uat.crm.unblock.health/legacy/Api/V8/module",
"method": "POST",
"headers": {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer " + access_token + "",
"Content-Type": "application/json"
},
"processData": false,
"data": "{\r\n \"data\": {\r\n \"type\": \"Contacts\",\r\n \"id\": \"" + uid + "\",\r\n \"attributes\": {\r\n \"first_name\":\"" + first_name + "\",\r\n \"email1\":\"" + email + "\"\r\n,\r\n \"lead_source\":\"Web Site\"\r\n,\r\n \"title\":\"" + patientdetails + "\"\r\n,\r\n \"account_id\":\"c548fc60-389f-8f5b-5ecb-64cce0924678\"\r\n }\r\n }\r\n}\r\n"
"data": "{\r\n \"data\": {\r\n \"type\": \"Contacts\",\r\n \"id\": \"" + uid + "\",\r\n \"attributes\": {\r\n \"first_name\":\"" + first_name + "\",\r\n \"email1\":\"" + email + "\"\r\n,\r\n \"lead_source\":\"Web Site\"\r\n,\r\n \"title\":\"" + patientdetails + "\"\r\n,\r\n \"account_id\":\"aba27ce2-d758-bdeb-adef-5da4294bf9e8\"\r\n }\r\n }\r\n}\r\n"
}

$.ajax(settings).done(function (response) {
Expand All @@ -212,7 +214,7 @@ $.ajax(settings).done(function (response) {
var settings = {
"async": true,
"crossDomain": true,
"url": "https://devl-crm.unblock.health/legacy/Api/V8/module/Accounts/c548fc60-389f-8f5b-5ecb-64cce0924678/relationships",
"url": "https://uat.crm.unblock.health/legacy/Api/V8/module/Accounts/aba27ce2-d758-bdeb-adef-5da4294bf9e8/relationships",
"method": "POST",
"headers": {
"Accept": "application/vnd.api+json",
Expand Down Expand Up @@ -298,12 +300,12 @@ $('#contact-submit-live').prop('disabled', 'disabled');
description += 'Message: '+message;
var form = new FormData();
form.append("grant_type", "client_credentials");
form.append("client_id", "220df659-3f88-9184-7aae-64d0ca060409");
form.append("client_id", "2876ba3c-cae4-e1a5-7d8e-6673cf6a799f");
form.append("client_secret", "ioDlA7#09yyM");
var settings = {
"async": true,
"crossDomain": true,
"url": "https://devl-crm.unblock.health/legacy/Api/access_token",
"url": "https://uat.crm.unblock.health/legacy/Api/access_token",
"method": "POST",
"headers": {
"Accept": "application/vnd.api+json"
Expand All @@ -319,15 +321,15 @@ $('#contact-submit-live').prop('disabled', 'disabled');
var obj = $.parseJSON(response);
var access_token = obj.access_token;
var settings = {
"url": "https://devl-crm.unblock.health/legacy/Api/V8/module",
"url": "https://uat.crm.unblock.health/legacy/Api/V8/module",
"method": "POST",
"headers": {
"Accept": "application/vnd.api+json",
"Authorization": "Bearer " + access_token + "",
"Content-Type": "application/json"
},
"processData": false,
"data": "{\r\n \"data\": {\r\n \"type\": \"Contacts\",\r\n \"id\": \"" + uid + "\",\r\n \"attributes\": {\r\n \"first_name\":\"" + first_name + "\",\r\n \"email1\":\"" + email + "\"\r\n,\r\n \"lead_source\":\"Web Site\"\r\n,\r\n \"title\":\"GEN\"\r\n,\r\n \"description\":\"" + description + "\"\r\n,\r\n \"account_id\":\"c548fc60-389f-8f5b-5ecb-64cce0924678\"\r\n }\r\n }\r\n}\r\n"
"data": "{\r\n \"data\": {\r\n \"type\": \"Contacts\",\r\n \"id\": \"" + uid + "\",\r\n \"attributes\": {\r\n \"first_name\":\"" + first_name + "\",\r\n \"email1\":\"" + email + "\"\r\n,\r\n \"lead_source\":\"Web Site\"\r\n,\r\n \"title\":\"GEN\"\r\n,\r\n \"description\":\"" + description + "\"\r\n,\r\n \"account_id\":\"aba27ce2-d758-bdeb-adef-5da4294bf9e8\"\r\n }\r\n }\r\n}\r\n"
}
$.ajax(settings).done(function (response) {
//console.log(response.data.id);
Expand All @@ -344,7 +346,7 @@ $('#contact-submit-live').prop('disabled', 'disabled');
var settings = {
"async": true,
"crossDomain": true,
"url": "https://devl-crm.unblock.health/legacy/Api/V8/module/Accounts/c548fc60-389f-8f5b-5ecb-64cce0924678/relationships",
"url": "https://uat.crm.unblock.health/legacy/Api/V8/module/Accounts/aba27ce2-d758-bdeb-adef-5da4294bf9e8/relationships",
"method": "POST",
"headers": {
"Accept": "application/vnd.api+json",
Expand Down

0 comments on commit c849ebd

Please sign in to comment.