static private async Task <ComponentResponse> CallApiAsync(string strBaseUrl, string strClientId, string strClientSecret, string strScope, string strUrl, OauthHelper oauth, List <string> PDIdentifiers) { ComponentRequest request = new ComponentRequest { PDIdentifiers = PDIdentifiers }; return(await oauth.SendHttpPostAsync <ComponentResponse>(strUrl, request)); }
public bool Initialize(string strBaseUrl, string strClientId, string strClientSecret, string strScope, string strUrl) { try { _strBaseUrl = strBaseUrl; _strClientId = strClientId; _strClientSecret = strClientSecret; _strScope = strScope; _strUrl = strUrl; _oauthClient = null; return(true); } catch { } return(false); }
public List <Reco3Component> Query() { ComponentResponse response = new ComponentResponse(); if (_oauthClient == null) { _oauthClient = new OauthHelper() { BaseUrl = _strBaseUrl, // "https://api.integration.prod.aws.scania.com/", ClientId = _strClientId, // "Iy0BxcywUXU1GdcLHfVnj8e0vvca", ClientSecret = _strClientSecret, // "GhlHbwLkFJrvtf5w64kk0m5syNka", Scope = _strScope // "PDComponentInfo_Prod_Full" }; } response = CallApiAsync(_strBaseUrl, _strClientId, _strClientSecret, _strScope, _strUrl, _oauthClient, _PDIdentifiers).GetAwaiter().GetResult(); if (response != null) { List <Reco3Component> Reco3Components = new List <Reco3Component>(); foreach (ComponentData ThreeDcomponent in response.ComponentData) { Reco3Component reco3Component = new Reco3Component(); reco3Component.PDNumber = ThreeDcomponent.PDId.ToString(); reco3Component.XML = Base64ToString(ThreeDcomponent.ComponentInfo); reco3Component.SetComponentTypeFromXml(); reco3Component.SetComponentDescriptionFromXml(); reco3Component.PD_Status = Reco3_Enums.PDStatus.ctReleased; Reco3Components.Add(reco3Component); } return(Reco3Components); } return(null); }