public byte[] ExecuteDownload(string resource, Guid id) { var request = new Servicem8.API.Serializers.RestRequest(resource, Method.GET); request.AddUrlSegment("id", id.ToString()); request.RequestFormat = DataFormat.Json; return(ExecuteFileRequest(request)); }
public Task <List <T> > ExecuteList <T>(string resource, object parameters = null) { var request = new Servicem8.API.Serializers.RestRequest(resource, Method.GET); request.AddParameters(parameters); request.RequestFormat = DataFormat.Json; return(ExecuteRequest <List <T> >(request)); }
public Task <T> ExecuteSingle <T>(string resource, Guid id) where T : new() { var request = new Servicem8.API.Serializers.RestRequest(resource, Method.GET); request.AddUrlSegment("id", id.ToString()); request.RequestFormat = DataFormat.Json; //Because the way ServiceM8 does it filtering, need to get the first one from the array in the response. return(ExecuteRequest <List <T> >(request).ContinueWith <T>(x => x.Result.FirstOrDefault())); }
public Task ExecuteDelete(string resource, Guid id) { if (id == Guid.Empty) { throw new ArgumentNullException("model"); } var request = new Servicem8.API.Serializers.RestRequest(resource, Method.DELETE); request.AddUrlSegment("id", id.ToString()); return(ExecuteRequest(request)); }
public Task ExecutePayload <T>(string resource, T model, Guid?id = null) where T : class, IKey, new() { if (model == null) { throw new ArgumentNullException("model"); } var request = new Servicem8.API.Serializers.RestRequest(resource, Method.POST); if (id.HasValue) { request.AddUrlSegment("id", id.ToString()); } var requestBody = request.JsonSerializer.Serialize(model); request.AddParameter("application/json", requestBody, ParameterType.RequestBody); return(ExecuteRequest(request)); }