public void Test() { var proxy = new AppProxy(BaseAddress); var credential = new AppCredentialModel { AppId = AppId, Key = AdminKey }; var app = proxy.Get(credential).Result; Assert.AreEqual(AppName, app.Name); Assert.AreEqual(AppSettings, app.Settings); proxy.Update(credential, new ApplicationModel { Name = "newApp", Settings = "newSettings" }).Wait(); app = proxy.Get(credential).Result; Assert.AreEqual("newApp", app.Name); Assert.AreEqual("newSettings", app.Settings); }
public async Task Delete(AppCredentialModel credential) { using (var client = new HttpClient()) { Initialize(client); var response = await client.DeleteAsync(GetCredentialUrl(credential)); response.TryException(); } }
public async Task Update(AppCredentialModel credential, ApplicationModel data) { using (var client = new HttpClient()) { Initialize(client); var response = await client.PostAsync(GetCredentialUrl(credential), data, JsonFormatter); response.TryException(); } }
public async Task<ApplicationModel> Get(AppCredentialModel credential) { using (var client = new HttpClient()) { Initialize(client); var response = await client.GetAsync(GetCredentialUrl(credential)); response.TryException(); return await response.Content.ReadAsAsync<ApplicationModel>(); } }
protected string GetCredentialUrl(AppCredentialModel credential) { return $"{RoutePrefix}?{GetCredentialParams(credential)}"; }
protected string GetCredentialParams(AppCredentialModel credential) { return $"{GetCredentialParams((CredentialModel) credential)}&appId={credential.AppId}"; }