public OnfleetTask CreateTask(OnfleetOrganization organization, OnfleetDestination destination, string recipient, string notes, bool pickupTask, string[] dependencies, bool autoAssign) { var task = new OnfleetCreateTask() { organization = organization.id, destination = destination, recipients = new List <string>(), notes = notes, pickupTask = pickupTask, dependencies = dependencies, merchant = organization.id, executor = organization.id }; task.recipients.Add(recipient); var request = new RestRequest("tasks", Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(task); var response = _client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <OnfleetTask>(response.Content)); } else { _logger.ErrorFormat("Onfleet Create task failed : {0}", response.ErrorMessage); return(null); } }
public OnfleetTask CreateTask(OnfleetOrganization organization, OnfleetDestination destination, string recipient, string notes, bool pickupTask, string[] dependencies, bool autoAssign) { var task = new OnfleetCreateTask() { organization = organization.id, destination = destination, recipients = new List<string>(), notes = notes, pickupTask = pickupTask, dependencies = dependencies, merchant = organization.id, executor = organization.id }; task.recipients.Add(recipient); var request = new RestRequest("tasks", Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddJsonBody(task); var response = _client.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { return JsonConvert.DeserializeObject<OnfleetTask>(response.Content); } else { _logger.ErrorFormat("Onfleet Create task failed : {0}", response.ErrorMessage); return null; } }