using PWAPPv2.Source.DataObjects; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PWAPPv2.Source.API { public class PWApiConnection { private APIConnection BaseConnection; private APIConnection UpdateConnection; private APIConnection AttachementConnection; private APIConnection ReferralConnection; private APIConnection ReferToConnection; private APIConnection ReferFromConnection; private APIConnection ReferTypesConnection; private APICredentials Credentials; private string AppVersion; public PWApiConnection(Source.Config.Configuration practiceConfig, Source.Config.Configuration universalConfig) { Credentials = new APICredentials(practiceConfig); BaseConnection = new APIConnection(universalConfig.Get("PWBaseURI"), Credentials); UpdateConnection = new APIConnection(universalConfig.Get("PWUpdateURI"), Credentials); AttachementConnection = new APIConnection(universalConfig.Get("PWAttachmentURI"), Credentials); ReferralConnection = new APIConnection(universalConfig.Get("PWReferralURI"), Credentials); ReferToConnection = new APIConnection(universalConfig.Get("PWReferToURI"), Credentials); ReferFromConnection = new APIConnection(universalConfig.Get("PWReferFromURI"), Credentials); ReferTypesConnection = new APIConnection(universalConfig.Get("PWReferTypesURI"), Credentials); AppVersion = universalConfig.Get("PWAppVersion"); } public string PostToApi(string uri, string data) { return BaseConnection.SendPostRequestAsync(uri, data); } public string GetFromApi(string uri) { return BaseConnection.SendPostRequestAsync(uri); } public bool CheckForUpdate() { string currentVersion = UpdateConnection.SendPostWithCredsInHeader("", ""); currentVersion = currentVersion.Replace("\"", ""); if(currentVersion != AppVersion) { return true; } return false; } public string GetReferalTypes() { return ReferTypesConnection.SendPostWithCredsInHeader("", ""); } public string GetReferTo() { return ReferToConnection.SendPostWithCredsInHeader("", ""); } public string GetReferFrom() { return ReferFromConnection.SendPostWithCredsInHeader("", ""); } public string SendReferral(string JsonData) { return ReferralConnection.SendPostWithCredsInHeader("", JsonData); } } }