public async void Upsert_Update_CheckReturn() { var account = new Account { Name = "New Account ExternalID", Description = "New Account Description" }; var response = await _serviceHttpClient.HttpPatchAsync(account, string.Format("sobjects/{0}/{1}/{2}", "Account", "ExternalID__c", "2")); Assert.IsNotNull(response); }
public Task <SuccessResponse> UpdateAsync(string objectName, string recordId, object record) { if (string.IsNullOrEmpty(objectName)) { throw new ArgumentNullException("objectName"); } if (string.IsNullOrEmpty(recordId)) { throw new ArgumentNullException("recordId"); } if (record == null) { throw new ArgumentNullException("record"); } return(_serviceHttpClient.HttpPatchAsync(record, string.Format("sobjects/{0}/{1}", objectName, recordId))); }
public Task <bool> UpdateAsync(string objectName, string recordId, object record) { if (string.IsNullOrEmpty(objectName)) { throw new ArgumentNullException("objectName"); } if (string.IsNullOrEmpty(recordId)) { throw new ArgumentNullException("recordId"); } if (record == null) { throw new ArgumentNullException("record"); } //TODO: implement try/catch and throw auth exception if appropriate return(_serviceHttpClient.HttpPatchAsync(record, string.Format("sobjects/{0}/{1}", objectName, recordId))); }
public async void Upsert_Update_CheckReturn() { const string userAgent = "common-libraries-dotnet"; var auth = new AuthenticationClient(); await auth.UsernamePasswordAsync(_consumerKey, _consumerSecret, _username, _password, userAgent, _tokenRequestEndpointUrl); var serviceHttpClient = new ServiceHttpClient(auth.InstanceUrl, auth.ApiVersion, auth.AccessToken, userAgent, new HttpClient()); var account = new Account { Name = "New Account ExternalID", Description = "New Account Description" }; var response = await serviceHttpClient.HttpPatchAsync(account, string.Format("sobjects/{0}/{1}/{2}", "Account", "ExternalID__c", "2")); Assert.IsNotNull(response); }
public async void Requests_CheckHttpRequestMessage_HttpPatch() { var client = new HttpClient(new ServiceClientRouteHandler(r => { Assert.AreEqual(r.RequestUri.ToString(), "http://localhost:1899/services/data/v30/wade"); Assert.IsNotNull(r.Headers.UserAgent); Assert.AreEqual(r.Headers.UserAgent.ToString(), "common-libraries-dotnet/v30"); Assert.IsNotNull(r.Headers.Authorization); Assert.AreEqual(r.Headers.Authorization.ToString(), "Bearer accessToken"); })); using (var httpClient = new ServiceHttpClient("http://localhost:1899", "v30", "accessToken", client)) { await httpClient.HttpPatchAsync(null, "wade"); } }
public async void Upsert_New_CheckReturnInclude() { const string userAgent = "common-libraries-dotnet"; var auth = new AuthenticationClient(); await auth.UsernamePasswordAsync(_consumerKey, _consumerSecret, _username, _password, userAgent, _tokenRequestEndpointUrl); var serviceHttpClient = new ServiceHttpClient(auth.InstanceUrl, auth.ApiVersion, auth.AccessToken, userAgent, new HttpClient()); var account = new Account { Name = "New Account" + DateTime.Now.Ticks, Description = "New Account Description" + DateTime.Now.Ticks }; var response = await serviceHttpClient.HttpPatchAsync(account, string.Format("sobjects/{0}/{1}/{2}", "Account", "ExternalID__c", DateTime.Now.Ticks)); Assert.IsNotNull(response); Assert.IsNotNull(response.id); }