public void SObjectUrlBuilderShouldReturnSObjectUrlWithNoId() { var url = new SObjectUrlBuilder("v45.0") .ForSObject("Account") .ToString(); Assert.AreEqual("/services/data/v45.0/sobjects/Account", url); }
public async Task <bool> Delete(string sObjectName, string id) { var url = new SObjectUrlBuilder(apiVersion) .ForSObject(sObjectName) .WithId(id) .ToString(); var response = await httpClient.DeleteAsync(url); return(response.IsSuccessStatusCode); }
public async Task <ObjectDescribeResponse> DescribeObject(string objectName) { var url = new SObjectUrlBuilder(apiVersion) .ForSObject(objectName) .Describe() .ToString(); var response = await httpClient.GetAsync(url); var content = await response.Content.ReadAsStringAsync(); return(serializer.Deserialize <ObjectDescribeResponse>(content)); }
public async Task <T> GetById <T>(string sObjectName, string id) { var url = new SObjectUrlBuilder(apiVersion) .ForSObject(sObjectName) .WithId(id) .ToString(); var response = await httpClient.GetAsync(url); var content = await response.Content.ReadAsStringAsync(); return(serializer.Deserialize <T>(content)); }
public async Task <bool> Update <T>(string sObjectName, string id, T record) { var url = new SObjectUrlBuilder(apiVersion) .ForSObject(sObjectName) .WithId(id) .ToString(); //var body = new StringContent(serializer.Serialize(record)); var content = new StringContent(serializer.Serialize(record), Encoding.UTF8, serializer.ContentType); var response = await httpClient.PatchAsync(url, content); return(response.IsSuccessStatusCode); }
public async Task <string> Create <T>(string objectName, T record) { var url = new SObjectUrlBuilder(apiVersion) .ForSObject(objectName) .ToString(); var body = new StringContent(serializer.Serialize(record), Encoding.UTF8, serializer.ContentType); var response = await httpClient.PostAsync(url, body); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); var success = serializer.Deserialize <CreatedResponse>(content); if (success.Success) { return(success.Id); } } return(null); }