updated with oauth, footer docs,
This commit is contained in:
+41
-82
@@ -31,25 +31,21 @@ const agent = new https.Agent({
|
||||
});
|
||||
|
||||
export const getToken = () => {
|
||||
if (cache.tokenResponse) {
|
||||
return cache.tokenResponse;
|
||||
} else {
|
||||
return axios
|
||||
.post(
|
||||
`${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`,
|
||||
tokenBody,
|
||||
tokenConfig
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.then((data) => {
|
||||
cache.tokenResponse = data;
|
||||
return data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("error :", error.response);
|
||||
// return error;
|
||||
});
|
||||
}
|
||||
return axios
|
||||
.post(
|
||||
`${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`,
|
||||
tokenBody,
|
||||
tokenConfig
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.then((data) => {
|
||||
cache.tokenResponse = data;
|
||||
return data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("error :", error.response);
|
||||
// return error;
|
||||
});
|
||||
};
|
||||
|
||||
const tokenBody =
|
||||
@@ -76,7 +72,7 @@ const azureHeaders = (access_token) => {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + access_token,
|
||||
@@ -89,7 +85,7 @@ const azureHeadersPaged = (access_token) => {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer":
|
||||
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
||||
"Content-Type": "application/json",
|
||||
@@ -110,7 +106,9 @@ const hashAPIPath = (queryPath) => {
|
||||
);
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
|
||||
return "&hash=" + hashlink;
|
||||
//return "&hash=" + hashlink;
|
||||
|
||||
return (hashPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export const getBasicSearch = (token, searchString) => {
|
||||
@@ -183,8 +181,6 @@ export const getBasicDNSSearch = (token, searchString) => {
|
||||
};
|
||||
|
||||
export const getBasicDNSSearchPaged = (pageNumber) => {
|
||||
var token = getToken();
|
||||
|
||||
var queryUrl =
|
||||
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
|
||||
(typeof pageNumber != "undefined"
|
||||
@@ -200,6 +196,7 @@ export const getBasicDNSSearchPaged = (pageNumber) => {
|
||||
};
|
||||
|
||||
export const getAdvancedSearch = (token, searchString) => {
|
||||
console.log("debug showing token: ", token);
|
||||
console.log(searchString.caseReference);
|
||||
|
||||
var queryString = "";
|
||||
@@ -252,8 +249,6 @@ export const getAdvancedSearch = (token, searchString) => {
|
||||
|
||||
export const getAdvancedSearchPaged = (searchString, pageNumber) => {
|
||||
//console.log(searchString);
|
||||
var token = getToken();
|
||||
|
||||
var queryString = "";
|
||||
|
||||
queryString +=
|
||||
@@ -388,7 +383,6 @@ export const getSearchDocumentHistory = (token, documentID) => {
|
||||
|
||||
export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
|
||||
console.log(incidentID);
|
||||
var token = getToken();
|
||||
|
||||
var queryUrl =
|
||||
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
|
||||
@@ -408,8 +402,6 @@ export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
|
||||
};
|
||||
|
||||
export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
|
||||
var token = getToken();
|
||||
|
||||
var queryUrl =
|
||||
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
||||
documentID +
|
||||
@@ -501,8 +493,6 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
|
||||
};
|
||||
|
||||
export const getBasicDNSSearchDetailsPaged = (caseReference) => {
|
||||
var token = getToken();
|
||||
|
||||
var queryUrl =
|
||||
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
@@ -535,9 +525,9 @@ export const getLinkedCases = (parentIncidentid) => {
|
||||
|
||||
export const getFormData = (token, whichForm) => {
|
||||
var queryUrl =
|
||||
"systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode%20eq%20%27pinswg_" +
|
||||
"systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode eq 'pinswg_" +
|
||||
whichForm +
|
||||
"%27and%20type%20eq%202)&$count=true&$top=201";
|
||||
"' and type eq 2)&$count=true&$top=201";
|
||||
return axios
|
||||
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
|
||||
.then((res) => res.data)
|
||||
@@ -650,10 +640,7 @@ export const getAppealID = (
|
||||
|
||||
console.log("proxy url ", queryUrl);
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeaders(getToken())
|
||||
)
|
||||
.get(queryUrl + hashAPIPath(queryUrl))
|
||||
.then((res) => {
|
||||
var appealID = res.data.value[0][primaryAttribute];
|
||||
return appealID;
|
||||
@@ -669,7 +656,7 @@ export const getLogin = (emailAddress, pwd) => {
|
||||
emailAddress +
|
||||
"' and pinswg_custom_password eq '" +
|
||||
pwd +
|
||||
"'&$count=true&$select=emailaddress1,%20contactid,pinswg_custom_password, yomifullname, firstname, lastname";
|
||||
"'&$count=true&$select=emailaddress1,contactid,pinswg_custom_password,yomifullname,firstname,lastname";
|
||||
|
||||
return axios
|
||||
.get(queryUrl + hashAPIPath(queryUrl))
|
||||
@@ -693,14 +680,14 @@ export const createCase = (token, appealTypeId, lpaID, contactid) => {
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"ServiceBusAuthorization": token,
|
||||
"Authorization": "Bearer " + token,
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
@@ -740,10 +727,9 @@ export const updateCase = async (
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
@@ -810,10 +796,9 @@ export const deleteMyRepresentations = (myRepresentationsID) => {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
};
|
||||
// console.log(config);
|
||||
@@ -889,10 +874,9 @@ export const createWatchedCases = (formValues) => {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
@@ -915,10 +899,9 @@ export const deleteWatchedCases = (watchedCaseID) => {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
};
|
||||
// console.log(config);
|
||||
@@ -990,19 +973,11 @@ export const getEmailAccountCheck = (emailAddress) => {
|
||||
};
|
||||
|
||||
export const createAccount = (formValues) => {
|
||||
var data = JSON.stringify(formValues);
|
||||
var data = formValues; //JSON.stringify(formValues);
|
||||
var queryUrl = "/api/proxy/contacts";
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
@@ -1016,48 +991,32 @@ export const createAccount = (formValues) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const updateAccount = (contactId, updateBody) => {
|
||||
var data = JSON.stringify(updateBody);
|
||||
export const updateAccount = async (contactId, updateBody) => {
|
||||
var data = updateBody; //JSON.stringify(updateBody);
|
||||
var queryUrl = "/api/proxy/contacts(" + contactId + ")";
|
||||
queryUrl = queryUrl + hashAPIPath(queryUrl);
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
url: queryUrl,
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
return axios(config)
|
||||
.then((res) => {
|
||||
//console.log("posted ", res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("this serror", error);
|
||||
console.log("this error:", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const updatePassword = (contactId, newpassword) => {
|
||||
let updateBody = { "pinswg_custom_password": newpassword };
|
||||
var data = JSON.stringify(updateBody);
|
||||
var data = updateBody; //JSON.stringify(updateBody);
|
||||
var queryUrl = "/api/proxy/contacts(" + contactId + ")";
|
||||
queryUrl = queryUrl + hashAPIPath(queryUrl);
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: queryUrl + hashAPIPath(queryUrl),
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": getToken(),
|
||||
},
|
||||
url: queryUrl,
|
||||
data: data,
|
||||
};
|
||||
// console.log(config);
|
||||
|
||||
Reference in New Issue
Block a user